{
String sPassword = (String)tobj.findValue(PASSWORD);
final PasswordAuthentication credentials = new PasswordAuthentication(sUser,
((sPassword == null) ? "" : sPassword).toCharArray());
m_client.setPasswordProvider(new PasswordAuthenticationProvider()
{
public PasswordAuthentication getPasswordAuthentication()
{
return credentials;
}
public boolean isAuthenticationDeterministic()
{
return true;
}
});
}
}
else
{
m_client.setPasswordProvider(this);
}
final String sProxyHost = (String)tobj.findValue(PROXY_HOST);
Proxy proxy = m_channel.getProxy();
if (sProxyHost != null)
{
final Integer proxyPort = (Integer)tobj.findValue(PROXY_PORT);
if (proxyPort != null)
{
proxy = new Proxy(Proxy.Type.HTTP, (InetSocketAddress)AccessController.doPrivileged(
new PrivilegedAction()
{
public Object run()
{
return InetSocketAddress.createUnresolved(sProxyHost, proxyPort.intValue());
}
}
));
}
}
m_client.setProxy(proxy);
switch (m_channel.getProxyAuthMode())
{
case HTTPChannel.AUTH_BASIC:
m_client.setProxySPNEGOMode(HTTPClient.SPNEGO_NONE);
break;
case HTTPChannel.AUTH_CRED:
m_client.setProxySPNEGOMode(HTTPClient.SPNEGO_CRED);
break;
case HTTPChannel.AUTH_SERVER:
m_client.setProxySPNEGOMode(HTTPClient.SPNEGO_SILENT);
break;
}
String sProxyUser = (String)tobj.findValue(PROXY_USER);
String sProxyPassword;
if (sProxyUser == null)
{
sProxyPassword = m_channel.getProxyPassword();
sProxyUser = m_channel.getUser();
}
else
{
sProxyPassword = (String)tobj.findValue(PROXY_PASSWORD);
}
if (sProxyUser != null)
{
final PasswordAuthentication proxyCredentials = new PasswordAuthentication(sProxyUser,
((sProxyPassword == null) ? "" : sProxyPassword).toCharArray());
m_client.setProxyPasswordProvider(new PasswordAuthenticationProvider()
{
public PasswordAuthentication getPasswordAuthentication()
{
return proxyCredentials;
}