如何在mule中为xml有效负载添加数字签名

时间:2017-08-07 03:48:40

标签: mule

我正在尝试添加数字签名 我的输入是一个xml有效载荷 我使用xml_signer作为默认签名者,使用jce-signer-config算法作为" HmacMD5"

我的流程如下                       

    <flow name="Flow1">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/sign" doc:name="HTTP"/>
    <byte-array-to-string-transformer doc:name="Byte Array to String"/>
    <logger message="Original payload:  #[payload]" level="INFO" doc:name="Logger"/>
    <signature:sign   config-ref="Signature" doc:name="Signature"/>
    <byte-array-to-string-transformer doc:name="Byte Array to String"/>
    <logger level="INFO" message="Payload with signature #[payload]" doc:name="Logger" />

</flow>

我的输入有效负载如下:

 <PurchaseOrder>
   <Item number="130046593231">
    <Description>Video Game</Description>
    <Price>10.29</Price>
    </Item>
    <Buyer id="8492340">
   <Name>My Name</Name>
   <Address>
   <Street>One Network Drive</Street>
   <Town>Burlington</Town>
   <State>MA</State>
   <Country>United States</Country>
   <PostalCode>01803</PostalCode>
   </Address>
   </Buyer>
  </PurchaseOrder>

我预期的有效载荷:

<PurchaseOrder>
<Item number="130046593231">
<Description>Video Game</Description>
<Price>10.29</Price>
 </Item>
 <Buyer id="8492340">
 <Name>My Name</Name>
 <Address>
 <Street>One Network Drive</Street>
 <Town>Burlington</Town>
 <State>MA</State>
 <Country>United States</Country>
 <PostalCode>01803</PostalCode>
</Address>
</Buyer>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
  <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
   <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
    <Reference URI="">
      <Transforms>
      <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>   
      </Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>  

      <DigestValue>tkrLEansVMTKqAOuW6b8Dx+OUNWk9bVpW6RFvfuEmM8=     </DigestValue>
        </Reference>
      </SignedInfo> 

    <SignatureValue>

   PeeHVw+XvZkkhhPlEopRp1PBDfTcR9U2IBimTTo1gOMF5cWq1tFqZ0B4ScNBiZVtd0yS4j06xl3
    WB2Q87oobwA==
     </SignatureValue>
   <KeyInfo>
 <KeyValue><RSAKeyValue><Modulus>i8OP+VX/EORWwHiHiqLmMgpXz4IubPv2y+gHdiSCUzKoFfUYD6wFGBwi6vVmRSrmNbNZvZ9DFvST
     PZJEyUhn5w==</Modulus>
         <Exponent>AQAB</Exponent>
            </RSAKeyValue>
            </KeyValue></KeyInfo>
            </Signature></PurchaseOrder>

实际输出:

  <PurchaseOrder>
    <Item number="130046593231">
    <Description>Video Game</Description>
 <Price>10.29</Price>
</Item>
 <Buyer id="8492340">
 <Name>My Name</Name>
 <Address>
  <Street>One Network Drive</Street>
 <Town>Burlington</Town>
  <State>MA</State>
  <Country>United States</Country>
  <PostalCode>01803</PostalCode>
  </Address>
  </Buyer>
 </PurchaseOrder>

我关注此链接:https://docs.mulesoft.com/mule-user-guide/v/3.7/mule-digital-signature-processor

我按照以下步骤操作:

(1)向您的应用程序添加一个全局签名消息处理器,为该元素应用唯一的Name,并在Default Signer字段中保留默认值JCE_SIGNER。

(2)单击JceSigner选项卡,然后根据下表配置消息处理器的属性。

(3)在您的流程中添加签名消息处理器。

(4)根据表格配置消息处理器的字段。

为什么我没有得到预期的输出?如何添加数字签名?

0 个答案:

没有答案