Skip to content

Commit

Permalink
Merge pull request #11 from zogs/cleaned
Browse files Browse the repository at this point in the history
add a protected createXmlSecurityDSig method
  • Loading branch information
Maks3w committed Feb 1, 2016
2 parents f98f22a + dbf864e commit 1edfaca
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Adapter/XmlseclibsAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function sign(DOMDocument $data)
);
$objKey->loadKey($this->privateKey);

$objXMLSecDSig = new XMLSecurityDSig();
$objXMLSecDSig = $this->createXmlSecurityDSig();
$objXMLSecDSig->setCanonicalMethod($this->canonicalMethod);
$objXMLSecDSig->addReference($data, $this->digestAlgorithm, $this->transforms, ['force_uri' => true]);
$objXMLSecDSig->sign($objKey, $data->documentElement);
Expand All @@ -135,7 +135,7 @@ public function sign(DOMDocument $data)
public function verify(DOMDocument $data)
{
$objKey = null;
$objXMLSecDSig = new XMLSecurityDSig();
$objXMLSecDSig = $this->createXmlSecurityDSig();
$objDSig = $objXMLSecDSig->locateSignature($data);
if (!$objDSig) {
throw new UnexpectedValueException('Signature DOM element not found.');
Expand Down Expand Up @@ -181,6 +181,16 @@ public function verify(DOMDocument $data)
return true;
}

/**
* Create the XMLSecurityDSig class.
*
* @return XMLSecurityDSig
*/
protected function createXmlSecurityDSig()
{
return new XMLSecurityDSig();
}

/**
* Try to extract the public key from DOM node.
*
Expand All @@ -196,7 +206,7 @@ public function verify(DOMDocument $data)
protected function setPublicKeyFromNode(DOMNode $dom)
{
// try to get the public key from the certificate
$objXMLSecDSig = new XMLSecurityDSig();
$objXMLSecDSig = $this->createXmlSecurityDSig();
$objDSig = $objXMLSecDSig->locateSignature($dom);
if (!$objDSig) {
return false;
Expand Down

0 comments on commit 1edfaca

Please sign in to comment.