code: @Override
      public void doSessionCreated() throws Exception {
          // establish the user principals.
          // XXX There's a question about what to do if they are changed on revalidate
          Set<Class<Principal>> userPrincipalClasses = serviceManagementBean.getUserPrincipalClasses();
  
          if (userPrincipalClasses != null && !userPrincipalClasses.isEmpty()) {
              Map<String, String> userPrincipals = new HashMap<>();
              Subject subject = session.getSubject();
              if (subject != null) {
                  Set<Principal> principals = subject.getPrincipals();
                  for (Principal principal : principals) {
                      String principalName = principal.getName();
                      for (Class<Principal> userPrincipal : userPrincipalClasses) {
                          if (userPrincipal.isInstance(principal)) {
                              userPrincipals.put(principalName, principal.getClass().getName());
                          }
                      }
                  }
  
                  // The following MUST run ON the IO thread.
                  setUserPrincipals(userPrincipals);
              }
          }
      }
docs: ---------------------------------------------------------------