Builds an XOAUTH SASL client response.

@return A base-64 encoded containing the auth string suitable for login via xoauth.
335680
public String build(Protocol protocol, String oauthToken, String oauthTokenSecret)
      throws IOException, OAuthException, URISyntaxException {
    OAuthAccessor accessor = new OAuthAccessor(consumer);
    accessor.tokenSecret = oauthTokenSecret;

    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put(OAuth.OAUTH_SIGNATURE_METHOD, "HMAC-SHA1");
    parameters.put(OAuth.OAUTH_TOKEN, oauthToken);

    String url = String.format("https://mail.google.com/mail/b/%s/%s/", email,
        (Protocol.IMAP == protocol) ? "imap" : "smtp");

    OAuthMessage message = new OAuthMessage(
        "GET",
        url,
        parameters.entrySet());
    message.addRequiredParameters(accessor);

    StringBuilder authString = new StringBuilder();
    authString.append("GET ");
    authString.append(url);
    authString.append(" ");
    int i = 0;
    for (Map.Entry<String, String> entry : message.getParameters()) {
      if (i++ > 0) {
        authString.append(",");
      }
      authString.append(OAuth.percentEncode(entry.getKey()));
      authString.append("=\"");
      authString.append(OAuth.percentEncode(entry.getValue()));
      authString.append("\"");
    }

    return Base64.encode(authString.toString().getBytes());
  }
94399
public static Subject generateSecuritySubject(String jassLoginConfig, String username, String password) throws LoginException {
  	  
        LoginContext loginCtx = null;
      
        try {
      
            // "Client" references the JAAS configuration in the jaas.conf file.
            loginCtx = new LoginContext(jassLoginConfig, new Krb5TokenUtils.LoginCallbackHandler(username, password));
            loginCtx.login();
 
            log.debug(" : Krb5Token Kerberos login succeeded against user: %s", username);
      
            return loginCtx.getSubject();
        }
        catch(LoginException e) {
            log.debug(" : Krb5Token Kerberos login failed against user: %s", username);
            throw e;
        }
    }
562586
public function makeAuthenticationCall()
    {
        $authResponse = $this->call('POST', [
            'grant_type' => 'client_credentials',
            'client_id' => $this->client->getClientID(),
            'client_secret' => $this->client->getClientSecret()
        ], false, ['Content-Type' => 'application/x-www-form-urlencoded'], false, false);

        if (empty($authResponse->getRaw()->access_token)) {
            throw new Exceptions\AuthenticationException;
        }

        return $authResponse;
    }
805727
def auth_payload(self, login_pwd):
        

        payload = '''<?xml version="1.0" encoding="utf-8"?>
        <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Body>
        <Login xmlns="http://purenetworks.com/HNAP1/">
        <Action>login</Action>
        <Username>{}</Username>
        <LoginPassword>{}</LoginPassword>
        <Captcha/>
        </Login>
        </soap:Body>
        </soap:Envelope>
        '''.format(self.user, login_pwd)

        return payload.encode()
311348
private SslContext buildSslContext() throws Exception {
        keyAndCertificateFactory().buildAndSaveCertificates();

        return SslContextBuilder.forServer(
            keyAndCertificateFactory().mockServerPrivateKey(),
            // do we need this password??
            ConfigurationProperties.javaKeyStorePassword(),
            new X509Certificate[]{
                keyAndCertificateFactory().mockServerX509Certificate(),
                keyAndCertificateFactory().mockServerCertificateAuthorityX509Certificate()
            }
        ).build();
    }
1128062
public final String buildAuthority() {
    // scheme, [user info], host, [port]
    StringBuilder buf = new StringBuilder();
    buf.append(Preconditions.checkNotNull(scheme));
    buf.append("://");
    if (userInfo != null) {
      buf.append(CharEscapers.escapeUriUserInfo(userInfo)).append('@');
    }
    buf.append(Preconditions.checkNotNull(host));
    int port = this.port;
    if (port != -1) {
      buf.append(':').append(port);
    }
    return buf.toString();
  }
751599
public String getConnectUserSQL() {

        StringBuffer sb = new StringBuffer();

        sb.append(Tokens.T_SET).append(' ');
        sb.append(Tokens.T_SESSION).append(' ');
        sb.append(Tokens.T_AUTHORIZATION).append(' ');
        sb.append(StringConverter.toQuotedString(getNameString(), '\'', true));

        return sb.toString();
    }
