Bonjour à tous
Je suis en train de tester le module spring-security mais aprés le login j'ai ce message Etat HTTP 404 - /projet/j_spring_security_check La ressource demandée :/projet/j_spring_security_check n'est pas disponible.
j'utilise spring-security 3.0.5
voici mon aplicationContext.xml
Mon web.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="org.gjt.mm.mysql.Driver" /> <property name="url" value="jdbc:mysql://localhost/e_learning" /> <property name="username" value="root" /> <property name="password" value="" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="annotatedClasses"> <list> <value>learning.model.Absence</value> <value>learning.model.Administrateur</value> <value>learning.model.Apprenant</value> <value>learning.model.Certificat</value> <value>learning.model.Cours</value> <value>learning.model.Compte</value> <value>learning.model.Discussion</value> <value>learning.model.Ecole</value> <value>learning.model.Examen</value> <value>learning.model.Formateur</value> <value>learning.model.Groupe</value> <value>learning.model.Intervention</value> <value>learning.model.Module</value> <value>learning.model.Note</value> <value>learning.model.NoteId</value> <value>learning.model.Salon</value> <value>learning.model.Seance</value> <value>learning.model.Session</value> <value>learning.model.Sousadministrateur</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer"> <property name="scopes"> <map> <entry key="session"> <bean class="org.springframework.web.context.request.SessionScope"/> </entry> </map> </property> </bean> <tx:annotation-driven transaction-manager="transactionManager"/> <context:annotation-config/> <context:component-scan base-package="learning"/> </beans>
mon LoginBean.java
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>test_learning</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <context-param> <param-name>contextConfigSecurity</param-name> <param-value>/WEB-INF/spring-security.xml</param-value> </context-param> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <context-param> <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> </context-param> <context-param> <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name> <param-value>resources.application</param-value> </context-param> <listener> <listener-class>com.sun.faces.config.ConfigureListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener> <filter> <filter-name>RichFaces Filter</filter-name> <filter-class>org.ajax4jsf.Filter</filter-class> </filter> <filter-mapping> <filter-name>RichFaces Filter</filter-name> <servlet-name>Faces Servlet</servlet-name> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> </web-app> mon spring-security.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:security="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"> <security:http auto-config="true"> <security:intercept-url pattern="/LoginBean*" access="IS_AUTHENTICATED_ANONYMOUSLY" /> <security:intercept-url pattern="/Views/admin/**" access="ROLE_ADMIN" /> <security:form-login login-processing-url="/j_spring_security_check" login-page="/Views/admin/login.jsp" authentication-failure-url="/Views/admin/login.jsp" default-target-url="/Views/admin/admin.jsp?" always-use-default-target="true" /> <security:session-management session-fixation-protection="migrateSession" session-authentication-error-url="/Views/admin/login.jsp" invalid-session-url="/Views/admin/login.jsp" > <security:concurrency-control max-sessions="1" error-if-maximum-exceeded="true" /> </security:session-management> </security:http> <security:authentication-manager > <security:authentication-provider> <security:jdbc-user-service data-source-ref="dataSource" users-by-username-query="select login,password, validation from compte where login=?" authorities-by-username-query="select c.login, c.role from login c where c.login =? " /> </security:authentication-provider> </security:authentication-manager> </beans>
page login.jsp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 package learning.bean; import java.io.IOException; import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @Component @Scope("request") public class LoginBean { private String login = ""; private String password = ""; public String doLogin() throws IOException, ServletException { ExternalContext context = FacesContext.getCurrentInstance().getExternalContext(); RequestDispatcher dispatcher = ((ServletRequest) context.getRequest()).getRequestDispatcher("/j_spring_security_check"); dispatcher.forward((ServletRequest) context.getRequest(), (ServletResponse) context.getResponse()); FacesContext.getCurrentInstance().responseComplete(); // It's OK to return null here because Faces is just going to exit. return null; } public String getLogin() { return this.login; } public void setLogin(final String login) { this.login = login; } public String getPassword() { return this.password; } public void setPassword(final String password) { this.password = password; } }
une solution s'il vous plait !!!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 .... <h:form id="loginForm" prependId="false"> <p style="margin-bottom: 30px"> <h:outputText styleClass="label_padding2" value="Nom d'utilisateur :" /> <h:inputText value="#{loginBean.login}" id="login" required="true" requiredMessage="Le Champs 'Nom d'utilisateur' est obligatoire ! " immediate="true"/> <rich:message for="login" id="ErreurLogin" style="color:red" /> </p> <p style="margin-bottom: 30px"> <h:outputText styleClass="label_padding2" value="Mot de passe :" /> <h:inputSecret value="#{loginBean.password}" id="password" required="true" requiredMessage="Le Champs 'Mot de passe' est obligatoire ! " immediate="true" /> <rich:message for="password" id="ErreurPassword" style="color:red" /> </p> <p class="clearfix"> <h:commandButton type="submit" id="idLogin" action="#{loginBean.doLogin}" value="Connexion" title="Connexion" styleClass="fr btn btn_admin fl log" style="width : 102px; height : 24px;"/> </p> </h:form>![]()
Partager