374.8. XAdES-BES/EPES 用于信号端点


从 Camel 2.15.0 开始提供 

XML 高级电子签名(XAdES) 定义 XML 签名的扩展。该标准由 欧洲电信标准研究所 定义,允许您在 用于电子签名的社区框架上创建符合欧盟指令(1999/93/EC)的签名。XAdES 定义不同的签名属性集合,称为签名表单。我们在 Signer Endpoint 中支持签名形式的签名形式 Basic Electronic Signature (XAdES-BES)和 Explicit Policy Based Electronic Signature (XAdES-EPES)。不支持使用Validation Data XAdES-T 和 XAdES-C 格式的 Electronic Signature 。

我们支持 XAdES-EPES 表单的以下属性("?" 表示零次或出现一项:

支持的 XAdES-EPES 属性

<QualifyingProperties Target>
    <SignedProperties>
        <SignedSignatureProperties>
            (SigningTime)?
            (SigningCertificate)?
            (SignaturePolicyIdentifier)
            (SignatureProductionPlace)?
            (SignerRole)?
        </SignedSignatureProperties>
        <SignedDataObjectProperties>
            (DataObjectFormat)?
            (CommitmentTypeIndication)?
        </SignedDataObjectProperties>
    </SignedProperties>
</QualifyingProperties>
Copy to Clipboard Toggle word wrap

XAdES-BES 表单的属性相同,但 SignaturePolicyIdentifier 属性不是 XAdES-BES 的一部分。 

您可以通过 bean org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties 或 org.apache.camel.component.xmlsecurity.api.DefaultXAdESSignatureProperties 配置 XAdES-BES/EPES 属性。XAdESSignatureProperties 支持上述所有属性,但 SigningCertificate 属性除外。要获取 SigningCertificate 属性,您必须覆盖方法 XAdESSignatureProperties.getSigningCertificate ()XAdESSignatureProperties.getSigningCertificateChain ()。 类 DefaultXAdESSignatureProperties 覆盖方法 getSigningCertificate () ,并通过密钥存储和别名指定签名证书。以下示例显示了您可以指定的所有参数。如果您不需要某些参数,您只需省略它们。

Java DSL 中的 XAdES-BES/EPES 示例

 Keystore keystore = ... // load a keystore
DefaultKeyAccessor accessor = new DefaultKeyAccessor();
accessor.setKeyStore(keystore);
accessor.setPassword("password");
accessor.setAlias("cert_alias"); // signer key alias
 
DefaultXAdESSignatureProperties props = new DefaultXAdESSignatureProperties();
props.setNamespace("http://uri.etsi.org/01903/v1.3.2#"); // sets the namespace for the XAdES elements; the namspace is related to the XAdES version, default value is "http://uri.etsi.org/01903/v1.3.2#", other possible values are "http://uri.etsi.org/01903/v1.1.1#" and "http://uri.etsi.org/01903/v1.2.2#"
props.setPrefix("etsi"); // sets the prefix for the XAdES elements, default value is "etsi"
 
// signing certificate
props.setKeystore(keystore));
props.setAlias("cert_alias"); // specify the alias of the signing certificate in the keystore = signer key alias
props.setDigestAlgorithmForSigningCertificate(DigestMethod.SHA256); // possible values for the algorithm are "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"
props.setSigningCertificateURIs(Collections.singletonList("http://certuri"));
 
// signing time
props.setAddSigningTime(true);
 
