Creates a new signature.

@internal

@return Signature
11670
public static function create(string $signature, array $protectedHeader, ?string $encodedProtectedHeader, array $header = []): self
    {
        return new self($signature, $protectedHeader, $encodedProtectedHeader, $header);
    }
801384
public function create()
    {
        $instance = self::createCustomerGroup($this);
        $this->setId($instance->getId());
        return $instance;
    }
89727
public static function version()
    {
        return function ($version, $service, $region) {
            switch ($version) {
                case 's3v4':
                case 'v4':
                    return !empty(self::$s3v4SignedServices[$service])
                        ? new S3SignatureV4($service, $region)
                        : new SignatureV4($service, $region);
                case 'v4-unsigned-body':
                    return new SignatureV4($service, $region, ['unsigned-body' => 'true']);
                case 'anonymous':
                    return new AnonymousSignature();
                default:
                    return null;
            }
        };
    }
250464
protected function createSwiftSigner($signature)
    {
        if (!isset($signature['type'])) {
            throw new InvalidConfigException('Signature configuration should contain "type" key');
        }
        switch (strtolower($signature['type'])) {
            case 'dkim' :
                $domain = ArrayHelper::getValue($signature, 'domain', null);
                $selector = ArrayHelper::getValue($signature, 'selector', null);
                if (isset($signature['key'])) {
                    $privateKey = $signature['key'];
                } elseif (isset($signature['file'])) {
                    $privateKey = file_get_contents(Yii::getAlias($signature['file']));
                } else {
                    throw new InvalidConfigException("Either 'key' or 'file' signature option should be specified");
                }
                return new \Swift_Signers_DKIMSigner($privateKey, $domain, $selector);
            case 'opendkim' :
                $domain = ArrayHelper::getValue($signature, 'domain', null);
                $selector = ArrayHelper::getValue($signature, 'selector', null);
                if (isset($signature['key'])) {
                    $privateKey = $signature['key'];
                } elseif (isset($signature['file'])) {
                    $privateKey = file_get_contents(Yii::getAlias($signature['file']));
                } else {
                    throw new InvalidConfigException("Either 'key' or 'file' signature option should be specified");
                }
                return new \Swift_Signers_OpenDKIMSigner($privateKey, $domain, $selector);
            default:
                throw new InvalidConfigException("Unrecognized signature type '{$signature['type']}'");
        }
    }
858558
public function getSignatureRequest($id)
    {
        $response = $this->rest->get(
            static::SIGNATURE_REQUEST_PATH . '/' . $id
        );

        $this->checkResponse($response);

        return new SignatureRequest($response);
    }
949368
private function generateSignature(DOMElement $signedInfoNode)
    {
        $signature = null;

        if (!openssl_sign(
            $signedInfoNode->C14N(true),
            $signature,
            $this->getPrivateKeyResource(),
            OPENSSL_ALGO_SHA1
        )
        ) {
            throw new \Exception('Unable to sign the request');
        }

        return $signature;
    }
550726
private function getSignature(): string
    {
        if (!empty($this->secret)) {
            return $this->encode->signature(
                $this->jsonEncode($this->getHeader()),
                $this->jsonEncode($this->getPayload()),
                $this->secret
            );
        }

        throw new ValidateException('Invalid secret.', 9);
    }
532144
public function createPrivateKey()
    {
        $rsa = new RSA();
        $rsa->setPrivateKeyFormat(RSA::PRIVATE_FORMAT_PKCS1);

        return $rsa->createKey($this->getPrivateKeySize())['privatekey'];
    }
716820
public function create()
    {
        $instance = self::createPaymentTransaction($this);
        $this->setId($instance->getId());
        return $instance;
    }
1081978
public function signature($url, $key = null, $timestamp = null, $signName = 'sign', $timeName = 't')
    {
        return $this->signatureD($url, $key, $timestamp, $signName, $timeName);
    }
218177
public function createCredentials()
    {
        $credentials = new Credentials();
        $credentials->setTransactor($this);
        $credentials->setCredentials(array(
            'providerId' => null,
            'providerGateId' => null,
            'providerGateKey' => null,
            'merchantId' => null,
            'merchantGateId' => null,
            'merchantGateKey' => null
        ));

        return $credentials;
    }
983680
public function assign($signature) {

        $file = $this->path.$this->language.DIRECTORY_SEPARATOR.$signature.'.php';

        // content does not loaded yet
        if(isset($this->required[$file]) === false) {

            if (file_exists($file) === true) {

                $content = include $file;
                $this->required[$file] = true;
            }
            else {
                // set default path by default language
                $file = $this->path.$this->default.DIRECTORY_SEPARATOR.$signature.'.php';
                if (file_exists($file) === true) {

                    $content = include $file;
                    $this->required[$file] = true;
                }
            }

            // assign to translate
            $this->adapter = new TranslateAdapterArray(['content' => [
                    $signature => (isset($content)) ? $content : false
            ]]);
        }

        // $this->adapter->offsetGet() was thrown error with Phalcon 2.0 (??)
        $reflection = new \ReflectionClass($this->adapter);
        $property = $reflection->getProperty('_translate');
        $property->setAccessible(true);
        //$this->signature = $this->adapter->offsetGet($signature);

        // setup signature
        $this->signature = $property->getValue($this->adapter)[$signature];

        return $this;
    }
3761
public function create()
    {
        $instance = self::createDiscountPromotion($this);
        $this->setId($instance->getId());
        return $instance;
    }
260644
public function create()
    {
        $instance = self::createBrand($this);
        $this->setId($instance->getId());
        return $instance;
    }
721678
public static function createFromUnsignedJwt(UnsignedJwt $unsignedJwt, string $signature) : SignedJwt
    {
        return new self($unsignedJwt->getHeader(), $unsignedJwt->getPayload(), $signature);
    }
336824
public function createBaseString()
    {
        if ($this->timestamp === 0) {
            $this->setTimestamp();
        }

        $paramArray = array(
            'oauth_nonce' => $this->getNonce(),
            'oauth_callback' => $this->callback,
            'oauth_signature_method' => $this->signatureMethod,
            'oauth_timestamp' => $this->getTimestamp(),
            'oauth_consumer_key' => $this->consumerCredential->getIdentifier(),
            'oauth_token' => $this->userCredential->getIdentifier(),
            'oauth_version' => $this->version,
            'oauth_verifier' => $this->getVerifier()
        );

        return $this->buildBaseString($paramArray);
    }
531052
public static function generateSigningKeypair() : Keypair
    {
        try {
            $keypair = \sodium_crypto_sign_keypair();
            return new Keypair(
                \sodium_crypto_sign_secretkey($keypair),
                \sodium_crypto_sign_publickey($keypair)
            );
        } catch (SodiumException $e) {
            throw new Exception($e->getMessage());
        }
    }