/** * Realiza a validação do documento. * @param bool $lVerificarIntegridadeDocumento true para validar a integridade do documento * @return bool */ public function validar($lVerificarIntegridadeDocumento = true) { if ($this->getDataFinal() < new DateTime()) { $this->lastError = self::ERRO_CERTIFICADO_VENCIDO; return false; } $oXMLSecDSig = new DBSeller_Helper_Xml_Security_XMLSecurityDSig(); $oAssinatura = $oXMLSecDSig->locateSignature($this->oDomDocument); if (empty($oAssinatura)) { $this->lastError = self::ERRO_ASSINATURA_NAO_ENCONTRADA; return false; } $oXMLSecDSig->canonicalizeSignedInfo(); if ($lVerificarIntegridadeDocumento && !$oXMLSecDSig->validateReference()) { $this->lastError = self::ERRO_INTEGRIDADE_DOCUMENTO; return false; } $oKeyData = $oXMLSecDSig->locateKey(); if (!$oKeyData) { $this->lastError = self::ERRO_ASSINATURA_INVALIDA; return false; } $objKeyInfo = DBSeller_Helper_Xml_Security_XMLSecEnc::staticLocateKeyInfo($oKeyData, $oAssinatura); return $oXMLSecDSig->verify($objKeyInfo); }
public function locateKeyInfo($objBaseKey = NULL, $node = NULL) { if (empty($node)) { $node = $this->rawNode; } return DBSeller_Helper_Xml_Security_XMLSecEnc::staticLocateKeyInfo($objBaseKey, $node); }
/** * Create key from an EncryptedKey-element. * * @param DOMElement $element The EncryptedKey-element. * @throws Exception * @return DBSeller_Helper_Xml_Security_SecurityKey The new key. */ public static function fromEncryptedKeyElement(DOMElement $element) { $objenc = new DBSeller_Helper_Xml_Security_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; DBSeller_Helper_Xml_Security_XMLSecEnc::staticLocateKeyInfo($objKey, $element); return $objKey; }