File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JBoss/WildFly and the fly likes Can't get my custom principal using getCallerPrincipal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Can Watch "Can New topic

Can't get my custom principal using getCallerPrincipal

tanguy le berre

Joined: Feb 26, 2004
Posts: 1
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.

I agree. Here's the link:
subject: Can't get my custom principal using getCallerPrincipal
It's not a secret anymore!