Package es.gob.afirma.signature
Class SignatureFormatDetectorCadesPades
- java.lang.Object
-
- es.gob.afirma.signature.SignatureFormatDetectorCadesPades
-
- All Implemented Interfaces:
ISignatureFormatDetector
public final class SignatureFormatDetectorCadesPades extends java.lang.Object implements ISignatureFormatDetector
Class that contains all the functionality related to recognize the signature formats.
Project:Library for the integration with the services of @Firma, eVisor and TS@.
- Version:
- 1.3, 06/10/2017.
-
-
Field Summary
-
Fields inherited from interface es.gob.afirma.signature.ISignatureFormatDetector
CADES_BASIC_FORMAT, FORMAT_ASIC_S_B_LEVEL, FORMAT_ASIC_S_LT_LEVEL, FORMAT_ASIC_S_LTA_LEVEL, FORMAT_ASIC_S_T_LEVEL, FORMAT_CADES_A, FORMAT_CADES_B_LEVEL, FORMAT_CADES_BES, FORMAT_CADES_C, FORMAT_CADES_EPES, FORMAT_CADES_LT_LEVEL, FORMAT_CADES_LTA_LEVEL, FORMAT_CADES_T, FORMAT_CADES_T_LEVEL, FORMAT_CADES_X1, FORMAT_CADES_X2, FORMAT_CADES_XL1, FORMAT_CADES_XL2, FORMAT_CMS, FORMAT_CMS_T, FORMAT_PADES_B_LEVEL, FORMAT_PADES_BASIC, FORMAT_PADES_BES, FORMAT_PADES_EPES, FORMAT_PADES_LT_LEVEL, FORMAT_PADES_LTA_LEVEL, FORMAT_PADES_LTV, FORMAT_PADES_T_LEVEL, FORMAT_PDF, FORMAT_UNRECOGNIZED, FORMAT_XADES_A, FORMAT_XADES_B_LEVEL, FORMAT_XADES_BES, FORMAT_XADES_C, FORMAT_XADES_EPES, FORMAT_XADES_LT_LEVEL, FORMAT_XADES_LTA_LEVEL, FORMAT_XADES_T, FORMAT_XADES_T_LEVEL, FORMAT_XADES_X1, FORMAT_XADES_X2, FORMAT_XADES_XL1, FORMAT_XADES_XL2, PKCS7_BASIC_FORMAT
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetSignatureFormat(byte[] signature)Method that obtains the format of a signature.static booleanhasSignaturePolicyIdentifier(org.bouncycastle.cms.SignerInformation signerInformation)Method that checks whether an ASN.1 signature hasSignaturePolicyIdentifierelement.static booleanisASN1Format(byte[] signature)Method that indicates whether a signature is ASN.1 (true) or not (false).static booleanisPAdESBasic(PDFSignatureDictionary signatureDictionary)Method that indicates whether a signature dictionary has PAdES-Basic signature format (true) or not (false).static booleanisPAdESBES(PDFSignatureDictionary signatureDictionary)Method that indicates whether a signature dictionary has PAdES-BES signature format (true) or not (false).static booleanisPAdESEPES(PDFSignatureDictionary signatureDictionary)Method that indicates whether a signature dictionary has PAdES-EPES signature format (true) or not (false).static booleanisPDF(PDFSignatureDictionary signatureDictionary)Method that indicates whether a signature dictionary has PDF signature format (true) or not (false).static booleanisPDFFormat(byte[] signature)Method that indicates whether a signature is PDF (true) or not (false).static booleanisXMLFormat(byte[] signature)Method that indicates whether a signature is XML (true) or not (false).static java.lang.StringresolveSignatureDictionaryFormat(PDFSignatureDictionary signatureDictionary)Method that obtains the format associated to a signature dictionary of a PDF document.static java.lang.StringresolveSignerCAdESFormat(org.bouncycastle.cms.CMSSignedData signedData, org.bouncycastle.cms.SignerInformation signerInformation)Method that obtains the format associated to a signer of an ASN.1 signature.
-
-
-
Method Detail
-
getSignatureFormat
public static java.lang.String getSignatureFormat(byte[] signature)
Method that obtains the format of a signature.- Parameters:
signature- Parameter that represents the element to evaluate. This element can be an ASN.1 signature or a PDF document.- Returns:
- the signature format of the element. If the element is an ASN.1 signature, the value to return will be on of these:
ISignatureFormatDetector.FORMAT_CADES_LTA_LEVEL.ISignatureFormatDetector.FORMAT_CADES_LT_LEVEL.ISignatureFormatDetector.FORMAT_CADES_T_LEVEL.ISignatureFormatDetector.FORMAT_CADES_B_LEVEL.ISignatureFormatDetector.FORMAT_CADES_A.ISignatureFormatDetector.FORMAT_CADES_XL2.ISignatureFormatDetector.FORMAT_CADES_XL1.ISignatureFormatDetector.FORMAT_CADES_X2.ISignatureFormatDetector.FORMAT_CADES_X1.ISignatureFormatDetector.FORMAT_CADES_T.ISignatureFormatDetector.FORMAT_CADES_C.ISignatureFormatDetector.FORMAT_CADES_BES.ISignatureFormatDetector.FORMAT_CADES_EPES.ISignatureFormatDetector.FORMAT_UNRECOGNIZED.
ISignatureFormatDetector.FORMAT_PADES_LTA_LEVEL.ISignatureFormatDetector.FORMAT_PADES_LT_LEVEL.ISignatureFormatDetector.FORMAT_PADES_T_LEVEL.ISignatureFormatDetector.FORMAT_PADES_B_LEVEL.ISignatureFormatDetector.FORMAT_PADES_LTV.ISignatureFormatDetector.FORMAT_PADES_EPES.ISignatureFormatDetector.FORMAT_PADES_BES.ISignatureFormatDetector.FORMAT_PADES_BASIC.ISignatureFormatDetector.FORMAT_PDF.ISignatureFormatDetector.FORMAT_UNRECOGNIZED.
-
isASN1Format
public static boolean isASN1Format(byte[] signature)
Method that indicates whether a signature is ASN.1 (true) or not (false).- Parameters:
signature- Parameter that represents the signature to check.- Returns:
- a boolean that indicates whether a signature is ASN.1 (true) or not (false).
-
isXMLFormat
public static boolean isXMLFormat(byte[] signature)
Method that indicates whether a signature is XML (true) or not (false).- Parameters:
signature- Parameter that represents the signature to check.- Returns:
- a boolean that indicates whether a signature is XML (true) or not (false).
-
isPDFFormat
public static boolean isPDFFormat(byte[] signature)
Method that indicates whether a signature is PDF (true) or not (false).- Parameters:
signature- Parameter that represents the signature to check.- Returns:
- a boolean that indicates whether a signature is PDF (true) or not (false).
-
isPAdESEPES
public static boolean isPAdESEPES(PDFSignatureDictionary signatureDictionary)
Method that indicates whether a signature dictionary has PAdES-EPES signature format (true) or not (false).- Parameters:
signatureDictionary- Parameter that represents the signature dictionary.- Returns:
- a boolean that indicates whether a signature dictionary has PAdES-EPES signature format (true) or not (false).
-
isPAdESBES
public static boolean isPAdESBES(PDFSignatureDictionary signatureDictionary)
Method that indicates whether a signature dictionary has PAdES-BES signature format (true) or not (false).- Parameters:
signatureDictionary- Parameter that represents the signature dictionary.- Returns:
- a boolean that indicates whether a signature dictionary has PAdES-BES signature format (true) or not (false).
-
isPAdESBasic
public static boolean isPAdESBasic(PDFSignatureDictionary signatureDictionary)
Method that indicates whether a signature dictionary has PAdES-Basic signature format (true) or not (false).- Parameters:
signatureDictionary- Parameter that represents the signature dictionary.- Returns:
- a boolean that indicates whether a signature dictionary has PAdES-Basic signature format (true) or not (false).
-
isPDF
public static boolean isPDF(PDFSignatureDictionary signatureDictionary)
Method that indicates whether a signature dictionary has PDF signature format (true) or not (false).- Parameters:
signatureDictionary- Parameter that represents the signature dictionary.- Returns:
- a boolean that indicates whether a signature dictionary has PDF signature format (true) or not (false).
-
hasSignaturePolicyIdentifier
public static boolean hasSignaturePolicyIdentifier(org.bouncycastle.cms.SignerInformation signerInformation)
Method that checks whether an ASN.1 signature hasSignaturePolicyIdentifierelement.- Parameters:
signerInformation- Parameter that represents the information about the signer.- Returns:
- a boolean that indicates whether the ASN.1 signature has
SignaturePolicyIdentifierelement (true) or not (false).
-
resolveSignerCAdESFormat
public static java.lang.String resolveSignerCAdESFormat(org.bouncycastle.cms.CMSSignedData signedData, org.bouncycastle.cms.SignerInformation signerInformation)Method that obtains the format associated to a signer of an ASN.1 signature.- Parameters:
signedData- Parameter that represents the signature message.signerInformation- Parameter that represents the information abput the signer to process.- Returns:
- the signature format. The value to return will be on of these:
ISignatureFormatDetector.FORMAT_CADES_LTA_LEVEL.ISignatureFormatDetector.FORMAT_CADES_LT_LEVEL.ISignatureFormatDetector.FORMAT_CADES_T_LEVEL.ISignatureFormatDetector.FORMAT_CADES_B_LEVEL.ISignatureFormatDetector.FORMAT_CADES_A.ISignatureFormatDetector.FORMAT_CADES_XL2.ISignatureFormatDetector.FORMAT_CADES_XL1.ISignatureFormatDetector.FORMAT_CADES_X2.ISignatureFormatDetector.FORMAT_CADES_X1.ISignatureFormatDetector.FORMAT_CADES_T.ISignatureFormatDetector.FORMAT_CADES_C.ISignatureFormatDetector.FORMAT_CADES_BES.ISignatureFormatDetector.FORMAT_CADES_EPES.ISignatureFormatDetector.FORMAT_UNRECOGNIZED.
-
resolveSignatureDictionaryFormat
public static java.lang.String resolveSignatureDictionaryFormat(PDFSignatureDictionary signatureDictionary)
Method that obtains the format associated to a signature dictionary of a PDF document.- Parameters:
signatureDictionary- Parameter that represents the information about the signature dictionary.- Returns:
- the signature format. The value to return will be on of these:
ISignatureFormatDetector.FORMAT_PADES_T_LEVEL.ISignatureFormatDetector.FORMAT_PADES_B_LEVEL.ISignatureFormatDetector.FORMAT_PDF.ISignatureFormatDetector.FORMAT_PADES_BASIC.ISignatureFormatDetector.FORMAT_PADES_BES.ISignatureFormatDetector.FORMAT_PADES_EPES.ISignatureFormatDetector.FORMAT_UNRECOGNIZED.
-
-