Search in sources :

Example 86 with AuthorizationPolicy

use of org.apache.cxf.configuration.security.AuthorizationPolicy in project liima by liimaorg.

the class DynWSAuthHTTPConduitConfigurer method configure.

@Override
public void configure(String name, String address, HTTPConduit conduit) {
    if (username != null) {
        AuthorizationPolicy ap = new AuthorizationPolicy();
        ap.setUserName(username);
        ap.setPassword(password);
        conduit.setAuthorization(ap);
    }
    // override the ssl configuration of cxf and use the default implementation instead
    // CXF doesn't like pkcs12 keystore for some reason (Default key managers cannot be initialized: Invalid keystore format)
    TLSClientParameters tls = new TLSClientParameters();
    try {
        tls.setSSLSocketFactory(SSLContext.getDefault().getSocketFactory());
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
    conduit.setTlsClientParameters(tls);
}
Also used : AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Aggregations

AuthorizationPolicy (org.apache.cxf.configuration.security.AuthorizationPolicy)86 Message (org.apache.cxf.message.Message)25 Test (org.junit.Test)22 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)16 IOException (java.io.IOException)15 ArrayList (java.util.ArrayList)11 Client (org.apache.cxf.endpoint.Client)11 List (java.util.List)9 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)9 URL (java.net.URL)7 HashMap (java.util.HashMap)7 ProxyAuthorizationPolicy (org.apache.cxf.configuration.security.ProxyAuthorizationPolicy)7 Map (java.util.Map)6 SecurityContext (org.apache.cxf.security.SecurityContext)6 Bus (org.apache.cxf.Bus)5 TLSClientParameters (org.apache.cxf.configuration.jsse.TLSClientParameters)5 WebClient (org.apache.cxf.jaxrs.client.WebClient)5 MessageImpl (org.apache.cxf.message.MessageImpl)5 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)5 Principal (java.security.Principal)4