public String resolvePrincipal(Session session) {
      String principalName = session.getAttribute(PRINCIPAL_NAME_INDEX_NAME);
      if (principalName != null) {
         return principalName;
      }
      Object authentication = session.getAttribute(SPRING_SECURITY_CONTEXT);
      if (authentication != null) {
         Expression expression = parser.parseExpression("authentication?.name");
         return expression.getValue(authentication, String.class);
      }
      return null;
   }
public String resolvePrincipal ( Session session ) { String principalName = session . getAttribute ( PRINCIPAL_NAME_INDEX_NAME ) ; if ( principalName != null ) { return principalName ; } Object authentication = session . getAttribute ( SPRING_SECURITY_CONTEXT ) ; if ( authentication != null ) { Expression expression = parser . parseExpression ( "authentication?.name" ) ; return expression . getValue ( authentication , String . class ) ; } return null ; }
Resolves Principal Name (e.g. user name) based on session.

@param session Session to be checked.
@return Extracted Principal Name