Class XAdESSignatureProperties

  • All Implemented Interfaces:
    XmlSignatureProperties
    Direct Known Subclasses:
    DefaultXAdESSignatureProperties

    public class XAdESSignatureProperties
    extends Object
    implements XmlSignatureProperties
    Implementation of the XAdES-BES and XAdES-EPES properties defined in http://www.etsi.org/deliver/etsi_ts%5C101900_101999%5C101903%5C01.04 .02_60%5Cts_101903v010402p.pdf. XAdES-T and XAdES-C is not implemented.

    You have to overwrite the method getSigningCertificate() or getSigningCertificateChain() if you want to have a 'SigningCertificate' element in your XML Signature.

    Further limitations:

    • No support for the 'QualifyingPropertiesReference' element (see section 6.3.2 of spec).
    • No support for the 'Transforms' element contained in the 'SignaturePolicyId' element contained in 'SignaturePolicyIdentifier' element
    • No support of the 'CounterSignature' element --> no support for the 'UnsignedProperties' element
    • A 'CommitmentTypeIndication' element contains always the 'AllSignedDataObjects' element. The 'ObjectReference' element within the 'CommitmentTypeIndication' element is not supported.
    • The 'AllDataObjectsTimeStamp' element is not supported (it requires a time authority)
    • The 'IndividualDataObjectsTimeStamp' element is not supported (it requires a time authority)
    • Constructor Detail

      • XAdESSignatureProperties

        public XAdESSignatureProperties()
    • Method Detail

      • isAddSigningTime

        public boolean isAddSigningTime()
      • setAddSigningTime

        public void setAddSigningTime​(boolean addSigningTime)
      • getNamespace

        public String getNamespace()
      • setNamespace

        public void setNamespace​(String namespace)
      • findNamespace

        protected String findNamespace​(org.apache.camel.Message message)
      • getPrefix

        public String getPrefix()
      • setPrefix

        public void setPrefix​(String prefix)
      • findPrefix

        protected String findPrefix​(org.apache.camel.Message message)
      • setSigningCertificateURIs

        public void setSigningCertificateURIs​(List<String> signingCertificateURIs)
        URIs of the signing certificate or signing certificate chain. For the sining certificate the first URI is taken. If there is a signing certificate chain specified, then the URIs are assigned to the certificates in the chain in the order given in the provided list. You have to specify an empty entry (null or empty srting), if no URI should be assigned to a specific certificate in the list. If you specify an empty list, then no URIs are assigned.
        Throws:
        IllegalArgumentException - if the parameter is null or one of the URIs is null
      • getSigningCertificateURIs

        public List<String> getSigningCertificateURIs()
      • getDigestAlgorithmForSigningCertificate

        public String getDigestAlgorithmForSigningCertificate()
      • setDigestAlgorithmForSigningCertificate

        public void setDigestAlgorithmForSigningCertificate​(String digestAlgorithm)
        Digest Algorithm for creating the digest of the signing certificate. Possible values: "http://www.w3.org/2000/09/xmldsig#sha1", "http://www.w3.org/2001/04/xmlenc#sha256", "http://www.w3.org/2001/04/xmldsig-more#sha384", "http://www.w3.org/2001/04/xmlenc#sha512". Default value is "http://www.w3.org/2001/04/xmlenc#sha256".
      • getSignaturePolicy

        public String getSignaturePolicy()
      • getSigPolicyId

        public String getSigPolicyId()
      • setSigPolicyId

        public void setSigPolicyId​(String sigPolicyId)
        Identifier must be specified if getSignaturePolicy() equals "ExplicitId". Must be an URI
      • getSigPolicyIdQualifier

        public String getSigPolicyIdQualifier()
      • setSigPolicyIdQualifier

        public void setSigPolicyIdQualifier​(String sigPolicyIdQualifier)
        Qualifier for the Signature Policy Identifier. Possible values are null (which means no Qualifier element is created), "OIDAsURI", or "OIDAsURN". Default value is null. If the identifier is an OID then a qualifier must be set.
      • getSigPolicyIdDescription

        public String getSigPolicyIdDescription()
      • setSigPolicyIdDescription

        public void setSigPolicyIdDescription​(String sigPolicyIdDescription)
      • getSigPolicyIdDocumentationReferences

        public List<String> getSigPolicyIdDocumentationReferences()
      • setSigPolicyIdDocumentationReferences

        public void setSigPolicyIdDocumentationReferences​(List<String> sigPolicyIdDocumentationReferences)
        Sets the documentation references of the signature policy.
        Throws:
        IllegalArgumentException - if the parameter is null or one of the documentation references is null or empty
      • getSignaturePolicyDigestAlgorithm

        public String getSignaturePolicyDigestAlgorithm()
      • setSignaturePolicyDigestAlgorithm

        public void setSignaturePolicyDigestAlgorithm​(String signaturePolicyDigestAlgorithm)
        Digest Algorithm for creating the digest of the signature policy document. Possible values: "http://www.w3.org/2000/09/xmldsig#sha1", "http://www.w3.org/2001/04/xmlenc#sha256", "http://www.w3.org/2001/04/xmldsig-more#sha384", "http://www.w3.org/2001/04/xmlenc#sha512". Default value is "http://www.w3.org/2001/04/xmlenc#sha256".
      • getSignaturePolicyDigestValue

        public String getSignaturePolicyDigestValue()
      • setSignaturePolicyDigestValue

        public void setSignaturePolicyDigestValue​(String signaturePolicyDigestValue)
        Digest value for the signature policy base 64 encoded.
      • getSigPolicyQualifiers

        public List<String> getSigPolicyQualifiers()
      • setSigPolicyQualifiers

        public void setSigPolicyQualifiers​(List<String> sigPolicyQualifiers)
        Sets the signature policy qualifiers. Each qualifier can be a text or a XML fragment with the root element 'SigPolicyQualifier' with the XAdES namespace.
        Throws:
        IllegalArgumentException - if the input parameter is null, or one of the qualifiers is null or empty
      • getDataObjectFormatDescription

        public String getDataObjectFormatDescription()
      • setDataObjectFormatDescription

        public void setDataObjectFormatDescription​(String dataObjectFormatDescription)
      • getDataObjectFormatMimeType

        public String getDataObjectFormatMimeType()
      • setDataObjectFormatMimeType

        public void setDataObjectFormatMimeType​(String dataObjectFormatMimeType)
      • getDataObjectFormatIdentifier

        public String getDataObjectFormatIdentifier()
      • setDataObjectFormatIdentifier

        public void setDataObjectFormatIdentifier​(String dataObjectFormatIdentifier)
      • getDataObjectFormatIdentifierQualifier

        public String getDataObjectFormatIdentifierQualifier()
      • setDataObjectFormatIdentifierQualifier

        public void setDataObjectFormatIdentifierQualifier​(String dataObjectFormatIdentifierQualifier)
        Qualifier for the Format Identifier. Possible values are null (which means no Qualifier element is created), "OIDAsURI", or "OIDAsURN". Default value is null. If the identifier is an OID then a qualifier must be set.
      • getDataObjectFormatIdentifierDescription

        public String getDataObjectFormatIdentifierDescription()
      • setDataObjectFormatIdentifierDescription

        public void setDataObjectFormatIdentifierDescription​(String dataObjectFormatIdentifierDescription)
      • getDataObjectFormatIdentifierDocumentationReferences

        public List<String> getDataObjectFormatIdentifierDocumentationReferences()
      • setDataObjectFormatIdentifierDocumentationReferences

        public void setDataObjectFormatIdentifierDocumentationReferences​(List<String> dataObjectFormatIdentifierDocumentationReferences)
        Sets the documentation references of the data object format identifier.
        Throws:
        IllegalArgumentException - if the parameter is null or one of the documentation references is null or empty
      • getSignerClaimedRoles

        public List<String> getSignerClaimedRoles()
      • setSignerClaimedRoles

        public void setSignerClaimedRoles​(List<String> signerClaimedRoles)
        Sets the claimed roles list. A role can be either a text or a XML fragment with the root element 'ClaimedRole' with the XAdES namespace.
        Throws:
        IllegalArgumentException - if signerClaimedRoles is null, or if one of the roles is null or empty
      • getSignatureProductionPlaceCity

        public String getSignatureProductionPlaceCity()
      • setSignatureProductionPlaceCity

        public void setSignatureProductionPlaceCity​(String signatureProductionPlaceCity)
      • getSignatureProductionPlaceStateOrProvince

        public String getSignatureProductionPlaceStateOrProvince()
      • setSignatureProductionPlaceStateOrProvince

        public void setSignatureProductionPlaceStateOrProvince​(String signatureProductionPlaceStateOrProvince)
      • getSignatureProductionPlacePostalCode

        public String getSignatureProductionPlacePostalCode()
      • setSignatureProductionPlacePostalCode

        public void setSignatureProductionPlacePostalCode​(String signatureProductionPlacePostalCode)
      • getSignatureProductionPlaceCountryName

        public String getSignatureProductionPlaceCountryName()
      • setSignatureProductionPlaceCountryName

        public void setSignatureProductionPlaceCountryName​(String signatureProductionPlaceCountryName)
      • getCommitmentTypeId

        public String getCommitmentTypeId()
      • setCommitmentTypeId

        public void setCommitmentTypeId​(String commitmentTypeId)
      • getCommitmentTypeIdQualifier

        public String getCommitmentTypeIdQualifier()
      • setCommitmentTypeIdQualifier

        public void setCommitmentTypeIdQualifier​(String commitmentTypeIdQualifier)
        Qualifier for the Commitment Type ID. Possible values are null (which means no Qualifier element is created), "OIDAsURI", or "OIDAsURN". Default value is null. If the identifier is an OID then a qualifier must be set.
      • getCommitmentTypeIdDescription

        public String getCommitmentTypeIdDescription()
      • setCommitmentTypeIdDescription

        public void setCommitmentTypeIdDescription​(String commitmentTypeIdDescription)
      • getCommitmentTypeIdDocumentationReferences

        public List<String> getCommitmentTypeIdDocumentationReferences()
      • setCommitmentTypeIdDocumentationReferences

        public void setCommitmentTypeIdDocumentationReferences​(List<String> commitmentTypeIdDocumentationReferences)
        Sets the documentation references for the Commitment Type ID:
        Throws:
        IllegalArgumentException - if the parameter is null or a documentation reference is null or empty
      • getCommitmentTypeQualifiers

        public List<String> getCommitmentTypeQualifiers()
      • setCommitmentTypeQualifiers

        public void setCommitmentTypeQualifiers​(List<String> commitmentTypeQualifiers)
        List of additional qualifying information on the commitment. Each list element can be a text or an XML fragment with the root element 'CommitmentTypeQualifier' with the XAdES namespace.
        Throws:
        IllegalArgumentException - if the input parameter is null, or one qualifier is null or empty
      • setAttribute

        protected void setAttribute​(Element element,
                                    String attrName,
                                    String value)
      • isAddSignedDataObjectPropeties

        protected boolean isAddSignedDataObjectPropeties()
      • isAddCommitmentType

        protected boolean isAddCommitmentType()
      • isAddDataObjectFormat

        protected boolean isAddDataObjectFormat()
      • isAddSignedSignatureProperties

        protected boolean isAddSignedSignatureProperties()
                                                  throws Exception
        Throws:
        Exception
      • isAddSignerRole

        protected boolean isAddSignerRole()
      • isAddSignatureProductionPlace

        protected boolean isAddSignatureProductionPlace()
      • isAddSignaturePolicy

        protected boolean isAddSignaturePolicy()
      • getSigningCertificate

        protected X509Certificate getSigningCertificate()
                                                 throws Exception
        Returns the signing certificate. If you want to have a "SigningCertificate" element then either this method or the method getSigningCertificateChain() must return a value which is different from null or an empty array.

        This implementation returns null

        Throws:
        Exception
      • getSigningCertificateChain

        protected X509Certificate[] getSigningCertificateChain()
                                                        throws Exception
        Returns the signing certificate. If you want to have a "SigningCertificate" element then either this method or the method getSigningCertificate() must return a value.

        This implementation returns null

        Throws:
        Exception
      • createDigSigElement

        protected Element createDigSigElement​(String localName,
                                              Document doc,
                                              String prefixForXmlSignatureNamespace)