use of org.apache.cxf.interceptor.LoggingOutInterceptor in project midpoint by Evolveum.
the class AbstractWebServiceClient method createPort.
protected P createPort() throws Exception {
String password = getDefaultPassword();
String username = getDefaultUsername();
String endpointUrl = getDefaultEndpointUrl();
if (commandLine.hasOption('p')) {
password = commandLine.getOptionValue('p');
}
if (commandLine.hasOption('u')) {
username = commandLine.getOptionValue('u');
}
if (commandLine.hasOption('e')) {
endpointUrl = commandLine.getOptionValue('e');
}
if (verbose) {
System.out.println("Username: " + username);
System.out.println("Password: <not shown>");
System.out.println("Endpoint URL: " + endpointUrl);
}
// uncomment this if you want to use Fiddler or any other proxy
//ProxySelector.setDefault(new MyProxySelector("127.0.0.1", 8888));
P modelPort = createService().getPort(getPortClass());
BindingProvider bp = (BindingProvider) modelPort;
Map<String, Object> requestContext = bp.getRequestContext();
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointUrl);
org.apache.cxf.endpoint.Client client = ClientProxy.getClient(modelPort);
org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
Map<String, Object> wssProps = new HashMap<String, Object>();
if (!commandLine.hasOption('a') || (commandLine.hasOption('a') && WSHandlerConstants.USERNAME_TOKEN.equals(commandLine.getOptionValue('a')))) {
wssProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
wssProps.put(WSHandlerConstants.USER, username);
wssProps.put(WSHandlerConstants.PASSWORD_TYPE, getPasswordType());
wssProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName());
ClientPasswordHandler.setPassword(password);
WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(wssProps);
cxfEndpoint.getOutInterceptors().add(wssOut);
} else if (commandLine.hasOption('a') && "none".equals(commandLine.getOptionValue('a'))) {
// Nothing to do
} else {
throw new IllegalArgumentException("Unknown authentication mechanism '" + commandLine.getOptionValue('a') + "'");
}
if (commandLine.hasOption('m')) {
cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor());
cxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor());
}
return modelPort;
}
use of org.apache.cxf.interceptor.LoggingOutInterceptor in project maven-plugins by apache.
the class RestJiraDownloader method setupWebClient.
private WebClient setupWebClient(String jiraUrl) {
WebClient client = WebClient.create(jiraUrl);
ClientConfiguration clientConfiguration = WebClient.getConfig(client);
HTTPConduit http = clientConfiguration.getHttpConduit();
// MCHANGES-324 - Maintain the client session
clientConfiguration.getRequestContext().put(Message.MAINTAIN_SESSION, Boolean.TRUE);
if (getLog().isDebugEnabled()) {
clientConfiguration.getInInterceptors().add(new LoggingInInterceptor());
clientConfiguration.getOutInterceptors().add(new LoggingOutInterceptor());
}
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
// MCHANGES-341 Externalize JIRA server timeout values to the configuration section
getLog().debug("RestJiraDownloader: connectionTimeout: " + connectionTimeout);
httpClientPolicy.setConnectionTimeout(connectionTimeout);
httpClientPolicy.setAllowChunking(false);
getLog().debug("RestJiraDownloader: receiveTimout: " + receiveTimout);
httpClientPolicy.setReceiveTimeout(receiveTimout);
// MCHANGES-334 RestJiraDownloader doesn't honor proxy settings
getProxyInfo(jiraUrl);
if (proxyHost != null) {
getLog().debug("Using proxy: " + proxyHost + " at port " + proxyPort);
httpClientPolicy.setProxyServer(proxyHost);
httpClientPolicy.setProxyServerPort(proxyPort);
httpClientPolicy.setProxyServerType(ProxyServerType.HTTP);
if (proxyUser != null) {
ProxyAuthorizationPolicy proxyAuthorizationPolicy = new ProxyAuthorizationPolicy();
proxyAuthorizationPolicy.setAuthorizationType("Basic");
proxyAuthorizationPolicy.setUserName(proxyUser);
proxyAuthorizationPolicy.setPassword(proxyPass);
http.setProxyAuthorization(proxyAuthorizationPolicy);
}
}
if (webUser != null) {
AuthorizationPolicy authPolicy = new AuthorizationPolicy();
authPolicy.setAuthorizationType("Basic");
authPolicy.setUserName(webUser);
authPolicy.setPassword(webPassword);
http.setAuthorization(authPolicy);
}
http.setClient(httpClientPolicy);
return client;
}
use of org.apache.cxf.interceptor.LoggingOutInterceptor in project ddf by codice.
the class AttributeQueryClaimsHandler method createDispatcher.
/**
* Creates a dispatcher for dispatching requests.
*/
protected Dispatch<StreamSource> createDispatcher(Service service) {
Dispatch<StreamSource> dispatch = null;
if (service != null) {
dispatch = service.createDispatch(QName.valueOf(portName), StreamSource.class, Service.Mode.MESSAGE);
dispatch.getRequestContext().put(Dispatch.ENDPOINT_ADDRESS_PROPERTY, externalAttributeStoreUrl);
dispatch.getRequestContext().put("ws-security.signature.properties", signatureProperties);
dispatch.getRequestContext().put("ws-security.encryption.properties", encryptionProperties);
((DispatchImpl) dispatch).getClient().getBus().getOutInterceptors().add(new LoggingInInterceptor());
((DispatchImpl) dispatch).getClient().getBus().getOutInterceptors().add(new LoggingOutInterceptor());
}
return dispatch;
}
Aggregations