J'ai securisé l'accés a mes pages jsp a l'aide de jaas.
Afin de pouvoir faire l'identification j'utilise un lien vers une page securisé car j'ai lu qu'avec jaas on ne peut pas directement appeler le formulaire de connection.
Mon probleme est que lorsque j'appel la page securisé, celle ci s'affiche quant meme et lors du deuxieme appel j'obtiens bien le formulaire de connection.
Mon fichier web.xml
Ma jsp qui appel la page securisé :
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 <?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>PremierProjetWeb</display-name> <welcome-file-list> <welcome-file>Welcome.jsp</welcome-file> </welcome-file-list> <!-- Configuration de JSF --> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> </context-param> <servlet> <servlet-name>FacesServlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>FacesServlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <!-- Fin de la configuration de JSF --> <!-- Configuration de la sécurité --> <security-constraint> <web-resource-collection> <web-resource-name>webRessourcetest</web-resource-name> <url-pattern>/faces/MainAccount.jsp</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>customer</role-name> </auth-constraint> <user-data-constraint> <description /> <transport-guarantee>NONE</transport-guarantee> </user-data-constraint> </security-constraint> <login-config> <auth-method>FORM</auth-method> <form-login-config> <form-login-page>/faces/SignOn.jsp</form-login-page> <form-error-page>/faces/SignOn.jsp</form-error-page> </form-login-config> </login-config> <security-role> <role-name>customer</role-name> </security-role> <!-- Fin de la configuration de la sécurité --> </web-app>
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 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %> <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%> <%@ page import="com.Session.Connection"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <head> <link rel="stylesheet" type="text/css" href="common/style_div.css"> <%@page import="java.security.Principal"%> <% boolean isConnected=false; Principal principal = request.getUserPrincipal(); if(principal!=null){ isConnected = true; } %> </head> <f:subview id="header"> <h:form> <div style="float: left;"> <h:commandLink action="Main"> <h:graphicImage width="197" height="87" url="imgs/Logo.jpg"/> </h:commandLink> </div> <div style="float: left;"> <div style="margin-left: 50px";> <span class="MainTitle"> <h:outputText value="#{i18n.LABEL_Header_TitlePart1}"/> <br> <h:outputText value="#{i18n.LABEL_Header_TitlePart2}"/> </span> </div> </div> <div style="float: right;"> <span class="MainSignon"> <c:choose> <c:when test="<%=isConnected%>"> <h:commandLink action="#{ConnectionManagedBean.doSignOff}"> <h:outputText value="#{i18n.LABEL_Header_SignOff}"/> </h:commandLink> </c:when> <c:otherwise> <h:commandLink action="MainAccount"> <h:outputText value="#{i18n.LABEL_Header_MyBankingAccount}"/> </h:commandLink> </c:otherwise> </c:choose> </span> </div> </h:form> </f:subview>
Partager