Create the oAuth headers

@param string $nonce The generated nonce
@param int    $timestamp The generated timestamp
@param string $hash The created hash

@return string[] The headers for the request
173280
private function createOAuthHeaders($nonce, $timestamp, $hash)
    {
        $oauth_header = [];
        $oauth_header[] = 'oauth_consumer_key="' . $this->key . '"';
        $oauth_header[] = 'oauth_nonce="' . $nonce . '"';
        $oauth_header[] = 'oauth_signature="' . $hash . '"';
        $oauth_header[] = 'oauth_signature_method="HMAC-SHA256"';
        $oauth_header[] = 'oauth_timestamp="' . $timestamp . '"';
        $oauth_header[] = 'oauth_version="1.0"';
        return $oauth_header;
    }
1100278
def header(verb, url)
      timestamp = Time.now.utc.to_i
      nonce = Digest::MD5.hexdigest([timestamp, SecureRandom.hex].join(':'))

      uri = URI.parse(url)

      raise(ArgumentError, "could not parse \"#{url}\" into URI") unless uri.is_a?(URI::HTTP)

      mac = signature(timestamp, nonce, verb, uri)

      "MAC id=\"#{token}\", ts=\"#{timestamp}\", nonce=\"#{nonce}\", mac=\"#{mac}\""
    end
855280
protected function validNonce($nonce)
    {
        $value = base64_decode($nonce);
        if ($value === false) {
            return false;
        }
        $parts = explode(':', $value);
        if (count($parts) !== 2) {
            return false;
        }
        list($expires, $checksum) = $parts;
        if ($expires < microtime(true)) {
            return false;
        }
        $secret = $this->getConfig('secret');
        $check = hash_hmac('sha1', $expires . ':' . $secret, $secret);

        return hash_equals($check, $checksum);
    }
1091640
public function getSignature(RequestInterface $request, $timestamp, $nonce)
    {
        $string = $this->getStringToSign($request, $timestamp, $nonce);
        $key = urlencode($this->config['consumer_secret']) . '&' . urlencode($this->config['token_secret']);

        return base64_encode(call_user_func($this->config['signature_callback'], $string, $key));
    }
826401
public static function create(string $baseUrl, array $headers = [], $timeout = 30, bool $allowRedirects = false): Client
    {
        return new Client([
            'base_uri' => $baseUrl,
            'headers'  => $headers,
            'timeout'  => $timeout,
            'allow_redirects' => $allowRedirects,
        ]);
    }
110476
public function get_oauth_params( $params, $method ) {

		$params = array_merge( $params, array(
			'oauth_consumer_key'     => $this->consumer_key,
			'oauth_timestamp'        => time(),
			'oauth_nonce'            => sha1( microtime() ),
			'oauth_signature_method' => 'HMAC-' . self::HASH_ALGORITHM,
		) );

		// the params above must be included in the signature generation
		$params['oauth_signature'] = $this->generate_oauth_signature( $params, $method );

		return $params;
	}
1036511
public static String generate(String encrypt, String signature, String timestamp, String nonce) {

		String format = "<xml>\n" + "<Encrypt><![CDATA[%1$s]]></Encrypt>\n"
				+ "<MsgSignature><![CDATA[%2$s]]></MsgSignature>\n"
				+ "<TimeStamp>%3$s</TimeStamp>\n" + "<Nonce><![CDATA[%4$s]]></Nonce>\n" + "</xml>";
		return String.format(format, encrypt, signature, timestamp, nonce);

	}
87830
public function hasHistory($timestamp = null)
    {
        if ($timestamp) {
            return (bool) $this->revisionAtTimestamp($timestamp);
        }

        return $this->revisions()->exists();
    }
1310018
public static String createAuthenticateHeader(final String realm, final String authMethod, final String nonce) {
        val stringBuilder = new StringBuilder("Digest realm=\"")
            .append(realm).append("\",");
        if (StringUtils.isNotBlank(authMethod)) {
            stringBuilder.append("qop=").append(authMethod).append(',');
        }
        return stringBuilder.append("nonce=\"").append(nonce)
            .append("\",opaque=\"").append(createOpaque(realm, nonce))
            .append('"')
            .toString();
    }
