Jose\Util\JWELoader::loadSerializedJsonJWE PHP Method

loadSerializedJsonJWE() public static method

public static loadSerializedJsonJWE ( array $data ) : Jose\Object\JWEInterface
$data array
return Jose\Object\JWEInterface
    public static function loadSerializedJsonJWE(array $data)
    {
        $jwe = new JWE();
        $jwe = $jwe->withCiphertext(Base64Url::decode($data['ciphertext']));
        self::populateIV($jwe, $data);
        self::populateAAD($jwe, $data);
        self::populateTag($jwe, $data);
        self::populateSharedProtectedHeaders($jwe, $data);
        self::populateSharedHeaders($jwe, $data);
        foreach ($data['recipients'] as $recipient) {
            $encrypted_key = self::getRecipientEncryptedKey($recipient);
            $recipient_headers = self::getRecipientHeaders($recipient);
            $jwe = $jwe->addRecipientWithEncryptedKey($encrypted_key, $recipient_headers);
        }
        return $jwe;
    }

Usage Example

Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function load($input)
 {
     $json = $this->convert($input);
     if (array_key_exists('signatures', $json)) {
         return Util\JWSLoader::loadSerializedJsonJWS($json);
     }
     if (array_key_exists('recipients', $json)) {
         return Util\JWELoader::loadSerializedJsonJWE($json);
     }
 }