0

我在为我的 OSGi 包设置基本身份验证时遇到问题。Bundle 部署在 Apache Karaf 中。在这里,我的 WSDL 中有政策声明:

<service name="MyService">
    <port name="MyPortTypeBindingPort"
          binding="MyPortTypeBinding">
        <soap:address location="http://localhost:8009/MyEndpoint"/>  
            <wsp:PolicyReference URI="#HttpBasicAuthBindingBindingRealmPolicy"/>
    </port>
</service>

<wsp:Policy wsu:Id="HttpBasicAuthBindingBindingRealmPolicy">
    <mysp:MustSupportBasicAuthentication on="true">
        <mysp:BasicAuthenticationDetail>
            <mysp:Realm realmName="MyRealm"/>
        </mysp:BasicAuthenticationDetail>
    </mysp:MustSupportBasicAuthentication>
</wsp:Policy>

问题是当我尝试从浏览器访问服务时,以下错误是我进入日志文件:

org.apache.cxf.interceptor.Fault: None of the policy alternatives can be satisfied.
    at org.apache.cxf.ws.policy.AbstractPolicyInterceptor.handleMessage(AbstractPolicyInterceptor.java:47)[140:org.apache.cxf.cxf-rt-ws-policy:2.6.0]
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)[105:org.apache.cxf.cxf-api:2.6.0]
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122)[105:org.apache.cxf.cxf-api:2.6.0]
    at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:344)[130:org.apache.cxf.cxf-rt-transports-http-jetty:2.6.0]
    at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:310)[130:org.apache.cxf.cxf-rt-transports-http-jetty:2.6.0]
    at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)[130:org.apache.cxf.cxf-rt-transports-http-jetty:2.6.0]
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:943)[85:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:879)[85:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)[85:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)[85:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)[85:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.server.Server.handle(Server.java:349)[85:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)[85:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:919)[85:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:582)[81:org.eclipse.jetty.http:7.5.4.v20111024]
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)[81:org.eclipse.jetty.http:7.5.4.v20111024]
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)[85:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)[80:org.eclipse.jetty.io:7.5.4.v20111024]
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)[80:org.eclipse.jetty.io:7.5.4.v20111024]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)[79:org.eclipse.jetty.util:7.5.4.v20111024]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)[79:org.eclipse.jetty.util:7.5.4.v20111024]
    at java.lang.Thread.run(Thread.java:662)[:1.6.0_33]
Caused by: org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives can be satisfied.
    at org.apache.cxf.ws.policy.EffectivePolicyImpl.chooseAlternative(EffectivePolicyImpl.java:186)[140:org.apache.cxf.cxf-rt-ws-policy:2.6.0]
    at org.apache.cxf.ws.policy.EffectivePolicyImpl.chooseAlternative(EffectivePolicyImpl.java:179)[140:org.apache.cxf.cxf-rt-ws-policy:2.6.0]
    at org.apache.cxf.ws.policy.EffectivePolicyImpl.initialise(EffectivePolicyImpl.java:113)[140:org.apache.cxf.cxf-rt-ws-policy:2.6.0]
    at org.apache.cxf.ws.policy.PolicyEngineImpl.getEffectiveServerRequestPolicy(PolicyEngineImpl.java:311)[140:org.apache.cxf.cxf-rt-ws-policy:2.6.0]
    at org.apache.cxf.ws.policy.EndpointPolicyImpl.initializeInterceptors(EndpointPolicyImpl.java:295)[140:org.apache.cxf.cxf-rt-ws-policy:2.6.0]
    at org.apache.cxf.ws.policy.EndpointPolicyImpl.getInterceptors(EndpointPolicyImpl.java:126)[140:org.apache.cxf.cxf-rt-ws-policy:2.6.0]
    at org.apache.cxf.ws.policy.PolicyInInterceptor.handle(PolicyInInterceptor.java:119)[140:org.apache.cxf.cxf-rt-ws-policy:2.6.0]
    at org.apache.cxf.ws.policy.AbstractPolicyInterceptor.handleMessage(AbstractPolicyInterceptor.java:45)[140:org.apache.cxf.cxf-rt-ws-policy:2.6.0]
    ... 21 more

我一直在搜索互联网,但找不到解决方案。也许有人知道可能出了什么问题?

我在用:

Apache Karaf 2.2.8
CXF 2.6.1
JDK 1.6
4

1 回答 1

0

您是否注册了策略处理程序等来处理 mysp:MustSupportBasicAuthentication 策略?这是一个非标准的策略断言并且没有标记为可选因此,CXF 不知道如何处理它。

我假设这是一个玻璃鱼政策?不太确定。

于 2012-07-27T11:15:27.363 回答