So, how do I assign a policy, or cause one to be associated with the service?  
Do I need to instantiate an STSClient object?  Or will CXF do that for me?

If I try to construct and use an STSClient object I get the following exception

Exception in thread "main" org.apache.cxf.ws.policy.PolicyException: None of 
the policy alternatives can be satisfied.
        at 
org.apache.cxf.ws.policy.EndpointPolicyImpl.chooseAlternative(EndpointPolicyImpl.java:166)

code

    STSClient client = new STSClient(cxf);
    client.setBeanName("{http://.../}SymbolService";);
    client.setRequiresEntropy(false);
    
client.setServiceName("{http://schemas.microsoft.com/ws/2008/06/identity/securitytokenservice/}SecurityTokenService";);
    
client.setEndpointName("{http://schemas.microsoft.com/ws/2008/06/identity/securitytokenservice/}UsernameAuthStsBinding_IWSTrust13Sync";);
    client.setWsdlLocation("http://.../SecurityTokenService?wsdl";);
    Policy newPolicy = new Policy();  ? How do I get the right policy
    client.setPolicy(newPolicy);
    SecurityToken token = client.requestSecurityToken("foo");

In the metro client I have the policy in an xml file, how do I express this 
with CXF?

    <wsp1:Policy wsu:Id = "SecurityTokenServicePolicy">
        <wsp1:ExactlyOne>
            <wsp1:All>
                <sc:TrustStore
                    wspp:visibility = "private"
                    peeralias = ".............."
                    type = "PKCS12"
                    callbackHandler = "...................."
                <sc:CallbackHandlerConfiguration wspp:visibility="private">
                    <sc:CallbackHandler name="usernameHandler" 
classname="...................."/>
                    <sc:CallbackHandler name="passwordHandler" 
classname="................"/>
                </sc:CallbackHandlerConfiguration>
            </wsp1:All>
        </wsp1:ExactlyOne>
    </wsp1:Policy>




________________________________________
From: Andrei Shakirin [[email protected]]
Sent: Thursday, January 16, 2014 6:51 AM
To: [email protected]
Subject: RE: Question on using CXF STS with 3rd party server without Spring

Hi,

Obviously you have Microsoft specific assertions in WS-Policy that CXF doesn't 
understand by default.

Regards,
Andrei.

> -----Original Message-----
> From: Walters, Jay M [mailto:[email protected]]
> Sent: Mittwoch, 15. Januar 2014 15:26
> To: [email protected]
> Subject: Question on using CXF STS with 3rd party server without Spring
>
> I have poked around a bit and not found a good example of what I need to
> do to get this working. I have a WCF C# webservice I am trying to call.  I 
> have
> working Metro code and also C# code calling the service (a third party
> product), but not getting any traction with CXF.  So far all the examples
> appear to use Spring which I cannot use.
>
> I am trying to use CXF 2.7.8 with JDK 1.6.0_21.
>
> Do I need to instantiate an STSClient object, or does this happen
> automatically?  If automatic, what do I need to configure in order to make it
> work. I have a X509 certificate as a byte stream, I do not have a keystore
> though I suppose I could make it if required to use CXF.
>
> So far I have uses wsdl2java to generate loads of stuff which I try to use as
> follows.
>
>     SymbolService_Service factory = new SymbolService_Service();
>     SymbolService ss = factory.getSymbolServiceHttp();
>     ArrayOfSymbolContract array = ss.queryForAll();
>
> This yields the following output/trace
>
> [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] - Creating
> Service
> {...<http://www.sungard.com/vpm/core/tables/Symbol/>}SymbolService
> from WSDL:
> http://bosdvpmapp1:8010/VPM/Core/Tables/SymbolService?wsdl
> [org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl] - No assertion
> builder for type
> {http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1}BinaryEnc
> oding registered.
> [org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl] - No assertion
> builder for type
> {http://schemas.microsoft.com/ws/2006/05/framing/policy}SslTransportSec
> urity registered.
> org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvid
> er] - Failed to build the policy
> 'SymbolServiceTcp_policy':org.apache.neethi.builders.PrimitiveAssertion
> cannot be cast to org.apache.cxf.ws.security.policy.model.Token
>
> Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: None of
> the policy alternatives can be satisfied.
>     at
> org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:157)
>     at $Proxy44.queryForAll(Unknown Source)
>     at Client.main(Client.java:112)
> Caused by: org.apache.cxf.ws.policy.PolicyException: None of the policy
> alternatives can be satisfied.
>     at
> org.apache.cxf.ws.policy.EndpointPolicyImpl.chooseAlternative(EndpointPoli
> cyImpl.java:166)
>     at
> org.apache.cxf.ws.policy.EndpointPolicyImpl.finalizeConfig(EndpointPolicyIm
> pl.java:145)
>     at
> org.apache.cxf.ws.policy.EndpointPolicyImpl.initialize(EndpointPolicyImpl.jav
> a:141)
> ....
>
> Thanks for any help

Reply via email to