Путь к ресурсу [cxf-ehcache.xml] недействителен

Я пытаюсь реализовать шифрование на уровне сообщений. В частности, тело сообщения SOAP будет зашифровано. Я пытаюсь зашифровать трафик от клиента к веб-службе.

Клиент успешно отправляет зашифрованные данные:

UTF-8
Content-Type: text/xml
Headers: {Accept=[*/*], SOAPAction=[""]}
Payload: <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustUnderstand="1">
      <xenc:EncryptedKey xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="EK-2F22184B9EAAC6244514331031642721">
        <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"/>
        <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
          <wsse:SecurityTokenReference>
            <ds:X509Data>
              <ds:X509IssuerSerial>
                <ds:X509IssuerName>CN=testkey</ds:X509IssuerName>
                <ds:X509SerialNumber>1940918168</ds:X509SerialNumber>
              </ds:X509IssuerSerial>
            </ds:X509Data>
          </wsse:SecurityTokenReference>
        </ds:KeyInfo>
        <xenc:CipherData>
          <xenc:CipherValue>n6hH/RHguV2YCqZxI2Sq+X6hnaDm/OSUJsNRvcsxEHZw6lpdR+JitcbEfdv2huhsQ0HbtGjj0dfOa9pOCiwuaZW5wdR2Nq8kq85lZ4g2l/rHkGBRch19/P2oT0wXHIh/qQRHSqDhBg4bUrLKlzw+mA/H8SZimFvUz5xymwzKaQcv8puc0r9yKukQRmKVCjiS7enBznN0PdAfoitKdJYIm44/UaXa+CLwySPAw1cHpETAWoKclMqtL8Wgs9cN8+aYCmbC8kSDS+DURXMWc8ilVcirrYVrPAyEVZIX/NE9Pe8SIQmfgD5GHdFaIOPYcmf0i1w4/YQdTxzCFIXlwNkI0w==</xenc:CipherValue>
        </xenc:CipherData>
        <xenc:ReferenceList>
          <xenc:DataReference URI="#ED-2F22184B9EAAC6244514331031642892"/>
        </xenc:ReferenceList>
      </xenc:EncryptedKey>
    </wsse:Security>
  </SOAP-ENV:Header>
  <soap:Body>
    <xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="ED-2F22184B9EAAC6244514331031642892" Type="http://www.w3.org/2001/04/xmlenc#Content">
      <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
      <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsse11="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd" wsse11:TokenType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey">
          <wsse:Reference URI="#EK-2F22184B9EAAC6244514331031642721"/>
        </wsse:SecurityTokenReference>
      </ds:KeyInfo>
      <xenc:CipherData>
        <xenc:CipherValue>PNHM0fKuMOHtpm0rGSpR0siGeiFRz/4Dwgwauwe2C6usChfH5a7PDXimplOvYSKE9d8zTNXie3tDMfprHLS/hPD0vABlSGA4haGMYrelFKNgAU8BhXbBfrQimD7e8ue6gV/BBwAGa0rgoExPYJQh0w==</xenc:CipherValue>
      </xenc:CipherData>
    </xenc:EncryptedData>
  </soap:Body>
</soap:Envelope>

But the web service response is bad:
NFORMACIÓN: Inbound Message
----------------------------
ID: 1
Response-Code: 500
Encoding: UTF-8
Content-Type: text/xml;charset=UTF-8
Headers: {connection=[close], content-type=[text/xml;charset=UTF-8], Date=[Sun, 31 May 2015 20:12:44 GMT], Server=[Apache-Coyote/1.1], transfer-encoding=[chunked]}
Payload: <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>
      <faultstring>The resource path [cxf-ehcache.xml] is not valid</faultstring>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

--------------------------------------
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: The resource path [cxf-ehcache.xml] is not valid
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:158)
    at com.sun.proxy.$Proxy37.factorial(Unknown Source)
    at com.mathutility.test.TestMathUtility.main(TestMathUtility.java:57)
Caused by: org.apache.cxf.binding.soap.SoapFault: The resource path [cxf-ehcache.xml] is not valid

Я использую: Apache Tomcat 8 и Apache CXF 2.6.13.


person corocraft    schedule 31.05.2015    source источник
comment
Требуется дополнительная информация, есть ли в вашем проекте файл cxf-ehcache.xml?   -  person Karthik Prasad    schedule 01.06.2015
comment
может быть, это может помочь вам. почта -archives.apache.org/mod_mbox/cxf-users/201410.mbox/   -  person user1167253    schedule 17.06.2015


Ответы (1)


Оказывается, tomcat8 не любит ресурсы, которые не начинаются с /. Поэтому вам нужно добавить к ресурсу по умолчанию (cxf-ehcache.xml) префикс «/». Ответ приведен в почтовые архивы CXF.

Что вам нужно сделать, так это установить свойство ws-security.cache.config.file, чтобы заменить значение по умолчанию (cxf-ehcache.xml) на «/cxf-ehcache.xml», как описано в документация по CXF.

Вы можете сделать это, добавив свойство в объявление bean-компонента конечной точки в вашей конфигурации CXF XML:

<jaxws:endpoint 
    id="your id"
   ...    
   <jaxws:properties>
   ... 
    <entry key="ws-security.cache.config.file"  value="/cxf-ehcache.xml"/>
   </jaxws:properties>
</jaxws:endpoint>
person HL'REB    schedule 27.01.2016