private static boolean proxyAuthenticationInitialized = false;
public static void updateJXBrowserProxy()
{
ProxyConfig proxyConf = BrowserServices.getInstance().getProxyConfig();
if( proxyConf == null )
return;
try
{
proxyConf.setAutoDetectForNetwork( false );
if( !proxyAuthenticationInitialized )
{
proxyConf.setAuthenticationHandler( ServerType.HTTP, new AuthenticationHandler()
{
@Override
public ProxyServerLogin authenticationRequired( ServerType arg0 )
{
Settings settings = SoapUI.getSettings();
PropertyExpansionContext context = null;
String proxyUsername = PropertyExpander.expandProperties( context,
settings.getString( ProxySettings.USERNAME, null ) );
String proxyPassword = PropertyExpander.expandProperties( context,
settings.getString( ProxySettings.PASSWORD, null ) );
return new ProxyServerLogin( proxyUsername, proxyPassword );
}
} );
proxyAuthenticationInitialized = true;
}
if( ProxyUtils.isProxyEnabled() )
{
Settings settings = SoapUI.getSettings();
PropertyExpansionContext context = null;
// check system properties first
String proxyHost = System.getProperty( "http.proxyHost" );
String proxyPort = System.getProperty( "http.proxyPort" );
if( proxyHost == null )
proxyHost = PropertyExpander.expandProperties( context, settings.getString( ProxySettings.HOST, "" ) );
if( proxyPort == null )
proxyPort = PropertyExpander.expandProperties( context, settings.getString( ProxySettings.PORT, "" ) );
proxyConf.setProxy( ServerType.HTTP, new ProxyServer( proxyHost, Integer.parseInt( proxyPort ) ) );
// check excludes
proxyConf.setExceptions( PropertyExpander.expandProperties( context,
settings.getString( ProxySettings.EXCLUDES, "" ) ) );
}
else
{
proxyConf.setDirectConnection();
}
}
catch( Throwable e )
{
}