lundi 23 mars 2015

JSF with Spring security - Redirect to specified page after -successful- login

I have a JSF project with spring security, after the login, if it's an JSP page, the redirection is allowed and I see the page , but when I try to access to my xhtml page (with JSF 2.2.4 and Primefaces) or any other type of pages, the server tell me that The requested resource is not available.


web.xml



<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://ift.tt/ra1lAU"
xmlns="http://ift.tt/nSRXKP"
xsi:schemaLocation="http://ift.tt/nSRXKP
http://ift.tt/1eWqHMP"
id="WebApp_ID" version="3.0">

<!-- Spring MVC -->
<display-name>Spring MVC Application</display-name>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>


<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>


<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-security.xml,classpath:applicationContext.xml</param-value>
</context-param>

<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>bootstrap</param-value>
</context-param>




<!-- 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>

</web-app>


spring-security.xml



<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://ift.tt/1c8inpe"
xmlns:beans="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:p="http://ift.tt/1jdM0fE"
xmlns:tx="http://ift.tt/OGfeU2"
xmlns:context="http://ift.tt/GArMu7"
xsi:schemaLocation="http://ift.tt/GArMu6
http://ift.tt/1CZCNBy
http://ift.tt/GArMu7
http://ift.tt/1tY3uA9
http://ift.tt/OGfeU2
http://ift.tt/18tm2Tg
http://ift.tt/1c8inpe
http://ift.tt/1epvZ6L">
<http pattern="/javax.faces.resource/**" security="none"/>
<http auto-config="true" use-expressions="false">
<intercept-url pattern="/welcome*" access="ROLE_USER"/>
<form-login />
<logout logout-success-url="/logout"/>
</http>

<authentication-manager>
<authentication-provider>
<user-service>
<user name="karim" password="karim" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>


</beans:beans>


mvc-dispatcher-servlet.xml



<beans xmlns="http://ift.tt/GArMu6"
xmlns:context="http://ift.tt/GArMu7"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="
http://ift.tt/GArMu6
http://ift.tt/QEDs1e
http://ift.tt/GArMu7
http://ift.tt/QEDs1k">

<context:component-scan base-package="ma.lezar.*" />

<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
</bean>
</beans>


LoginController.java



package ma.lezar.controller;

import java.security.Principal;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class LoginController {

@RequestMapping(value = { "/welcome*" }, method = RequestMethod.GET)
public String printWelcome(ModelMap model, Principal principal){
System.out.println("***********************Login controller Called**************");
return "ListeDesEtudiant.xhtml";
}

@RequestMapping(value = { "/login" }, method = RequestMethod.GET)
public String login(ModelMap model){
return "login";
}

@RequestMapping(value = { "/loginFailed" }, method = RequestMethod.GET)
public String loginError(ModelMap model){
return "login";
}


@RequestMapping(value = { "/logout" }, method = RequestMethod.GET)
public String logout(ModelMap model){
return "login";
}


@RequestMapping(value = { "/*" }, method = RequestMethod.GET)
public String home(ModelMap model){
return "home";
}

}


faces-config.xml



<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://ift.tt/19L2NlC"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/19L2NlC
http://ift.tt/1mXF9WB"
version="2.2">

<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>

</faces-config>


There is no error message except this, but the application run without any problem:



Description Resource Path Location Type src-resolve: Cannot resolve the name 'javaee:service-refGroup' to a(n) 'group' component. faces-config.xml /WebProjectTest/WebContent/WEB-INF line 130 Spring Beans Problem



Aucun commentaire:

Enregistrer un commentaire