Jose\Factory\JWEFactory::createJWE PHP Method

createJWE() public static method

public static createJWE ( $payload, array $shared_protected_headers = [], array $shared_headers = [], $aad = null )
$shared_protected_headers array
$shared_headers array
    public static function createJWE($payload, array $shared_protected_headers = [], array $shared_headers = [], $aad = null)
    {
        $jwe = new JWE();
        $jwe = $jwe->withSharedProtectedHeaders($shared_protected_headers);
        $jwe = $jwe->withSharedHeaders($shared_headers);
        $jwe = $jwe->withPayload($payload);
        if (null !== $aad) {
            $jwe = $jwe->withAAD($aad);
        }
        return $jwe;
    }

Usage Example

Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function encrypt($payload, array $encryption_protected_headers, Object\JWKInterface $encryption_key)
 {
     Assertion::true($this->isEncryptionSupportEnabled(), 'The encryption support is not enabled');
     $jwe = Factory\JWEFactory::createJWE($payload, $encryption_protected_headers);
     $jwe = $jwe->addRecipientInformation($encryption_key);
     $this->encrypter->encrypt($jwe);
     return $jwe->toCompactJSON(0);
 }