public final class UtilsSignature 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@.
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 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 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<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.w3c.dom.Document |
getDocumentFromXML(byte[] xmlDocument)
Method that obtains an object as a representation of a XML document.
|
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 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 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 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 void |
validateCertificate(java.security.cert.X509Certificate certificate,
java.util.Date validationDate,
boolean isUpgradeOperation)
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
es.gob.afirma.integraFacade.IntegraFacadeConstants#VALIDATION_LEVEL_COMPLETE). |
static void |
validatePAdESEnhancedMandatoryAttributes(PDFSignatureDictionary signatureDictionary,
org.bouncycastle.cms.CMSSignedData signedData)
Method that validates the mandatory attributes for a PAdES enhanced signature.
|
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 |
validatePDFSigner(org.bouncycastle.cms.CMSSignedData signedData,
org.bouncycastle.cms.SignerInformation signerInformation,
com.lowagie.text.pdf.PdfDictionary pdfSignatureDictionary,
java.util.Date validationDate)
Method that validates the signer of a signature contained inside of a PDF document.
|
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)
Method that validates the signer of a XAdES signature.
|
public static void validateCertificate(java.security.cert.X509Certificate certificate,
java.util.Date validationDate,
boolean isUpgradeOperation)
throws SigningException
es.gob.afirma.integraFacade.IntegraFacadeConstants#VALIDATION_LEVEL_COMPLETE).
If the validation level for the certificates is defined with the value es.gob.afirma.integraFacade.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).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)
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.SigningException - If the validation fails.public static java.util.List<XAdESSignerInfo> getXAdESListSigners(org.w3c.dom.Document doc)
doc - Parameter that represents the XML document.public static java.util.List<CAdESSignerInfo> getCAdESListSigners(org.bouncycastle.cms.CMSSignedData signedData)
signedData - Parameter that represents the signed data.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)
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.SigningException - If the validation fails.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 org.w3c.dom.Document getDocumentFromXML(byte[] xmlDocument)
throws SigningException
xmlDocument - Parameter that represents the XML document.SigningException - If the XML document has a bad format.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.