SessionContext.getcontext() = null with custom loginModule with jboss 5.1
villagra Jun 15, 2010 6:24 AMHi all... after a lot of reading i still dont have a solution for this problem, i'm kind of desperate...
In this example bean, the context.getcontext() is allways null but, if i retrieve the subject with the securityAssociation i get the correct principals (+ a null ¿?¿? )
This is what i have:
And this is my project structure (i'm using maven)
Bean test (server-ejb-project):
}
After the login p ( name = null )
but subject s =
Principal: jm.villagra
Principal: Roles(members:Admin)
Principal: CallerPrincipal(members:jm.villagra)
Principal: null <== ¿?¿?
This is the dummy LoginModule
public class TestModule implements LoginModule {
private Subject subject;
private SimplePrincipal caller;
@Override
public void initialize(Subject aSubject, CallbackHandler aCallbackHandler, Map aSharedState, Map aOptions) {
subject = aSubject;
}
@Override
public boolean login() throws LoginException {
caller = new SimplePrincipal("jm.villagra");
return true;
}
@Override
public boolean commit() throws LoginException {
try {
Set<Principal> principals = subject.getPrincipals();
Group roles = new SimpleGroup("Roles");
roles.addMember(new SimplePrincipal("Admin"));
Group callerPrincipal = new SimpleGroup("CallerPrincipal");
callerPrincipal.addMember(caller);
principals.add(caller);
principals.add(roles);
principals.add(callerPrincipal);
return true;
} catch (Exception e) {
throw new LoginException(e.getMessage());
}
}
}
What am i doing wrong??? I've spent a lot of time with this and i cannot find a solution
Thank you very much