Skip to content

Commit

Permalink
Add XMLSecurityKey::fromEncryptedKeyElement().
Browse files Browse the repository at this point in the history
Moves the code for converting an EncryptedKey element to a
XMLSecurityKey object into a separate function.
  • Loading branch information
olavmrk committed Aug 2, 2010
1 parent 48b5b9b commit cbaf35d
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions xmlseclibs.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,27 @@ public function getX509Certificate() {
public function getX509Thumbprint() {
return $this->X509Thumbprint;
}


/**
* Create key from an EncryptedKey-element.
*
* @param DOMElement $element The EncryptedKey-element.
* @return XMLSecurityKey The new key.
*/
public static function fromEncryptedKeyElement(DOMElement $element) {

$objenc = new XMLSecEnc();
$objenc->setNode($element);
if (! $objKey = $objenc->locateKey()) {
throw new Exception("Unable to locate algorithm for this Encrypted Key");
}
$objKey->isEncrypted = TRUE;
$objKey->encryptedCtx = $objenc;
XMLSecEnc::staticLocateKeyInfo($objKey, $element);
return $objKey;
}

}

class XMLSecurityDSig {
Expand Down Expand Up @@ -1623,16 +1644,7 @@ static function staticLocateKeyInfo($objBaseKey=NULL, $node=NULL) {
/* Not currently supported */
break;
case 'EncryptedKey':
$objenc = new XMLSecEnc();
$objenc->setNode($child);
if (! $objKey = $objenc->locateKey()) {
throw new Exception("Unable to locate algorithm for this Encrypted Key");
}
$objKey->isEncrypted = TRUE;
$objKey->encryptedCtx = $objenc;
XMLSecEnc::staticLocateKeyInfo($objKey, $child);
return $objKey;
break;
return XMLSecurityKey::fromEncryptedKeyElement($child);
case 'X509Data':
if ($x509certNodes = $child->getElementsByTagName('X509Certificate')) {
if ($x509certNodes->length > 0) {
Expand Down

0 comments on commit cbaf35d

Please sign in to comment.