JAAS + authentification from database
Posted
by
AhmedDrira
on Stack Overflow
See other posts from Stack Overflow
or by AhmedDrira
Published on 2012-04-11T23:17:39Z
Indexed on
2012/04/11
23:29 UTC
Read the original article
Hit count: 286
i am traying to performe an authentification from data base using JAAS i v configured the login-config.xml like this
<application-policy name="e-procurment_domaine">
<authentication>
<login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
<module-option name = "dsJndiName">BasepfeDS</module-option>
<module-option name="securityDomain">java:/jaas/e-procurment_domaine</module-option>
<module-option name="principalsQuery">SELECT pass FROM personne WHERE login=?</module-option>
<module-option name="rolesQuery">SELECT disc FROM personne WHERE login=?</module-option>
</login-module>
</authentication>
</application-policy>
and I've written a test : this one
@Test
public void testFindALL() {
System.out.println("Debut test de la méthode findALL");
// WebAuthentication wa=new WebAuthentication();
// wa.login("zahrat", "zahrat");
securityClient.setSimple("zahrat", "zahrat");
try {
securityClient.login();
} catch (LoginException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Acheteur acheteur = new Acheteur();
System.out.println("" + acheteurRemote.findAll().size());
// } catch (EJBAccessException ex) {
// System.out.println("Erreur attendue de type EJBAccessException: "
// + ex.getMessage());
// } catch (Exception ex) {
// ex.printStackTrace();
// fail("Exception pendant le test find ALL");
System.out.println("Fin test find ALL");}
// }
the test is fail i dont know why , but when i change the polycy with the methode of .property file it works ..
i am using the annotation on the session BEAN classes
@SecurityDomain("e-procurment_domaine")
@DeclareRoles({"acheteur","vendeur","physique"})
@RolesAllowed({"acheteur","vendeur","physique"})
and the annotation on the session for the methode
@RolesAllowed("physique")
@Override
public List<Acheteur> findAll() {
log.debug("fetching all Acheteur");
return daoGenerique.findWithNamedQuery("Acheteur.findAll");
}
i think that the test have an acess to my data base doe's it need mysql DRIVER or a special config on JBOSS?
© Stack Overflow or respective owner