Here’s a useful bit of code that uses the information in the security context and populate the ADF App Module Session’s user data. This snippet is used in your ADF Fusion project’s Application Module’s “prepareSession” method, as shown below, and it uses the “session.getUserData()” to get a handle to the session to populate the user info.
Here’s the code:
protected void prepareSession(Session session) { ..... .... java.security.AccessControlContext context = java.security.AccessController.getContext(); javax.security.auth.Subject subject = javax.security.auth.Subject.getSubject(context); if (subject != null && subject.getPrincipals() != null) { Iterator iteratorOverPrincipals = subject.getPrincipals().iterator(); String user = null; if (iteratorOverPrincipals.hasNext()) user = ((Principal)iteratorOverPrincipals.next()).getName(); if (user != null) log.log(Level.INFO, "PrepareSession:" + user); Hashtable userData = session.getUserData(); userData.put(UserSession.USER_SESSION_KEY, new UserSession(user)); } else { Hashtable userData = session.getUserData(); userData.put(UserSession.USER_SESSION_KEY, new UserSession(null)); .... ... } .... .... }