SAML2\Certificate\PrivateKeyLoader::loadDecryptionKeys PHP 메소드

loadDecryptionKeys() 공개 메소드

public loadDecryptionKeys ( SAML2\Configuration\DecryptionProvider $identityProvider, SAML2\Configuration\DecryptionProvider $serviceProvider ) : SAML2\Utilities\ArrayCollection
$identityProvider SAML2\Configuration\DecryptionProvider
$serviceProvider SAML2\Configuration\DecryptionProvider
리턴 SAML2\Utilities\ArrayCollection
    public function loadDecryptionKeys(DecryptionProvider $identityProvider, DecryptionProvider $serviceProvider)
    {
        $decryptionKeys = new ArrayCollection();
        $senderSharedKey = $identityProvider->getSharedKey();
        if ($senderSharedKey) {
            $key = new XMLSecurityKey(XMLSecurityKey::AES128_CBC);
            $key->loadKey($senderSharedKey);
            $decryptionKeys->add($key);
            return $decryptionKeys;
        }
        $newPrivateKey = $serviceProvider->getPrivateKey(PrivateKeyConfiguration::NAME_NEW);
        if ($newPrivateKey instanceof PrivateKey) {
            $loadedKey = $this->loadPrivateKey($newPrivateKey);
            $decryptionKeys->add($this->convertPrivateKeyToRsaKey($loadedKey));
        }
        $privateKey = $serviceProvider->getPrivateKey(PrivateKeyConfiguration::NAME_DEFAULT, true);
        $loadedKey = $this->loadPrivateKey($privateKey);
        $decryptionKeys->add($this->convertPrivateKeyToRsaKey($loadedKey));
        return $decryptionKeys;
    }

Usage Example

예제 #1
0
파일: Decrypter.php 프로젝트: SysBind/saml2
 /**
  * @param \SAML2\EncryptedAssertion $assertion
  *
  * @return \SAML2\Assertion
  */
 public function decrypt(EncryptedAssertion $assertion)
 {
     $decryptionKeys = $this->privateKeyLoader->loadDecryptionKeys($this->identityProvider, $this->serviceProvider);
     $blacklistedKeys = $this->identityProvider->getBlacklistedAlgorithms();
     if (is_null($blacklistedKeys)) {
         $blacklistedKeys = $this->serviceProvider->getBlacklistedAlgorithms();
     }
     // reflects the simplesamlphp behaviour for BC, see
     // https://github.com/simplesamlphp/simplesamlphp/blob/3d735912342767d391297cc5e13272a76730aca0/modules/saml/lib/Message.php#L369
     foreach ($decryptionKeys as $index => $key) {
         try {
             $decryptedAssertion = $assertion->getAssertion($key, $blacklistedKeys);
             $this->logger->debug(sprintf('Decrypted Assertion with key "#%d"', $index));
             return $decryptedAssertion;
         } catch (\Exception $e) {
             $this->logger->debug(sprintf('Could not decrypt assertion with key "#%d", "%s" thrown: "%s"', $index, get_class($e), $e->getMessage()));
         }
     }
     throw new NotDecryptedException(sprintf('Could not decrypt the assertion, tried with "%d" keys. See the debug log for more information', count($decryptionKeys)));
 }
All Usage Examples Of SAML2\Certificate\PrivateKeyLoader::loadDecryptionKeys