Gets the {@link Authentication} object that represents the user
associated with the current request.
324366
public static @Nonnull Authentication getAuthentication() {
        Authentication a = SecurityContextHolder.getContext().getAuthentication();
        // on Tomcat while serving the login page, this is null despite the fact
        // that we have filters. Looking at the stack trace, Tomcat doesn't seem to
        // run the request through filters when this is the login request.
        // see http://www.nabble.com/Matrix-authorization-problem-tp14602081p14886312.html
        if(a==null)
            a = ANONYMOUS;
        return a;
    }
714922
public static User get(AlluxioConfiguration conf) throws IOException {
    if (!SecurityUtils.isAuthenticationEnabled(conf)) {
      throw new IOException(ExceptionMessage.AUTHENTICATION_IS_NOT_ENABLED.getMessage());
    }
    return sUserThreadLocal.get();
  }
576486
public String getRemoteUser()
    {
        if (WCCustomProperties.CHECK_REQUEST_OBJECT_IN_USE){
            checkRequestObjectInUse();
        }
        String remoteUser = null;
        Principal principal = getUserPrincipal();
        if (principal == null) {
            //remoteUser = null;

            if (_request != null) {
                remoteUser = _request.getRemoteUser();
            }

        } else {
            remoteUser = principal.getName();
            if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {
                logger.logp(Level.FINE, CLASS_NAME, "getRemoteUser", "(security enabled)");
            }
        }
        if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {  //306998.15
            logger.logp(Level.FINE, CLASS_NAME, "getRemoteUser", "user=" + remoteUser);
        }
        return remoteUser;
    }
708316
protected Credential getCredential(HttpServletRequest req) {
    Credential cred = (Credential) req.getAttribute(AUTH_CREDENTIAL);
    return cred;
  }
686887
public User getCurrentUser() throws GitLabApiException {
        Response response = get(Response.Status.OK, null, "user");
        return (response.readEntity(User.class));
    }
336199
protected AuthenticationHandlerExecutionResult createAuthenticatedSubjectResult(final Credential credential, final Subject currentUser) {
        val username = currentUser.getPrincipal().toString();
        return createHandlerResult(credential, this.principalFactory.createPrincipal(username));
    }
1072021
public static SimpleConnectionAuthenticator getAuthenticationRequest(String userName, String password)
    {
        SimpleConnectionAuthenticator authenticator = null;
        if (userName != null || password != null)
        {
            authenticator = new SimpleConnectionAuthenticator(userName, password);
        }
        return authenticator;
    }
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);

    }
991059
def getAuthenticatedUser(self, headers=None, query_params=None, content_type="application/json"):
        
        uri = self.client.base_url + "/self"
        return self.client.get(uri, None, headers, query_params, content_type)
258987
function getAuthenticationObject () {
    const authString = url.parse(parts[0]).auth;

    if (authString) {
      return {
        source: getName(),
        user: authString.split(':')[0],
        pass: authString.split(':')[1]
      };
    } else {
      return {};
    }
  }
321614
public java.security.Principal getUserPrincipal()
    {
        if (WCCustomProperties.CHECK_REQUEST_OBJECT_IN_USE){
            checkRequestObjectInUse();
        }
        IWebAppSecurityCollaborator webAppSec=null;
        if (getDispatchContext()!=null && getDispatchContext().getWebApp() != null) {
            webAppSec = CollaboratorHelperImpl.getCurrentSecurityCollaborator(getDispatchContext().getWebApp());
        } else {
            webAppSec = CollaboratorHelperImpl.getCurrentSecurityCollaborator();           
        } 
            
        if (webAppSec != null) {
            if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)){  //306998.15
                logger.logp(Level.FINE, CLASS_NAME,"getUserPrincipal", "calling getUserPrincipal on " + webAppSec.getClass().getName());
            }
            return webAppSec.getUserPrincipal();
        } else {
            if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)){  //306998.15
                logger.logp(Level.FINE, CLASS_NAME,"getUserPrincipal", "returning null");
            }
            // No IWebAppSecurityCollaborator means no security, so no Principal 
            return null;
        }
    }
107708
def get_authuser_by_userid(cls, request):
        
        userid = authenticated_userid(request)
        if userid:
            cache_request_user(cls, request, userid)
            return request._user
211061
public User getUser(String name){
        ProtocolHeader header = new ProtocolHeader();
        header.setType(ProtocolType.GetUser);

        GetUserProtocol p = new GetUserProtocol(name);

        Response resp = connection.submitRequest(header, p, null);
        return ((GetUserResponse) resp).getUser();
    }
387449
@Nullable
  public StitchUserT getUser() {
    authLock.readLock().lock();
    try {
      return activeUser;
    } finally {
      authLock.readLock().unlock();
    }
  }
1060146
protected PasswordAuthentication getPasswordAuthentication() {
        // Don't worry, this is just a hack to figure out if we were able
        // to set this Authenticator through the setDefault method.
        if (!sInitialized && MAGIC.equals(getRequestingScheme()) && getRequestingPort() == FOURTYTWO) {
            return new PasswordAuthentication(MAGIC, ("" + FOURTYTWO).toCharArray());
        }
        /*
         System.err.println("getPasswordAuthentication");
         System.err.println(getRequestingSite());
         System.err.println(getRequestingPort());
         System.err.println(getRequestingProtocol());
         System.err.println(getRequestingPrompt());
         System.err.println(getRequestingScheme());
         */

        // TODO:
        // Look for a more specific PasswordAuthenticatior before using
        // Default:
        //
        // if (...)
        //    return pa.requestPasswordAuthentication(getRequestingSite(),
        //    	                                      getRequestingPort(),
        //                                            getRequestingProtocol(),
        //                                            getRequestingPrompt(),
        //                                    	      getRequestingScheme());

        return passwordAuthentications.get(new AuthKey(getRequestingSite(),
                getRequestingPort(),
                getRequestingProtocol(),
                getRequestingPrompt(),
                getRequestingScheme()));
    }
1201877
public SipPrincipal getUserPrincipal() {
		if(this.userPrincipal == null) {
			if(this.getSipSession() != null) {
				this.userPrincipal = this.getSipSession().getUserPrincipal();
			}
		}
		return this.userPrincipal;
	}
118912
public Principal authenticate(String username,
                                  Object credentials,
                                  HttpRequest request)
    {

    	synchronized(this)
    	{
    		long now = System.currentTimeMillis();
    		if (now - _lastHashPurge > _cacheTime || _cacheTime == 0)
    		{
    			super.clear();
    			_roles.clear();
    			_lastHashPurge = now;
    		}
    		Principal user = (Principal)super.get(username);
    		if (user == null)
    		{
    			loadUser(username);
    			user = (Principal)super.get(username);
    		}
    	}
        return super.authenticate(username, credentials, request);
    }