// policy
props.setSignaturePolicy(XAdESSignatureProperties.SIG_POLICY_EXPLICIT_ID);
// also the values XAdESSignatureProperties.SIG_POLICY_NONE ("None"), and XAdESSignatureProperties.SIG_POLICY_IMPLIED ("Implied")are possible, default value is XAdESSignatureProperties.SIG_POLICY_EXPLICIT_ID ("ExplicitId")
// For "None" and "Implied" you must not specify any further policy parameters
props.setSigPolicyId("urn:oid:1.2.840.113549.1.9.16.6.1");
props.setSigPolicyIdQualifier("OIDAsURN"); //allowed values are empty string, "OIDAsURI", "OIDAsURN"; default value is empty string
props.setSigPolicyIdDescription("invoice version 3.1");
props.setSignaturePolicyDigestAlgorithm(DigestMethod.SHA256);// possible values for the algorithm are "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"
props.setSignaturePolicyDigestValue("Ohixl6upD6av8N7pEvDABhEL6hM=");
// you can add  qualifiers for the signature policy either by specifying text or an XML fragment with the root element "SigPolicyQualifier"
props.setSigPolicyQualifiers(Arrays
    .asList(new String[] {
        "<SigPolicyQualifier xmlns=\"http://uri.etsi.org/01903/v1.3.2#\"><SPURI>http://test.com/sig.policy.pdf</SPURI><SPUserNotice><ExplicitText>display text</ExplicitText>"
            + "</SPUserNotice></SigPolicyQualifier>", "category B" }));
props.setSigPolicyIdDocumentationReferences(Arrays.asList(new String[] {"http://test.com/policy.doc.ref1.txt",
    "http://test.com/policy.doc.ref2.txt" }));
 
// production place
props.setSignatureProductionPlaceCity("Munich");
props.setSignatureProductionPlaceCountryName("Germany");
props.setSignatureProductionPlacePostalCode("80331");
props.setSignatureProductionPlaceStateOrProvince("Bavaria");
 
//role
// you can add claimed roles either by specifying text or an XML fragment with the root element "ClaimedRole"
props.setSignerClaimedRoles(Arrays.asList(new String[] {"test",
    "<a:ClaimedRole xmlns:a=\"http://uri.etsi.org/01903/v1.3.2#\"><TestRole>TestRole</TestRole></a:ClaimedRole>" }));
props.setSignerCertifiedRoles(Collections.singletonList(new XAdESEncapsulatedPKIData("Ahixl6upD6av8N7pEvDABhEL6hM=",
    "http://uri.etsi.org/01903/v1.2.2#DER", "IdCertifiedRole")));
 
// data object format
props.setDataObjectFormatDescription("invoice");
props.setDataObjectFormatMimeType("text/xml");
props.setDataObjectFormatIdentifier("urn:oid:1.2.840.113549.1.9.16.6.2");
props.setDataObjectFormatIdentifierQualifier("OIDAsURN"); //allowed values are empty string, "OIDAsURI", "OIDAsURN"; default value is empty string
props.setDataObjectFormatIdentifierDescription("identifier desc");
props.setDataObjectFormatIdentifierDocumentationReferences(Arrays.asList(new String[] {
    "http://test.com/dataobject.format.doc.ref1.txt", "http://test.com/dataobject.format.doc.ref2.txt" }));
 
//commitment
props.setCommitmentTypeId("urn:oid:1.2.840.113549.1.9.16.6.4");
props.setCommitmentTypeIdQualifier("OIDAsURN"); //allowed values are empty string, "OIDAsURI", "OIDAsURN"; default value is empty string
props.setCommitmentTypeIdDescription("description for commitment type ID");
props.setCommitmentTypeIdDocumentationReferences(Arrays.asList(new String[] {"http://test.com/commitment.ref1.txt",
    "http://test.com/commitment.ref2.txt" }));
// you can specify a commitment type qualifier either by simple text or an XML fragment with root element "CommitmentTypeQualifier"
props.setCommitmentTypeQualifiers(Arrays.asList(new String[] {"commitment qualifier",
    "<c:CommitmentTypeQualifier xmlns:c=\"http://uri.etsi.org/01903/v1.3.2#\"><C>c</C></c:CommitmentTypeQualifier>" }));
 
beanRegistry.bind("xmlSignatureProperties",props);
beanRegistry.bind("keyAccessorDefault",keyAccessor);
 
// you must reference the properties bean in the "xmlsecurity" URI
from("direct:xades").to("xmlsecurity:sign://xades?keyAccessor=#keyAccessorDefault&properties=#xmlSignatureProperties")
             .to("mock:result");
