Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can't get my custom principal using getCallerPrincipal  RSS feed

tanguy le berre
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);
// Set the roles for this principal in the 'Roles' group
Group group = getGroup(principals,"Roles");
group.addMember(new SimplePrincipal("JBossAdmin"));
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.

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!