Announcement Announcement Module
Collapse
No announcement yet.
Form Authentication not working !! Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Form Authentication not working !!

    I did all the configuration necessary to make Form authentication work for my app , but it seems like it is not working at all ! when I try to access home.jsp in my app I am able land there without any authentication and my login.jsp never comes in picture. When I go directly to login page and try to login I get the error saying "The requested resource (/j_acegi_security_check) is not available.". I think I am missing something although I have referenced threads on similar problems and the sample-contacts app that ships with acegi, I am not able to make it work for me. Can someone please help me around this. Any pointers will be appreciated. Thanks in advance !
    I am using
    acegisecurity-1.0.7
    Tomcat 5.0
    Spring 2.0

    -----------------------Web.xml-----------------------------

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    
    	<display-name>MyApp</display-name>
    	
    	
    
    	<listener>
    		<listener-class>
    			org.springframework.web.context.ContextLoaderListener
    		</listener-class>
    	</listener>
    	   <listener>
            <listener-class>org.acegisecurity.ui.session.HttpSessionEventPublisher</listener-class>
        </listener>
    	<filter>
    	<filter-name>Spring Security Filter Chain Proxy</filter-name>
    		<filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>
    			<init-param>
    				<param-name>targetClass</param-name>
    				<param-value>org.acegisecurity.util.FilterChainProxy</param-value>
    			</init-param>
    	</filter>
    	
    		<filter-mapping>
    		<filter-name>Spring Security Filter Chain Proxy</filter-name>
    		<url-pattern>/*</url-pattern>
    	</filter-mapping>
    
    	<servlet>
    		<servlet-name>
    			spring
    		</servlet-name>
    		<servlet-class>
    			org.springframework.web.servlet.DispatcherServlet
    		</servlet-class>
    		<init-param>
    			<param-name>detectAllViewResolvers</param-name>
    			<param-value>true</param-value>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	
    	
    
    	<servlet-mapping>
    		<servlet-name>spring</servlet-name>
    		<url-pattern>/app/*</url-pattern>
    	</servlet-mapping>
    
    
    
    
    	<welcome-file-list>
    		<welcome-file>home.html</welcome-file>
    		<welcome-file>home.jsp</welcome-file>
    	</welcome-file-list>
    
    </web-app>
    ---------------------applicationContext.xml--------------------------

    Code:
     <bean id="filterChainProxy" class="org.acegisecurity.util.FilterChainProxy">
    		<property name="filterInvocationDefinitionSource">
    			<value><![CDATA[
    			CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    			PATTERN_TYPE_APACHE_ANT
    			/**=httpSessionIntegrationFilter,authenticationProcessingFilter,exceptionTranslationFilter,filterSecurityInterceptor]]></value>
    		</property>
    	</bean>
    	
    	
    	
    	<bean id="httpSessionIntegrationFilter" class="org.acegisecurity.context.HttpSessionContextIntegrationFilter"/>
    	
    	<bean id="authenticationProcessingFilter" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter">
    		<property name="filterProcessesUrl" value="/j_acegi_security_check"/>
    		<property name="authenticationFailureUrl" value="/login.jsp?login_error=1" />
    		<property name="defaultTargetUrl" value="/" />
    		
    		<property name="authenticationManager" ref="authenticationManager"/>
    		
    	</bean>
    	
      <bean id="authenticationProcessingFilter" class="org.acegisecurity.ui.basicauth.BasicProcessingFilter">
    		<property name="authenticationManager" ref="authenticationManager"/>
    		<property name="authenticationEntryPoint" ref="authenticationEntryPoint"/>
    	</bean>
       
       
          <bean id="authenticationEntryPoint" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">
    		<property name="loginFormUrl" value="/login.jsp" />
    		<property name="forceHttps" value="false" />
    	</bean>
       <bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">
    		<property name="providers">
    			<list>
    				<ref bean="daoAuthenticationProvider"/>
    				
    			</list>
    		</property>
    	</bean>
    	
    	<bean id="daoAuthenticationProvider" class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">
    		<property name="userDetailsService" ref="authenticationDao"/>
    	</bean>
    	
    	<bean id="authenticationDao" class="org.acegisecurity.userdetails.memory.InMemoryDaoImpl">
    <property name="userMap">
    <value>
    admin=admin,ROLE_USER
    bauerj=ineedsleep,ROLE_USER
    obrianc=nosmile,ROLE_USER
    myersn=traitor,ROLE_USER
    </value>
    </property>
    </bean>
    	
        <bean id="exceptionTranslationFilter" class="org.acegisecurity.ui.ExceptionTranslationFilter">
    		<property name="authenticationEntryPoint" ref="authenticationEntryPoint" />
    	</bean>
    	
     	<!--  <bean id="authenticationEntryPoint" class="org.acegisecurity.ui.basicauth.BasicProcessingFilterEntryPoint">
    		<property name="realmName" value="Alert_BIR" />
    	</bean>  -->
    	
    	<bean id="filterSecurityInterceptor" class="org.acegisecurity.intercept.web.FilterSecurityInterceptor">
    		<property name="authenticationManager" ref="authenticationManager" />
    		<property name="accessDecisionManager" ref="httpRequestAccessDecisionManager" />
    		<property name="objectDefinitionSource">
    <value>
    CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    PATTERN_TYPE_APACHE_ANT
    /home.jsp=ROLE_USER
    /login.jsp=ROLE_USER
    /**=ROLE_USER
    </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="roleVoter"
    class="org.acegisecurity.vote.RoleVoter"/>
    -------------------------------login.jsp(fragment)----------------------
    Code:
    <form method="POST" action="/j_acegi_security_check">
    <b>Username: </b><input type="text" name="j_username"><br>
    <b>Password: </b><input type="password" name="j_password"><br>
    <input type="submit" value="Login">
Working...
X