Package es.gob.afirma.signature.policy
Class SignaturePolicyManager
- java.lang.Object
-
- es.gob.afirma.signature.policy.SignaturePolicyManager
-
public final class SignaturePolicyManager extends java.lang.ObjectClass that manages all the operations related to signature policies.
Project:Library for the integration with the services of @Firma, eVisor and TS@.
- Version:
- 1.4, 18/04/2022.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddASN1SignPolicy(org.bouncycastle.asn1.ASN1EncodableVector contexExpecific, java.lang.String qualifier, java.lang.String policyID, java.util.Properties properties, boolean isPAdES)Method that adds theSignaturePolicyIdentifierelement to an ASN.1 object.static voidaddASN1SignPolicy(org.bouncycastle.asn1.ASN1EncodableVector contexExpecific, java.lang.String qualifier, java.lang.String policyID, java.util.Properties properties, boolean isPAdES, java.lang.String idClient)Method that adds theSignaturePolicyIdentifierelement to an ASN.1 object.static voidaddXMLSignPolicy(XAdES_EPES xades, java.lang.String qualifier, java.lang.String policyID, java.util.Properties properties)Method that adds thexades:SignaturePolicyIdentifierelement to a XAdES object.static voidaddXMLSignPolicy(XAdES_EPES xades, java.lang.String qualifier, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient)Method that adds thexades:SignaturePolicyIdentifierelement to a XAdES object.static booleanisValidASN1HashAlgorithmByPolicy(org.bouncycastle.asn1.x509.AlgorithmIdentifier digestAlgorithmId, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient)Method that checks if the OID of a hash algorithm is valid for certain signature policy.static booleanisValidASN1SignAlgorithmByPolicy(org.bouncycastle.asn1.x509.AlgorithmIdentifier signAlgorithmId, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient)Method that checks if the OID of a signature algorithm is valid for certain signature policy.static booleanisValidASN1SigningModeByPolicy(boolean includeContent, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient)Method that checks if the signing mode of the CAdES-EPES signature is allowed by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.static booleanisValidXMLHashAlgorithmByPolicy(java.lang.String uriAlgorithm, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient)Method that checks if the URI of a hash algorithm is valid for certain signature policy.static booleanisValidXMLSignAlgorithmByPolicy(java.lang.String uriAlgorithm, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient)Method that checks if the URI of a signature algorithm is valid for certain signature policy.static booleanisValidXMLSigningModeByPolicy(java.lang.String signingMode, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient)Method that checks if the signing mode of the XAdES-EPES signature is allowed by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.static voidvalidateCAdESEPESSignature(org.bouncycastle.cms.SignerInformation signerInformation, java.util.Properties properties, boolean isCounterSigner, boolean includeContent, java.lang.String idClient)Method that validates a CAdES-EPES signature by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.static voidvalidateGeneratedCAdESEPESSignature(org.bouncycastle.asn1.cms.SignerInfo signerInfo, java.lang.String policyID, java.util.Properties properties, boolean isCounterSigner, java.lang.String idClient)Method that validates a generated CAdES-EPES signature by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.static voidvalidateGeneratedPAdESEPESSignature(com.lowagie.text.pdf.PdfDictionary pdfSignatureDictionary, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient)Method that validates a generated PAdES-EPES signature by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.static voidvalidateGeneratedXAdESEPESSignature(org.w3c.dom.Element dsSignature, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient)Method that validates a generated XAdES-EPES signature by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.static voidvalidatePAdESEPESSignature(org.bouncycastle.cms.SignerInformation signerInformation, com.lowagie.text.pdf.PdfDictionary pdfSignatureDictionary, java.util.Properties properties, java.lang.String idClient)Method that validates a PAdES-EPES signature by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.static voidvalidateXAdESEPESSignature(org.w3c.dom.Element dsSignature, java.util.Properties properties, java.lang.String signingMode, java.lang.String idClient)Method that validates a XAdES-EPES signature by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.
-
-
-
Method Detail
-
addASN1SignPolicy
public static void addASN1SignPolicy(org.bouncycastle.asn1.ASN1EncodableVector contexExpecific, java.lang.String qualifier, java.lang.String policyID, java.util.Properties properties, boolean isPAdES, java.lang.String idClient) throws SignaturePolicyExceptionMethod that adds theSignaturePolicyIdentifierelement to an ASN.1 object.- Parameters:
contexExpecific- Parameter that represents the set of values of the signer info.qualifier- Parameter that represents the signature policy qualifier.policyID- Parameter that represents the identifier of the signature policy defined inside of the properties file where to configure the validation and generation of signatures with signature policies.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.isPAdES- Parameter that indicates if theSignaturePolicyIdentifierwill be added to a PAdES signature (true) or to a CAdESidClient- Parameter that represents the client application identifier. signature (false).- Throws:
SignaturePolicyException- If the method fails.
-
addASN1SignPolicy
public static void addASN1SignPolicy(org.bouncycastle.asn1.ASN1EncodableVector contexExpecific, java.lang.String qualifier, java.lang.String policyID, java.util.Properties properties, boolean isPAdES) throws SignaturePolicyExceptionMethod that adds theSignaturePolicyIdentifierelement to an ASN.1 object.- Parameters:
contexExpecific- Parameter that represents the set of values of the signer info.qualifier- Parameter that represents the signature policy qualifier.policyID- Parameter that represents the identifier of the signature policy defined inside of the properties file where to configure the validation and generation of signatures with signature policies.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.isPAdES- Parameter that indicates if theSignaturePolicyIdentifierwill be added to a PAdES signature (true) or to a CAdES signature (false).- Throws:
SignaturePolicyException- If the method fails.
-
addXMLSignPolicy
public static void addXMLSignPolicy(XAdES_EPES xades, java.lang.String qualifier, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient) throws SignaturePolicyException
Method that adds thexades:SignaturePolicyIdentifierelement to a XAdES object.- Parameters:
xades- Parameter that represents the XAdES object.qualifier- Parameter that represents the signature policy qualifier.policyID- Parameter that represents the identifier of the signature policy defined inside of the properties file where to configure the validation and generation of signatures with signature policies.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.idClient- Parameter that represents the client application identifier.- Throws:
SignaturePolicyException- If the method fails.
-
addXMLSignPolicy
public static void addXMLSignPolicy(XAdES_EPES xades, java.lang.String qualifier, java.lang.String policyID, java.util.Properties properties) throws SignaturePolicyException
Method that adds thexades:SignaturePolicyIdentifierelement to a XAdES object.- Parameters:
xades- Parameter that represents the XAdES object.qualifier- Parameter that represents the signature policy qualifier.policyID- Parameter that represents the identifier of the signature policy defined inside of the properties file where to configure the validation and generation of signatures with signature policies.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.- Throws:
SignaturePolicyException- If the method fails.
-
validateGeneratedPAdESEPESSignature
public static void validateGeneratedPAdESEPESSignature(com.lowagie.text.pdf.PdfDictionary pdfSignatureDictionary, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient) throws SignaturePolicyExceptionMethod that validates a generated PAdES-EPES signature by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.- Parameters:
pdfSignatureDictionary- Parameter that represents the PDF signature dictionary.policyID- Parameter that represents the identifier of the signature policy defined inside of the properties file where to configure the validation and generation of signatures with signature policies.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.idClient- Parameter that represents the client application identifier.- Throws:
SignaturePolicyException- If the method fails.
-
validateGeneratedCAdESEPESSignature
public static void validateGeneratedCAdESEPESSignature(org.bouncycastle.asn1.cms.SignerInfo signerInfo, java.lang.String policyID, java.util.Properties properties, boolean isCounterSigner, java.lang.String idClient) throws SignaturePolicyExceptionMethod that validates a generated CAdES-EPES signature by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.- Parameters:
signerInfo- Parameter that represents the information related to the signer.policyID- Parameter that represents the identifier of the signature policy defined inside of the properties file where to configure the validation and generation of signatures with signature policies.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.isCounterSigner- Parameter that indicates if the signer a counter-signer (true) or not (false).idClient- Parameter that represents the client application identifier.- Throws:
SignaturePolicyException- If the method fails.
-
validateGeneratedXAdESEPESSignature
public static void validateGeneratedXAdESEPESSignature(org.w3c.dom.Element dsSignature, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient) throws SignaturePolicyExceptionMethod that validates a generated XAdES-EPES signature by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.- Parameters:
dsSignature- Parameter that represents the ds:Signature element of the XAdES-EPES signature.policyID- Parameter that represents the identifier of the signature policy defined inside of the properties file where to configure the validation and generation of signatures with signature policies.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.idClient- Parameter that represents the client application identifier.- Throws:
SignaturePolicyException- If the method fails.
-
validatePAdESEPESSignature
public static void validatePAdESEPESSignature(org.bouncycastle.cms.SignerInformation signerInformation, com.lowagie.text.pdf.PdfDictionary pdfSignatureDictionary, java.util.Properties properties, java.lang.String idClient) throws SignaturePolicyExceptionMethod that validates a PAdES-EPES signature by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.- Parameters:
signerInformation- Parameter that represents the information related to the signer.pdfSignatureDictionary- Parameter that represents the PDF signature dictionary.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.idClient- Parameter that represents the client application identifier.- Throws:
SignaturePolicyException- If the method fails.
-
validateCAdESEPESSignature
public static void validateCAdESEPESSignature(org.bouncycastle.cms.SignerInformation signerInformation, java.util.Properties properties, boolean isCounterSigner, boolean includeContent, java.lang.String idClient) throws SignaturePolicyExceptionMethod that validates a CAdES-EPES signature by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.- Parameters:
signerInformation- Parameter that represents the information related to the signer.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.isCounterSigner- Parameter that indicates if the signer a counter-signer (true) or not (false).includeContent- Parameter that indicates if the signature includes the signed data (true) or not (false).idClient- Parameter that represents the client application identifier.- Throws:
SignaturePolicyException- If the method fails.
-
validateXAdESEPESSignature
public static void validateXAdESEPESSignature(org.w3c.dom.Element dsSignature, java.util.Properties properties, java.lang.String signingMode, java.lang.String idClient) throws SignaturePolicyExceptionMethod that validates a XAdES-EPES signature by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.- Parameters:
dsSignature- Parameter that represents theds:Signatureelement of the XAdES-EPES signature.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.signingMode- Parameter that represents the signing mode of the XAdES-EPES signature. The possible values are:es.gob.afirma.Utils.IUtilsSignature#DETACHED_SIGNATURE_MODEes.gob.afirma.Utils.IUtilsSignature#ENVELOPED_SIGNATURE_MODEes.gob.afirma.Utils.IUtilsSignature#ENVELOPING_SIGNATURE_MODE
idClient- Parameter that represents the client application identifier.- Throws:
SignaturePolicyException- If the method fails.
-
isValidASN1SigningModeByPolicy
public static boolean isValidASN1SigningModeByPolicy(boolean includeContent, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient)Method that checks if the signing mode of the CAdES-EPES signature is allowed by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.- Parameters:
includeContent- Parameter that indicates whether the document content is included in the signature (true) or is only referenced (false).policyID- Parameter that represents the identifier of the signature policy defined inside of the properties file where to configure the validation and generation of signatures with signature policies.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.idClient- Parameter that represents the client application identifier.- Returns:
- a boolean that indicates if the signing mode of the CAdES-EPES signature is allowed by the signature policy (true) or not (false).
-
isValidXMLSigningModeByPolicy
public static boolean isValidXMLSigningModeByPolicy(java.lang.String signingMode, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient)Method that checks if the signing mode of the XAdES-EPES signature is allowed by the signature policy defined on the properties file where to configure the validation and generation of signatures with signature policies.- Parameters:
signingMode- Parameter that represents the signing mode of the XAdES-EPES signature. The possible values are:es.gob.afirma.Utils.IUtilsSignature#DETACHED_SIGNATURE_MODEes.gob.afirma.Utils.IUtilsSignature#ENVELOPED_SIGNATURE_MODEes.gob.afirma.Utils.IUtilsSignature#ENVELOPING_SIGNATURE_MODE
policyID- Parameter that represents the identifier of the signature policy defined inside of the properties file where to configure the validation and generation of signatures with signature policies.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.idClient- Parameter that represents the client application identifier.- Returns:
- a boolean that indicates if the signing mode of the XAdES-EPES signature is allowed by the signature policy (true) or not (false).
-
isValidXMLHashAlgorithmByPolicy
public static boolean isValidXMLHashAlgorithmByPolicy(java.lang.String uriAlgorithm, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient)Method that checks if the URI of a hash algorithm is valid for certain signature policy.- Parameters:
uriAlgorithm- Parameter that represents the URI of the hash algorithm.policyID- Parameter that represents the identifier of the signature policy defined inside of the properties file where to configure the validation and generation of signatures with signature policies.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.idClient- Parameter that represents the client application identifier.- Returns:
- a boolean that indicates if the URI of the hash algorithm is valid for the signature policy (true) or not (false).
-
isValidASN1HashAlgorithmByPolicy
public static boolean isValidASN1HashAlgorithmByPolicy(org.bouncycastle.asn1.x509.AlgorithmIdentifier digestAlgorithmId, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient)Method that checks if the OID of a hash algorithm is valid for certain signature policy.- Parameters:
digestAlgorithmId- Parameter that represents the OID of the hash algorithm.policyID- Parameter that represents the identifier of the signature policy defined inside of the properties file where to configure the validation and generation of signatures with signature policies.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.idClient- Parameter that represents the client application identifier.- Returns:
- a boolean that indicates if the OID of the hash algorithm is valid for the signature policy (true) or not (false).
-
isValidASN1SignAlgorithmByPolicy
public static boolean isValidASN1SignAlgorithmByPolicy(org.bouncycastle.asn1.x509.AlgorithmIdentifier signAlgorithmId, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient)Method that checks if the OID of a signature algorithm is valid for certain signature policy.- Parameters:
signAlgorithmId- Parameter that represents the OID of the signature algorithm.policyID- Parameter that represents the identifier of the signature policy defined inside of the properties file where to configure the validation and generation of signatures with signature policies.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.idClient- Parameter that represents the client application identifier.- Returns:
- a boolean that indicates if the OID of the signature algorithm is valid for the signature policy (true) or not (false).
-
isValidXMLSignAlgorithmByPolicy
public static boolean isValidXMLSignAlgorithmByPolicy(java.lang.String uriAlgorithm, java.lang.String policyID, java.util.Properties properties, java.lang.String idClient)Method that checks if the URI of a signature algorithm is valid for certain signature policy.- Parameters:
uriAlgorithm- Parameter that represents the URI of the signature algorithm.policyID- Parameter that represents the identifier of the signature policy defined inside of the properties file where to configure the validation and generation of signatures with signature policies.properties- Parameter that represents the set of properties defined inside of the properties file where to configure the validation and generation of signatures with signature policies.idClient- Parameter that represents the client application identifier.- Returns:
- a boolean that indicates if the URI of the signature algorithm is valid for the signature policy (true) or not (false).
-
-