Package es.gob.afirma.signature
Class SignatureFormatDetector
- java.lang.Object
-
- es.gob.afirma.signature.SignatureFormatDetector
-
- All Implemented Interfaces:
ISignatureFormatDetector
public final class SignatureFormatDetector 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.0, 10/11/2014.
-
-
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 booleanhasSignaturePolicyIdentifier(org.w3c.dom.Element dsSignature)Method that checks whether a XML signature hasSignaturePolicyIdentifierelement.static booleanisASiCFormat(byte[] signature)Method that indicates if a signature has the ASiC-S format (true) or not (false).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).
-
-
-
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, a XML document, a PDF document or a ZIP file.- 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_XADES_LTA_LEVEL.ISignatureFormatDetector.FORMAT_XADES_LT_LEVEL.ISignatureFormatDetector.FORMAT_XADES_T_LEVEL.ISignatureFormatDetector.FORMAT_XADES_B_LEVEL.ISignatureFormatDetector.FORMAT_XADES_A.ISignatureFormatDetector.FORMAT_XADES_XL2.ISignatureFormatDetector.FORMAT_XADES_XL1.ISignatureFormatDetector.FORMAT_XADES_X2.ISignatureFormatDetector.FORMAT_XADES_X1.ISignatureFormatDetector.FORMAT_XADES_T.ISignatureFormatDetector.FORMAT_XADES_C.ISignatureFormatDetector.FORMAT_XADES_BES.ISignatureFormatDetector.FORMAT_XADES_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.
-
isASiCFormat
public static boolean isASiCFormat(byte[] signature)
Method that indicates if a signature has the ASiC-S format (true) or not (false).- Parameters:
signature- Parameter that represents a ZIP file.- Returns:
- a boolean that indicates if the signature has the ASiC-S format (true) or not (false).
-
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).
-
hasSignaturePolicyIdentifier
public static boolean hasSignaturePolicyIdentifier(org.w3c.dom.Element dsSignature)
Method that checks whether a XML signature hasSignaturePolicyIdentifierelement.- Parameters:
dsSignature- Parameter that representsSignatureelement.- Returns:
- a boolean that indicates whether the XML signature has
SignaturePolicyIdentifierelement (true) or not (false).
-
-