Package es.gob.afirma.integraFacade
Class IntegraFacade
- java.lang.Object
-
- es.gob.afirma.integraFacade.IntegraFacade
-
public final class IntegraFacade extends java.lang.ObjectClass that represents the facade which manages the generation, validation, and upgrade of signatures.
Project:@Firma and TS@ Web Services Integration Platform.
- Version:
- 1.3, 18/04/2022.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]generateCoSignature(byte[] signature, byte[] signedData, java.security.KeyStore.PrivateKeyEntry privateKey, boolean includeSignaturePolicy, boolean includeTimestamp)Method that generates a co-signature.static byte[]generateCounterSignature(byte[] signature, java.security.KeyStore.PrivateKeyEntry privateKey, boolean includeSignaturePolicy, boolean includeTimestamp)Method that generates a counter-signature over a signature.static byte[]generateMultiSignaturePAdESRubric(byte[] dataToSign, java.security.KeyStore.PrivateKeyEntry privateKey, boolean includeSignaturePolicy, boolean includeTimestamp, byte[] image, java.lang.String imagePage, int lowerLeftX, int lowerLeftY, int upperRightX, int upperRightY)Method that generates a multi-signature with rubric.static byte[]generateSignature(byte[] dataToSign, java.security.KeyStore.PrivateKeyEntry privateKey, boolean includeSignaturePolicy, boolean includeTimestamp)Method that generates a signature.static byte[]generateSignaturePAdESRubric(byte[] dataToSign, java.security.KeyStore.PrivateKeyEntry privateKey, boolean includeSignaturePolicy, boolean includeTimestamp, byte[] image, java.lang.String imagePage, int lowerLeftX, int lowerLeftY, int upperRightX, int upperRightY)Method that generates a signature with rubric.static OriginalSignedDatagetSignedData(byte[] signature)Method that obtains the data originally signed from a signature.static byte[]upgradeSignature(byte[] signature, java.util.List<java.security.cert.X509Certificate> listSigners)Method that upgrades a signature adding a timestamp to all of the signers indicated.static java.lang.ObjectverifySignature(byte[] signature, byte[] signedData)Method that validates the signers of a signature.
-
-
-
Method Detail
-
generateSignature
public static byte[] generateSignature(byte[] dataToSign, java.security.KeyStore.PrivateKeyEntry privateKey, boolean includeSignaturePolicy, boolean includeTimestamp) throws SigningExceptionMethod that generates a signature.- Parameters:
dataToSign- Parameter that represents the data to sign.privateKey- Parameter that represents the private key of the signing certificate.includeSignaturePolicy- Parameter that indicates if to include signature policy into the signature (true) or not (false).includeTimestamp- Parameter that indicates if to add a timestamp to the signature (true) or not (false).- Returns:
- a signature with one of the next formats:
ISignatureFormatDetector.FORMAT_CADES_BESISignatureFormatDetector.FORMAT_CADES_EPESISignatureFormatDetector.FORMAT_CADES_TISignatureFormatDetector.FORMAT_XADES_BESISignatureFormatDetector.FORMAT_XADES_EPESISignatureFormatDetector.FORMAT_XADES_TISignatureFormatDetector.FORMAT_PADES_BESISignatureFormatDetector.FORMAT_PADES_EPESISignatureFormatDetector.FORMAT_CADES_B_LEVELISignatureFormatDetector.FORMAT_XADES_B_LEVELISignatureFormatDetector.FORMAT_PADES_B_LEVELISignatureFormatDetector.FORMAT_CADES_T_LEVELISignatureFormatDetector.FORMAT_XADES_T_LEVELISignatureFormatDetector.FORMAT_PADES_T_LEVEL
- Throws:
SigningException- If the method fails.
-
generateCoSignature
public static byte[] generateCoSignature(byte[] signature, byte[] signedData, java.security.KeyStore.PrivateKeyEntry privateKey, boolean includeSignaturePolicy, boolean includeTimestamp) throws SigningExceptionMethod that generates a co-signature.- Parameters:
signature- Parameter that represents the signature to co-sign.signedData- Parameter that represents the data to sign.privateKey- Parameter that represents the private key of the signing certificate.includeSignaturePolicy- Parameter that indicates if to include signature policy into the co-signature (true) or not (false).includeTimestamp- Parameter that indicates if to add a timestamp to the co-signature (true) or not (false).- Returns:
- a co-signature with one of the next formats:
ISignatureFormatDetector.FORMAT_CADES_BESISignatureFormatDetector.FORMAT_CADES_EPESISignatureFormatDetector.FORMAT_CADES_TISignatureFormatDetector.FORMAT_XADES_BESISignatureFormatDetector.FORMAT_XADES_EPESISignatureFormatDetector.FORMAT_XADES_TISignatureFormatDetector.FORMAT_PADES_BESISignatureFormatDetector.FORMAT_PADES_EPESISignatureFormatDetector.FORMAT_CADES_B_LEVELISignatureFormatDetector.FORMAT_XADES_B_LEVELISignatureFormatDetector.FORMAT_PADES_B_LEVELISignatureFormatDetector.FORMAT_CADES_T_LEVELISignatureFormatDetector.FORMAT_XADES_T_LEVELISignatureFormatDetector.FORMAT_PADES_T_LEVEL
- Throws:
SigningException- If the method fails.
-
generateCounterSignature
public static byte[] generateCounterSignature(byte[] signature, java.security.KeyStore.PrivateKeyEntry privateKey, boolean includeSignaturePolicy, boolean includeTimestamp) throws SigningExceptionMethod that generates a counter-signature over a signature.- Parameters:
signature- Parameter that represents the signature to counter-sign.privateKey- Parameter that represents the private key of the signing certificate.includeSignaturePolicy- Parameter that indicates if to include signature policy into the co-signature (true) or not (false).includeTimestamp- Parameter that indicates if to add a timestamp to the co-signature (true) or not (false).- Returns:
- a signature with a counter-signature with one of the next formats:
ISignatureFormatDetector.FORMAT_CADES_BESISignatureFormatDetector.FORMAT_CADES_EPESISignatureFormatDetector.FORMAT_CADES_TISignatureFormatDetector.FORMAT_XADES_BESISignatureFormatDetector.FORMAT_XADES_EPESISignatureFormatDetector.FORMAT_XADES_TISignatureFormatDetector.FORMAT_PADES_BESISignatureFormatDetector.FORMAT_PADES_EPESISignatureFormatDetector.FORMAT_CADES_B_LEVELISignatureFormatDetector.FORMAT_XADES_B_LEVELISignatureFormatDetector.FORMAT_PADES_B_LEVELISignatureFormatDetector.FORMAT_CADES_T_LEVELISignatureFormatDetector.FORMAT_XADES_T_LEVELISignatureFormatDetector.FORMAT_PADES_T_LEVEL
- Throws:
SigningException- If the method fails.
-
generateSignaturePAdESRubric
public static byte[] generateSignaturePAdESRubric(byte[] dataToSign, java.security.KeyStore.PrivateKeyEntry privateKey, boolean includeSignaturePolicy, boolean includeTimestamp, byte[] image, java.lang.String imagePage, int lowerLeftX, int lowerLeftY, int upperRightX, int upperRightY) throws SigningExceptionMethod that generates a signature with rubric.- Parameters:
dataToSign- Parameter that represents the data to sign.privateKey- Parameter that represents the private key of the signing certificate.includeSignaturePolicy- Parameter that indicates if to include signature policy into the signature (true) or not (false).includeTimestamp- Parameter that indicates if to add a timestamp to the signature (true) or not (false).image- Parameter that represents the image to be inserted as a rubric in the PDF.imagePage- Parameter that represents the page where the image will be inserted.lowerLeftX- Parameter that represents the coordinate horizontal lower left of the image position.lowerLeftY- Parameter that represents the coordinate vertically lower left of the image position.upperRightX- Parameter that represents the coordinate horizontal upper right of the image position.upperRightY- Parameter that represents the coordinate vertically upper right of the image position.- Returns:
- a signature PAdES (Baseline or no)
- Throws:
SigningException- If the method fails.
-
generateMultiSignaturePAdESRubric
public static byte[] generateMultiSignaturePAdESRubric(byte[] dataToSign, java.security.KeyStore.PrivateKeyEntry privateKey, boolean includeSignaturePolicy, boolean includeTimestamp, byte[] image, java.lang.String imagePage, int lowerLeftX, int lowerLeftY, int upperRightX, int upperRightY) throws SigningExceptionMethod that generates a multi-signature with rubric.- Parameters:
dataToSign- Parameter that represents the data to sign.privateKey- Parameter that represents the private key of the signing certificate.includeSignaturePolicy- Parameter that indicates if to include signature policy into the signature (true) or not (false).includeTimestamp- Parameter that indicates if to add a timestamp to the signature (true) or not (false).image- Parameter that represents the image to be inserted as a rubric in the PDF.imagePage- Parameter that represents the page where the image will be inserted.lowerLeftX- Parameter that represents the coordinate horizontal lower left of the image position.lowerLeftY- Parameter that represents the coordinate vertically lower left of the image position.upperRightX- Parameter that represents the coordinate horizontal upper right of the image position.upperRightY- Parameter that represents the coordinate vertically upper right of the image position.- Returns:
- a signature PAdES (Baseline or no)
- Throws:
SigningException- If the method fails.
-
upgradeSignature
public static byte[] upgradeSignature(byte[] signature, java.util.List<java.security.cert.X509Certificate> listSigners) throws SigningExceptionMethod that upgrades a signature adding a timestamp to all of the signers indicated. If the list of signers is null or empty, the timestamp will be added to all of the signers of the signature. The timestamp will be added only to those signers that don't have a previous timestamp. If the signature has a PDF format (PAdES-Basic, PAdES-BES, PAdES-EPES or PAdES-LTV), this method adds a Document Time-stamp dictionary and the signature form will be PAdES-LTV.- Parameters:
signature- Parameter that represents the signature to upgrade.listSigners- Parameter that represents the list of signers of the signature to upgrade with a timestamp. Only for ASN.1 and XML signatures.- Returns:
- the upgraded signature.
- Throws:
SigningException- If the method fails.
-
verifySignature
public static java.lang.Object verifySignature(byte[] signature, byte[] signedData)Method that validates the signers of a signature.- Parameters:
signature- Parameter that represents the signature to validate.signedData- Parameter that represents the original data signed by the signature.- Returns:
- an object that contains the information about the validation result. The object will be an instance of
ValidationResultfor ASN.1, XML and ASiC-S signatures.PDFValidationResultfor PDF signatures.
-
getSignedData
public static OriginalSignedData getSignedData(byte[] signature) throws SigningException
Method that obtains the data originally signed from a signature.- Parameters:
signature- Parameter that represents the signature of which is to obtain the data.- Returns:
- Information about data originally signed.
- Throws:
SigningException- If the method fails.
-
-