/** * @covers WindowsAzure\MediaServices\Templates\X509CertTokenVerificationKey::getRawBody * @covers WindowsAzure\MediaServices\Templates\X509CertTokenVerificationKey::setRawBody */ public function testGetSetRawBody() { // Setup $entity = new X509CertTokenVerificationKey(); $payload = 'payload string'; // Test $entity->setRawBody($payload); $result = $entity->getRawBody(); // Assert $this->assertEquals($payload, $result); }
/** * @param mixed $xmlElement * @return TokenVerificationKey */ private static function deserializeTokenVerificationKey($xmlElement) { if (!isset($xmlElement->attributes(Resources::XSI_XML_NAMESPACE)->type)) { throw new \RuntimeException("A TokenVerificationKey must contains a 'type' attribute"); } $type = $xmlElement->attributes(Resources::XSI_XML_NAMESPACE)->type; if ($type == "SymmetricVerificationKey") { if (!isset($xmlElement->KeyValue)) { throw new \RuntimeException("The SymmetricVerificationKey must contains an 'KeyValue' element"); } $key = new SymmetricVerificationKey(); $key->setKeyValue(base64_decode($xmlElement->KeyValue)); return $key; } if ($type == "X509CertTokenVerificationKey") { if (!isset($xmlElement->RawBody)) { throw new \RuntimeException("The X509CertTokenVerificationKey must contains a 'RawBody' element"); } $key = new X509CertTokenVerificationKey(); $key->setRawBody(base64_decode($xmlElement->RawBody)); return $key; } throw new \RuntimeException("Unknown TokenVerificationKey type: type='{$type}'"); }