Bonsoir,
j'ai entrain de developper une app j2ee jsf+primefaces et hibernate
j'arrive a faire tous les interfaces concernant l'acteur administrateur et employe.
maintenant, je developpe la partie authentification et l'autorisation selon le rôle d'acteur.
je fais une interface jsf nommée log.xhtml et je cree une fichier managed bean nommée loginbean pour tester la verfication login et password.
je cree une methode nommée login() qui retourne une chaine de caractere soit la chaine "failure" si la connexion est echouée ou une chaine qui contient le role de l'acteur "super-admin" ou "employe".
la verification est réussi et la connexion passe correctement aussi la redirection des liens en utilisant la balise <navigation-rules> dans le fichier faces-config.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <navigation-rule>
<from-view-id>log.xhtml</from-view-id>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>log.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>super</from-outcome>
<to-view-id>admin/ad.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>simple</from-outcome>
<to-view-id>adminsp/profil.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>employe</from-outcome>
<to-view-id>user/test.xhtml</to-view-id>
</navigation-case>
</navigation-rule> |
mais le probleme c'est apres la redirection le lien url reste la même et lorsque je clique sur un autre lien dans la partie employe il m'affiche cette erreur
/Profil_Employe.xhtml Not Found in ExternalContext as a Resource
c'est le code loginbean
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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
package com.bean;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.Vector;
import ma.Authentification.Authentification;
public class loginbean {
/**
* Creates a new instance of loginbean
*/
public loginbean() {
}
private String nom;
private String prenom;
private String username;
private String password;
private String role;
private String matricule;
boolean connecte = false;
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getLog() {
return log;
}
public void setLog(String log) {
this.log = log;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getPrenom() {
return prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getMatricule() {
return matricule;
}
public void setMatricule(String matricule) {
this.matricule = matricule;
}
public String log;
public String pass;
public Vector resultat_final;
public int a ;
public String ch;
public String login() throws SQLException
{
try{
if(username.equals("") || password.equals("")){
ch= "failure";
}
else {
Authentification id= new Authentification(username,password);
int a=0;
Enumeration e = id.resultat.elements();
while(e.hasMoreElements()){
for(int k=0;k<id.resultat.size();++k)
{//retourner les résultats
resultat_final=(Vector)id.resultat.elementAt(k);
log = resultat_final.elementAt(0).toString();
pass = resultat_final.elementAt(1).toString();
role=resultat_final.elementAt(2).toString();
matricule=resultat_final.elementAt(3).toString();
nom=resultat_final.elementAt(4).toString();
prenom=resultat_final.elementAt(5).toString();
}
if(username.equals(log) || pass.equals(pass)){
a=1;
break;
}
}
if(a==1){
if(role.equals("super-administrateur"))
{
ch= "super"; }
else if(role.equals("simple-administrateur"))
{ ch="simple";
}
else if(role.equals("employe"))
{
ch= "employe";
}
else if(role.equals("consultant"))
{
ch= "consultant";
}
}
else{
ch= "failure";
}
}
}catch (Exception e){e.printStackTrace();}
return ch;
}
} |
j'ouvre un sujet la dernière période concerne la meme probleme et il y a une solution mais je trouve pas cet sujet dans le forum.
je pense qu'il y a un membre qui a conceille d'utiliser la methode Facescontext.
s'il possible de m'aider et merci d'avance.
Partager