2016-10-22 11 views
0

スタンドアロンのhttpサーバーでwsdl2javaツールを使用してCXF Webサービスを作成しました。 wsdlにはws-securityが指定されています。CXF Webサービスでws-securityヘッダーを無視する方法

私は本当に気にしないのでws-securityヘッダーを強制したくありませんが、クライアントは以下のようにws-securityヘッダーを送信します。ユーザー名だけのパスワードがないことに注目してください。

<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
     <wsse:UsernameToken> 
      <wsse:Username>USER</wsse:Username> 
     </wsse:UsernameToken> 
    </wsse:Security> 

これを処理するためのオプションは何ですか?

UPDATE: OK私は今、これを持っている:

EndpointImpl impl = (EndpointImpl)Endpoint.publish(address, implementor); 
    impl.getInInterceptors().add(new LoggingInInterceptor()); 
    impl.getOutInterceptors().add(new LoggingOutInterceptor()); 

    Map<String, Object> inProps = new HashMap<String, Object>(); 
    inProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN_NO_PASSWORD); 
    inProps.put(WSHandlerConstants.USER, "USER"); 
    impl.getOutInterceptors().add(new WSS4JInInterceptor(inProps)); 

クライアントは以下のようにヘッダを送信している:

<soapenv:Header> 
    <wsa:To>http://www.test.com/Namespace/testb</wsa:To> 
    <wsa:ReplyTo> 
     <wsa:Address>http://www.test.com/Namespace/testa</wsa:Address> 
    </wsa:ReplyTo> 
    <wsa:Action>http://www.test.com/test</wsa:Action> 
    <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing" 
     >6158a795-46d5-4481-8467-da8ffda95664</wsa:MessageID> 
    <wsse:Security soapenv:mustUnderstand="1" 
     xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
     <wsse:UsernameToken> 
      <wsse:Username>USER</wsse:Username> 
     </wsse:UsernameToken> 
    </wsse:Security> 
</soapenv:Header> 

WSDLのポリシーは次のとおりです。

<wsp:Policy wsu:Id="RequestPolicy"> 
    <wsp:PolicyReference URI="#RequestAddressingPolicy"/> 
</wsp:Policy> 
<wsp:Policy wsu:Id="ResponsePolicy"> 
    <!--<wsp:PolicyReference URI="#ResponseAddressingPolicy"/>--> 
</wsp:Policy> 
<wsp:Policy wsu:Id="RequestAddressingPolicy"> 
    <wsp:All> 
     <sp:RequiredElements> 
      <!-- wsa:MessageID --> 
      <sp:XPath>/*[local-name() = 'Envelope']/*[local-name() = 'Header']/*[local-name() = 'MessageID' and namespace-uri() = 
       'http://www.w3.org/2005/08/addressing'][1]</sp:XPath> 
     </sp:RequiredElements> 
     <sp:RequiredElements> 
      <!-- wsa:Action --> 
      <sp:XPath>/*[local-name() = 'Envelope']/*[local-name() = 'Header']/*[local-name() = 'Action' and namespace-uri() = 
       'http://www.w3.org/2005/08/addressing'][1]</sp:XPath> 
     </sp:RequiredElements> 
    </wsp:All> 
</wsp:Policy> 
<wsp:Policy wsu:Id="ResponseAddressingPolicy"> 
    <wsp:All> 
     <sp:RequiredElements> 
      <!-- wsa:MessageID --> 
      <sp:XPath>/*[local-name() = 'Envelope']/*[local-name() = 'Header']/*[local-name() = 'MessageID' and namespace-uri() = 
       'http://www.w3.org/2005/08/addressing'][1]</sp:XPath> 
     </sp:RequiredElements> 
     <sp:RequiredElements> 
      <!-- wsa:Action --> 
      <sp:XPath>/*[local-name() = 'Envelope']/*[local-name() = 'Header']/*[local-name() = 'Action' and namespace-uri() = 
       'http://www.w3.org/2005/08/addressing'][1]</sp:XPath> 
     </sp:RequiredElements> 
     <sp:RequiredElements> 
      <!-- wsa:RelatesTo --> 
      <sp:XPath>/*[local-name() = 'Envelope']/*[local-name() = 'Header']/*[local-name() = 'RelatesTo' and namespace-uri() = 
       'http://www.w3.org/2005/08/addressing'][1]</sp:XPath> 
     </sp:RequiredElements> 
    </wsp:All> 
</wsp:Policy> 

しかし、私は、このエラーが発生する:

DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:268) - Invoking handleMessage on interceptor [email protected] 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:268) - Invoking handleMessage on interceptor [email protected]77080e9 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:268) - Invoking handleMessage on interceptor [email protected]5100a0c1 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:268) - Invoking handleMessage on interceptor [email protected]346e 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:268) - Invoking handleMessage on interceptor or[email protected]14429e20 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:268) - Invoking handleMessage on interceptor [email protected]446563 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:268) - Invoking handleMessage on interceptor or[email protected]47663389 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:268) - Invoking handleMessage on interceptor [email protected] 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:268) - Invoking handleMessage on interceptor [email protected]7fcf24 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:268) - Invoking handleMessage on interceptor [email protected] 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:268) - Invoking handleMessage on interceptor [email protected]ae79 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:268) - Invoking handleMessage on interceptor [email protected] 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:268) - Invoking handleMessage on interceptor [email protected] 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:268) - Invoking handleMessage on interceptor [email protected]c 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected]c 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected] 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected] 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected]ae79 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected] 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected]7fcf24 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected] 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor or[email protected]47663389 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected]446563 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor or[email protected]14429e20 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected]346e 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected]5100a0c1 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected]77080e9 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected] 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected] 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected]14 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor org.apache.cxf.interceptor.AttachmentInInterc[email protected] 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected] 
DEBUG [qtp1254651534-15 - /Identity/] (PhaseInterceptorChain.java:437) - Invoking handleFault on interceptor [email protected] 
WARN [qtp1254651534-15 - /Identity/] (LogUtils.java:443) - Interceptor for CENSORED has thrown exception, unwinding now 
org.apache.cxf.ws.policy.PolicyException: These policy alternatives can not be satisfied: 
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}RequiredElements 
    at org.apache.cxf.ws.policy.AssertionInfoMap.checkEffectivePolicy(AssertionInfoMap.java:167) 
    at org.apache.cxf.ws.policy.PolicyVerificationInInterceptor.handle(PolicyVerificationInInterceptor.java:101) 
    at org.apache.cxf.ws.policy.AbstractPolicyInterceptor.handleMessage(AbstractPolicyInterceptor.java:44) 
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271) 
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) 
    at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:355) 
    at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:319) 
    at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72) 
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1074) 
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1010) 
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) 
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255) 
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) 
    at org.eclipse.jetty.server.Server.handle(Server.java:361) 
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485) 
    at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926) 
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988) 
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:642) 
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) 
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) 
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:627) 
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:51) 
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) 
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) 
    at java.lang.Thread.run(Unknown Source) 

答えて

0

CXFでWSS4JInInterceptorを設定して、パスワードを含まないUsernameTokenを期待することができます。ここでの設定:http://cxf.apache.org/docs/ws-security.html - 指定する必要のある「アクション」は「UsernameTokenNoPassword」です。

+0

ありがとうございました。私は更なる情報で質問を更新しました。私はあなたが提案したものを試しました。 – rukiman

関連する問題