A WSO2 SOA Enablement Server client may need to access a service via a proxy server requiring authentication. The current version of WSO2 SOA Enablement Server lets the client authenticate through the proxy server with basic authentication as specified in RFC 2617.
Entering a username and password for HTTP(S) proxy authentication is very simple. Just specify the system properties http.proxyUserName (https.ProxyUserName) and http.proxyPassword (https.ProxyUserName). For example:
java "-Djava.security.auth.login.config=%WASP_HOME%\conf\jaas.config" "-Dhttp.proxyUserName=Mustafa"
"-Dhttp.proxyPassword=open sesame" demo.hello.HelloWorldClient
Lookup operations using ServiceClient.create(wsdlURL, contextData) and ServiceClient.createProxy(Class)) may also specify a username and password for proxy authentication. If the parameter contextData contains security properties defined in ServiceClientContext and WaspSecurity, these properties will be used and take a higher priority than the properties defined in the system properties. Example 7 shows how to look up the Deploy service if a client runs via a proxy requiring authentication:
Example 7. HTTP Proxy Authentication Using Lookup Properties
// Copyright 2001-2003 Systinet Corp. All rights reserved.
// Use is subject to license terms.
package example.security;
import org.systinet.wasp.admin.DeployService;
import org.systinet.wasp.webservice.CallContext;
import org.systinet.wasp.webservice.ServiceClient;
import java.util.HashMap;
import java.util.Map;
public class ProxyAuthentication {
public static final String PROXY_USERNAME = "admin";
public static final String PROXY_PASSWORD = "changeit";
public static final String DEPLOY_URL =
"http://localhost:6060/admin/DeployService";
public static void main(String[] args) throws Exception {
// prepare user name and password into the contextData
Map contextData = new HashMap(2);
contextData.put(CallContext.HTTP_PROXY_USER_NAME, PROXY_USERNAME);
contextData.put(CallContext.HTTP_PROXY_PASSWORD, PROXY_PASSWORD);
/*
* lookup operation with the properties defining user
* name and password for http proxy
*/
ServiceClient deployServiceClient =
ServiceClient.create(DEPLOY_URL, contextData);
DeployService deployService =
(DeployService) deployServiceClient.createProxy(
DeployService.class);
}
}