Hi,
I'm making my first steps to integrate Acegi as a weblogic replacement.
I use the following definition in web.xml:
and the following beans:Code:<welcome-file-list> <welcome-file>secured/redirect.jsp</welcome-file> </welcome-file-list> <filter> <filter-name>Acegi-Integration</filter-name> <filter-class>net.sf.acegisecurity.util.FilterToBeanProxy</filter-class> <init-param> <param-name>targetClass</param-name> <param-value>net.sf.acegisecurity.context.HttpSessionContextIntegrationFilter</param-value> </init-param> </filter> <filter> <filter-name>Acegi-Authentication</filter-name> <filter-class>net.sf.acegisecurity.util.FilterToBeanProxy</filter-class> <init-param> <param-name>targetClass</param-name> <param-value>net.sf.acegisecurity.ui.webapp.AuthenticationProcessingFilter</param-value> </init-param> </filter> <filter-mapping> <filter-name>Acegi-Integration</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>Acegi-Authentication</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
Code:<bean id="httpSessionIntegrationFilter" class="net.sf.acegisecurity.context.HttpSessionContextIntegrationFilter"> <property name="context" value="net.sf.acegisecurity.context.security.SecureContextImpl"/> </bean> <bean id="authenticationProcessingFilter" class="net.sf.acegisecurity.ui.webapp.AuthenticationProcessingFilter"> <property name="authenticationManager"> <ref bean="authenticationManager"/> </property> <property name="authenticationFailureUrl"> <value>/login_error.jsp</value> </property> <property name="defaultTargetUrl"> <value>/</value> </property> <property name="filterProcessesUrl"> <value>/j_acegi_security_check</value> </property> </bean> <bean id="authenticationManager" class="net.sf.acegisecurity.providers.ProviderManager"> <property name="providers"> <list> <ref bean="safewordAuthenticationProvider"/> </list> </property> </bean> <bean id="safewordAuthenticationProvider" class="com.itp.gt.security.acegi.providers.SafewordAuthenticationProvider"> </bean>
the safewordAuthenticationProvider implementation looks like:
and using debug logging (not in the code above) I see that when the user+password combination is correct login is successful.Code:public Authentication authenticate(Authentication authentication)throws AuthenticationException { Authentication auth = null; String loginName = (String)authentication.getPrincipal(); String password = (String)authentication.getCredentials(); try{ User user = UserDAO.getUser(loginName); } catch(Exception e){ throw new AuthenticationServiceException("Exceprion getting user from database: ", e); } if(user == null){ throw new BadCredentialsException("User "+loginName+" Not Found!"); } //check password: if(user.getPassword().equals(password)){ try{ // load permissions: UserPermissions perms = UserDAO.loadPermissionsForUser(user); auth = new UsernamePasswordAuthenticationToken(user, perms); auth.setAuthenticated(true); } catch(Exception e){ throw new AuthenticationServiceException("Exceprion logging in user: ", e); } } else{ throw new BadCredentialsException("Password for User "+loginName+" Did Not Match!"); } return auth; } public boolean supports(Class authentication) { if (authentication.equals(UsernamePasswordAuthenticationToken.class)){return true;} return false; }
however there is something I'm probably missing here as a successful login results only in a refresh to the login screen
can anyone point me to what am I doing wrong?
Thanks
naor


