Create an instance of SSOAuthenticator.

@param webRequest
@return The SSOAuthenticator, or {@code null} if it could not be created.
178790
public WebAuthenticator getSSOAuthenticator(WebRequest webRequest, String ssoCookieName) {
        SecurityMetadata securityMetadata = webRequest.getSecurityMetadata();
        SecurityService securityService = securityServiceRef.getService();
        SSOCookieHelper cookieHelper;
        if (ssoCookieName != null) {
            cookieHelper = new SSOCookieHelperImpl(webAppSecurityConfig, ssoCookieName);
        } else {
            cookieHelper = webAppSecurityConfig.createSSOCookieHelper();
        }
        return new SSOAuthenticator(securityService.getAuthenticationService(), securityMetadata, webAppSecurityConfig, cookieHelper);
    }
975086
public Principal authenticate(String username,
                                  Object credentials,
                                  HttpRequest request)
    {
        KnownUser user;
        synchronized (this)
        {
            user = (KnownUser)super.get(username);
        }
        if (user==null)
            return null;

        if (user.authenticate(credentials))
            return user;
        
        return null;
    }
866026
@POST
    @Path("create")
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    public Response createFromBasicAuth() throws Exception {
        return doCreateFromBasicAuth(null);
    }
855758
protected HttpRequest addAuthHeader(HttpRequest request) {
        if (authToken != null) {
            request.header("authorization", "Bearer " + authToken);
        }

        return request;
    }
697578
public CertificateOperation createCertificate(CreateCertificateRequest createCertificateRequest) {
        return createCertificate(createCertificateRequest.vaultBaseUrl(), createCertificateRequest.certificateName(),
                createCertificateRequest.certificatePolicy(), createCertificateRequest.certificateAttributes(),
                createCertificateRequest.tags());
    }
643207
public WsFederationCredential createCredentialFromToken(final Assertion assertion) {
        val retrievedOn = ZonedDateTime.now(ZoneOffset.UTC);
        LOGGER.debug("Retrieved on [{}]", retrievedOn);
        val credential = new WsFederationCredential();
        credential.setRetrievedOn(retrievedOn);
        credential.setId(assertion.getID());
        credential.setIssuer(assertion.getIssuer());
        credential.setIssuedOn(ZonedDateTime.parse(assertion.getIssueInstant().toDateTimeISO().toString()));
        val conditions = assertion.getConditions();
        if (conditions != null) {
            credential.setNotBefore(ZonedDateTime.parse(conditions.getNotBefore().toDateTimeISO().toString()));
            credential.setNotOnOrAfter(ZonedDateTime.parse(conditions.getNotOnOrAfter().toDateTimeISO().toString()));
            if (!conditions.getAudienceRestrictionConditions().isEmpty()) {
                credential.setAudience(conditions.getAudienceRestrictionConditions().get(0).getAudiences().get(0).getUri());
            }
        }
        if (!assertion.getAuthenticationStatements().isEmpty()) {
            credential.setAuthenticationMethod(assertion.getAuthenticationStatements().get(0).getAuthenticationMethod());
        }
        //retrieve an attributes from the assertion
        val attributes = new HashMap<String, List<Object>>();
        assertion.getAttributeStatements().stream().flatMap(attributeStatement -> attributeStatement.getAttributes().stream()).forEach(item -> {
            LOGGER.debug("Processed attribute: [{}]", item.getAttributeName());
            final List<Object> itemList = item.getAttributeValues().stream()
                .map(xmlObject -> ((XSAny) xmlObject).getTextContent())
                .collect(Collectors.toList());
            if (!itemList.isEmpty()) {
                attributes.put(item.getAttributeName(), itemList);
            }
        });
        credential.setAttributes(attributes);
        LOGGER.debug("Credential: [{}]", credential);
        return credential;
    }
937583
public void validateWsFederationAuthenticationRequest(final RequestContext context) {
        val service = wsFederationCookieManager.retrieve(context);
        LOGGER.debug("Retrieved service [{}] from the session cookie", service);

        val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(context);
        val wResult = request.getParameter(WRESULT);
        LOGGER.debug("Parameter [{}] received: [{}]", WRESULT, wResult);
        if (StringUtils.isBlank(wResult)) {
            LOGGER.error("No [{}] parameter is found", WRESULT);
            throw new IllegalArgumentException("Missing parameter " + WRESULT);
        }
        LOGGER.debug("Attempting to create an assertion from the token parameter");
        val rsToken = wsFederationHelper.getRequestSecurityTokenFromResult(wResult);
        val assertion = wsFederationHelper.buildAndVerifyAssertion(rsToken, configurations);
        if (assertion == null) {
            LOGGER.error("Could not validate assertion via parsing the token from [{}]", WRESULT);
            throw new IllegalArgumentException("Could not validate assertion via the provided token");
        }
        LOGGER.debug("Attempting to validate the signature on the assertion");
        if (!wsFederationHelper.validateSignature(assertion)) {
            val msg = "WS Requested Security Token is blank or the signature is not valid.";
            LOGGER.error(msg);
            throw new IllegalArgumentException(msg);
        }
        buildCredentialsFromAssertion(context, assertion, service);
    }
738448
protected OAuthProviderToken createOAuthToken(ConsumerAuthentication authentication) {
    return getTokenServices().createUnauthorizedRequestToken(authentication.getConsumerDetails().getConsumerKey(),
                                                             authentication.getOAuthParameters().get(OAuthConsumerParameter.oauth_callback.toString()));
  }
