Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't get my custom principal using getCallerPrincipal

 
tanguy le berre
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written my own LoginModule using my own Principal in JBoss. After Login, I can't get back my CallerPrincipal using the EJBContext.getCallerPrincpal or in a Servlet using getUserPrincipal. In fact I have a principal with the same name but not of my custom principal class, I have a SimplePrincipal.
Here is my commit method in my loginmodule:

public boolean commit() throws LoginException {
if(subject != null)
{
Set principals = subject.getPrincipals();
if(principals != null)
{
principals.add((TestPrincipal) caller);
Group callerPrincipal = new SimpleGroup("CallerPrincipal");
callerPrincipal.addMember((TestPrincipal) caller);
principals.add(callerPrincipal);
// Set the roles for this principal in the 'Roles' group
Group group = getGroup(principals,"Roles");
group.addMember(new SimplePrincipal("JBossAdmin"));
principals.add(group);
return true;
}
}
return false;
}
This is only a test class and that's why I don't look for the roles of my principal but I give him the JBossAdmin role. The Principal Caller is a TestPrincipal I created in the loginmethod.Why do the method getCallerPrincipal return a SimplePrincipal??
I verified my Subject was successfully filled by using SecurityAssociation.getSubject but I don't want to use this method to get my callerPrincipal back.

Thank's
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic