/** * Updates the DSS with verification data received during the signature process. * * @param SetaPDF_Core_Document $document * @param $fieldName * @throws SetaPDF_Exception_NotImplemented */ public function updateDss(SetaPDF_Core_Document $document, $fieldName) { throw new SetaPDF_Exception_NotImplemented('This method is implemented but currently not available.'); if ($this->_collectVerificationData == false || !$this->_verificationData) { throw new BadMethodCallException('No verification data collected.'); } $ocsps = array(); $certificates = array(); $crls = array(); $data = $this->_verificationData; $certificates[] = $data->signatureInfos->basicInfo->signerCertificate; if (isset($data->signatureInfos->basicInfo->basicOcspResponse)) { $ocsps[] = $data->signatureInfos->basicInfo->basicOcspResponse; } $chain = $data->signatureInfos->chain; foreach ($chain as $cert) { $certificates[] = $cert->encoded; } $revocationInfo = $data->signatureInfos->revocationInfo; if (isset($revocationInfo->crlInfo)) { $crls[] = $revocationInfo->crlInfo->encoded; } if (isset($revocationInfo->basicOcspInfo)) { // file_put_contents('ocsp-before.dat', $revocationInfo->basicOcspInfo->encoded); $ocsp = $this->_prepareOscpResponse($revocationInfo->basicOcspInfo->encoded); // file_put_contents('ocsp-after.dat', $ocsp); $ocsps[] = $ocsp; $certificates[] = $revocationInfo->basicOcspInfo->endCertificate; $certificates[] = $revocationInfo->basicOcspInfo->issuerCertificate; } if (isset($data->timestampInfo)) { $certificates[] = $data->timestampInfo->signerCertificate; } $dss = new SetaPDF_Signer_DocumentSecurityStore($document); $dss->addValidationRelatedInfoByField($fieldName, $crls, $ocsps, $certificates); }
/** * Updates the document security store by the last received revoke information. * * @param SetaPDF_Core_Document $document * @param string $fieldName The signature field, that was signed. */ public function updateDss(SetaPDF_Core_Document $document, $fieldName) { if (!isset($this->_lastResult->SignResponse->OptionalOutputs->RevocationInformation)) { throw new BadMethodCallException('No verification data collected.'); } $ocsps = array(); $certificates = array(); $crls = array(); $data = $this->_lastResult->SignResponse->OptionalOutputs->RevocationInformation; if (isset($data->CRLs->CRL)) { $crls[] = $data->CRLs->CRL; } if (isset($data->OCSPs->OCSP)) { $ocsps[] = $data->OCSPs->OCSP; } $dss = new SetaPDF_Signer_DocumentSecurityStore($document); $dss->addValidationRelatedInfoByField($fieldName, $crls, $ocsps, $certificates); }