code: private IAuthorizationPrincipal getAuthorizationPrincipal(Authentication authentication) {
  
          final Object authPrincipal = authentication.getPrincipal();
          logger.trace("getAuthorizationPrincipal -- authPrincipal=[{}]", authPrincipal);
  
          String username;
          if (authPrincipal instanceof UserDetails) {
              // User is authenticated
              UserDetails userDetails = (UserDetails) authPrincipal;
              logger.trace(
                      "getAuthorizationPrincipal -- AUTHENTICATED, userDetails=[{}]", userDetails);
              username = userDetails.getUsername();
          } else {
              // Which guest user are we?
              final HttpServletRequest req = portalRequestUtils.getCurrentPortalRequest();
              final IPerson person = personManager.getPerson(req);
              logger.trace("getAuthorizationPrincipal -- UNAUTHENTICATED, person=[{}]", person);
              username = person.getUserName();
          }
  
          return authorizationServiceFacade.newPrincipal(username, IPerson.class);
      }
docs: Prepare a uPortal IAuthorizationPrincipal based in the Spring principal