354732
public function login()
    {

        //connect if not connected
        if(!$this->connected){

            $this->reconnect();
        }
        //calc the jid from uname+host
        $this->jid = $this->uname.'@'.substr($this->host, strpos($this->host, '//')+2);

        if($this->pass){

            $this->write("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" . base64_encode("\x00" . $this->uname . "\x00" . $this->pass) . "</auth>");
        } else {
            $this->write("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS' />");
    }

        $buffer = $this->read();
        if(substr($buffer, 0, 5) == '<fail'){
            $this->onError(0, 'Cound not log in');
            return false;

        }

        $this->client_name = empty($this->client_name) ? __CLASS__ : $this->client_name;

        if(!$this->sendClientName()){
            return false;
        }

        $this->setStatus($this->status);

        $this->onAfterLogin();

        return true;

    }
1244078
protected function requestAuthorizationToken(): string
    {
        $result = $this->options->getAuthorizationToken();
        if ($result === '') {
            $authRequest = new AuthRequest();
            $authRequest->setAgent($this->options->getAgent())
                        ->setAccessKey($this->options->getAccessKey())
                        ->setEnabledModNames($this->options->getEnabledModNames());

            $authResponse = $this->fetchResponse($authRequest);
            if ($authResponse instanceof AuthResponse) {
                $result = $authResponse->getAuthorizationToken();
                $this->options->setAuthorizationToken($result);
            }
        }
        return $result;
    }
1319505
public function getAuthCredentialsWithBearer()
    {
        $b64token = null;
        
        if (isset($_SERVER['HTTP_AUTHORIZATION'])) {

            if (strpos(strtolower($_SERVER['HTTP_AUTHORIZATION']), 'bearer ')===0) {

                $b64token = substr($_SERVER['HTTP_AUTHORIZATION'], 7);
            }
        }

        return $b64token;
    }
317015
function getOBAuth(config) {
  // debugger;

  // Encoding as per API Specification.
  const combinedCredential = `${config.clientId}:${config.clientSecret}`;
  // var base64Credential = window.btoa(combinedCredential);
  const base64Credential = Buffer.from(combinedCredential).toString("base64");
  const readyCredential = `Basic ${base64Credential}`;

  return readyCredential;
}
1087554
public String login(Authentication authentication) {
		String token = getToken();
		return login(token, authentication);
	}
469834
public String getHeader() {
        String authPair = username + ':' + apiKey;
        return "Basic " + Base64.getEncoder().encodeToString(authPair.getBytes());
    }
173440
def process_auth_plain(session, encoded_auth_response)
      begin
        # extract auth id (and password)
        @auth_values = Base64.decode64(encoded_auth_response).split("\x00")
        # check for valid credentials parameters
        raise Smtpd500Exception unless @auth_values.length == 3
        # call event function to test credentials
        return_value = on_auth_event(session[:ctx], @auth_values[0], @auth_values[1], @auth_values[2])
        if return_value
          # overwrite data with returned value as authorization id
          @auth_values[0] = return_value
        end
        # save authentication information to ctx
        session[:ctx][:server][:authorization_id] = @auth_values[0].to_s.empty? ? @auth_values[1] : @auth_values[0]
        session[:ctx][:server][:authentication_id] = @auth_values[1]
        session[:ctx][:server][:authenticated] = Time.now.utc
        # response code
        return '235 OK'

      ensure
        # whatever happens in this check, reset next sequence
        session[:cmd_sequence] = :CMD_RSET
      end
    end
785266
public static Builder forAuth(final String auth) {
    // split with limit=2 to catch case where password contains a colon
    final String[] authParams = Base64.decodeAsString(auth).split(":", 2);

    if (authParams.length != 2) {
      return builder();
    }

    return builder()
        .username(authParams[0].trim())
        .password(authParams[1].trim());
  }
490300
public String constructLocalLoginServiceUrl(final HttpServletRequest request,
      final HttpServletResponse response, final String service, final String serverName,
      final String artifactParameterName, final boolean encode) {
    if (Strings.isNotBlank(service)) return encode ? response.encodeURL(service) : service;
    final StringBuilder buffer = new StringBuilder();

    if (!serverName.startsWith("https://") && !serverName.startsWith("http://")) {
      buffer.append(request.isSecure() ? "https://" : "http://");
    }
    buffer.append(serverName);
    buffer.append(request.getContextPath());
    buffer.append(localLogin);
    final String returnValue = encode ? response.encodeURL(buffer.toString()) : buffer.toString();
    return returnValue;
  }
1323960
private void sendAuthResponse(HttpServletResponse response) throws IOException {
        response.setHeader("WWW-Authenticate", String.format("Basic realm=\"%1$s\"", realm)); //$NON-NLS-1$ //$NON-NLS-2$
        response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    }