Copy to Clipboard Toggle word wrap

Spring XML 中的 XAdES-BES/EPES 示例

...
<from uri="direct:xades" />
    <to
        uri="xmlsecurity:sign://xades?keyAccessor=#accessorRsa&amp;properties=#xadesProperties" />
    <to uri="mock:result" />
...
<bean id="xadesProperties"
    class="org.apache.camel.component.xmlsecurity.api.XAdESSignatureProperties">
    <!-- For more properties see the previous Java DSL example. 
         If you want to have a signing certificate then use the bean class DefaultXAdESSignatureProperties (see the previous Java DSL example). -->
    <property name="signaturePolicy" value="ExplicitId" />
    <property name="sigPolicyId" value="http://www.test.com/policy.pdf" />
    <property name="sigPolicyIdDescription" value="factura" />
    <property name="signaturePolicyDigestAlgorithm" value="http://www.w3.org/2000/09/xmldsig#sha1" />
    <property name="signaturePolicyDigestValue" value="Ohixl6upD6av8N7pEvDABhEL1hM=" />
    <property name="signerClaimedRoles" ref="signerClaimedRoles_XMLSigner" />
    <property name="dataObjectFormatDescription" value="Factura electrónica" />
    <property name="dataObjectFormatMimeType" value="text/xml" />
</bean>
<bean class="java.util.ArrayList" id="signerClaimedRoles_XMLSigner">
    <constructor-arg>
        <list>
            <value>Emisor</value>
            <value>&lt;ClaimedRole
                xmlns=&quot;http://uri.etsi.org/01903/v1.3.2#&quot;&gt;&lt;test
                xmlns=&quot;http://test.com/&quot;&gt;test&lt;/test&gt;&lt;/ClaimedRole&gt;</value>
        </list>
    </constructor-arg>
</bean>
Copy to Clipboard Toggle word wrap

374.8.1. Headers

Expand
标头类型描述

CamelXmlSignatureXAdESQualifyingPropertiesId

字符串

对于 QualifyingProperties 元素的 'Id' 属性值

CamelXmlSignatureXAdESSignedDataObjectPropertiesId

字符串

对于 SignedDataObjectProperties 元素的 'Id' 属性值

CamelXmlSignatureXAdESSignedSignaturePropertiesId

字符串

对于 SignedSignatureProperties 元素的 'Id' 属性值

CamelXmlSignatureXAdESDataObjectFormatEncoding

字符串

对于 DataObjectFormat 元素的 Encoding 元素的值

CamelXmlSignatureXAdESNamespace

字符串

 覆盖 XAdES 命名空间参数值

CamelXmlSignatureXAdESPrefix

字符串

覆盖 XAdES 前缀参数值

374.8.2. XAdES 版本 1.4.2 的限制

  • 不支持 XAdES-T 和 XAdES-C 的签名
  • 只有签名人部分实施。verifier 部分当前不可用。
  • 不支持 QualifyingPropertiesReference 元素(请参阅 spec 的 6.3.2 部分)。
  • 不支持 SignaturePolicy Identifier 元素中包含的 SignaturePolicyId 元素中的 Transforms 元素
  • 不支持 CounterSignature 元素 不支持 UnsignedProperties 元素
  • 最多一个 DataObjectFormat 元素。多个 DataObjectFormat 元素没有意义,因为我们只有一个已签名的数据对象(这是 XML 签名者端点的传入消息正文)。
  • 最多一个 CommitmentTypeIndication 元素。多个 CommitmentTypeIndication 元素没有意义,因为我们只有一个已签名的数据对象(这是 XML 签名者端点的传入消息正文)。
  • CommitmentTypeIndication 元素始终包含 AllSignedDataObjects 元素。不支持 CommitmentTypeIndication 元素中的 ObjectReference 元素。
  • 不支持 AllDataObjectsTimeStamp 元素
  • 不支持 IndividualDataObjectsTimeStamp 元素
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat