Announcement Announcement Module
Collapse
No announcement yet.
Can't access login page Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't access login page

    Hello, thanks for helping

    Spring MVC Project 3.2.2
    Spring Security 3.1.4
    Tiles 2.2.2

    Created a project in Openshift and it was working the MVC very well. As i inserted Spring Security, can't access any page, especially the login page. I am not sure of what can be. Well, i'll try to explain what i did until now. The project structure can be found here and there's a login.jsp page inside the login folder.

    Le web.xml
    Code:
    <servlet>
    		<servlet-name>spring</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<load-on-startup>2</load-on-startup>
    	</servlet>
    
    	<servlet-mapping>
    		<servlet-name>spring</servlet-name>
    		<url-pattern>/</url-pattern>
    	</servlet-mapping>
    	
    	<context-param>
          	<param-name>contextClass</param-name>
    		<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
       	</context-param>
    
       	<context-param>
        	<param-name>contextConfigLocation</param-name>
    		<param-value>br.com.meuprojeto.config</param-value>
       	</context-param>
    
       	<listener>
       		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
       	</listener>
    	
    	<!-- Spring Security -->
    	<filter>
    		<filter-name>springSecurityFilterChain</filter-name>
    		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    	</filter>
    	
    	<filter-mapping>
    		<filter-name>springSecurityFilterChain</filter-name>
    		<url-pattern>/*</url-pattern>
    	</filter-mapping>
    	<!-- fim security -->
    Le tiles-context
    Code:
    	<bean id="tilesviewResolver"
    		class="org.springframework.web.servlet.view.tiles2.TilesViewResolver" 
    		p:order="0" />
    
    	<bean id="tilesConfigurer"
    		class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    		<property name="definitions">
    			<list>
    				<value>/WEB-INF/jsp/**/tiles.xml/</value>
    			</list>
    		</property>
    	</bean>
    Le applicationContext
    Code:
    <context:annotation-config />
    	
    	<mvc:annotation-driven /> 
    	
    	<context:component-scan base-package="br.com.meuprojeto" />
    		
    	<import resource="tiles-context.xml" />
    	
     	<mvc:resources mapping="imagens/**" location="/resources/images/*" /> 	
     	<mvc:resources mapping="css/**" location="/resources/css/*" /> 	
     	<mvc:resources mapping="javascript/**" location="/resources/javascript/*" />
     	
     	<mvc:default-servlet-handler />
    spring-servlet...
    Code:
    	<bean 	id="viewResolver" 
    	    	class="org.springframework.web.servlet.view.InternalResourceViewResolver" 
        		p:prefix="/WEB-INF/jsp/" 
        		p:suffix=".jsp" 
        		p:order="1" />
    And finally, the webSecurityConfig (it's called by an annotated class @Configuration)
    Code:
    	<http use-expressions="true">
    
    	<intercept-url pattern="/anonymous*" access="isAnonymous()" />
            <intercept-url pattern="/login*" access="permitAll" />
            <intercept-url pattern="/**" access="isAuthenticated()" />
              
    		<form-login
    			login-page="/login/login.jsp"
    			login-processing-url="/perform_login" 
    			default-target-url="/login/homepage.jsp"
    			authentication-failure-url="/login.html?error=true" 
    			always-use-default-target="true"/>
                
                <logout 
                	logout-url="/perform_logout"
                    delete-cookies="JSESSIONID"
                    success-handler-ref="customLogoutSuccessHandler" />
    	</http>
        
        <beans:bean name="customLogoutSuccessHandler" class="br.com.meuprojeto.security.CustomLogoutSuccessHandler" />
    	
    	<authentication-manager>
    		<authentication-provider>
    			<user-service>
    				<user name="user1" password="user1Pass" authorities="ROLE_USER" />
    			</user-service>
    		</authentication-provider>
    	</authentication-manager>
    First try 1:As it is written in spring-servlet, i'll try to call directly the login page, starting from /jsp -> so i've tried myproject:8080/login/login.jsp and i got two errors - one with firefox and the other with chrome. I think it entered in an infinite loop, but can't be sure why. Isn't the /login permitted?

    Try number two: Well, REST. Created a Controller
    Code:
    @Controller
    @RequestMapping("/")
    public class MeuProjetoController {
    
    	@RequestMapping(value = "/teste", method = RequestMethod.GET)
    	public String testeLogin(ModelMap map, Model model) {
    
    		logger.info("going to the login page!");
    
    		return "login-page";
    
    	}
    In the tiles.xml definition, returns
    Code:
    <definition name="login-page" extends="template-main">
    		<put-attribute name="primary-content" value="/WEB-INF/jsp/login/login.jsp" />
    	</definition>
    Andin the webSecurityConfig file i inserted
    Code:
    <intercept-url pattern="/teste*" access="permitAll" />
    and updated
    Code:
     <form-login
    			login-page="/teste"
    So i've tried myproject:8080/teste and i got a nice 404 -> PAGE NOT FOUND. In the server log i got the message
    2013/06/12 18:38:27,189 WARN [org.springframework.web.servlet.PageNotFound] (http-ip-8080-1) No mapping found for HTTP request with URI [/teste] in DispatcherServlet with name 'spring'

    But the /teste isn't allowed? Where's the access to my Controller?
    Can the View Resolvers configurations (Tiles and Internal) affect the configurations for Spring Security?

    Hope i was clear... thanks for reading until here
Working...
X