public final class UtilsSignatureOp extends java.lang.Object implements IUtilsSignature
Class that contains methods related to the manage of signatures.
Project:Library for the integration with the services of @Firma, eVisor and TS@.
| Modifier and Type | Field and Description |
|---|---|
static com.lowagie.text.pdf.PdfName |
CADES_SUBFILTER_VALUE
Constant attribute that represents the value for the key SubFilter of the signature dictionary for a
PAdES Enhanced signature.
|
static com.lowagie.text.pdf.PdfName |
DOC_TIME_STAMP_DICTIONARY_NAME
Constant attribute that represents the value to identify the type of a Document Time-stamp.
|
static com.lowagie.text.pdf.PdfName |
DSS_DICTIONARY_NAME
Constant attribute that represents the value to identify the DSS entry in a PDF's Catalog.
|
static com.lowagie.text.pdf.PdfName |
TST_SUBFILTER_VALUE
Constant attribute that represents the value for the key SubFilter of a Document Time-stamp dictionary.
|
DETACHED_SIGNATURE_MODE, ENVELOPED_SIGNATURE_MODE, ENVELOPING_SIGNATURE_MODE, EXPLICIT_SIGNATURE_MODE, IMPLICIT_SIGNATURE_MODE, VALIDATION_LEVEL_COMPLETE, VALIDATION_LEVEL_NONE, VALIDATION_LEVEL_SIMPLE| Modifier and Type | Method and Description |
|---|---|
static org.bouncycastle.util.Store |
addCertificateToStore(org.bouncycastle.util.Store certificates,
java.security.cert.X509Certificate certificate)
Method that adds a certificate to a certificates store.
|
static void |
appendXMLDocument(org.w3c.dom.Document xmlDocument,
org.w3c.dom.Document documentToAppend)
Method that appends a XML document to certain signed XML document.
|
static java.util.Date |
calculateExpirationDate(java.util.List<PDFSignatureDictionary> signatureDictionaries,
java.util.List<PDFDocumentTimestampDictionary> timestampDictionaries)
Method that calculates the expiration date of a PAdES signature, that is, the moment in which the signature will become invalid.
|
static java.util.Date |
calculateExpirationDateForValidations(SignerValidationResult signerValidationResult,
java.util.Date currentDate)
Auxiliary method that calculate the expiration date of a validation or update response.
|
static boolean |
checkExtraParamsSignWithRubric(java.util.Properties externalParams)
Method that checks if the signature includes a rubric.
|
static void |
checkPDFCertificationLevel(java.util.Map<java.lang.Integer,java.io.InputStream> mapRevisions)
Method that validates if some approval signature was added to a PDF document after that it was defined as certified.
|
static void |
checkSubFilterConditionsISO320001(PDFSignatureDictionary dictionarySignature,
org.bouncycastle.cms.CMSSignedData signedData)
The ISO 32000-1 specifies in section 12.8.3.3.1:
- adbe.pkcs7.detached: The original signed message digest over the document’s byte range shall
be incorporated as the normal PKCS#7 SignedData field.
|
static org.w3c.dom.Document |
composeCoSignaturesDocument(org.w3c.dom.Document xmlDocument,
javax.xml.parsers.DocumentBuilderFactory dBFactory)
Method that composes and obtains a XML document with the root node <ROOT_COSIGNATURES> for adding new cosigns
over that (on enveloping signature mode).
|
static boolean |
equalsHash(com.lowagie.text.pdf.PdfArray pdfArrayByteRange,
java.security.MessageDigest messageDigestSignature,
byte[] pdfDocument,
byte[] hashSignature)
Method that compares two bytes arrays and indicates if the hash of each is equals (true) or not (false).
|
static java.util.List<ReferenceDataBaseline> |
fromNodeListToReferenceDataBaselineList(org.w3c.dom.Node manifestNode,
org.w3c.dom.Node signedDataObjectPropertiesNode)
Method that parse a manifest and signedDataObjectProperties element into a list of ReferenceDataBaseline objects.
|
static java.util.List<CAdESSignerInfo> |
getCAdESListSigners(org.bouncycastle.cms.CMSSignedData signedData)
Method that obtains a list with the principal information related to the signers of a CAdES signature.
|
static org.bouncycastle.cms.CMSSignedData |
getCMSSignature(PDFSignatureDictionary signatureDictionary)
Method that obtains the
SignedData contained inside of a signature dictionary of a PDF document. |
static org.bouncycastle.cms.CMSSignedData |
getCMSSignedData(byte[] signature)
Method that obtains the CAdES structure of an ASN.1 signature.
|
static java.util.Date |
getExpirationDate(byte[] signature)
Method that calculates the expiration date of a signature.
|
static java.util.List<org.w3c.dom.Element> |
getListSignatures(org.w3c.dom.Document doc)
Method that obtains the list of
ds:Signature elements, as signatures, contained inside of a XML document. |
static java.util.List<org.w3c.dom.Element> |
getListSignaturesToCounterSign(org.w3c.dom.Element rootElement)
Method that obtains from a root element the list of
ds:Signature elements to add xades:CounterSignature element. |
static byte[] |
getOriginalDataFromSignedXMLDocument(org.w3c.dom.Document xmlDocument)
Method that obtains the original data from a signed XML document.
|
static org.bouncycastle.asn1.x509.AlgorithmIdentifier |
getSignatureAlgorithm(org.bouncycastle.cms.SignerInformation signerInformation)
Obtiene el OID del algoritmo de firma empleado.
|
static org.bouncycastle.asn1.x509.AlgorithmIdentifier |
getSignatureAlgorithm(java.lang.String encryptionAlgOid,
java.lang.String hashAlgOid)
Obtiene el identificador de algoritmo de firma que se corresponde al usar el
algoritmo de encriptación con el algoritmo de hash indicados.
|
static java.lang.String |
getSignedElementIdValue(org.w3c.dom.Document xmlDocument)
Method that obtains the value of the attribute
Id of the Content node of the wrapper, or an empty String if the signed XML document doesn't contain that attribute
(wrapper signed on enveloped mode). |
static java.security.cert.X509Certificate |
getSigningCertificate(org.bouncycastle.cms.CMSSignedData signedData,
org.bouncycastle.cms.SignerInformation signerInformation)
Method that obtains the singing certificate of a signer of a signature.
|
static java.lang.String |
getTypeOfXMLSignature(org.w3c.dom.Document xmlDocument)
Method that obtains the signature mode of a signed XML document.
|
static org.bouncycastle.cert.X509CertificateHolder |
getX509CertificateHolderBySignerId(org.bouncycastle.util.Store certificatesStore,
org.bouncycastle.cms.SignerId signerId)
Method that obtains the structure of a certificate from a certificates store.
|
static java.util.List<XAdESSignerInfo> |
getXAdESListSigners(org.w3c.dom.Document doc)
Method that obtains a list with the principal information related to the signers of a XAdES signature.
|
static org.w3c.dom.Element |
getXMLSignatureById(org.w3c.dom.Document document,
java.lang.String signatureId)
Method that obtains a
Signature element from a XML document. |
static org.w3c.dom.Document |
insertAfirmaRootNode(org.w3c.dom.Document xmlDocument,
javax.xml.parsers.DocumentBuilderFactory dBFactory)
Method that defines the
AFIRMA node as root node of a signed XML document. |
static void |
insertRubric(com.lowagie.text.pdf.PdfReader reader,
com.lowagie.text.pdf.PdfSignatureAppearance signatureAppearance,
java.util.Properties externalParams)
Method that inserts the rubric in a document.
|
static boolean |
isDocumentTimeStampDictionary(java.lang.String pdfType,
java.lang.String subFilter)
Method that indicates whether a pdf dictionary is a document Time-stamp dictionary (true) or not (false).
|
static boolean |
isDSSTimestamp(org.w3c.dom.Node eSignature)
Method that indicates if the signature is an XMLTimeStamp element by the OASIS-DSS specifications (true) or not (false).
|
static boolean |
isImplicit(org.bouncycastle.cms.CMSSignedData cmsSignedData)
Method that indicates whether the signature includes the original document (true) or not (false).
|
static boolean |
isNotPAdESEnhancedPDF(com.lowagie.text.pdf.PdfDictionary pdfDic)
Method that indicates whether a signature dictionary refers to a PDF or PAdES-Basic signature (true) or to a PAdES-BES or PAdES-EPES signature (false).
|
static boolean |
isSignatureDictionary(java.lang.String pdfType,
java.lang.String subFilter)
Method that indicates whether a pdf dictionary is a signature dictionary (true) or not (false).
|
static java.security.cert.X509Certificate |
obtainCertificateArchiveTimestamps(org.bouncycastle.asn1.cms.AttributeTable unsignedAttributes)
Method that gets the last archive timestamp certificate from the the list of archive timestamps of a signature.
|
static java.security.cert.X509Certificate |
obtainCertificateArchiveTimestampsXAdES(XAdESSignerInfo signerInfo)
Method that obtains the signing certificate of the last archiveTimestamp of a XAdES signature.
|
static byte[] |
obtainFirstRevision(byte[] pdfDocument)
Method that obtains the first revision of the signature dictionary.
|
static com.lowagie.text.pdf.PdfReader |
obtainLatestRevision(com.lowagie.text.pdf.PdfReader reader)
Method that obtains the revision of the signature dictionary most recent.
|
static PDFSignatureDictionary |
obtainLatestSignatureFromPDF(com.lowagie.text.pdf.PdfReader reader)
Method that obtains the signature dictionary with major review.
|
static org.w3c.dom.Element |
retrieveNode(org.w3c.dom.Element parentNode,
java.lang.String nodeName,
java.lang.String namespaceURI,
boolean isRequired)
Method that obtains an element from a XML document.
|
static java.security.cert.X509Certificate |
retrieveSigningCertificateOfXMLSigner(org.w3c.dom.Element signedSignaturePropertiesElement,
java.lang.String signatureId,
org.w3c.dom.Element signatureElement)
Method that retrieves the signing certificate of a signer contained inside of a XML signature.
|
static void |
validateCAdESPublicKeyInfo(org.bouncycastle.cms.CMSSignedData signedData,
org.bouncycastle.cms.SignerInformation signerInformation,
java.security.cert.X509Certificate signingCertificate)
Method that checks if the signer includes a
SigningCertificate signed attribute, or a SigningCertificateV2 signed attribute,
and this matches to the signing certificate. |
static void |
validateCAdESSignatureCore(org.bouncycastle.cms.SignerInformation signerInformation,
java.security.cert.X509Certificate signingCertificate,
boolean isPadesSignature)
Method that validates the CAdES signature core associated to a signer.
|
static void |
validateCAdESSigningTime(org.bouncycastle.cms.CMSSignedData signedData,
org.bouncycastle.cms.SignerInformation signerInformation,
boolean isRequired,
java.util.Date validationDate,
java.security.cert.X509Certificate signingCertificate)
Method that validates if the signing time of a signature is previous than certain date.
|
static void |
validateCertificate(java.security.cert.X509Certificate certificate,
java.util.Date validationDate,
boolean isUpgradeOperation,
java.lang.String idClient,
boolean isTimestampCertificate)
Method that validates the validity period of a certificate and the revocation status
of a certificate (if the validation level for the certificates is defined with the value
IntegraFacadeConstants#VALIDATION_LEVEL_COMPLETE). |
static void |
validateCMSPublicKeyInfo(org.bouncycastle.cms.SignerInformation signerInformation,
java.security.cert.X509Certificate signingCertificate)
Method that checks if the value of the signed attribute
SerialNumber of a signature matches to the serial number of the signing certificate. |
static void |
validateDocumentTimeStampDictionaryStructurally(PDFDocumentTimestampDictionary pdfDocumentTimestampDictionary,
byte[] pdfDocument)
Method that validates for a Document Time-stamp dictionary:
The ByteRange entry of the Document Time-stamp dictionary isn't null.
|
static void |
validateDocumentTimeStampSigningTime(PDFDocumentTimestampDictionary pdfDocumentTimeStampDictionary,
java.util.Date validationDate)
Method that checks if the generation date of a time-stamp contained inside of a Document Time-stamp dictionary is previous than a validation date.
|
static void |
validatePAdESBaselineMandatoryAttributes(PDFSignatureDictionary signatureDictionary,
org.bouncycastle.cms.CMSSignedData signedData,
java.util.Date validationDate)
Method that checks, for the signature contained inside of a signature dictionary of a PDF document:
If the SignedData field is explicit.
|
static void |
validatePAdESBaselineOptionalAttributes(PDFSignatureDictionary signatureDictionary,
org.bouncycastle.cms.CMSSignedData signedData)
Method that checks, for the signature contained inside of a signature dictionary of a PDF document:
If the signature doesn't contain the
signing-time attribute. |
static boolean |
validatePAdESBaselineStructurally(PDFSignatureDictionary signatureDictionary,
byte[] pdfDocument,
org.bouncycastle.cms.CMSSignedData signedData)
Method that checks if a signature dictionary is valid against PAdES Baseline profile.
|
static void |
validatePAdESBasicSigningTime(org.bouncycastle.cms.SignerInformation signerInformation,
java.util.Date validationDate,
java.security.cert.X509Certificate signingCertificate,
PDFSignatureDictionary signatureDictionary)
Method that validates the signing time of a PAdES-Basic signature.
|
static void |
validatePAdESBasicStructurally(PDFSignatureDictionary signatureDictionary,
byte[] pdfDocument,
org.bouncycastle.cms.CMSSignedData signedData)
Method that validates the structure of a signature dictionary by PAdES-Basic signature form.
|
static void |
validatePAdESEnhancedMandatoryAttributes(PDFSignatureDictionary signatureDictionary,
org.bouncycastle.cms.CMSSignedData signedData)
Method that validates the mandatory attributes for a PAdES enhanced signature.
|
static void |
validatePAdESEnhancedStructurally(PDFSignatureDictionary signatureDictionary,
byte[] pdfDocument,
org.bouncycastle.cms.CMSSignedData signedData,
boolean isEPES)
Method that checks if a signature dictionary is valid against PAdES Enhanced profile.
|
static void |
validatePAdESOptionalAttributes(PDFSignatureDictionary signatureDictionary,
org.bouncycastle.cms.CMSSignedData signedData,
boolean isEPES,
boolean isBasic)
Method that validates the optional attributes for a PAdES signature.
|
static void |
validatePAdESSigningTime(PDFSignatureDictionary signatureDictionary,
java.util.Date validationDate,
boolean isRequired)
Method that validates if the signature dictionary has /M entry that entry must be a date with a valid format by PDF Referente and
that date must be before of the validation date.
|
static void |
validatePDFSigner(org.bouncycastle.cms.CMSSignedData signedData,
org.bouncycastle.cms.SignerInformation signerInformation,
com.lowagie.text.pdf.PdfDictionary pdfSignatureDictionary,
java.util.Date validationDate,
java.lang.String idClient)
Method that validates the signer of a signature contained inside of a PDF document.
|
static void |
validateXAdESPublicKeyInfo(java.lang.String signatureId,
org.w3c.dom.Element signatureElement,
org.apache.xml.security.signature.XMLSignature xmlSignature,
boolean isBaseline,
boolean isCounterSignature)
Method that validates if the public key information contained inside of a XML signature is valid.
|
static void |
validateXAdESSignatureCore(org.w3c.dom.Element qualifyingPropertiesElement,
java.lang.String signatureId,
org.w3c.dom.Element signatureElement,
org.apache.xml.security.signature.XMLSignature xmlSignature,
byte[] signedFile,
java.lang.String signedFileName,
java.security.cert.X509Certificate signingCertificate,
org.w3c.dom.Element signedSignaturePropertiesElement,
org.w3c.dom.Element signedPropertiesElement,
boolean isBaseline,
boolean isCounterSignature)
Method that validates the XAdES signature core associated to a signer.
|
static void |
validateXAdESSigner(org.apache.xml.security.signature.XMLSignature xmlSignature,
java.security.cert.X509Certificate signingCertificate,
org.bouncycastle.tsp.TimeStampToken tst,
org.w3c.dom.Element xmlTst,
java.lang.String signingMode,
byte[] signedFile,
java.lang.String signedFileName,
java.lang.String idClient)
Method that validates the signer of a XAdES signature.
|
static void |
validateXAdESSigningTime(org.w3c.dom.Element signedSignaturePropertiesElement,
boolean isRequired,
java.lang.String signatureId,
java.util.Date validationDate)
Method that validates if the signing time of a XML signature is previous than certain validation date.
|
public static final com.lowagie.text.pdf.PdfName CADES_SUBFILTER_VALUE
public static final com.lowagie.text.pdf.PdfName TST_SUBFILTER_VALUE
public static final com.lowagie.text.pdf.PdfName DOC_TIME_STAMP_DICTIONARY_NAME
public static final com.lowagie.text.pdf.PdfName DSS_DICTIONARY_NAME
public static void validateCertificate(java.security.cert.X509Certificate certificate,
java.util.Date validationDate,
boolean isUpgradeOperation,
java.lang.String idClient,
boolean isTimestampCertificate)
throws SigningException
IntegraFacadeConstants#VALIDATION_LEVEL_COMPLETE).
If the validation level for the certificates is defined with the value IntegraFacadeConstants#VALIDATION_LEVEL_COMPLETE the validation of
the revocation status will be via OCSP.certificate - Parameter that represents the certificate to validate.validationDate - Parameter that represents the validation date.isUpgradeOperation - Parameter that indicates if the origin operation is an upgrade signature operation (true) or not (false).idClient - Parameter that represents the client application identifier.isTimestampCertificate - Parameter that indicates if the certificate is the signing certificate of a time-stamp (true) or not (false).SigningException - If the certificate isn't valid or the method fails.public static PDFSignatureDictionary obtainLatestSignatureFromPDF(com.lowagie.text.pdf.PdfReader reader)
reader - Parameter that represents the reader for the PDF document.public static boolean isNotPAdESEnhancedPDF(com.lowagie.text.pdf.PdfDictionary pdfDic)
pdfDic - Parameter that represents the signature dictionary.public static org.bouncycastle.cms.CMSSignedData getCMSSignature(PDFSignatureDictionary signatureDictionary) throws SigningException
SignedData contained inside of a signature dictionary of a PDF document.signatureDictionary - Parameter that represents the signature dictionary.SignedData.SigningException - If the method fails.public static boolean isImplicit(org.bouncycastle.cms.CMSSignedData cmsSignedData)
cmsSignedData - Parameter that represents the pkcs7-signature message.public static boolean equalsHash(com.lowagie.text.pdf.PdfArray pdfArrayByteRange,
java.security.MessageDigest messageDigestSignature,
byte[] pdfDocument,
byte[] hashSignature)
pdfArrayByteRange - Parameter that represents the exact byte range for the digest calculation.messageDigestSignature - Parameter that represents the message digest algorithm.pdfDocument - Parameter that represents the first bytes array to compare.hashSignature - Parameter that represents the second bytes array to compare.public static void checkSubFilterConditionsISO320001(PDFSignatureDictionary dictionarySignature, org.bouncycastle.cms.CMSSignedData signedData) throws SigningException
dictionarySignature - Parameter that represents the signature dictionary.signedData - Parameter that represents the signed data.SigningException - If one of the conditiones isn't valid.public static void validatePAdESEnhancedMandatoryAttributes(PDFSignatureDictionary signatureDictionary, org.bouncycastle.cms.CMSSignedData signedData) throws SigningException
id-data.signatureDictionary - Parameter that represents the signature dictionary.signedData - Parameter that represents the signed data.SigningException - If the validation fails.public static void validatePAdESOptionalAttributes(PDFSignatureDictionary signatureDictionary, org.bouncycastle.cms.CMSSignedData signedData, boolean isEPES, boolean isBasic) throws SigningException
signatureDictionary - Parameter that represents the signature dictionary.signedData - Parameter that represents the signed data.isEPES - Parameter that indicates if the signature has PAdES-EPES profile (true) or PAdES-BES profile (false).isBasic - Parameter that indicates if the signature has PAdES-Basic profile (true) or PAdES Enhanced profile (false).SigningException - If the validation fails.public static org.bouncycastle.cert.X509CertificateHolder getX509CertificateHolderBySignerId(org.bouncycastle.util.Store certificatesStore,
org.bouncycastle.cms.SignerId signerId)
certificatesStore - Parameter that represents the certificates store.signerId - Parameter that represents the identifier of the signer used to find the certificate.public static void validatePDFSigner(org.bouncycastle.cms.CMSSignedData signedData,
org.bouncycastle.cms.SignerInformation signerInformation,
com.lowagie.text.pdf.PdfDictionary pdfSignatureDictionary,
java.util.Date validationDate,
java.lang.String idClient)
throws SigningException
signedData - Parameter that represents the signed data.signerInformation - Parameter that represents the signer information.pdfSignatureDictionary - Parameter that represents the PDF signature dictionary.validationDate - Parameter that represents the validation date.idClient - Parameter that represents the client application identifier.SigningException - If the validation fails.public static java.util.List<CAdESSignerInfo> getCAdESListSigners(org.bouncycastle.cms.CMSSignedData signedData)
signedData - Parameter that represents the signed data.public static java.security.cert.X509Certificate getSigningCertificate(org.bouncycastle.cms.CMSSignedData signedData,
org.bouncycastle.cms.SignerInformation signerInformation)
throws SigningException
signedData - Parameter that represents the signed data.signerInformation - Parameter that represents the information about the signer of the signature.SigningException - If the certificate hasn't could be retrieved.public static com.lowagie.text.pdf.PdfReader obtainLatestRevision(com.lowagie.text.pdf.PdfReader reader)
throws SigningException
reader - Parameter that represents the reader for the PDF document.null if the PDF document doesn't contain any signature dictionary.SigningException - If cannot access to some revision.public static void checkPDFCertificationLevel(java.util.Map<java.lang.Integer,java.io.InputStream> mapRevisions)
throws SigningException
mapRevisions - Parameter that represents a map with the revisions of the PDF document. Each revision represents a signature dictionary. The key
is the revision number, and the value is the revision.SigningException - If the method fails or some approval signature was added to a PDF document after that it was defined as certified.public static java.util.List<XAdESSignerInfo> getXAdESListSigners(org.w3c.dom.Document doc)
doc - Parameter that represents the XML document.public static java.util.List<org.w3c.dom.Element> getListSignatures(org.w3c.dom.Document doc)
ds:Signature elements, as signatures, contained inside of a XML document.doc - Parameter that represents the XML document.ds:Signature elements.public static void validateXAdESSigner(org.apache.xml.security.signature.XMLSignature xmlSignature,
java.security.cert.X509Certificate signingCertificate,
org.bouncycastle.tsp.TimeStampToken tst,
org.w3c.dom.Element xmlTst,
java.lang.String signingMode,
byte[] signedFile,
java.lang.String signedFileName,
java.lang.String idClient)
throws SigningException
xmlSignature - Parameter that represents the XAdES signature.signingCertificate - Parameter that represents the signing certificatetst - Parameter that represents the RFC 3161 timestamp associated to the signer.xmlTst - Parameter that represents the XML timestamp associated to the signer.signingMode - Parameter that represents the signing mode of the XAdES signature. The possible values are:
IUtilsSignature.DETACHED_SIGNATURE_MODEIUtilsSignature##ENVELOPED_SIGNATURE_MODEIUtilsSignature##ENVELOPING_SIGNATURE_MODEsignedFile - Parameter that represents the file signed by the XML signature when the signed data isn't included into the signed XML document.signedFileName - Parameter that represents the name of the file signed by the XML signature when the signed data isn't included into the signed XML document.idClient - Parameter that represents the client application identifier.SigningException - If the validation fails.public static org.bouncycastle.util.Store addCertificateToStore(org.bouncycastle.util.Store certificates,
java.security.cert.X509Certificate certificate)
throws SigningException
certificates - Parameter that represents the certificates store.certificate - Parameter that represents the certificate to add.SigningException - If the method fails.public static org.bouncycastle.cms.CMSSignedData getCMSSignedData(byte[] signature)
throws SigningException
signature - Parameter that represents the ASN.1 signature.SigningException - If the method fails.public static boolean isDocumentTimeStampDictionary(java.lang.String pdfType,
java.lang.String subFilter)
pdfType - Parameter that represents the value of /Type entry.subFilter - Parameter that represents the value of /SubFilter entry.public static boolean isSignatureDictionary(java.lang.String pdfType,
java.lang.String subFilter)
pdfType - Parameter that represents the value of /Type entry.subFilter - Parameter that represents the value of /SubFilter entry.public static void validatePAdESBaselineMandatoryAttributes(PDFSignatureDictionary signatureDictionary, org.bouncycastle.cms.CMSSignedData signedData, java.util.Date validationDate) throws SigningException
content-type attribute and it has the value "id-data"./Cert entry./M entry and it's after than the validation date.signatureDictionary - Parameter that represents the signature dictionary.signedData - Parameter that represents the signed data.validationDate - Parameter that represents the date defined for validating the signature. If this values is null the validation date will be the current date.SigningException - If the validation fails.public static void validatePAdESBaselineOptionalAttributes(PDFSignatureDictionary signatureDictionary, org.bouncycastle.cms.CMSSignedData signedData) throws SigningException
signing-time attribute.counter-signature attribute.content-reference attribute.content-identifier attribute.content-hints attribute.commitment-type-indication attribute.signer-location attribute.signatureDictionary - Parameter that represents the signature dictionary.signedData - Parameter that represents the signed data.SigningException - If the validation fails.public static org.w3c.dom.Element getXMLSignatureById(org.w3c.dom.Document document,
java.lang.String signatureId)
throws SigningException
Signature element from a XML document.document - Parameter that represents the XML document.signatureId - Parameter that represents the attribute Id of the element to obtain.Signature element, or null.SigningException - If the element is null.public static java.lang.String getTypeOfXMLSignature(org.w3c.dom.Document xmlDocument)
throws SigningException
xmlDocument - Parameter that represents the signed XML document.SigningException - If the method fails.public static byte[] getOriginalDataFromSignedXMLDocument(org.w3c.dom.Document xmlDocument)
throws SigningException
xmlDocument - Parameter that represents the signed XML document.SigningException - If the method fails.public static org.w3c.dom.Document composeCoSignaturesDocument(org.w3c.dom.Document xmlDocument,
javax.xml.parsers.DocumentBuilderFactory dBFactory)
throws SigningException
xmlDocument - Parameter that represents the XML signature. It can be null.dBFactory - Parameter that represents a factory for building XML documents.SigningException - If the method fails.public static void appendXMLDocument(org.w3c.dom.Document xmlDocument,
org.w3c.dom.Document documentToAppend)
throws SigningException
xmlDocument - Parameter that represents the signed XML document.documentToAppend - Parameter that represents the XML document to append to the signed XML document.SigningException - If the method fails.public static java.lang.String getSignedElementIdValue(org.w3c.dom.Document xmlDocument)
throws SigningException
Id of the Content node of the wrapper, or an empty String if the signed XML document doesn't contain that attribute
(wrapper signed on enveloped mode).xmlDocument - Parameter that represents the signed XML document.Id of the Content node of the wrapper, or an empty String if the signed XML document doesn't contain that attribute
(wrapper signed on enveloped mode).SigningException - If the method fails.public static org.w3c.dom.Document insertAfirmaRootNode(org.w3c.dom.Document xmlDocument,
javax.xml.parsers.DocumentBuilderFactory dBFactory)
throws SigningException
AFIRMA node as root node of a signed XML document.xmlDocument - Parameter that represents the signed XML document.dBFactory - Parameter that represents a factory for building XML documents.SigningException - If the method fails.public static java.util.List<org.w3c.dom.Element> getListSignaturesToCounterSign(org.w3c.dom.Element rootElement)
ds:Signature elements to add xades:CounterSignature element.
The method only obtains the signature element withouth any signature element child.rootElement - Parameter that represents the root element of the XML document.ds:Signature elements to add xades:CounterSignature element.public static org.w3c.dom.Element retrieveNode(org.w3c.dom.Element parentNode,
java.lang.String nodeName,
java.lang.String namespaceURI,
boolean isRequired)
throws SigningException
parentNode - Parameter that represents the parent node of the element to retrieve.nodeName - Parameter that represents the name of the element to retrieve.namespaceURI - Parameter that represents the namespace URI of the element to match on. The special value "*" matches all namespaces.isRequired - Parameter that indicates if the element to retrieve is required (true) or not (false).SigningException - If the XML document doesn't contain the required element.public static boolean isDSSTimestamp(org.w3c.dom.Node eSignature)
eSignature - Parameter that represents the XML signature.public static byte[] obtainFirstRevision(byte[] pdfDocument)
throws SigningException
pdfDocument - Parameter that represents the PDF document.null if the PDF document doesn't contain any signature dictionary.SigningException - exception if any errorpublic static boolean checkExtraParamsSignWithRubric(java.util.Properties externalParams)
externalParams - Represents the optional input parameters.public static void insertRubric(com.lowagie.text.pdf.PdfReader reader,
com.lowagie.text.pdf.PdfSignatureAppearance signatureAppearance,
java.util.Properties externalParams)
throws SigningException
reader - Parameter representing the PDF to be signed.signatureAppearance - Parameter that represents the appearances that form a signature.externalParams - Represents the optional input parameters.SigningException - If the method fails.public static void validateCAdESSignatureCore(org.bouncycastle.cms.SignerInformation signerInformation,
java.security.cert.X509Certificate signingCertificate,
boolean isPadesSignature)
throws SigningException
signerInformation - Parameter that represents the information about the signer.signingCertificate - Parameter that represents the certificate of the signer.isPadesSignature - Parameter that indicates if the signature is contained inside of a signature dictionary (true) or not (false).SigningException - If the validation fails.public static void validateCAdESPublicKeyInfo(org.bouncycastle.cms.CMSSignedData signedData,
org.bouncycastle.cms.SignerInformation signerInformation,
java.security.cert.X509Certificate signingCertificate)
throws SigningException
SigningCertificate signed attribute, or a SigningCertificateV2 signed attribute,
and this matches to the signing certificate.signedData - Parameter that represents the signed data.signerInformation - Parameter that represents the information about the signer.signingCertificate - Parameter that represents the signing certificate.SigningException - If the validation fails.public static void validateCAdESSigningTime(org.bouncycastle.cms.CMSSignedData signedData,
org.bouncycastle.cms.SignerInformation signerInformation,
boolean isRequired,
java.util.Date validationDate,
java.security.cert.X509Certificate signingCertificate)
throws SigningException
signedData - Parameter that represents the signed data.signerInformation - Parameter that represents the information about the signer.isRequired - Parameter that indicates if the SigningTime attribute shall be included as a signed attribute for the signer (true) or not (false).validationDate - Parameter that represents the validation date.signingCertificate - Parameter that represents the signing certificate.SigningException - If the validation fails.public static void validateXAdESSignatureCore(org.w3c.dom.Element qualifyingPropertiesElement,
java.lang.String signatureId,
org.w3c.dom.Element signatureElement,
org.apache.xml.security.signature.XMLSignature xmlSignature,
byte[] signedFile,
java.lang.String signedFileName,
java.security.cert.X509Certificate signingCertificate,
org.w3c.dom.Element signedSignaturePropertiesElement,
org.w3c.dom.Element signedPropertiesElement,
boolean isBaseline,
boolean isCounterSignature)
throws SigningException
qualifyingPropertiesElement - Parameter that represents xades:QualifyingProperties element.signatureId - Parameter that represents the value of Id attribute of ds:Signature element.signatureElement - Parameter that represents ds:Signature element.xmlSignature - Parameter that represents the XML signature.signedFile - Parameter that represents the file signed by the XML signature when the signed data isn't included into the signed XML document.signedFileName - Parameter that represents the name of the file signed by the XML signature when the signed data isn't included into the signed XML document.signingCertificate - Parameter that represents the signing certificate.signedSignaturePropertiesElement - Parameter that represents xades:SignedSignatureProperties element.signedPropertiesElement - Parameter that represents xades:SignedProperties element.isBaseline - Parameter that indicates if the signature to validate has Baseline form (true) or not (false).isCounterSignature - Parameter that indicates if the signature to validate is a countersignature (true) or not (false).SigningException - If the validation fails.public static java.security.cert.X509Certificate retrieveSigningCertificateOfXMLSigner(org.w3c.dom.Element signedSignaturePropertiesElement,
java.lang.String signatureId,
org.w3c.dom.Element signatureElement)
throws SigningException
signedSignaturePropertiesElement - Parameter that represents xades:SignedSignatureProperties element.signatureId - Parameter that represents the value of Id attribute of ds:Signature element.signatureElement - Parameter that represents ds:Signature element.SigningException - If the method fails of the certificate cannot be retrieved.public static void validateXAdESPublicKeyInfo(java.lang.String signatureId,
org.w3c.dom.Element signatureElement,
org.apache.xml.security.signature.XMLSignature xmlSignature,
boolean isBaseline,
boolean isCounterSignature)
throws SigningException
signatureId - Parameter that represents the value of Id attribute of ds:Signature element.signatureElement - Parameter that represents ds:Signature element.xmlSignature - Parameter that represents the XML signature.isBaseline - Parameter that indicates if the XML signature has Baseline form (true) or not (false).isCounterSignature - Parameter that indicates if the element to validate is a signer (false) or a counter-signer (true).SigningException - If the validation fails.public static void validateXAdESSigningTime(org.w3c.dom.Element signedSignaturePropertiesElement,
boolean isRequired,
java.lang.String signatureId,
java.util.Date validationDate)
throws SigningException
signedSignaturePropertiesElement - Parameter that represents xades:SignedSignatureProperties element.isRequired - Parameter that indicates if the XML signature must contain xades:SigningTime element (true) or not (false).signatureId - Parameter that represents the value of Id attribute of ds:Signature element.validationDate - Parameter that represents the validation date.SigningException - if the validation fails.public static void validatePAdESBasicStructurally(PDFSignatureDictionary signatureDictionary, byte[] pdfDocument, org.bouncycastle.cms.CMSSignedData signedData) throws SigningException
signatureDictionary - Parameter that represents the signature dictionary.pdfDocument - Parameter that represents the PDF document.signedData - Parameter that represents the signature message.SigningException - If the validation fails.public static void validateCMSPublicKeyInfo(org.bouncycastle.cms.SignerInformation signerInformation,
java.security.cert.X509Certificate signingCertificate)
throws SigningException
SerialNumber of a signature matches to the serial number of the signing certificate.signerInformation - Parameter that represents the information about the signer.signingCertificate - Parameter that represents the signing certificate.SigningException - If the validation fails.public static void validatePAdESBasicSigningTime(org.bouncycastle.cms.SignerInformation signerInformation,
java.util.Date validationDate,
java.security.cert.X509Certificate signingCertificate,
PDFSignatureDictionary signatureDictionary)
throws SigningException
signerInformation - Parameter that represents the information about the first signer of the signature.validationDate - Parameter that represents the validation date.signingCertificate - Parameter that represents the signing certificate.signatureDictionary - Parameter that represents the information about the signature dictionary.SigningException - If the validation fails.public static void validatePAdESEnhancedStructurally(PDFSignatureDictionary signatureDictionary, byte[] pdfDocument, org.bouncycastle.cms.CMSSignedData signedData, boolean isEPES) throws SigningException
signatureDictionary - Parameter that represents the information about the signature dictionary.pdfDocument - Parameter that represents the signed PDF document.signedData - Parameter that represents the signature message of the signature contained inside of the signature dictionary.isEPES - Parameter that indicates if the signature dictionary represents a PAdES-EPES signature (true) or a PAdES-BES signature (false).SigningException - If the validation fails.public static void validatePAdESSigningTime(PDFSignatureDictionary signatureDictionary, java.util.Date validationDate, boolean isRequired) throws SigningException
signatureDictionary - Parameter that represents the information about the signature dictionary.validationDate - Parameter that represents the validation date.isRequired - Parameter that indicates if the /M is required for the signature dictionary (true) or not (false).SigningException - If the validation fails.public static void validateDocumentTimeStampDictionaryStructurally(PDFDocumentTimestampDictionary pdfDocumentTimestampDictionary, byte[] pdfDocument) throws SigningException
pdfDocumentTimestampDictionary - Parameter that represents the information about the Document Time-stamp dictionary.pdfDocument - Parameter that represents the PDF document.SigningException - If the validation fails.public static void validateDocumentTimeStampSigningTime(PDFDocumentTimestampDictionary pdfDocumentTimeStampDictionary, java.util.Date validationDate) throws SigningException
pdfDocumentTimeStampDictionary - Parameter that represents the information about the Document Time-stamp dictionary.validationDate - Parameter that represents the validation date.SigningException - If the generation date of a time-stamp contained inside of a Document Time-stamp dictionary is after than the validation date.public static boolean validatePAdESBaselineStructurally(PDFSignatureDictionary signatureDictionary, byte[] pdfDocument, org.bouncycastle.cms.CMSSignedData signedData) throws SigningException
signatureDictionary - Parameter that represents the information about the signature dictionary.pdfDocument - Parameter that represents the signed PDF document.signedData - Parameter that represents the signature message of the signature contained inside of the signature dictionary.signature-policy-id
attribute (true) or not (false).SigningException - If the validation fails.public static java.util.Date calculateExpirationDateForValidations(SignerValidationResult signerValidationResult, java.util.Date currentDate)
signerValidationResult - Result of the signature validation/update.currentDate - The current closest expiration date.public static java.security.cert.X509Certificate obtainCertificateArchiveTimestamps(org.bouncycastle.asn1.cms.AttributeTable unsignedAttributes)
unsignedAttributes - Unsigned attributes of the signature.public static java.util.Date getExpirationDate(byte[] signature)
signature - Signature to analyze.public static java.security.cert.X509Certificate obtainCertificateArchiveTimestampsXAdES(XAdESSignerInfo signerInfo)
signerInfo - Unsigned properties element of the signer.public static java.util.Date calculateExpirationDate(java.util.List<PDFSignatureDictionary> signatureDictionaries, java.util.List<PDFDocumentTimestampDictionary> timestampDictionaries)
signatureDictionaries - Signature dictionaries from the PAdES signature.timestampDictionaries - Timestamp dictionaries from the PAdES signature.public static java.util.List<ReferenceDataBaseline> fromNodeListToReferenceDataBaselineList(org.w3c.dom.Node manifestNode, org.w3c.dom.Node signedDataObjectPropertiesNode) throws SigningException
manifestNode - Node Element that represents the manifest node.signedDataObjectPropertiesNode - Element taht represents the signed data object properties node.SigningException - if the signature is invalid, that is, the elements has a invalid structure or the data are not correct.public static org.bouncycastle.asn1.x509.AlgorithmIdentifier getSignatureAlgorithm(org.bouncycastle.cms.SignerInformation signerInformation)
throws SignaturePolicyException
signerInformation - Información de la firma.SignaturePolicyException - Cuando no se puede identificar el algoritmo de firma a
través del de encriptación y huella.public static org.bouncycastle.asn1.x509.AlgorithmIdentifier getSignatureAlgorithm(java.lang.String encryptionAlgOid,
java.lang.String hashAlgOid)
throws SignaturePolicyException
encryptionAlgOid - OID del algoritmo de encriptación.hashAlgOid - OID del algoritmo de huella.SignaturePolicyException - Cuando no se conozca el OID del algoritmo
correspondiente a utilizar el algoritmo de encriptación y el algoritmo
de hash indicados.