Hello there,
I'm building a webapp (tomcat/spring) and start including security with acegi.
My pb is that authentification looks to work (i.e. if i was not authentifiate i get redirected to the login form) great, but this code
inside my jsp View show me that the Authentifaction object is nullCode:<% Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (auth != null) { %> Authentication object is of type: <%= auth.getClass().getName() %><BR><BR> Authentication object as a String: <%= auth.toString() %><BR><BR> Authentication object holds the following granted authorities:<BR><BR> <% GrantedAuthority[] granted = auth.getAuthorities(); for (int i = 0; i < granted.length; i++) { %> <%= granted[i].toString() %> (getAuthority(): <%= granted[i].getAuthority() %>)<BR> <% } if (auth instanceof AuthByAdapter) { %> <BR><B>SUCCESS! Your container adapter appears to be properly configured!</B><BR><BR> <% } else { %> <BR><B>SUCCESS! Your web filters appear to be properly configured!</B><BR> <% } } else { %> Authentication object is null.<BR> This is an error and your Acegi Security application will not operate properly until corrected.<BR><BR> <% }%>
why?
here is my security config
looking at the logs i saw this:Code:<bean id="filterChainProxy" class="org.acegisecurity.util.FilterChainProxy"> <property name="filterInvocationDefinitionSource"> <value> CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON PATTERN_TYPE_APACHE_ANT /**=httpSessionContextIntegrationFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor </value> </property> </bean> <bean id="daoAuthenticationProvider" class="org.acegisecurity.providers.dao.DaoAuthenticationProvider"> <property name="userDetailsService"><ref local="inMemoryDaoImpl"/></property> <property name="userCache"><ref local="userCache"/></property> </bean> <!-- daoImpl --> <bean id="inMemoryDaoImpl" class="org.acegisecurity.userdetails.memory.InMemoryDaoImpl"> <property name="userMap"> <value> sg=xxx,ROLE_USER,ROLE_ROOT jc=xxx,ROLE_USER </value> </property> </bean> <!-- cache --> <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/> <bean id="userCacheBackend" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> <property name="cacheManager"> <ref local="cacheManager"/> </property> <property name="cacheName"> <value>userCache</value> </property> </bean> <bean id="userCache" class="org.acegisecurity.providers.dao.cache.EhCacheBasedUserCache"> <property name="cache"><ref local="userCacheBackend"/></property> </bean> <bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager"> <property name="providers"> <list> <ref bean="daoAuthenticationProvider"/> <ref bean="anonymousAuthenticationProvider"/> <ref local="rememberMeAuthenticationProvider"/> </list> </property> </bean> <bean id="anonymousAuthenticationProvider" class="org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider"> <property name="key"><value>guest</value></property> </bean> <bean id="anonymousProcessingFilter" class="org.acegisecurity.providers.anonymous.AnonymousProcessingFilter"> <property name="key"><value>guest</value></property> <property name="userAttribute"><value>anonymousUser,ROLE_ANONYMOUS</value></property> </bean> <bean id="securityContextHolderAwareRequestFilter" class="org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter"/> <bean id="httpSessionContextIntegrationFilter" class="org.acegisecurity.context.HttpSessionContextIntegrationFilter"> </bean> <bean id="rememberMeProcessingFilter" class="org.acegisecurity.ui.rememberme.RememberMeProcessingFilter"> <property name="authenticationManager"><ref local="authenticationManager"/></property> <property name="rememberMeServices"><ref local="rememberMeServices"/></property> </bean> <bean id="rememberMeServices" class="org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices"> <property name="userDetailsService"><ref local="inMemoryDaoImpl"/></property> <property name="key"><value>springRocks</value></property> </bean> <bean id="httpRequestIntegrationFilter" class="org.acegisecurity.adapters.HttpRequestIntegrationFilter"> </bean> <bean id="rememberMeAuthenticationProvider" class="org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider"> <property name="key"><value>springRocks</value></property> </bean> <bean id="exceptionTranslationFilter" class="org.acegisecurity.ui.ExceptionTranslationFilter"> <property name="authenticationEntryPoint"><ref local="authenticationProcessingFilterEntryPoint"/></property> </bean> <bean id="authenticationProcessingFilter" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter"> <property name="authenticationManager"><ref bean="authenticationManager"/></property> <property name="authenticationFailureUrl"><value>/login.html?login_error=1</value></property> <property name="defaultTargetUrl"><value>/element/list.html</value></property> <property name="filterProcessesUrl"><value>/j_acegi_security_check</value></property> <property name="rememberMeServices"><ref local="rememberMeServices"/></property> </bean> <bean id="authenticationProcessingFilterEntryPoint" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint"> <property name="loginFormUrl"><value>/login.html</value></property> <property name="forceHttps"><value>false</value></property> </bean> <bean id="httpRequestAccessDecisionManager" class="org.acegisecurity.vote.AffirmativeBased"> <property name="allowIfAllAbstainDecisions"><value>false</value></property> <property name="decisionVoters"> <list> <ref bean="roleVoter"/> </list> </property> </bean> <bean id="filterInvocationInterceptor" class="org.acegisecurity.intercept.web.FilterSecurityInterceptor"> <property name="authenticationManager"><ref bean="authenticationManager"/></property> <property name="accessDecisionManager"><ref local="httpRequestAccessDecisionManager"/></property> <property name="objectDefinitionSource"> <value> CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON PATTERN_TYPE_APACHE_ANT /login.html*=ROLE_ANONYMOUS,ROLE_USER /costing/*=ROLE_COSTING,ROLE_USER,ROLE_ROOT /element/*=ROLE_ELEMENT,ROLE_USER,ROLE_ROOT /rollup/*=ROLE_ROLLUP,ROLE_USER,ROLE_ROOT /**=ROLE_USER,ROLE_ROOT </value> </property> </bean> <bean id="roleVoter" class="org.acegisecurity.vote.RoleVoter"/> </beans>
The very last line puzzle me.Code:DEBUG http-8080-1 org.acegisecurity.intercept.web.PathBasedFilterInvocationDefinitionMap - Candidate is: '/pages/js/confirmation.jsp'; pattern is /**; matched=true DEBUG http-8080-1 org.acegisecurity.intercept.AbstractSecurityInterceptor - Secure object: FilterInvocation: URL: /pages/js/confirmation.jsp; ConfigAttributes: [ROLE_USER, ROLE_ROOT] DEBUG http-8080-1 org.acegisecurity.intercept.AbstractSecurityInterceptor - Previously Authenticated: org.acegisecurity.providers.UsernamePasswordAuthenticationToken@fa22c2a1: Username: org.acegisecurity.userdetails.User@0: Username: sg; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER, ROLE_ROOT; Password: [PROTECTED]; Authenticated: true; Details: org.acegisecurity.ui.WebAuthenticationDetails@12afc: RemoteIpAddress: 127.0.0.1; SessionId: 3DB9E41C591AE156E2C30902A3BA26D3; Granted Authorities: ROLE_USER, ROLE_ROOT DEBUG http-8080-1 org.acegisecurity.intercept.AbstractSecurityInterceptor - Authorization successful DEBUG http-8080-1 org.acegisecurity.intercept.AbstractSecurityInterceptor - RunAsManager did not change Authentication object DEBUG http-8080-1 org.acegisecurity.util.FilterChainProxy - /pages/js/confirmation.jsp reached end of additional filter chain; proceeding with original chain DEBUG http-8080-1 org.acegisecurity.ui.ExceptionTranslationFilter - Chain processed normally DEBUG http-8080-1 org.acegisecurity.context.HttpSessionContextIntegrationFilter - SecurityContextHolder set to new context, as request processing completed
Any help would be much appreciate.
nota: sitemesh decorate all views


