Search code examples
javajakarta-eejbosswildflywildfly-8

Get principal for wildfly


I am migrating a legacy application from Orion web server to Wildfly. In orion web server, the security principal is fetched in the following way:

String  remoteUser = request.getRemoteUser();
javax.naming.InitialContext  initialContext =new javax.naming.InitialContext(); 
Object rmo = initialContext.lookup("java:comp/RoleManager");
com.evermind.security.RoleManager roleManager = (com.evermind.security.RoleManager) rmo;
if (remoteUser != null) {
    java.security.Principal  principal = roleManager.getPrincipal(remoteUser);
}

I would like to know an equivalent method to obtain the principal in JBoss/Wildfly.

Please let me know if you need any additional information.


Solution

  • If you are using JAAS you can do it through the standard way:

    java.security.Principal  principal = request.getUserPrincipal();