I have a problem with setting up basic authentication to my OSGi bundle. Bundle is deployed in Apache Karaf. Here I have policy statement in my 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>
The problem is when I am trying to access the service from browser, the following error is that I get in the log files:
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
I have been searching the internet and I am not able to find the solution. Maybe someone know what might be wrong?
I am using:
Apache Karaf 2.2.8
CXF 2.6.1
JDK 1.6
Did you register policy handlers and such to handle the mysp:MustSupportBasicAuthentication policy? That's a non-standard policy assertion and not marked optional Thus, CXF doesn't know what to do with it.
I'm assuming that's a glassfish policy? Not really sure.