Class XAdESSignatureProperties
- java.lang.Object
-
- org.apache.camel.component.xmlsecurity.api.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()
orgetSigningCertificateChain()
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)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.camel.component.xmlsecurity.api.XmlSignatureProperties
XmlSignatureProperties.Input, XmlSignatureProperties.Output
-
-
Field Summary
Fields Modifier and Type Field Description static String
HTTP_URI_ETSI_ORG_01903_V1_1_1
static String
HTTP_URI_ETSI_ORG_01903_V1_2_2
static String
HTTP_URI_ETSI_ORG_01903_V1_3_2
static String
SIG_POLICY_EXPLICIT_ID
static String
SIG_POLICY_IMPLIED
static String
SIG_POLICY_NONE
-
Constructor Summary
Constructors Constructor Description XAdESSignatureProperties()
-
Method Summary
-
-
-
Field Detail
-
HTTP_URI_ETSI_ORG_01903_V1_3_2
public static final String HTTP_URI_ETSI_ORG_01903_V1_3_2
- See Also:
- Constant Field Values
-
HTTP_URI_ETSI_ORG_01903_V1_1_1
public static final String HTTP_URI_ETSI_ORG_01903_V1_1_1
- See Also:
- Constant Field Values
-
HTTP_URI_ETSI_ORG_01903_V1_2_2
public static final String HTTP_URI_ETSI_ORG_01903_V1_2_2
- See Also:
- Constant Field Values
-
SIG_POLICY_NONE
public static final String SIG_POLICY_NONE
- See Also:
- Constant Field Values
-
SIG_POLICY_IMPLIED
public static final String SIG_POLICY_IMPLIED
- See Also:
- Constant Field Values
-
SIG_POLICY_EXPLICIT_ID
public static final String SIG_POLICY_EXPLICIT_ID
- See Also:
- Constant Field Values
-
-
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 isnull
or one of the URIs isnull
-
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()
-
setSignaturePolicy
public void setSignaturePolicy(String signaturePolicy)
Signature Policy. Possible values:SIG_POLICY_NONE
,SIG_POLICY_IMPLIED
,SIG_POLICY_EXPLICIT_ID
. Default value isSIG_POLICY_NONE
.
-
getSigPolicyId
public String getSigPolicyId()
-
setSigPolicyId
public void setSigPolicyId(String sigPolicyId)
Identifier must be specified ifgetSignaturePolicy()
equals "ExplicitId". Must be an URI
-
getSigPolicyIdQualifier
public String getSigPolicyIdQualifier()
-
setSigPolicyIdQualifier
public void setSigPolicyIdQualifier(String sigPolicyIdQualifier)
Qualifier for the Signature Policy Identifier. Possible values arenull
(which means no Qualifier element is created), "OIDAsURI", or "OIDAsURN". Default value isnull
. If the identifier is an OID then a qualifier must be set.
-
getSigPolicyIdDescription
public String getSigPolicyIdDescription()
-
setSigPolicyIdDescription
public void setSigPolicyIdDescription(String sigPolicyIdDescription)
-
setSigPolicyIdDocumentationReferences
public void setSigPolicyIdDocumentationReferences(List<String> sigPolicyIdDocumentationReferences)
Sets the documentation references of the signature policy.- Throws:
IllegalArgumentException
- if the parameter isnull
or one of the documentation references isnull
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.
-
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 isnull
, or one of the qualifiers isnull
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 arenull
(which means no Qualifier element is created), "OIDAsURI", or "OIDAsURN". Default value isnull
. 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 isnull
or one of the documentation references isnull
or empty
-
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 isnull
, or if one of the roles isnull
or empty
-
getSignerCertifiedRoles
public List<XAdESEncapsulatedPKIData> getSignerCertifiedRoles()
-
setSignerCertifiedRoles
public void setSignerCertifiedRoles(List<XAdESEncapsulatedPKIData> signerCertifiedRoles)
Sets the certified roles.- Throws:
IllegalArgumentException
- if signerCertifiedRoles isnull
-
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 arenull
(which means no Qualifier element is created), "OIDAsURI", or "OIDAsURN". Default value isnull
. 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 isnull
or a documentation reference isnull
or empty
-
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 isnull
, or one qualifier isnull
or empty
-
get
public XmlSignatureProperties.Output get(XmlSignatureProperties.Input input) throws Exception
Description copied from interface:XmlSignatureProperties
Returns further configuration objects for the XML signature- Specified by:
get
in interfaceXmlSignatureProperties
- Parameters:
input
- input- Returns:
- output must not be
null
- Throws:
Exception
- if an error occurs during creating the output
-
setIdAttributeFromHeader
protected void setIdAttributeFromHeader(String header, Element element, XmlSignatureProperties.Input input)
-
addSignedDataObjectProperties
protected String addSignedDataObjectProperties(Document doc, Element signedProperties, XmlSignatureProperties.Input input) throws XmlSignatureException, IOException, ParserConfigurationException
-
isAddSignedDataObjectPropeties
protected boolean isAddSignedDataObjectPropeties()
-
addCommitmentTypeIndication
protected void addCommitmentTypeIndication(Element signedDataObjectProperties, Document doc, XmlSignatureProperties.Input input) throws IOException, ParserConfigurationException, XmlSignatureException
-
isAddCommitmentType
protected boolean isAddCommitmentType()
-
addDataObjectFormat
protected String addDataObjectFormat(Element signedDataObjectProperties, Document doc, XmlSignatureProperties.Input input)
-
isAddDataObjectFormat
protected boolean isAddDataObjectFormat()
-
addSignedSignatureProperties
protected void addSignedSignatureProperties(Document doc, Element signedProperties, XmlSignatureProperties.Input input) throws Exception
- Throws:
Exception
-
isAddSignedSignatureProperties
protected boolean isAddSignedSignatureProperties() throws Exception
- Throws:
Exception
-
isAddSignerRole
protected boolean isAddSignerRole()
-
addSignatureProductionPlace
protected void addSignatureProductionPlace(Document doc, Element signedSignatureProperties, XmlSignatureProperties.Input input)
-
isAddSignatureProductionPlace
protected boolean isAddSignatureProductionPlace()
-
addSignerRole
protected void addSignerRole(Document doc, Element signedSignatureProperties, XmlSignatureProperties.Input input) throws XmlSignatureException, IOException, ParserConfigurationException
-
addSignaturePolicyIdentifier
protected void addSignaturePolicyIdentifier(Document doc, Element signedProperties, XmlSignatureProperties.Input input) throws XmlSignatureException, IOException, ParserConfigurationException
-
createChildFromXmlFragmentOrText
protected Element createChildFromXmlFragmentOrText(Document doc, XmlSignatureProperties.Input input, String localElementName, String errorMessage, String elementOrText) throws IOException, ParserConfigurationException, XmlSignatureException
-
replacePrefixes
protected void replacePrefixes(Document qualifierDoc, XmlSignatureProperties.Input input)
-
replacePrefix
protected void replacePrefix(Element el, XmlSignatureProperties.Input input)
-
replacePrefixForNode
protected void replacePrefixForNode(Node node, XmlSignatureProperties.Input input)
-
isAddSignaturePolicy
protected boolean isAddSignaturePolicy()
-
addSigningCertificate
protected void addSigningCertificate(Document doc, Element signedProperties, XmlSignatureProperties.Input input) throws Exception
- Throws:
Exception
-
getSigningCertificate
protected X509Certificate getSigningCertificate() throws Exception
Returns the signing certificate. If you want to have a "SigningCertificate" element then either this method or the methodgetSigningCertificateChain()
must return a value which is different fromnull
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 methodgetSigningCertificate()
must return a value.This implementation returns
null
- Throws:
Exception
-
addSigningTime
protected void addSigningTime(Document doc, Element signedProperties, XmlSignatureProperties.Input input)
-
addCertificate
protected void addCertificate(X509Certificate cert, Element signedCertificate, Document doc, int index, XmlSignatureProperties.Input input) throws CertificateEncodingException, NoSuchAlgorithmException, XmlSignatureException
-
getMessageDigestAlgorithm
protected String getMessageDigestAlgorithm(String xmlSigDigestMethod, String errorMessage) throws XmlSignatureException
- Throws:
XmlSignatureException
-
calculateDigest
protected String calculateDigest(String algorithm, byte[] bytes) throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
-
createElementNS
protected Element createElementNS(Document doc, XmlSignatureProperties.Input input, String elementName)
-
createDigSigElement
protected Element createDigSigElement(String localName, Document doc, String prefixForXmlSignatureNamespace)
-
createElement
protected Element createElement(String localName, Document doc, XmlSignatureProperties.Input input)
-
-