Bonjour à tous,
J'ai une application JEE qui utilise les realms sous Glassfish pour la gestion des droits. Tout fonctionne bien niveau authentification, vérification et redirections.
Mon souci est au niveau de l'affichage du template. J'utilise la composition disponible avec JSF.
Au moment de lancer l'application, Glassfish me demande une authentification avant d’accéder à la page d'accueil, cette page d'authentification s'affiche sans le template.
Dois-je configurer le web.xml ou le glassfish.xml d'une certaine manière ou s'agit-il d'un problème d'accès aux ressources (css, images, etc) ?
Authentification.xhtml
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 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtmll/DTD/xhtml-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets"> <ui:composition template="include/template.xhtml"> <ui:define name="title">Authentification</ui:define> <ui:define name="content"> <h1>Identifiez-vous ...</h1> <form method="post" action="j_security_check"> <h:panelGrid columns="2"> <h:outputLabel for="j_username" value="Username" /> <input type="text" name="j_username" /> <h:outputLabel for="j_password" value="Password" /> <input type="password" name="j_password" /> <h:outputText value="" /> <h:panelGrid columns="2"> <input type="submit" name="submit" value="Login" /> <h:button outcome="index" value="Cancel" /> </h:panelGrid> </h:panelGrid> </form> </ui:define> </ui:composition> </html>
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
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 <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsf</welcome-file> </welcome-file-list> <security-constraint> <display-name>SecurityConstraintGlobal</display-name> <web-resource-collection> <web-resource-name>MSDSHostingGlobal</web-resource-name> <url-pattern>/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>adminmsds</role-name> <role-name>professormsds</role-name> <role-name>studentmsds</role-name> </auth-constraint> <user-data-constraint> <transport-guarantee>NONE</transport-guarantee> </user-data-constraint> </security-constraint> <security-constraint> <display-name>SecurityConstraintAdmin</display-name> <web-resource-collection> <web-resource-name>MSDSHostingAdmin</web-resource-name> <url-pattern>/admin/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>adminmsds</role-name> </auth-constraint> <user-data-constraint> <transport-guarantee>NONE</transport-guarantee> </user-data-constraint> </security-constraint> <security-constraint> <display-name>SecurityConstraintProfessors</display-name> <web-resource-collection> <web-resource-name>MSDSHostingProfessors</web-resource-name> <url-pattern>/professors/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>adminmsds</role-name> <role-name>professormsds</role-name> </auth-constraint> <user-data-constraint> <transport-guarantee>NONE</transport-guarantee> </user-data-constraint> </security-constraint> <security-constraint> <display-name>SecurityConstraintStudents</display-name> <web-resource-collection> <web-resource-name>MSDSHostingStudents</web-resource-name> <url-pattern>/students/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>adminmsds</role-name> <role-name>professormsds</role-name> <role-name>studentmsds</role-name> </auth-constraint> <user-data-constraint> <transport-guarantee>NONE</transport-guarantee> </user-data-constraint> </security-constraint> <login-config> <auth-method>FORM</auth-method> <realm-name>msds-jdbcrealm</realm-name> <form-login-config> <form-login-page>/authentification.jsf</form-login-page> <form-error-page>/erreurauth.jsf</form-error-page> </form-login-config> </login-config> <error-page> <error-code>403</error-code> <location>/accessdenied.jsf</location> </error-page> </web-app>
Template.xhtml
La page authentification.jsf fonctionne correctement si je pointe normalement dessus.
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 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:head> <title> <ui:insert name="title">Default title</ui:insert> </title> <style type="text/css" media="screen">@import "css/style.css";</style> <script type="text/javascript" src="js/jquery.js"></script> </h:head> <h:body> <div id="header"> <div id="logo"><a href="" title="" target="_parent"></a></div> <div id="authForm"> </div> </div> <!-- appel du menu principal--> <div id="navbar"> <ul id="menu" > <li><a href="index.jsf" title="" target="_parent" class="m_accueil">Taleau de bord</a></li> <li><a href="manageDomain.jsp" title="" target="_parent" class="m_hebergement">Gérer votre domaine</a></li> <li><a href="statistical.jsp" title="" target="_parent" class="m_nomdedomaine">Statistiques</a></li> <li><a href="assistance.jsp" title="" target="_parent" class="m_serveurdedie">Assistance</a></li> <li><a href="help.jsp" title="" target="_parent" class="m_contact">Aide</a></li> </ul> </div> <div id="corpshaut"></div> <div id="bloc"> <div id="corps"> <ui:insert name="content">Default content</ui:insert> <div style="clear:both;"></div> <img src="images/ban.png" alt="ban.png"/> </div> </div> <div id="footer"> <p>2012 MSDS </p> </div> </h:body> </html>
Partager