Skip to content

Instantly share code, notes, and snippets.

@jfarcand
Created November 1, 2010 14:39
Show Gist options
  • Save jfarcand/658269 to your computer and use it in GitHub Desktop.
Save jfarcand/658269 to your computer and use it in GitHub Desktop.
protected void setCredentials(XmlRpcHttpClientConfig pConfig) throws XmlRpcClientException {
String userName = pConfig.getBasicUserName();
if (userName != null) {
String enc = pConfig.getBasicEncoding();
if (enc == null) {
enc = XmlRpcStreamConfig.UTF8_ENCODING;
}
client.getParams().setParameter(HttpMethodParams.CREDENTIAL_CHARSET, enc);
Credentials creds = new UsernamePasswordCredentials(userName, pConfig.getBasicPassword());
AuthScope scope = new AuthScope(null, AuthScope.ANY_PORT, null, AuthScope.ANY_SCHEME);
client.getState().setCredentials(scope, creds);
client.getParams().setAuthenticationPreemptive(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment