Build authentication context pair pair.

@param request      the request
@param authnRequest the authn request
@return the pair
325242
protected static Pair<AuthnRequest, MessageContext> buildAuthenticationContextPair(final HttpServletRequest request,
                                                                                       final AuthnRequest authnRequest) {
        val messageContext = bindRelayStateParameter(request);
        return Pair.of(authnRequest, messageContext);
    }
1168990
public Object getUserFromPrincipal(HttpServletRequest request) {
    Debug.logVerbose("[JdonFramework]--> enter getUserFromPrincipal", module);
    Principal principal = request.getUserPrincipal();
    if (principal == null) {
      Debug.logVerbose("[JdonFramework]principal is null, not login by JAAS", module);
      return null;
    }
    String username = principal.getName();
    Debug.logVerbose("[JdonFramework]--> find the logined username=" + username, module);
    HttpSession session = request.getSession();
    Object model =  session.getAttribute(USERMODEL);
    if (model == null) {
      model = findUserModelIFByName(request, username);
      session.setAttribute(USERMODEL, model);
    }
    return model;
  }
1022686
function createAuthDetails( request ) {
   var auth= { scopedUsers: {} };
   request._connect_auth= auth;
   if( request.session ) {
     request.session.auth= auth;
   }
 }
1177606
public Event buildAuthenticationRequestEvent(final RequestContext context) {
        val clients = new ArrayList<WsFedClient>();
        val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(context);
        val service = (Service) context.getFlowScope().get(CasProtocolConstants.PARAMETER_SERVICE);
        this.configurations.forEach(cfg -> {
            val c = new WsFedClient();
            c.setName(cfg.getName());
            val id = UUID.randomUUID().toString();
            val rpId = wsFederationHelper.getRelyingPartyIdentifier(service, cfg);
            c.setAuthorizationUrl(cfg.getAuthorizationUrl(rpId, id));
            c.setReplyingPartyId(rpId);
            c.setId(id);
            c.setRedirectUrl(getRelativeRedirectUrlFor(cfg, service, request));
            c.setAutoRedirect(cfg.isAutoRedirect());
            clients.add(c);

            if (cfg.isAutoRedirect()) {
                WebUtils.putDelegatedAuthenticationProviderPrimary(context, cfg);
            }
        });
        context.getFlowScope().put(PARAMETER_NAME_WSFED_CLIENTS, clients);
        return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_PROCEED);
    }
129916
public static AuthenticationResult authenticationResultFromRequest(final HttpServletRequest request)
  {
    final AuthenticationResult authenticationResult = (AuthenticationResult) request.getAttribute(
        AuthConfig.DRUID_AUTHENTICATION_RESULT
    );

    if (authenticationResult == null) {
      throw new ISE("Null authentication result");
    }

    return authenticationResult;
  }
529533
public Object getUserModelAfterLogin(HttpServletRequest request) {
		Object model = userPrincipal.getUserFromSession(request);
		if (model == null)
			model = userPrincipal.getUserFromPrincipal(request);
		return (Model) model;
	}
621891
function (auth, request, done) {
        var result,
            params = auth.get([
                'authId',
                'authKey',
                'algorithm',
                'nonce',
                'timestamp',
                'extraData',
                'app',
                'delegation',
                'user'
            ]),
            contentType = request.headers.get('content-type'),

            // force toString to add a protocol to the URL.
            url = urlEncoder.toNodeUrl(request.url.toString(true)),

            self = this;

        if (!params.authId || !params.authKey) {
            return done(); // Nothing to do if required parameters are not present.
        }

        request.removeHeader('Authorization', {ignoreCase: true});

        computeBodyHash(request.body, params.algorithm, 'base64', contentType, function (bodyHash) {
            result = self.computeHeader({
                credentials: {
                    id: params.authId,
                    key: params.authKey,
                    algorithm: params.algorithm
                },
                nonce: params.nonce,
                timestamp: params.timestamp,
                ext: params.extraData,
                app: params.app,
                dlg: params.delegation,
                user: params.user,
                url: url.href, // force toString to add a protocol to the URL.
                method: request.method,
                hash: bodyHash
            });
            request.addHeader({
                key: 'Authorization',
                value: result,
                system: true
            });

            return done();
        });
    }
508283
public SetRequestAuthResponse setRequestAuth(SetRequestAuthRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        InternalRequest internalRequest = 
                createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config");
        internalRequest.addParameter("requestAuth", "");
        this.attachRequestToBody(request, internalRequest);
        return invokeHttpClient(internalRequest, SetRequestAuthResponse.class);
    }
