搜索

第 374 章 XML 安全组件

download PDF

从 Camel 版本 2.12 开始提供

使用这个 Apache Camel 组件,您可以生成并验证 XML 签名,如 W3C 标准 XML 签名语法和处理 中所述,或者在后续版本 1.1 中所述。有关 XML 加密支持,请参阅 XML 安全 数据格式

您可以在此处找到 XML 签名简介。http://www.oracle.com/technetwork/articles/javase/dig-signatures-141823.html组件的实施基于 JSR 105,即与 W3C 标准对应的 Java API,并支持 Apache Santuario 和 JSR 105 的 JDK 提供程序。该实施将首先尝试使用 Apache Santuario 供应商;如果它找不到 Santuario 供应商,它将使用 JDK 供应商。此外,实施基于 DOM。

自 Camel 2.15.0 起,我们还为签名人端点提供对 XAdES-BES/EPES 的支持;请参见"签名端点的 XAdES-BES/EPES"部分。

Maven 用户需要将以下依赖项添加到这个组件的 pom.xml 中:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-xmlsecurity</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

374.1. XML 签名表示模式

XML 签名在信封、信封和分离的 XML 签名之间有所不同。在 信封 的 XML 签名案例中,XML 签名由签名的 XML 文档打包;这意味着 XML 签名元素是父元素的一个子元素,属于签名的 XML 文档。在 信封 XML 签名案例中,XML 签名包含签名内容。所有其他情况都称为 分离的 XML 签名。从 2.14.0 开始,支持某种形式分离的 XML 签名。

信封的 XML 签名 案例中,支持的生成的 XML 签名具有以下结构(Variables 由 []括起)。

<[parent element]>
   ... <!-- Signature element is added as last child of the parent element-->
   <Signature Id="generated_unique_signature_id">
       <SignedInfo>
             <Reference URI="">
                   <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
                   (<Transform>)* <!-- By default "http://www.w3.org/2006/12/xml-c14n11" is added to the transforms -->
                   <DigestMethod>
                   <DigestValue>
             </Reference>
             (<Reference URI="#[keyinfo_Id]">
                   <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
                   <DigestMethod>
                   <DigestValue>
             </Reference>)?
             <!-- further references possible, see option 'properties' below -->
      </SignedInfo>
      <SignatureValue>
      (<KeyInfo Id="[keyinfo_id]">)?
      <!-- Object elements possible, see option 'properties' below -->
  </Signature>
</[parent element]>

信封 XML 签名 案例中,支持的生成的 XML 签名有结构:

<Signature Id="generated_unique_signature_id">
  <SignedInfo>
         <Reference URI="#generated_unique_object_id" type="[optional_type_value]">
               (<Transform>)* <!-- By default "http://www.w3.org/2006/12/xml-c14n11" is added to the transforms -->
               <DigestMethod>
               <DigestValue>
         </Reference>
         (<Reference URI="#[keyinfo_id]">
               <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
               <DigestMethod>
               <DigestValue>
         </Reference>)?
          <!-- further references possible, see option 'properties' below  -->
  </SignedInfo>
  <SignatureValue>
  (<KeyInfo Id="[keyinfo_id]">)?
  <Object Id="generated_unique_object_id"/> <!-- The Object element contains the in-message body; the object ID can either be generated or set by the option parameter "contentObjectId" -->
  <!-- Further Object elements possible, see option 'properties' below -->
</Signature>

从 2.14.0 分离 XML 签名 时,支持以下结构(请参阅子章节 XML 签名作为 Signed Elements 的 Sibling):

(<[signed element] Id="[id_value]">
<!-- signed element must have an attribute of type ID -->
      ...

</[signed element]>
<other sibling/>*
<!-- between the signed element and the corresponding signature element, there can be other siblings.
 Signature element is added as last sibling. -->
<Signature Id="generated_unique_ID">
   <SignedInfo>
      <CanonicalizationMethod>
      <SignatureMethod>
      <Reference URI="#[id_value]" type="[optional_type_value]">
      <!-- reference URI contains the ID attribute value of the signed element -->
            (<Transform>)* <!-- By default "http://www.w3.org/2006/12/xml-c14n11" is added to the transforms -->
            <DigestMethod>
            <DigestValue>
      </Reference>
      (<Reference URI="#[generated_keyinfo_Id]">
            <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
            <DigestMethod>
            <DigestValue>
      </Reference>)?
   </SignedInfo>
   <SignatureValue>
   (<KeyInfo Id="[generated_keyinfo_id]">)?
</Signature>)+
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

© 2024 Red Hat, Inc.