spring security web-inf/jsp/admin/
Bonjour a tous et merci de prendre 5 minutes de votre temps.
Je débute en Spring je souhaite utilisé spring security.
Mon application fonctionne quand je met les jsp a la racide du web-inf
j'ai une page ou je demande un login et password
et me renvoie sur une page en cas de succes
login.jsp renvoie sur backhome.jsp
mais voilà je souhaite mettre la page de login et ma page backhome.jsp dans /web-inf/jsp/admin
j'atteind bien la page /web-inf/jsp/admin/login mais quand j'ai entré mon login et pass
j'ai l'erreur suivante HTTP Status 404 - /website/admin/j_spring_security_check
donc je cherche des informations ou une information qui m'a échappée.
je pense que je fais mal le mapping mais un coup de main est le bien venue.
voici la gestion de spring security
Code:
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
|
<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-2.5.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
<!-- Stratégie de Sécurité : ressources et Remember me -->
<security:http auto-config="true">
<security:intercept-url pattern="/login.jsp"
filters="none" />
<security:intercept-url pattern="/css/**"
filters="none" />
<security:intercept-url pattern="/info/**"
access="ROLE_PARTICIPANT,ROLE_FORMATEUR,ROLE_COMMERCIAL,ROLE_MAINTENANCE,ROLE_ANONYMOUS" />
<security:intercept-url pattern="/logo*"
filters="none" />
<security:intercept-url pattern="/img/**"
filters="none" />
<security:intercept-url pattern="/css/**"
filters="none" />
<security:intercept-url pattern="/admin/**"
access="ROLE_PARTICIPANT,ROLE_FORMATEUR,ROLE_COMMERCIAL,ROLE_MAINTENANCE" />
<security:intercept-url pattern="/index.html"
access="ROLE_PARTICIPANT,ROLE_FORMATEUR,ROLE_COMMERCIAL,ROLE_MAINTENANCE,ROLE_ANONYMOUS" />
<security:intercept-url pattern="/**"
access="ROLE_PARTICIPANT,ROLE_FORMATEUR,ROLE_MAINTENANCE,ROLE_COMMERCIAL" />
<security:form-login login-page='/admin/login.jsp'
default-target-url="/admin/backhome.jsp" always-use-default-target="true" />
<security:logout />
<security:anonymous />
<security:remember-me />
</security:http>
<security:authentication-provider
user-service-ref='myUserDetailsService' />
</beans> |
la configuration de tiles
Code:
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
|
<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-2.5.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
<!-- Stratégie de Sécurité : ressources et Remember me -->
<security:http auto-config="true">
<security:intercept-url pattern="/**"
access="ROLE_ANONYMOUS" />
<security:intercept-url pattern="/admin/login.jsp"
filters="none" />
<security:intercept-url pattern="/admin/**"
access="ROLE_ANONYMOUS" />
<security:intercept-url pattern="/css/**"
filters="none" />
<security:intercept-url pattern="/info/**"
access="ROLE_PARTICIPANT,ROLE_FORMATEUR,ROLE_COMMERCIAL,ROLE_MAINTENANCE,ROLE_ANONYMOUS" />
<security:intercept-url pattern="/logo*"
filters="none" />
<security:intercept-url pattern="/img/**"
filters="none" />
<security:intercept-url pattern="/css/**"
filters="none" />
<security:intercept-url pattern="/index.html"
access="ROLE_PARTICIPANT,ROLE_FORMATEUR,ROLE_COMMERCIAL,ROLE_MAINTENANCE,ROLE_ANONYMOUS" />
<security:form-login login-page='/login.jsp'
default-target-url="/admin/backhome.jsp" always-use-default-target="true" />
<security:logout />
<security:anonymous />
<security:remember-me />
</security:http>
<security:authentication-provider
user-service-ref='myUserDetailsService' />
</beans> |
Voici le fichier xml qui permet de certifier les utilisateurs via la DB datasource ....
Code:
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
|
<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-2.5.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://unix-db/springsecurity" />
<property name="username" value="----" />
<property name="password" value="xxxxx" />
</bean>
<bean id="myUserDetailsService"
class="org.springframework.security.userdetails.jdbc.JdbcDaoImpl">
<property name="dataSource" ref="dataSource" />
<property name="usersByUsernameQuery"
value="SELECT login as username, password, enabled , nom, prenom FROM utilisateurs WHERE login = ?" />
<property name="authoritiesByUsernameQuery"
value="SELECT login as username, role FROM roles WHERE login = ?" />
</bean>
<bean
class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" />
<bean
class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" />
<!-- Declare the Interceptor -->
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="locale"/>
</bean>
<!-- Declare the Resolver -->
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"/>
</beans> |
et voici mon webxml
Code:
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
|
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>WebSite test</display-name>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/website-data.xml
/WEB-INF/spring/website-servlet.xml
/WEB-INF/spring/website-security.xml
</param-value>
</context-param>
<servlet>
<servlet-name>website</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>website</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
</web-app> |
et pour finir voici mon fichier Pom
Code:
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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>website</groupId>
<artifactId>website</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>website Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>20041127.091804</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-dao</artifactId>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.15</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-acl</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>20030825.184428</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>datetime</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>com.springsource.org.apache.tiles</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>com.springsource.org.apache.tiles.core</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>com.springsource.org.apache.tiles.jsp</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>com.springsource.org.apache.commons.logging</artifactId>
<version>99.0-does-not-exist</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>website</finalName>
</build>
</project> |
i vous avez une idée .
Je vous remercie encore pour avoir lu et essayé de comprendre mon problème.
Si vous pouvez me mettre sur le bon chemin.
bonne fin de weekend