SAML2\Assertion::isNameIdEncrypted PHP Method

isNameIdEncrypted() public method

Check whether the NameId is encrypted.
public isNameIdEncrypted ( ) : true
return true if the NameId is encrypted, false if not.
    public function isNameIdEncrypted()
    {
        return $this->encryptedNameId !== null;
    }

Usage Example

 public function transform(Assertion $assertion)
 {
     if (!$assertion->isNameIdEncrypted()) {
         return $assertion;
     }
     $decryptionKeys = $this->privateKeyLoader->loadDecryptionKeys($this->identityProvider, $this->serviceProvider);
     $blacklistedKeys = $this->identityProvider->getBlacklistedAlgorithms();
     if (is_null($blacklistedKeys)) {
         $blacklistedKeys = $this->serviceProvider->getBlacklistedAlgorithms();
     }
     foreach ($decryptionKeys as $index => $key) {
         try {
             $assertion->decryptNameId($key, $blacklistedKeys);
             $this->logger->debug(sprintf('Decrypted assertion NameId with key "#%d"', $index));
         } catch (\Exception $e) {
             $this->logger->debug(sprintf('Decrypting assertion NameId with key "#%d" failed, "%s" thrown: "%s"', $index, get_class($e), $e->getMessage()));
         }
     }
     if ($assertion->isNameIdEncrypted()) {
         throw new NotDecryptedException('Could not decrypt the assertion NameId with the configured keys, see the debug log for information');
     }
     return $assertion;
 }
All Usage Examples Of SAML2\Assertion::isNameIdEncrypted