1 23 24 package org.infoglue.cms.security; 25 26 import java.security.Principal ; 27 import java.util.Map ; 28 import java.util.Properties ; 29 30 import javax.servlet.FilterChain ; 31 import javax.servlet.http.HttpServletRequest ; 32 import javax.servlet.http.HttpServletResponse ; 33 34 import org.apache.log4j.Logger; 35 import org.infoglue.cms.controllers.kernel.impl.simple.UserControllerProxy; 36 import org.infoglue.cms.exception.SystemException; 37 38 43 44 public abstract class AuthenticationModule 45 { 46 private final static Logger logger = Logger.getLogger(AuthenticationModule.class.getName()); 47 48 public static AuthenticationModule getAuthenticationModule(Object transactionObject, String successLoginUrl) throws SystemException 49 { 50 AuthenticationModule authenticationModule = null; 51 52 try 53 { 54 String authenticatorClass = InfoGlueAuthenticationFilter.authenticatorClass; 55 String authorizerClass = InfoGlueAuthenticationFilter.authorizerClass; 56 String invalidLoginUrl = InfoGlueAuthenticationFilter.invalidLoginUrl; 57 String loginUrl = InfoGlueAuthenticationFilter.loginUrl; 58 String logoutUrl = InfoGlueAuthenticationFilter.logoutUrl; 59 String serverName = InfoGlueAuthenticationFilter.serverName; 60 Properties extraProperties = InfoGlueAuthenticationFilter.extraProperties; 61 String casRenew = InfoGlueAuthenticationFilter.casRenew; 62 String casServiceUrl = InfoGlueAuthenticationFilter.casServiceUrl; 63 String casValidateUrl = InfoGlueAuthenticationFilter.casValidateUrl; 64 String casLogoutUrl = InfoGlueAuthenticationFilter.casLogoutUrl; 65 66 74 75 authenticationModule = (AuthenticationModule)Class.forName(authenticatorClass).newInstance(); 76 authenticationModule.setAuthenticatorClass(authenticatorClass); 77 authenticationModule.setAuthorizerClass(authorizerClass); 78 authenticationModule.setInvalidLoginUrl(invalidLoginUrl); 79 authenticationModule.setLoginUrl(loginUrl); 80 authenticationModule.setLogoutUrl(logoutUrl); 81 authenticationModule.setServerName(serverName); 82 authenticationModule.setExtraProperties(extraProperties); 83 authenticationModule.setCasRenew(casRenew); 84 85 if(successLoginUrl != null && successLoginUrl.length() > 0) 86 { 87 int index = successLoginUrl.indexOf("&ticket="); 88 if(index > -1) 89 { 90 successLoginUrl = successLoginUrl.substring(0, index); 91 } 92 logger.info("successLoginUrl:" + successLoginUrl); 93 authenticationModule.setCasServiceUrl(successLoginUrl); 94 authenticationModule.setSuccessLoginUrl(successLoginUrl); 95 } 96 else 97 authenticationModule.setCasServiceUrl(casServiceUrl); 98 99 authenticationModule.setCasValidateUrl(casValidateUrl); 100 authenticationModule.setCasLogoutUrl(casLogoutUrl); 101 authenticationModule.setTransactionObject(transactionObject); 102 } 103 catch(Exception e) 104 { 105 logger.error("An error occurred when we tried to get an authenticationModule:" + e, e); 106 throw new SystemException("An error occurred when we tried to get an authenticationModule: " + e.getMessage(), e); 107 } 108 109 return authenticationModule; 110 } 111 112 public abstract String authenticateUser(HttpServletRequest request, HttpServletResponse response, FilterChain fc) throws Exception ; 113 114 public abstract String authenticateUser(Map request) throws Exception ; 115 116 public abstract Principal loginUser(HttpServletRequest request, HttpServletResponse response, Map status) throws Exception ; 117 118 public abstract boolean logoutUser(HttpServletRequest request, HttpServletResponse response) throws Exception ; 119 120 public abstract String getLoginDialogUrl(HttpServletRequest request, HttpServletResponse response) throws Exception ; 121 122 public abstract String getAuthenticatorClass(); 123 124 public abstract void setAuthenticatorClass(String authenticatorClass); 125 126 public abstract String getAuthorizerClass(); 127 128 public abstract void setAuthorizerClass(String authorizerClass); 129 130 public abstract String getInvalidLoginUrl(); 131 132 public abstract void setInvalidLoginUrl(String invalidLoginUrl); 133 134 public abstract String getLoginUrl(); 135 136 public abstract void setLoginUrl(String loginUrl); 137 138 public abstract String getSuccessLoginUrl(); 139 140 public abstract void setSuccessLoginUrl(String successLoginUrl); 141 142 public abstract String getLogoutUrl(); 143 144 public abstract void setLogoutUrl(String logoutUrl); 145 146 public abstract String getServerName(); 147 148 public abstract void setServerName(String serverName); 149 150 public abstract Properties getExtraProperties(); 151 152 public abstract void setExtraProperties(Properties properties); 153 154 public abstract String getCasRenew(); 155 156 public abstract void setCasRenew(String casRenew); 157 158 public abstract String getCasServiceUrl(); 159 160 public abstract void setCasServiceUrl(String casServiceUrl); 161 162 public abstract String getCasValidateUrl(); 163 164 public abstract void setCasValidateUrl(String casValidateUrl); 165 166 public abstract String getCasLogoutUrl(); 167 168 public abstract void setCasLogoutUrl(String casLogoutUrl); 169 170 public abstract String getCasAuthorizedProxy(); 171 172 public abstract void setCasAuthorizedProxy(String casAuthorizedProxy); 173 174 public abstract Object getTransactionObject(); 175 176 public abstract void setTransactionObject(Object transactionObject); 177 178 } | Popular Tags |