249519
public LoginWithSignResult loginWithSign(LoginWithSignRequest request) {

		ObjectNode body = JsonNodeFactory.instance.objectNode()
				.put("serviceId", request.getServiceId())
				.put("userId", request.getUserId())
				.put("keyName", request.getKeyName())
				.put("sign", request.getSign());

		HttpPost post = createHttpPost(
				Gs2Constant.ENDPOINT_HOST + "/login/signed",
				credential,
				ENDPOINT,
				LoginWithSignRequest.Constant.MODULE,
				LoginWithSignRequest.Constant.FUNCTION,
				body.toString());
        if(request.getRequestId() != null) {
            post.setHeader("X-GS2-REQUEST-ID", request.getRequestId());
        }


		return doRequest(post, LoginWithSignResult.class);

	}
1051741
public HttpAuthService build(Service<HttpRequest, HttpResponse> delegate) {
        return new HttpAuthService(requireNonNull(delegate, "delegate"), authorizer(),
                                   successHandler, failureHandler);
    }
200967
public static ResponseEntity<String> createResponseEntityForAuthnFailure(final AuthenticationException e,
                                                                             final HttpServletRequest request,
                                                                             final ApplicationContext applicationContext) {
        try {
            val authnExceptions = e.getHandlerErrors().values()
                .stream()
                .map(ex -> mapExceptionToMessage(e, request, applicationContext, ex))
                .collect(Collectors.toList());
            val errorsMap = new HashMap<String, List<String>>();
            errorsMap.put("authentication_exceptions", authnExceptions);
            LOGGER.warn("[{}] Caused by: [{}]", e.getMessage(), authnExceptions);

            return new ResponseEntity<>(MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(errorsMap), HttpStatus.UNAUTHORIZED);
        } catch (final JsonProcessingException exception) {
            LOGGER.error(e.getMessage(), e);
            return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }
811798
protected String getBasicAuthRealmName(WebRequest webRequest) {
        SecurityMetadata securityMetadata = webRequest.getSecurityMetadata();
        if (securityMetadata != null) {
            LoginConfiguration loginConfig = securityMetadata.getLoginConfiguration();
            if (loginConfig != null && loginConfig.getRealmName() != null) {
                return loginConfig.getRealmName();
            }
            if (config.getDisplayAuthenticationRealm()) {
                return userRegistry.getRealm();
            }
        }
        String realm = "defaultRealm";
        return realm;
    }
1191365
private String buildAuthorizationHeader(SignableRequest<?> request,
            byte[] signature, AWSCredentials credentials,
            AWS4SignerRequestParams signerParams) {
        final String signingCredentials = credentials.getAWSAccessKeyId() + "/"
                + signerParams.getScope();

        final String credential = "Credential="
                + signingCredentials;
        final String signerHeaders = "SignedHeaders="
                + getSignedHeadersString(request);
        final String signatureHeader = "Signature="
                + BinaryUtils.toHex(signature);

        final StringBuilder authHeaderBuilder = new StringBuilder();

        authHeaderBuilder.append(AWS4_SIGNING_ALGORITHM)
                         .append(" ")
                         .append(credential)
                         .append(", ")
                         .append(signerHeaders)
                         .append(", ")
                         .append(signatureHeader);

        return authHeaderBuilder.toString();
    }
857526
private ApiKeyAuthenticationInfo createAuthenticationInfo(String authenticationId, ApiKey apiKey) {
        return new ApiKeyAuthenticationInfo(authenticationId, apiKey, getName());
    }
471479
public GetVerifiedDomainResponse getVerifiedDomain(GetVerifiedDomainRequest request) {
        checkNotNull(request, "object request should not be null.");
        assertStringNotNullOrEmpty(request.getDomainName(), "object domainName should not be null or empty");

        InternalRequest internalRequest =
                this.createRequest("verifiedDomain", request, HttpMethodName.GET, request.getDomainName());
        return this.invokeHttpClient(internalRequest, GetVerifiedDomainResponse.class);
    }
90260
public AuthenticationResult authenticateRequest(WebRequest webRequest) {
        WebAuthenticator authenticator = getWebAuthenticatorProxy();
        return authenticator.authenticate(webRequest);
    }
596355
public String authenticateBASIC(final HttpServletRequest request) {
        LOG.debug("authenticateBASIC");
        boolean valid = false;
        String userID = null;
        String password = null;
        try {
            final String authHeader = request.getHeader("Authorization");
            if (authHeader != null) {
                final StringTokenizer st = new StringTokenizer(authHeader);
                if (st.hasMoreTokens()) {
                    final String basic = st.nextToken();
                    if (basic.equalsIgnoreCase("Basic")) {
                        final String credentials = st.nextToken();
                        final String userPass = new String(Base64.decodeBase64(credentials.getBytes()));
                        final int p = userPass.indexOf(":");
                        if (p != -1) {
                            userID = userPass.substring(0, p);
                            password = userPass.substring(p + 1);

                            // Validate the User.
                            valid = validateUser(userID, password);
                        }
                    }
                }
            }
        } catch (final Exception e) {
            LOG.debug("An error occured while processing Basic authentication", e);
        }
        if (valid) {
            // For now assume userID as userName
            return userID;
        }
        return null;
    }