• Post Reply Bookmark Topic Watch Topic
  • New Topic

JAAS DatabaseServerLoginModule  RSS feed

 
Hannes Sch�nb�ck
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I want to use the org.jboss.security.auth.spi.DatabaseServerLoginModule to authenticate the User. I use the deafualt Hypersonic DB that is included in JBoss 3.2.5. I have created my own security domain named ProjectManagement and i have written following statements into the login-config.xml

<application-policy name = "ProjectManagement">
<authentication>
<login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule" flag = "required">
<module-option name = "unauthenticatedIdentity">guest</module-option>
<module-option name = "dsJndiName">java:/DefaultDS</module-option>
<module-option name = "principalsQuery">SELECT PW FROM PROJECTMEMBER WHERE MEMBERID=?</module-option>
<module-option name = "rolesQuery">SELECT ROLEID FROM ROLETOMEMBER WHERE MEMBERID=?</module-option>
</login-module>
</authentication>
</application-policy>

If I use a testclient that want to log in, I always get the exception

javax.security.auth.login.LoginException: javax.naming.NameNotFoundException: DefaultDS not bound
at org.jboss.security.auth.spi.DatabaseServerLoginModule.getUsersPassword(DatabaseServerLoginModule.java:110)
at org.jboss.security.auth.spi.UsernamePasswordLoginModule.login(UsernamePasswordLoginModule.java:156)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)........

How can I bind the JNDI name of the the Database???

thx in advance

Hannes
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
first check if you datasource is beeing bound for other operations.
Then, try the following queries (jboss has some restricitions on it`s queries).



Note that in the rolesQuery, the you should return the Role name and the Role group and not the ROLEID. Also note that you should use the aliases for the queries.

There`s one thing left. I don`t know how your client looks like but you need to pay attention to jboss jaas structure. Basically, if you`re using a web client that creates a LoginContext() and authenticates via Tomcat (servlet or jsp) it won`t work. Get more information on jboss jaas forum.
[ August 30, 2004: Message edited by: Leandro Melo ]
 
Hannes Sch�nb�ck
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i call my entity beans it works, so it seems to me that my database is known by my EJB's. Nevertheless I still have the same troubles as mentioned before.

Here is my Client code:

public ProjectManagementDelegate(String username,String password) throws Exception {
try{
jaasLogin(username,password);
}catch(Exception e){
e.printStackTrace();
}


public void jaasLogin(String login,String pw){
try {
lc = new LoginContext("ProjectManagement",new UsernamePasswordHandler(login,pw.toCharArray()));
lc.login();
} catch (LoginException e) {
e.printStackTrace();
}
}


}
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean the same problems that you're getting the exception???

Is this code inside a a servlet, or what?

If this s a web application, try creating the jboss-web.xml (save it in web-inf dir) and insert the following line.

<jboss-web>
<security-domain>java:/jaas/ProjectManagement</security-domain>
</jboss-web>
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!