Gets the user name from the request principal.

@param req the servlet request
@return the authenticated user, or null if none is authenticated
3747
@Override
    public String getUserName(HttpServletRequest req) {
        Principal princ = null;
        if (req != null && (princ = req.getUserPrincipal()) != null) {
            String userName = princ.getName();
            if (userName != null && !userName.isEmpty()) {
                LOG.debug("HTTP request had user (" + userName + ")");
                return userName;
            }
        }
        return null;
    }
413879
public @CheckForNull User getUser(String name) {
        return User.get(name, User.ALLOW_USER_CREATION_VIA_URL && hasPermission(ADMINISTER));
    }
669679
protected User getUser() {
        User visitor = ThreadContext.getSessionVisitor();
        if (visitor != null) {
            return visitor;
        }
        return null;
    }
1239728
public String getPrincipal(ContainerRequestContext httpRequest) {
        if (principalCookieName != null && httpRequest.getCookies().size() > 0) {
            Map<String, Cookie> cookies = httpRequest.getCookies();
            for (Cookie cookie : cookies.values()) {
                if (principalCookieName.equals(cookie.getName())) {
                    return cookie.getValue();
                }
            }
        }

        return null;
    }
713635
protected function getUsername()
    {

        // initialize the name
        $name = null;

        // query whether or not we've an principal
        if ($identity = $this->getIdentity()) {
            $name = $identity->getName();
        }

        // return the name
        return $name;
    }
447266
public static String getSessionID(HttpServletRequest req) {
        String sessionID = null;
        final HttpServletRequest f_req = req;

        try {
            sessionID = AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
                @Override
                public String run() throws Exception {
                    HttpSession session = f_req.getSession();
                    if (session != null) {
                        return session.getId();
                    } else {
                        return null;
                    }
                }
            });
        } catch (PrivilegedActionException e) {
            if ((e.getException()) instanceof com.ibm.websphere.servlet.session.UnauthorizedSessionRequestException) {
                if (!req.isRequestedSessionIdFromCookie()) {
                    sessionID = AccessController.doPrivileged(new PrivilegedAction<String>() {
                        @Override
                        public String run() {
                            return f_req.getSession().getId();
                        }
                    });
                } else {
                    sessionID = AccessController.doPrivileged(new PrivilegedAction<String>() {
                        @Override
                        public String run() {
                            return f_req.getRequestedSessionId();
                        }
                    });
                }

            }
        } catch (com.ibm.websphere.servlet.session.UnauthorizedSessionRequestException e) {
            try {
                if (!req.isRequestedSessionIdFromCookie()) {
                    sessionID = AccessController.doPrivileged(new PrivilegedAction<String>() {
                        @Override
                        public String run() {
                            return f_req.getSession().getId();
                        }
                    });
                } else {
                    sessionID = AccessController.doPrivileged(new PrivilegedAction<String>() {
                        @Override
                        public String run() {
                            return f_req.getRequestedSessionId();
                        }
                    });
                }

            } catch (java.lang.NullPointerException ee) {
                sessionID = "UnauthorizedSessionRequest";
            } catch (com.ibm.websphere.servlet.session.UnauthorizedSessionRequestException ue) {
                sessionID = "UnauthorizedSessionRequest";
            }

        }
        return sessionID;
    }
447200
public Principal getUserPrincipal()
    {
        if (_userPrincipal == __NO_USER) return null;

        if (_userPrincipal == __NOT_CHECKED)
        {
            _userPrincipal = __NO_USER;

            // Try a lazy authentication
            HttpContext context = getHttpResponse().getHttpContext();
            if (context != null)
            {
                Authenticator auth = context.getAuthenticator();
                UserRealm realm = context.getRealm();
                if (realm != null && auth != null)
                {
                    try
                    {
                        // TODO - should not need to recalculate this!
                        String pathInContext = getPath().substring(
                                context.getContextPath().length());
                        auth.authenticate(realm, pathInContext, this, null);
                    }
                    catch (Exception e)
                    {
                        LogSupport.ignore(log, e);
                    }
                }
            }

            if (_userPrincipal == __NO_USER) return null;
        }
        return _userPrincipal;
    }
46130
@Override
    public String getName() {
        final Object attributeValue = this.getAttributeValue(this.userNameAttribute);
        if (attributeValue == null) {
            return null;
        }

        return attributeValue.toString();
    }
837447
public boolean isAuthorized(HttpServletRequest req) {
		if(all)return true;
		if(roles!=null) {
			for(String srole : roles) {
				if(req.isUserInRole(srole)) return true;
			}
		}
		return false;
	}
1107639
private Bearer getBearer(final HttpServletRequest req) {
        final String authorizationHeader = req.getHeader(Headers.AUTHORIZATION.getName());
        if (StringUtils.isNotBlank(authorizationHeader)) {
            final String bearerToken =
                    authorizationHeader.substring(Headers.BEARER_TOKEN_PREFIX.length());
            return bearerService.parseBearerToken(bearerToken);
        }
        return MissingModelElement.BEARER;
    }
42804
@Override
	public User getCurrentUser() {
		HttpSession session = getRequest().getSession(false);

		if (session == null)
			return null;

		return (User) session.getAttribute(SESSION_ATTR_USER);
	}
911753
public static String getSessionId(final HttpServletRequest pRequest) {
        HttpSession session = pRequest.getSession();

        return (session != null) ? session.getId() : null;
    }
1047528
@Override
    public String getRemoteUser() {
        Principal principal = getUserPrincipal();
        String user = principal == null ? null : principal.getName();
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { // 306998.15
            Tr.debug(tc, "getRemoteUser: " + user);
        }
        return user;
    }
1300935
@Override
    public String getUsernameFromQuery(final Map<String, List<Object>> query) {
        final List<Object> usernameAttributeValues = query.get(this.usernameAttribute);

        if (usernameAttributeValues == null || usernameAttributeValues.size() == 0) {
            return null;
        }

        final Object firstValue = usernameAttributeValues.get(0);
        if (firstValue == null) {
            return null;
        }

        final String username = StringUtils.trimToNull(String.valueOf(firstValue));
        if (username == null || username.contains(IPersonAttributeDao.WILDCARD)) {
            return null;
        }

        return username;
    }
743951
def get_user(request):
    
    if settings.LOCKDOWN and hasattr(request, 'user'):
        if request.user.is_authenticated:
            user = request.user.username
        else:
            # This may happen with crafted requests
            user = ''
    else:
        user = getattr(settings, 'DEFAULT_USER', getpass.getuser())

    return user
1063779
public static String getLocation (HttpServletRequest req)
    {
        StringBuffer rurl = req.getRequestURL();
        String qs = req.getQueryString();
        if (qs != null) {
            rurl.append("?").append(qs);
        }
        return rurl.toString();
    }
425694
public static String getUserNameFromSubject(Subject subject) {
        Iterator<Principal> it = subject.getPrincipals().iterator();
        String username = it.next().getName();
        return username;
    }