Announcement Announcement Module
Collapse
No announcement yet.
username not reaching at j_acegi_security_check Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • username not reaching at j_acegi_security_check

    I started with acegi tutorial and changed 3 things
    1. Path to the login page.
    2. userDetailsService
    3. secure URLs.


    Now It takes me to the login page when trying to access a protected page, but on submitting the login form, acegi is not invoking my custom userDetailsService ( verified by putting log in loadUserByUsername()).

    From following server logs it appears that user name is null -

    2007-03-02 18:46:14,165 DEBUG [org.springframework.web.context.support.XmlWebAppl icationContext] - <Publishing event in context [Root WebApplicationContext]: ServletRequestHandledEvent: url=[/user/acegilogin]; client=[0:0:0:0:0:0:0:1%0]; method=[GET]; servlet=[user]; session=[6E63E9F8B11384FA0E7AE9CED34D1D4C]; user=[null]; time=[6ms]; status=[OK]>
    2007-03-02 18:46:14,166 DEBUG [org.acegisecurity.ui.ExceptionTranslationFilter] - <Chain processed normally>
    2007-03-02 18:46:14,166 DEBUG [org.acegisecurity.ui.ExceptionTranslationFilter] - <Chain processed normally>
    2007-03-02 18:46:14,166 DEBUG [org.acegisecurity.context.HttpSessionContextIntegr ationFilter] - <SecurityContextHolder set to new context, as request processing completed>
    2007-03-02 18:46:14,166 DEBUG [org.acegisecurity.context.HttpSessionContextIntegr ationFilter] - <SecurityContextHolder set to new context, as request processing completed>

    Its most likely a silly mistake somewhere but I cant figure out, Do you see some obvious mistake in this?

    thanks for the help!


    My applicationContext ------
    Code:
    	<bean id="filterChainProxy" class="org.acegisecurity.util.FilterChainProxy">
    		<property name="filterInvocationDefinitionSource">
    			<value>
    				CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    				PATTERN_TYPE_APACHE_ANT
    				/**=httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor
    			</value>
    		</property>
    	</bean>
    
    	<bean id="httpSessionContextIntegrationFilter" class="org.acegisecurity.context.HttpSessionContextIntegrationFilter"/>
    
    	<bean id="logoutFilter" class="org.acegisecurity.ui.logout.LogoutFilter">
    		<constructor-arg value="/index.jsp"/> <!-- URL redirected to after logout -->
    		<constructor-arg>
    			<list>
    				<ref bean="rememberMeServices"/>
    				<bean class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler"/>
    			</list>
    		</constructor-arg>
    	</bean>
    
    	<bean id="authenticationProcessingFilter" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter">
    		<property name="authenticationManager" ref="authenticationManager"/>
    		<property name="authenticationFailureUrl" value="/user/acegilogin?login_error=1"/>
    		<property name="defaultTargetUrl" value="/"/>
    		<property name="filterProcessesUrl" value="/j_acegi_security_check"/>
    		<property name="rememberMeServices" ref="rememberMeServices"/>
    	</bean>
       
    	<bean id="securityContextHolderAwareRequestFilter" class="org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter"/>
    
    	<bean id="rememberMeProcessingFilter" class="org.acegisecurity.ui.rememberme.RememberMeProcessingFilter">
    		<property name="authenticationManager" ref="authenticationManager"/>
    		<property name="rememberMeServices" ref="rememberMeServices"/>
    	</bean>
    
    	<bean id="anonymousProcessingFilter" class="org.acegisecurity.providers.anonymous.AnonymousProcessingFilter">
    		<property name="key" value="changeThis"/>
    		<property name="userAttribute" value="anonymousUser,ROLE_ANONYMOUS"/>
    	</bean>
    
    	<bean id="exceptionTranslationFilter" class="org.acegisecurity.ui.ExceptionTranslationFilter">
    		<property name="authenticationEntryPoint">
    			<bean class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">
    				<property name="loginFormUrl" value="/user/acegilogin"/>
    				<property name="forceHttps" value="false"/>
    			</bean>
    		</property>
    		<property name="accessDeniedHandler">
    			<bean class="org.acegisecurity.ui.AccessDeniedHandlerImpl">
    				<property name="errorPage" value="/accessDenied.jsp"/>
    			</bean>
    		</property>
    	</bean>
    
    	<bean id="filterInvocationInterceptor" class="org.acegisecurity.intercept.web.FilterSecurityInterceptor">
    		<property name="authenticationManager" ref="authenticationManager"/>
    		<property name="accessDecisionManager">
    			<bean class="org.acegisecurity.vote.AffirmativeBased">
    				<property name="allowIfAllAbstainDecisions" value="false"/>
    				<property name="decisionVoters">
    					<list>
    						<bean class="org.acegisecurity.vote.RoleVoter"/>
    						<bean class="org.acegisecurity.vote.AuthenticatedVoter"/>
    					</list>
    				</property>
    			</bean>
    		</property>
    		<property name="objectDefinitionSource">
    			<value>
    				CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    				PATTERN_TYPE_APACHE_ANT
    				/admin/**=IS_AUTHENTICATED_FULLY
    				/**=IS_AUTHENTICATED_ANONYMOUSLY
    			</value>
    		</property>
    	</bean>
    
    	<bean id="rememberMeServices" class="org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices">
    		<property name="userDetailsService" ref="userManager"/>
    		<property name="key" value="changeThis"/>
    	</bean>
    
    	<bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">
    		<property name="providers">
    			<list>
    				<ref local="daoAuthenticationProvider"/>
    				<bean class="org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider">
    					<property name="key" value="changeThis"/>
    				</bean>
    				<bean class="org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider">
    					<property name="key" value="changeThis"/>
    				</bean>
    			</list>
    		</property>
    	</bean>
    
    	<bean id="daoAuthenticationProvider" class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">
    		<property name="userDetailsService" ref="userManager"/>
    		<property name="userCache">
    			<bean class="org.acegisecurity.providers.dao.cache.EhCacheBasedUserCache">
    				<property name="cache">
    					<bean class="org.springframework.cache.ehcache.EhCacheFactoryBean">
    						<property name="cacheManager">
    							<bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>
    						</property>
    						<property name="cacheName" value="userCache"/>
    					</bean>
    				</property>
    			</bean>
    		</property>
    	</bean>
    --- acegilogin.jsp
    Code:
    <form action="/mysite/j_acegi_security_check" method="post">
      <table width="95%" bgcolor="f8f8ff" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td alignment="right" width="20%">User Id:</td>
            <td width="20%">
              <input type="text" name="j_username"></input>
            </td>
        </tr>
        <tr>
          <td alignment="right" width="20%">Password : </td>
            <td width="20%">
              <input type="password" name="j_password"></input>
            </td>
        </tr>
      </table>
      <br>
      <br><br>
      <input type="submit" alignment="center" value="Login">
    </form>
    Last edited by sanjay.dahiya; Mar 2nd, 2007, 02:14 PM. Reason: Formatting change

  • #2
    It really helps if you put this in [ code] [ /code] tags, it's soooooo much easier to read! One thing I did notice is that you haven't defined a bean called "userManager" yet it's referenced in a couple of places. I usually find that it's a good idea to only change one thing at a time when playing around. It makes it so much easier to revert changes.

    Comment


    • #3
      Apologies for the formatting, I edited the original post.
      Yes the userManager bean is defined in the context elsewhere and its available here as well ( otherwise the context will fail to initialize ).
      To get acegi working in an existing codebase i think these changes would be minimum, else i'd be running the demo itself.
      still stuck,
      thanks for the help

      Comment


      • #4
        got it working, I recreated from scratch again and its working now. Still not sure what was the error.

        Comment


        • #5
          Originally posted by sanjay.dahiya View Post
          got it working, I recreated from scratch again and its working now. Still not sure what was the error.
          Glad you got it working. It's very hard to just look at all the configuration and just see what the problem is. If you haven't done much it's far easier just to reapply your changes to a working version.

          Comment

          Working...
          X