Get the current logged-in user.  Goes through a custom {@link LoginHandler}, if one has been configured in
beehive-netui-config.xml.

@return the current logged-in <code>Principal</code>, or <code>null</code> if there is no logged-in user.
346238
public Principal getUserPrincipal()
    {
        LoginHandler lh = Handlers.get( getServletContext() ).getLoginHandler();
        return lh.getUserPrincipal(getHandlerContext());
    }
718052
public static Authentication getCurrentAuthentication() {
        RequestContext context = RequestContext.getCurrent();
        if (context != null) {
            return getAuthentication(context.getRequest());
        } else {
            return null;
        }
    }
770267
public User getUser() {
        ClientResource resource = new ClientResource(Route.ME.url());
        resource.setChallengeResponse(this.auth.toChallenge());

        try {
            Representation repr = resource.get();
            return mapper.readValue(repr.getText(), User.class);
        } catch (IOException ex) {
            LEX4JLogger.log(Level.WARNING, "Could not retrieve user (me) correctly!");
            return null;
        }
    }
1114779
protected Principal getPrincipal() {
        final Object principal = requestContext.getProperty("Principal");
        if (principal != null) {
            return (Principal) principal;
        } else {
            return null;
        }
    }
220626
protected User getLoggedUser() {
    UUID userId = getLoggedUserId();
    if (userId == null) {
      return null;
    }
    
    return userController.findUserByKeycloakId(userId);
  }
90265
public function getuser(){
		if(empty($this->user)){
			return NULL;
			}
		bimport('users.general');
		$bu=BUsers::getInstance();
		$user=$bu->itemGet($this->user);
		return $user;
		}
1321298
public static Optional<String> getCurrentTenant() {
        final UserDetails userDetails = getCurrentUser();
        if (!(userDetails instanceof UserPrincipal)) {
            return Optional.empty();
        }

        final UserPrincipal userPrincipal = (UserPrincipal) userDetails;
        return Optional.of(userPrincipal.getTenant().trim());
    }
259948
public User getCurrentUser() throws ProvisioningApiException {

		try {
			GetUsersSuccessResponse resp = usersApi.getCurrentUser();

			if (!resp.getStatus().getCode().equals(0)) {
				throw new ProvisioningApiException("Error getting current user. Code: " + resp.getStatus().getCode());
			}
            return new User((Map<String, Object>)resp.getData().getUser());

        } catch(ApiException e) {
        	throw new ProvisioningApiException("Error getting current user", e);
        }
	}
834471
@Override
    public String getRemoteUser() {
        String user = getHeader("X_REMOTE_USER");
        if (user != null) {
            return user;
        } else {
            return super.getRemoteUser();
        }
    }
188369
protected function getUser()
    {
        if ($this->_user === null) {
            $this->_user = Admin::findByEmailOrMobileOrUsername($this->login);
        }
        return $this->_user;
    }
478321
public function user()
    {
        if (!is_null($this->user)) {
            return $this->user;
        }
        $user = null;
        try {
            $resourceId = Authorizer::getResourceOwnerId();
            $resourceType = Authorizer::getResourceOwnerType();
        } catch (\Exception $e) {
            $resourceId = null;
            $resourceType = null;
            // throw $e;
        }
        if ($resourceType !== $this->id) {
            return null;
        }
        if (!empty($resourceId)) {
            $user = $this->getProvider()->retrieveById($resourceId);
        }
        return $this->user = $user;

    }
1180794
@Override
    public LoginCredential getLoginCredential() {
        return LaRequestUtil
                .getOptionalRequest()
                .map(request -> {
                    final HttpServletResponse response = LaResponseUtil.getResponse();
                    final SpnegoHttpServletResponse spnegoResponse = new SpnegoHttpServletResponse(response);

                    // client/caller principal
                    final SpnegoPrincipal principal;
                    try {
                        principal = getAuthenticator().authenticate(request, spnegoResponse);
                    } catch (final Exception e) {
                        final String msg = "HTTP Authorization Header=" + request.getHeader(Constants.AUTHZ_HEADER);
                        if (logger.isDebugEnabled()) {
                            logger.debug(msg);
                        }
                        throw new SsoLoginException(msg, e);
                    }

                    // context/auth loop not yet complete
                    if (spnegoResponse.isStatusSet()) {
                        return new ActionResponseCredential(() -> {
                            throw new RequestLoggingFilter.RequestClientErrorException("Your request is not authorized.",
                                    "401 Unauthorized", HttpServletResponse.SC_UNAUTHORIZED);
                        });
                    }

                    // assert
                    if (null == principal) {
                        final String msg = "Principal was null.";
                        if (logger.isDebugEnabled()) {
                            logger.debug(msg);
                        }
                        throw new SsoLoginException(msg);
                    }

                    if (logger.isDebugEnabled()) {
                        logger.debug("principal=" + principal);
                    }

                    final String[] username = principal.getName().split("@", 2);
                    return new SpnegoCredential(username[0]);
                }).orElseGet(() -> null);

    }
102902
public CompletionStage<Result> currentUser() {
        return SecureSocial.currentUser(env).thenApply( new Function<Object, Result>() {
            public Result apply(Object maybeUser) {
                String id;

                if ( maybeUser != null ) {
                    DemoUser user = (DemoUser) maybeUser;
                    id = user.main.userId();
                } else {
                    id = "not available. Please log in.";
                }
                return ok("your id is " + id);
            }
        });
    }
560882
public static @Nullable @CheckForNull String getCurrentUsername() {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication == null) {
      return null;
    }
    return getUsername(authentication);
  }
1276301
public User getRemoteUser() {
        HttpServletRequest request = ServletActionContext.getRequest();

        if (request != null) {
            String remoteUserName = request.getRemoteUser();

            if (remoteUserName != null) {
                return getUserAccessor().getUserIfAvailable(remoteUserName);
            }
        }

        return AuthenticatedUserThreadLocal.getUser();
    }
144036
public function getCurrentUser()
    {
        if ($this->currentuser === null) {
            $hash = $this->getCurrentSessionHash();
            if ($hash === false) {
                return false;
            }

            $uid = $this->getSessionUID($hash);
            if ($uid === false) {
                return false;
            }

            $this->currentuser = $this->getUser($uid);
        }
        return $this->currentuser;
    }
699418
public function user()
    {
        // If we've already retrieved the user for the current request we can just
        // return it back immediately. We do not want to fetch the user data on
        // every call to this method because that would be tremendously slow.
        if (! is_null($this->user)) {
            return $this->user;
        }

        $user = null;

        if ($this->jwt->isHealthy()) {
            $id = $this->jwt->getId();
            $user = $this->provider->retrieveById($id);
        }

        return $this->user = $user;
    }