I have a custom principal class which I want to use for SSO. I have a login service EJB (in an EAR) which creates this CustomPrincipal instance and returns the same to a client WAR when the client logs in to the web app.
On further EJB invocations (which lie in the EAR which has the Login service also) from client WAR, the CustomPrincipal instance returned from the LoginService is set the on the InitialContext's SECURITY_PRINCIPAL attribute:
contextProperties.put(Context.SECURITY_PRINCIPAL, customPrincipal); contextProperties.put(Context.SECURITY_CREDENTIALS, customCredential); // ... other properties set here context = new InitialContext(contextProperties);
Principal principal = sessionContext.getCallerPrincipal(); if (principal instanceof CustomPrincipal) { //do some logging and timing checks and continue .... } else throw new Exception("Unsupported principal");
<?xml version="1.0"?> <jboss-app> <loader-repository> fx:loader=fx.ear <loader-repository-config>Java2ParentDelegation=false</loader-repository-config> </loader-repository> </jboss-app>
<?xml version="1.0"?> <jboss-web> <class-loading> <loader-repository> fx:loader=fxtestharness_i2.war </loader-repository> </class-loading> </jboss-web>