1031578
public static function create($namespace = null, $name = null)
    {
        $fields = [
            self::TIME_LOW                  => '00000000',
            self::TIME_MID                  => '0000',
            self::TIME_HI_AND_VERSION       => '0000',
            self::CLOCK_SEQ_HI_AND_RESERVED => '00',
            self::CLOCK_SEQ_LOW             => '00',
            self::NODE                      => '000000000000',
        ];

        if (!($namespace instanceof Uuid5)) {
            $fields = self::fromString($namespace);
        }

        $hash = \sha1(self::getBytes($fields) . $name);

        return self::toString(self::uuidFromHashedName($hash, 5));
    }
241040
public function checkSignature($signature, $timestamp, $nonce) {
		return \Yii::$app->security->compareString($this->sign([$this->manager->app->token, $timestamp, $nonce]), $signature);
	}
918331
public static function splitHeader($header, $only_allow_oauth_parameters = true)
    {
        $params = [];
        if (preg_match_all('/('.($only_allow_oauth_parameters ? 'oauth_' : '').'[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches)) {
            foreach ($matches[1] as $i => $h) {
                $params[$h] = Util::urldecodeRfc3986(empty($matches[3][$i]) ? $matches[4][$i] : $matches[3][$i]);
            }
            if (isset($params['realm'])) {
                unset($params['realm']);
            }
        }
        return $params;
    }
821696
public function encrypt($xml, $nonce = null, $timestamp = null): string
    {
        try {
            $xml = $this->pkcs7Pad(str_random(16).pack('N', strlen($xml)).$xml.$this->appId, $this->blockSize);

            $encrypted = base64_encode(AES::encrypt(
                $xml,
                $this->aesKey,
                substr($this->aesKey, 0, 16),
                OPENSSL_NO_PADDING
            ));
            // @codeCoverageIgnoreStart
        } catch (Throwable $e) {
            throw new RuntimeException($e->getMessage(), self::ERROR_ENCRYPT_AES);
        }
        // @codeCoverageIgnoreEnd

        !is_null($nonce) || $nonce = substr($this->appId, 0, 10);
        !is_null($timestamp) || $timestamp = time();

        $response = [
            'Encrypt' => $encrypted,
            'MsgSignature' => $this->signature($this->token, $timestamp, $nonce, $encrypted),
            'TimeStamp' => $timestamp,
            'Nonce' => $nonce,
        ];

        //生成响应xml
        return XML::build($response);
    }
637013
public function createIdToken($client_id, $userInfo, $nonce = null, $userClaims = null, $access_token = null)
    {
        // pull auth_time from user info if supplied
        list($user_id, $auth_time) = $this->getUserIdAndAuthTime($userInfo);

        $token = array(
            'iss'        => $this->config['issuer'],
            'sub'        => $user_id,
            'aud'        => $client_id,
            'iat'        => time(),
            'exp'        => time() + $this->config['id_lifetime'],
            'auth_time'  => $auth_time,
        );

        if ($nonce) {
            $token['nonce'] = $nonce;
        }

        if ($userClaims) {
            $token += $userClaims;
        }

        if ($access_token) {
            $token['at_hash'] = $this->createAtHash($access_token, $client_id);
        }

        return $this->encodeToken($token, $client_id);
    }
165154
public function makeSignature($token = null, $time = null, $nonce = null)
    {
        if (!is_string($token) || empty($token)) {
            exit("$token 参数错误");
        }

        $timestamp = !empty($time) ? $time : $_GET['timestamp'];
        $nonce     = !empty($nonce) ? $nonce : $_GET['nonce'];
        $tmpArr    = [$token, $timestamp, $nonce];
        sort($tmpArr, SORT_STRING);
        $tmpStr = implode($tmpArr);
        $tmpStr = sha1($tmpStr);

        return $tmpStr;
    }
627111
private function checkMsgSignature($msg_signature, $timestamp, $nonce, $encrypt) {
		return \Yii::$app->security->compareString($this->sign([$this->manager->app->token, $timestamp, $nonce, $encrypt]), $msg_signature);
	}
433521
public static function splitHeader( $header, $oauthOnly = true ) {
		$re = '/(' . ( $oauthOnly ? 'oauth_' : '' ) .
			'[a-z_-]*)=(:?"([^"]*)"|([^,]*))/';
		$params = [];
		if ( preg_match_all( $re, $header, $m ) ) {
			foreach ( $m[1] as $i => $h ) {
				$params[$h] = static::urldecode(
					empty( $m[3][$i] ) ? $m[4][$i] : $m[3][$i]
				);
			}
			if ( isset( $params['realm'] ) ) {
				unset( $params['realm'] );
			}
		}
		return $params;
	}