Constructs the base64 encoded basic authentication header value.

@return the base64 encoded basic authentication header value
554681
private String buildHttpAuthHeaderValue() {
        final String user = settings.getString(Settings.KEYS.ANALYZER_NEXUS_USER, "");
        final String pass = settings.getString(Settings.KEYS.ANALYZER_NEXUS_PASSWORD, "");
        String result = "";
        if (user.isEmpty() || pass.isEmpty()) {
            LOGGER.debug("Skip authentication as user and/or password for nexus is empty");
        } else {
            final String auth = user + ':' + pass;
            final String base64Auth = Base64.getEncoder().encodeToString(auth.getBytes(StandardCharsets.UTF_8));
            result = new StringBuilder("Basic ").append(base64Auth).toString();
        }
        return result;
    }
609835
def decode(cls, auth_header: str, encoding: str='latin1') -> 'BasicAuth':
        """"""
        try:
            auth_type, encoded_credentials = auth_header.split(' ', 1)
        except ValueError:
            raise ValueError('Could not parse authorization header.')

        if auth_type.lower() != 'basic':
            raise ValueError('Unknown authorization method %s' % auth_type)

        try:
            decoded = base64.b64decode(
                encoded_credentials.encode('ascii'), validate=True
            ).decode(encoding)
        except binascii.Error:
            raise ValueError('Invalid base64 encoding.')

        try:
            # RFC 2617 HTTP Authentication
            # https://www.ietf.org/rfc/rfc2617.txt
            # the colon must be present, but the username and password may be
            # otherwise blank.
            username, password = decoded.split(':', 1)
        except ValueError:
            raise ValueError('Invalid credentials.')

        return cls(username, password, encoding=encoding)
3348
public String getDecodedMessage()
    {
        if (message == null)
        {
            return null;
        }
        return new String(Base64.base64ToByteArray(message), Charset.forName("UTF-8"));
    }
759521
def basic_auth_string(username, password):
    
    b64 = base64.encodestring('%s:%s' % (username, password)).strip()
    return 'Basic %s' % b64
1045620
def _get_authorization_headers(self) -> dict:
        
        auth = base64.encodestring((self.client_id + ':' + self.client_secret).encode('latin-1')).decode('latin-1')
        auth = auth.replace('\n', '').replace(' ', '')
        auth = 'Basic {}'.format(auth)
        headers = {'Authorization': auth}
        return headers
407218
public String getResponseBodyAsString() {
        final ByteBuf bodyByteBuf = httpInputMessage.getBody();
        final String contentEncoding = httpInputMessage.getHeaders().get(HttpHeaders.CONTENT_ENCODING);
        byte[] bytes = new byte[bodyByteBuf.readableBytes()];
        bodyByteBuf.readBytes(bytes);
        return new String(bytes, contentEncoding != null ? Charset.forName(contentEncoding) : Charset.forName(DEFAULT_CHARSET));
    }
668893
def encodeStringForB64Header(s):
    
    if isinstance(s, six.text_type):
        s = s.encode()
    return base64.encodestring(s).strip().replace(b'\n', b'')
857283
def getHeaders(self):
        
        basicauth = base64.encodestring(b(self.user + ':' + self.password)).strip()
        return {
            "Depth": "1",
            "Authorization": 'Basic ' + _decode_utf8(basicauth),
            "Accept": "*/*"
        }
583557
private function _authHeader(): string
    {
        if (empty($this->_client_id)) {
            throw new VimeoException('A client ID must be set in order to generate an auth header.');
        } elseif (empty($this->_client_secret)) {
            throw new VimeoException('A client secret must be set in order to generate an auth header.');
        }

        return base64_encode($this->_client_id . ':' . $this->_client_secret);
    }
549151
public function getHeader() : string
    {
        $salt = $this->getEncodedSalt();
        $hmac = $this->getEncodedHMAC();

        if ($this->version === 2) {
            $data = \base64_encode(\json_encode([
                'access_token' => $this->token->accessToken,
                'date' => $this->date,
                'hmac' => $hmac,
                'salt' => $salt,
                'v' => 2
            ]));

            return "HMAC {$data}";
        }

        // The version 1 HMAC is returned by default
        return "HMAC {$this->token->accessToken},{$hmac},{$salt}";
    }
722156
def RequestPacket(self):
        

        attr = self._PktEncodeAttributes()

        if self.id is None:
            self.id = self.CreateID()

        header = struct.pack('!BBH', self.code, self.id, (20 + len(attr)))
        self.authenticator = md5_constructor(header[0:4] + 16 * six.b('\x00') + attr
            + self.secret).digest()
        return header + self.authenticator + attr
1239187
private String toNetscapeHeaderString() {
        StringBuilder sb = new StringBuilder();

        sb.append(getName() + "=" + getValue());

        return sb.toString();
    }
44732
public function toHeaderValue()
    {
        $value = $this->value;
        if ($this->isExpanded) {
            $value = $this->_flatten($this->value);
        }
        $headerValue[] = sprintf('%s=%s', $this->name, rawurlencode($value));

        if ($this->expiresAt) {
            $headerValue[] = sprintf('expires=%s', $this->getFormattedExpires());
        }
        if ($this->path !== '') {
            $headerValue[] = sprintf('path=%s', $this->path);
        }
        if ($this->domain !== '') {
            $headerValue[] = sprintf('domain=%s', $this->domain);
        }
        if ($this->secure) {
            $headerValue[] = 'secure';
        }
        if ($this->httpOnly) {
            $headerValue[] = 'httponly';
        }

        return implode('; ', $headerValue);
    }
654476
def basicauth(self, realm = b'all', nofail = False):
        ""
        if b'authorization' in self.headerdict:
            auth = self.headerdict[b'authorization']
            auth_pair = auth.split(b' ', 1)
            if len(auth_pair) < 2:
                raise HttpInputException('Authorization header is malformed')
            if auth_pair[0].lower() == b'basic':
                try:
                    userpass = base64.b64decode(auth_pair[1])
                except Exception:
                    raise HttpInputException('Invalid base-64 string')
                userpass_pair = userpass.split(b':', 1)
                if len(userpass_pair) != 2:
                    raise HttpInputException('Authorization header is malformed')
                return userpass_pair
        if nofail:
            return (None, None)
        else:
            self.basicauthfail(realm)
836872
public function getAuthorizationBasic()
    {
        if ( ! empty($this->key) && ! empty($this->secret)) {
            $key = rawurlencode($this->key);
            $secret = rawurlencode($this->secret);

            return 'Basic ' . base64_encode($key . ':' . $secret);
        }

        return false;
    }
994811
public static String generateAuthorizationCode() {
        StringBuilder buf = new StringBuilder(AUTHORIZATION_CODE_LENGTH);
        SecureRandom rand = new SecureRandom();
        for (int i = 0; i < AUTHORIZATION_CODE_LENGTH; i++) {
            buf.append(allowedCharacters[rand.nextInt(allowedCharacters.length)]);
        }
        return buf.toString();
    }
840981
public static JWEHeader fromBase64String(String base64) throws IOException {
        String json = MessageSecurityHelper.base64UrltoString(base64);
        return deserialize(json);
    }