How to deploy a custom login module in JBoss AS 5.1
sacha Mar 1, 2011 4:42 AMHi all,
My problem is very simple. I use the JBoss LDAPLoginModule and it works i can see it in the log of my LDAP server. But when i try to use my own login module it does'nt work.
This is the code of my LoginModule he is very simple because i want to be sure that he works before implementing the complete methods :
import java.util.Map;
import javax.security.auth.Subject;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.LoginException;
import org.jboss.security.auth.spi.LdapLoginModule;
import org.Myapp.portal.logger.PortalLogger;
public class MyApp_LdapLoginModule extends LdapLoginModule
{
private static PortalLogger logger = new PortalLogger(MyLoginModule.class);
@Override
public boolean login() throws LoginException
{
boolean response = super.login();
logger.debug("Login");
return response;
}
public void initialize(Subject subject, CallbackHandler CallbackHandler, Map sharedState, Map options)
{
logger.debug("Initialize");
super.initialize(subject, CallbackHandler, sharedState, options);
}
public boolean commit() throws LoginException
{
logger.debug("Commit");
return super.commit();
}
public boolean abort() throws LoginException
{
logger.debug("Abort");
return super.abort();
}
public boolean logout() throws LoginException
{
logger.debug("Logout");
return super.logout();
}
}
In the login-config.xml i've just replace this line :
<login-module code="org.jboss.security.auth.spi.LdapLoginModule" flag="required">
By this one :
<login-module code="org.MyApp.security.MyApp_LdapLoginModule" flag="required">
And my class MyApp_LdapLoginModule is in a Jar file. I've place this jar in JBoss_HOME/server/default/lib
The problem is that JBoss don't give me any error. He start normaly and when i start my application the Jboss server use the default policy for login.
<application-policy name="other">
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required"/>
</authentication>
</application-policy>
And never make any request to my loginModule or my LDAP server... I don't understand why the JBoss LoginModule works and mine don't.
I think JBoss can't find my Jar file. i have try all directory : default/deploy, JBoss_HOME/lib, common/lib etc...
Have you any idea ?
Best regards