I need to store in the principal class not only name of the principal but also id from database. So I have created my own login module which inherits from the jboss DatabaseServerLoginModule. In the method getUsersPassword I also get the id of the user from the db. Here is the code snipet :

Everything works fine I can login to the application but when I try to get the callerPrincipal from the SessionContext object I get SimplePrincipal instance. I can't cast to SmartOfficePrincipal.

Also when I try to get principal in the entitylistener using the following statement :

Principal principal = SecurityAssociation.getPrincipal();

I get the instance of SimplePrincipal class. I need user id because in entity listener i would like to set the user who have last modify object or created. So I don't have to remember to set up this by hand in the code.

I get the set of the principals where the first element in this set is the my own implementation of the principal class and that's right, subject gets filled with principals in the LoginModule commit method.

However when I call Sec

SecurityAssociation.getPrincipal();
or
SecurityAssociation.getCallerPrincipal();
or
sessionContext.getCallerPrincipal();

I always get the instance of the SimplePrincipal.

It seems that my loginModule works well, but during the propagation of the caller principal jboss is ignoring my principal class and sets his default.

I have exactly the same problem with Micheal, JBoss 6.0.0 final. always get the SimplePrincipal instead of my Cumtom Principal, has anyone successfully get Cumtom Principal from SessionContext under JBoss 6.0.0 final ?

I have exactly the same problem with Micheal, JBoss 6.0.0 final. always get the SimplePrincipal instead of my Cumtom Principal, has anyone successfully get Cumtom Principal from SessionContext under JBoss 6.0.0 final ?

It seems this is simply impossible. It's a LONG standing bug in JBoss AS and there doesn't seem to be any hope of this ever getting fixed.

Via the PolicyContext you can get the original Subject that the login module (parent) creates, and from that you can get your Custom Principal. I'm going to try this method. If anyone knows of any bad side-effects with using this method, please let me know.