1028598
def authenticate(self, request):
        
        auth = get_authorization_header(request).split()

        if not auth or auth[0].lower() != b'token':
            return None

        if len(auth) == 1:
            msg = _('Invalid auth token header. No credentials provided.')
            raise AuthenticationFailed(msg)
        elif len(auth) > 2:
            msg = _('Invalid auth token.')
            raise AuthenticationFailed(msg)

        try:
            token = urlsafe_b64decode(auth[1])
        except ValueError:
            msg = _('Invalid auth token.')
            raise AuthenticationFailed(msg)

        return self.authenticate_credentials(token, request)
273267
public static UIContext getContext(final String key, final Request request) {
		return (UIContext) request.getSessionAttribute(DATA_LIST_UIC_SESSION_KEY);
	}
1103161
protected Headers getHeaders(Request request)
    {
        Headers.Builder headers = new Headers.Builder();
        MultiMap resolvedHeaders = null;
        if(headerFactory != null)
            resolvedHeaders = headerFactory.getHeaders();

        if(hasEntries(resolvedHeaders))
            resolvedHeaders = resolvedHeaders.merge(request.getHeaders());
        else
            resolvedHeaders = request.getHeaders();

        if(authorizationFactory != null)
        {
            MultiMap authEntries = authorizationFactory.getHeaders();
            if(hasEntries(authEntries))
                resolvedHeaders = resolvedHeaders.merge(authEntries);
        }

        if(resolvedHeaders.getFirst("user-agent") == null)
            headers.add("user-agent",userAgent);

        if(resolvedHeaders.getFirst(CLIENT_VERSION_HEADER_NAME) == null)
            headers.add(CLIENT_VERSION_HEADER_NAME,getClientVersion());

        for (Map.Entry<String, List<String>> entry : resolvedHeaders.entries())
        {
            for (String value : entry.getValue())
            {
                headers.add(entry.getKey(), value);
            }
        }
        return headers.build();
    }
368251
protected String determineProfileBinding(final Pair<AuthnRequest, MessageContext> authenticationContext,
                                             final Assertion assertion) {

        val authnRequest = authenticationContext.getKey();
        val pair = getRegisteredServiceAndFacade(authnRequest);
        val facade = pair.getValue();

        val binding = StringUtils.defaultIfBlank(authnRequest.getProtocolBinding(), SAMLConstants.SAML2_POST_BINDING_URI);
        LOGGER.debug("Determined authentication request binding is [{}], issued by [{}]", binding, authnRequest.getIssuer().getValue());

        val entityId = facade.getEntityId();
        LOGGER.debug("Checking metadata for [{}] to see if binding [{}] is supported", entityId, binding);
        val svc = facade.getAssertionConsumerService(binding);
        LOGGER.debug("Binding [{}] is supported by [{}]", svc.getBinding(), entityId);
        return binding;
    }
343322
public String getEndUserAuthorizationRequestUri(final HttpServletRequest request) {

		OAuthClientRequest oauthClientRequest;

		try {

			oauthClientRequest = OAuthClientRequest
				.authorizationLocation(authorizationLocation)
				.setClientId(clientId)
				.setRedirectURI(getAbsoluteUrl(request, redirectUri))
				.setScope(getScope())
				.setResponseType(getResponseType())
				.setState(getState())
				.buildQueryMessage();

			logger.info("Authorization request location URI: {}", oauthClientRequest.getLocationUri());

			return oauthClientRequest.getLocationUri();

		} catch (OAuthSystemException ex) {
			logger.error("", ex);
		}

		return null;

	}
512858
protected static String getRequiredNameIdFormatIfAny(final RequestAbstractType authnRequest) {
        val nameIDPolicy = getNameIDPolicy(authnRequest);
        val requiredNameFormat = nameIDPolicy != null ? nameIDPolicy.getFormat() : null;
        LOGGER.debug("AuthN request indicates [{}] is the required NameID format", requiredNameFormat);
        return requiredNameFormat;
    }
1007085
@Override
    public final void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {

        AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE);
        if (authState.getAuthScheme() == null) {

            HttpHost targetHost = (HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST);
            AuthCache authCache = new BasicAuthCache();
            authCache.put(targetHost, new BasicScheme());
            context.setAttribute(HttpClientContext.AUTH_CACHE, authCache);
        }
    }
398693
static public String getBasicAuthUsername(HttpServletRequest request){
		String[] userAndPassword = getBasicAuthUsernameAndPassword(request);
		return userAndPassword == null || userAndPassword.length == 0 ? null : userAndPassword[0];
	}
88423
protected void configureBasicAuth(HttpRequest request) {
        try {
            String username = getConfig().getUsername();
            String password = getConfig().getPassword();
            String up = username + ":" + password; //$NON-NLS-1$
            String base64 = new String(Base64.encodeBase64(up.getBytes("UTF-8"))); //$NON-NLS-1$
            String authHeader = "Basic " + base64; //$NON-NLS-1$
            request.setHeader("Authorization", authHeader); //$NON-NLS-1$
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }