当前位置: 首页>>代码示例>>PHP>>正文


PHP XMLSecEnc::staticLocateKeyInfo方法代码示例

本文整理汇总了PHP中XMLSecEnc::staticLocateKeyInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLSecEnc::staticLocateKeyInfo方法的具体用法?PHP XMLSecEnc::staticLocateKeyInfo怎么用?PHP XMLSecEnc::staticLocateKeyInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLSecEnc的用法示例。


在下文中一共展示了XMLSecEnc::staticLocateKeyInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: is_valid

function is_valid($document, $x509certificate)
{
    $objXMLSecDSig = new XMLSecurityDSig();
    $objDSig = $objXMLSecDSig->locateSignature($document);
    if (!$objDSig) {
        throw new Exception("Cannot locate Signature Node");
    }
    $objXMLSecDSig->canonicalizeSignedInfo();
    $objXMLSecDSig->idKeys = array('ID');
    $retVal = $objXMLSecDSig->validateReference();
    if (!$retVal) {
        throw new Exception("Reference Validation Failed");
    }
    $objKey = $objXMLSecDSig->locateKey();
    if (!$objKey) {
        throw new Exception("We have no idea about the key");
    }
    $key = NULL;
    $singleAssertion = validateNumAssertions($document);
    if (!$singleAssertion) {
        throw new Exception("Only one SAMLAssertion allowed");
    }
    $validTimestamps = validateTimestamps($document);
    if (!$validTimestamps) {
        throw new Exception("SAMLAssertion conditions not met");
    }
    $objKeyInfo = XMLSecEnc::staticLocateKeyInfo($objKey, $objDSig);
    $objKey->loadKey($x509certificate, FALSE, true);
    $result = $objXMLSecDSig->verify($objKey);
    return $result;
}
开发者ID:nethad,项目名称:experiments,代码行数:31,代码来源:saml2.php

示例2: is_valid

 function is_valid()
 {
     $objXMLSecDSig = new XMLSecurityDSig();
     $objDSig = $objXMLSecDSig->locateSignature($this->doc);
     if (!$objDSig) {
         throw new Exception("Cannot locate Signature Node");
         //, 'error', FALSE
         return false;
     }
     $objXMLSecDSig->canonicalizeSignedInfo();
     $objXMLSecDSig->idKeys = array('ID');
     $retVal = $objXMLSecDSig->validateReference();
     if (!$retVal) {
         throw new Exception("SAML Assertion Error: Reference Validation Failed");
         //, 'error', FALSE
         return false;
         // throw new Exception("Reference Validation Failed");
     }
     $objKey = $objXMLSecDSig->locateKey();
     if (!$objKey) {
         throw new Exception("SAML Assertion Error: We have no idea about the key");
         //, 'error', FALSE
         return false;
         // throw new Exception("We have no idea about the key");
     }
     $key = NULL;
     $singleAssertion = $this->validateNumAssertions();
     if (!$singleAssertion) {
         throw new Exception("SAML Assertion Error: Only ONE SAML Assertion Allowed");
         //, 'error', FALSE
         return false;
         // throw new Exception("Only ONE SamlAssertion allowed");
     }
     $validTimestamps = $this->validateTimestamps();
     if (!$validTimestamps) {
         throw new Exception("SAML Assertion Error: Check your timestamp conditions");
         //, 'error', FALSE
         return false;
         // throw new Exception("Check your timestamp conditions");
     }
     $objKeyInfo = XMLSecEnc::staticLocateKeyInfo($objKey, $objDSig);
     $objKey->loadKey($this->x509certificate, FALSE, true);
     $result = $objXMLSecDSig->verify($objKey);
     return $result;
 }
开发者ID:stefanotirati,项目名称:moodle-google-apps,代码行数:45,代码来源:xmlsec.php

示例3: __construct

 /**
  * This function initializes the validator.
  *
  * @param $xmlNode  The XML node which contains the Signature element.
  * @param $idAttribute  The ID attribute which is used in node references. If this attribute is
  *                      NULL (the default), then we will use whatever is the default ID.
  */
 public function __construct($xmlNode, $idAttribute = NULL, $publickey = FALSE)
 {
     assert('$xmlNode instanceof DOMNode');
     /* Create an XML security object. */
     $objXMLSecDSig = new XMLSecurityDSig();
     /* Add the id attribute if the user passed in an id attribute. */
     if ($idAttribute !== NULL) {
         assert('is_string($idAttribute)');
         $objXMLSecDSig->idKeys[] = $idAttribute;
     }
     /* Locate the XMLDSig Signature element to be used. */
     $signatureElement = $objXMLSecDSig->locateSignature($xmlNode);
     if (!$signatureElement) {
         throw new Exception('Could not locate XML Signature element.');
     }
     /* Canonicalize the XMLDSig SignedInfo element in the message. */
     $objXMLSecDSig->canonicalizeSignedInfo();
     /* Validate referenced xml nodes. */
     if (!$objXMLSecDSig->validateReference()) {
         throw new Exception('XMLsec: digest validation failed');
     }
     /* Find the key used to sign the document. */
     $objKey = $objXMLSecDSig->locateKey();
     if (empty($objKey)) {
         throw new Exception('Error loading key to handle XML signature');
     }
     /* Load the key data. */
     if ($publickey) {
         $objKey->loadKey($publickey);
     } else {
         if (!XMLSecEnc::staticLocateKeyInfo($objKey, $signatureElement)) {
             throw new Exception('Error finding key data for XML signature validation.');
         }
     }
     /* Check the signature. */
     if (!$objXMLSecDSig->verify($objKey)) {
         throw new Exception("Unable to validate Signature");
     }
     /* Extract the certificate fingerprint. */
     $this->x509Fingerprint = $objKey->getX509Fingerprint();
     /* Find the list of validated nodes. */
     $this->validNodes = $objXMLSecDSig->getValidatedNodes();
 }
开发者ID:stefanotirati,项目名称:moodle-google-apps,代码行数:50,代码来源:Validator.php

示例4: is_valid

 function is_valid()
 {
     $objXMLSecDSig = new XMLSecurityDSig();
     $objDSig = $objXMLSecDSig->locateSignature($this->doc);
     if (!$objDSig) {
         throw new Exception("Cannot locate Signature Node");
     }
     $objXMLSecDSig->canonicalizeSignedInfo();
     $objXMLSecDSig->idKeys = array('ID');
     $retVal = $objXMLSecDSig->validateReference();
     if (!$retVal) {
         throw new Exception("Reference Validation Failed");
     }
     $objKey = $objXMLSecDSig->locateKey();
     if (!$objKey) {
         throw new Exception("We have no idea about the key");
     }
     $key = NULL;
     $objKeyInfo = XMLSecEnc::staticLocateKeyInfo($objKey, $objDSig);
     $objKey->loadKey($this->x509certificate, FALSE, true);
     $result = $objXMLSecDSig->verify($objKey);
     return $result;
 }
开发者ID:sysraj86,项目名称:carnivalcrm,代码行数:23,代码来源:xmlsec.php

示例5: locateKeyInfo

 public function locateKeyInfo($objBaseKey = NULL, $node = NULL)
 {
     if (empty($node)) {
         $node = $this->rawNode;
     }
     return XMLSecEnc::staticLocateKeyInfo($objBaseKey, $node);
 }
开发者ID:BGCX067,项目名称:face-proveedor-cliente-php-git,代码行数:7,代码来源:XMLSecEnc.php

示例6: decryptSoapDoc

 public function decryptSoapDoc($doc, $options)
 {
     $privKey = null;
     $privKey_isFile = false;
     $privKey_isCert = false;
     if (is_array($options)) {
         $privKey = !empty($options["keys"]["private"]["key"]) ? $options["keys"]["private"]["key"] : null;
         $privKey_isFile = !empty($options["keys"]["private"]["isFile"]) ? true : false;
         $privKey_isCert = !empty($options["keys"]["private"]["isCert"]) ? true : false;
     }
     $objenc = new XMLSecEnc();
     $xpath = new DOMXPath($doc);
     $envns = $doc->documentElement->namespaceURI;
     $xpath->registerNamespace("soapns", $envns);
     $xpath->registerNamespace("soapenc", "http://www.w3.org/2001/04/xmlenc#");
     $nodes = $xpath->query('/soapns:Envelope/soapns:Header/*[local-name()="Security"]/soapenc:EncryptedKey');
     $references = array();
     if ($node = $nodes->item(0)) {
         $objenc = new XMLSecEnc();
         $objenc->setNode($node);
         if (!($objKey = $objenc->locateKey())) {
             throw new Exception("Unable to locate algorithm for this Encrypted Key");
         }
         $objKey->isEncrypted = true;
         $objKey->encryptedCtx = $objenc;
         XMLSecEnc::staticLocateKeyInfo($objKey, $node);
         if ($objKey && $objKey->isEncrypted) {
             $objencKey = $objKey->encryptedCtx;
             $objKey->loadKey($privKey, $privKey_isFile, $privKey_isCert);
             $key = $objencKey->decryptKey($objKey);
             $objKey->loadKey($key);
         }
         $refnodes = $xpath->query('./soapenc:ReferenceList/soapenc:DataReference/@URI', $node);
         foreach ($refnodes as $reference) {
             $references[] = $reference->nodeValue;
         }
     }
     foreach ($references as $reference) {
         $arUrl = parse_url($reference);
         $reference = $arUrl['fragment'];
         $query = '//*[@Id="' . $reference . '"]';
         $nodes = $xpath->query($query);
         $encData = $nodes->item(0);
         if ($algo = $xpath->evaluate("string(./soapenc:EncryptionMethod/@Algorithm)", $encData)) {
             $objKey = new XMLSecurityKey($algo);
             $objKey->loadKey($key);
         }
         $objenc->setNode($encData);
         $objenc->type = $encData->getAttribute("Type");
         $decrypt = $objenc->decryptNode($objKey, true);
     }
     return true;
 }
开发者ID:KoenLav,项目名称:wse-php,代码行数:53,代码来源:WSSESoap.php

示例7: isValid

 /**
  * @return bool
  * @throws Exception
  */
 public function isValid()
 {
     $singleAssertion = $this->validateNumAssertions();
     if (!$singleAssertion) {
         throw new Exception('Multiple assertions are not supported');
     }
     $validTimestamps = $this->validateTimestamps();
     if (!$validTimestamps) {
         throw new Exception('Timing issues (please check your clock settings)');
     }
     $objXMLSecDSig = new XMLSecurityDSig();
     $objDSig = $objXMLSecDSig->locateSignature($this->_document);
     if (!$objDSig) {
         throw new Exception('Cannot locate Signature Node');
     }
     $objXMLSecDSig->canonicalizeSignedInfo();
     $objXMLSecDSig->idKeys = array('ID');
     $objKey = $objXMLSecDSig->locateKey();
     if (!$objKey) {
         throw new Exception('We have no idea about the key');
     }
     try {
         $retVal = $objXMLSecDSig->validateReference();
     } catch (Exception $e) {
         throw new Exception('Reference Validation Failed');
     }
     XMLSecEnc::staticLocateKeyInfo($objKey, $objDSig);
     $objKey->loadKey($this->_settings->idpPublicCertificate, false, true);
     return $objXMLSecDSig->verify($objKey) === 1;
 }
开发者ID:maestrano,项目名称:maestrano-php,代码行数:34,代码来源:XmlSec.php

示例8: validateSign

 /**
  * Validates a signature (Message or Assertion).
  *
  * @param string|DomDocument $xml         The element we should validate
  * @param string|null        $cert        The pubic cert
  * @param string|null        $fingerprint The fingerprint of the public cert
  */
 public static function validateSign($xml, $cert = null, $fingerprint = null)
 {
     if ($xml instanceof DOMDocument) {
         $dom = clone $xml;
     } else {
         if ($xml instanceof DOMElement) {
             $dom = clone $xml->ownerDocument;
         } else {
             $dom = new DOMDocument();
             $dom = self::loadXML($dom, $xml);
         }
     }
     $objXMLSecDSig = new XMLSecurityDSig();
     $objXMLSecDSig->idKeys = array('ID');
     $objDSig = $objXMLSecDSig->locateSignature($dom);
     if (!$objDSig) {
         throw new Exception('Cannot locate Signature Node');
     }
     $objKey = $objXMLSecDSig->locateKey();
     if (!$objKey) {
         throw new Exception('We have no idea about the key');
     }
     $objXMLSecDSig->canonicalizeSignedInfo();
     try {
         $retVal = $objXMLSecDSig->validateReference();
     } catch (Exception $e) {
         throw $e;
     }
     XMLSecEnc::staticLocateKeyInfo($objKey, $objDSig);
     if (!empty($cert)) {
         $objKey->loadKey($cert, false, true);
         return $objXMLSecDSig->verify($objKey) === 1;
     } else {
         $domCert = $objKey->getX509Certificate();
         $domCertFingerprint = OneLogin_Saml2_Utils::calculateX509Fingerprint($domCert);
         if (OneLogin_Saml2_Utils::formatFingerPrint($fingerprint) !== $domCertFingerprint) {
             return false;
         } else {
             $objKey->loadKey($domCert, false, true);
             return $objXMLSecDSig->verify($objKey) === 1;
         }
     }
 }
开发者ID:faxe-kommune,项目名称:OS2loop,代码行数:50,代码来源:Utils.php

示例9: __construct

 /**
  * This function initializes the validator.
  *
  * This function accepts an optional parameter $publickey, which is the public key
  * or certificate which should be used to validate the signature. This parameter can
  * take the following values:
  * - NULL/FALSE: No validation will be performed. This is the default.
  * - A string: Assumed to be a PEM-encoded certificate / public key.
  * - An array: Assumed to be an array returned by SimpleSAML_Utilities::loadPublicKey.
  *
  * @param DOMNode $xmlNode  The XML node which contains the Signature element.
  * @param string|array $idAttribute  The ID attribute which is used in node references. If
  *          this attribute is NULL (the default), then we will use whatever is the default
  *          ID. Can be eigther a string with one value, or an array with multiple ID
  *          attrbute names.
  * @param array $publickey  The public key / certificate which should be used to validate the XML node.
  */
 public function __construct($xmlNode, $idAttribute = NULL, $publickey = FALSE)
 {
     assert('$xmlNode instanceof DOMNode');
     if ($publickey === NULL) {
         $publickey = FALSE;
     } elseif (is_string($publickey)) {
         $publickey = array('PEM' => $publickey);
     } else {
         assert('$publickey === FALSE || is_array($publickey)');
     }
     /* Create an XML security object. */
     $objXMLSecDSig = new XMLSecurityDSig();
     /* Add the id attribute if the user passed in an id attribute. */
     if ($idAttribute !== NULL) {
         if (is_string($idAttribute)) {
             $objXMLSecDSig->idKeys[] = $idAttribute;
         } elseif (is_array($idAttribute)) {
             foreach ($idAttribute as $ida) {
                 $objXMLSecDSig->idKeys[] = $ida;
             }
         }
     }
     /* Locate the XMLDSig Signature element to be used. */
     $signatureElement = $objXMLSecDSig->locateSignature($xmlNode);
     if (!$signatureElement) {
         throw new Exception('Could not locate XML Signature element.');
     }
     /* Canonicalize the XMLDSig SignedInfo element in the message. */
     $objXMLSecDSig->canonicalizeSignedInfo();
     /* Validate referenced xml nodes. */
     if (!$objXMLSecDSig->validateReference()) {
         throw new Exception('XMLsec: digest validation failed');
     }
     /* Find the key used to sign the document. */
     $objKey = $objXMLSecDSig->locateKey();
     if (empty($objKey)) {
         throw new Exception('Error loading key to handle XML signature');
     }
     /* Load the key data. */
     if ($publickey !== FALSE && array_key_exists('PEM', $publickey)) {
         /* We have PEM data for the public key / certificate. */
         $objKey->loadKey($publickey['PEM']);
     } else {
         /* No PEM data. Search for key in signature. */
         if (!XMLSecEnc::staticLocateKeyInfo($objKey, $signatureElement)) {
             throw new Exception('Error finding key data for XML signature validation.');
         }
         if ($publickey !== FALSE) {
             /* $publickey is set, and should therefore contain one or more fingerprints.
              * Check that the response contains a certificate with a matching
              * fingerprint.
              */
             assert('is_array($publickey["certFingerprint"])');
             $certificate = $objKey->getX509Certificate();
             if ($certificate === NULL) {
                 /* Wasn't signed with an X509 certificate. */
                 throw new Exception('Message wasn\'t signed with an X509 certificate,' . ' and no public key was provided in the metadata.');
             }
             self::validateCertificateFingerprint($certificate, $publickey['certFingerprint']);
             /* Key OK. */
         }
     }
     /* Check the signature. */
     if (!$objXMLSecDSig->verify($objKey)) {
         throw new Exception("Unable to validate Signature");
     }
     /* Extract the certificate. */
     $this->x509Certificate = $objKey->getX509Certificate();
     /* Find the list of validated nodes. */
     $this->validNodes = $objXMLSecDSig->getValidatedNodes();
 }
开发者ID:danielkjfrog,项目名称:docker,代码行数:88,代码来源:Validator.php

示例10: processSignature

 public function processSignature($refNode)
 {
     $objXMLSecDSig = new XMLSecurityDSig();
     $objXMLSecDSig->idKeys[] = 'wswsu:Id';
     $objXMLSecDSig->idNS['wswsu'] = WSSESoapServer::WSUNS;
     $objXMLSecDSig->sigNode = $refNode;
     /* Canonicalize the signed info */
     $objXMLSecDSig->canonicalizeSignedInfo();
     $retVal = $objXMLSecDSig->validateReference();
     if (!$retVal) {
         throw new Exception("Validation Failed");
     }
     $key = NULL;
     $objKey = $objXMLSecDSig->locateKey();
     if ($objKey) {
         if ($objKeyInfo = XMLSecEnc::staticLocateKeyInfo($objKey, $refNode)) {
             /* Handle any additional key processing such as encrypted keys here */
         }
     }
     if (empty($objKey)) {
         throw new Exception("Error loading key to handle Signature");
     }
     do {
         if (empty($objKey->key)) {
             $this->SOAPXPath->registerNamespace('xmlsecdsig', XMLSecurityDSig::XMLDSIGNS);
             $query = "./xmlsecdsig:KeyInfo/wswsse:SecurityTokenReference/wswsse:Reference";
             $nodeset = $this->SOAPXPath->query($query, $refNode);
             if ($encmeth = $nodeset->item(0)) {
                 if ($uri = $encmeth->getAttribute("URI")) {
                     $arUrl = parse_url($uri);
                     if (empty($arUrl['path']) && ($identifier = $arUrl['fragment'])) {
                         $query = '//wswsse:BinarySecurityToken[@wswsu:Id="' . $identifier . '"]';
                         $nodeset = $this->SOAPXPath->query($query);
                         if ($encmeth = $nodeset->item(0)) {
                             $x509cert = $encmeth->textContent;
                             $x509cert = str_replace(array("\r", "\n"), "", $x509cert);
                             $x509cert = "-----BEGIN CERTIFICATE-----\n" . chunk_split($x509cert, 64, "\n") . "-----END CERTIFICATE-----\n";
                             $objKey->loadKey($x509cert);
                             break;
                         }
                     }
                 }
             }
             throw new Exception("Error loading key to handle Signature");
         }
     } while (0);
     if (!$objXMLSecDSig->verify($objKey)) {
         throw new Exception("Unable to validate Signature");
     }
     return TRUE;
 }
开发者ID:binondord,项目名称:wse-php,代码行数:51,代码来源:soap-server-wsse.php

示例11: validateSign

 /**
  * Validates a signature (Message or Assertion).
  *
  * @param string|DomDocument $xml            The element we should validate
  * @param string|null        $cert           The pubic cert
  * @param string|null        $fingerprint    The fingerprint of the public cert
  * @param string|null        $fingerprintalg The algorithm used to get the fingerprint
  */
 public static function validateSign($xml, $cert = null, $fingerprint = null, $fingerprintalg = 'sha1')
 {
     if ($xml instanceof DOMDocument) {
         $dom = clone $xml;
     } else {
         if ($xml instanceof DOMElement) {
             $dom = clone $xml->ownerDocument;
         } else {
             $dom = new DOMDocument();
             $dom = self::loadXML($dom, $xml);
         }
     }
     # Check if Reference URI is empty
     try {
         $signatureElems = $dom->getElementsByTagName('Signature');
         foreach ($signatureElems as $signatureElem) {
             $referenceElems = $dom->getElementsByTagName('Reference');
             if (count($referenceElems) > 0) {
                 $referenceElem = $referenceElems->item(0);
                 if ($referenceElem->getAttribute('URI') == '') {
                     $referenceElem->setAttribute('URI', '#' . $signatureElem->parentNode->getAttribute('ID'));
                 }
             }
         }
     } catch (Exception $e) {
         continue;
     }
     $objXMLSecDSig = new XMLSecurityDSig();
     $objXMLSecDSig->idKeys = array('ID');
     $objDSig = $objXMLSecDSig->locateSignature($dom);
     if (!$objDSig) {
         throw new Exception('Cannot locate Signature Node');
     }
     $objKey = $objXMLSecDSig->locateKey();
     if (!$objKey) {
         throw new Exception('We have no idea about the key');
     }
     $objXMLSecDSig->canonicalizeSignedInfo();
     try {
         $retVal = $objXMLSecDSig->validateReference();
     } catch (Exception $e) {
         throw $e;
     }
     XMLSecEnc::staticLocateKeyInfo($objKey, $objDSig);
     if (!empty($cert)) {
         $objKey->loadKey($cert, false, true);
         return $objXMLSecDSig->verify($objKey) === 1;
     } else {
         $domCert = $objKey->getX509Certificate();
         $domCertFingerprint = OneLogin_Saml2_Utils::calculateX509Fingerprint($domCert, $fingerprintalg);
         if (OneLogin_Saml2_Utils::formatFingerPrint($fingerprint) !== $domCertFingerprint) {
             return false;
         } else {
             $objKey->loadKey($domCert, false, true);
             return $objXMLSecDSig->verify($objKey) === 1;
         }
     }
 }
开发者ID:hukmedia,项目名称:Magento-WSO2-SAML,代码行数:66,代码来源:Utils.php

示例12: checkXMLSignature

function checkXMLSignature($token)
{
    $objXMLSecDSig = new XMLSecurityDSig();
    $objXMLSecDSig->idKeys[] = 'ID';
    $objDSig = $objXMLSecDSig->locateSignature($token);
    /* Must check certificate fingerprint now - validateReference removes it */
    if (!validateCertFingerprint($token)) {
        throw new Exception("Fingerprint Validation Failed");
    }
    /* Canonicalize the signed info */
    $objXMLSecDSig->canonicalizeSignedInfo();
    $retVal = NULL;
    if ($objDSig) {
        $retVal = $objXMLSecDSig->validateReference();
    }
    if (!$retVal) {
        throw new Exception("SAML Validation Failed");
    }
    $key = NULL;
    $objKey = $objXMLSecDSig->locateKey();
    if ($objKey) {
        if ($objKeyInfo = XMLSecEnc::staticLocateKeyInfo($objKey, $objDSig)) {
            /* Handle any additional key processing such as encrypted keys here */
        }
    }
    if (empty($objKey)) {
        throw new Exception("Error loading key to handle Signature");
    }
    return $objXMLSecDSig->verify($objKey) == 1;
}
开发者ID:GajendraNaidu,项目名称:openam,代码行数:30,代码来源:saml-lib.php

示例13: testVerify

 /**
  * @param $testName
  * @param $testFile
  *
  * @dataProvider verifyProvider
  */
 public function testVerify($testName, $testFile)
 {
     $doc = new \DOMDocument();
     $doc->load($testFile);
     $objXMLSecDSig = new XMLSecurityDSig();
     $objDSig = $objXMLSecDSig->locateSignature($doc);
     $this->assertInstanceOf('\\DOMElement', $objDSig, "Cannot locate Signature Node");
     $objXMLSecDSig->canonicalizeSignedInfo();
     $objXMLSecDSig->idKeys = array('wsu:Id');
     $objXMLSecDSig->idNS = array('wsu' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd');
     $retVal = $objXMLSecDSig->validateReference();
     $this->assertTrue($retVal, "Reference Validation Failed");
     $objKey = $objXMLSecDSig->locateKey();
     $this->assertInstanceOf('\\XmlSecLibs\\XMLSecurityKey', $objKey, "We have no idea about the key");
     $key = null;
     $objKeyInfo = XMLSecEnc::staticLocateKeyInfo($objKey, $objDSig);
     if (!$objKeyInfo->key && empty($key)) {
         $objKey->loadKey(dirname(__FILE__) . '/../mycert.pem', true);
     }
     $this->assertEquals(1, $objXMLSecDSig->verify($objKey), "{$testName}: Signature is invalid");
 }
开发者ID:ddvzwzjm,项目名称:xmlseclibs,代码行数:27,代码来源:XmlSecEncTest.php

示例14: define

define('DS', '\\');
$doc = new DOMDocument();
$doc->load('C:\\Users\\Miha Nahtigal\\Downloads\\Obcina_Trebnje_koledar_eslog (82).xml');
require dirname(dirname(__FILE__)) . DS . 'Plugin' . DS . 'LilInvoices' . DS . 'Lib' . DS . 'xmlseclibs_bes.php';
$objXMLSecDSig = new XMLSecurityDSig();
$objDSig = $objXMLSecDSig->locateSignature($doc);
if (!$objDSig) {
    throw new Exception("Cannot locate Signature Node");
}
$objXMLSecDSig->canonicalizeSignedInfo();
//$objXMLSecDSig->idKeys = array('xds:Id');
//$objXMLSecDSig->idNS = array('xds'=>'http://uri.etsi.org/01903/v1.1.1#');
$retVal = $objXMLSecDSig->validateReference();
if (!$retVal) {
    throw new Exception("Reference Validation Failed");
}
$objKey = $objXMLSecDSig->locateKey();
if (!$objKey) {
    throw new Exception("We have no idea about the key");
}
$key = NULL;
$objKeyInfo = XMLSecEnc::staticLocateKeyInfo($objKey, $objDSig);
if (!$objKeyInfo->key && empty($key)) {
    $objKey->loadKey(dirname(__FILE__) . '/mycert.pem', TRUE);
}
if ($objXMLSecDSig->verify($objKey)) {
    print "Signature validated!";
} else {
    print "Failure!!!!!!!!";
}
print "\n";
开发者ID:malamalca,项目名称:lil-intranet,代码行数:31,代码来源:verify.php

示例15: fromEncryptedKeyElement

 /**
  * 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;
 }
开发者ID:RKathees,项目名称:is-connectors,代码行数:19,代码来源:XMLSecurityKey.php


注:本文中的XMLSecEnc::staticLocateKeyInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。