Private Sub ConfigureHttpClient (Username As String, Password As String)
Dim jo As JavaObject = HttpUtils2Service.hc
Dim builder As JavaObject = jo.RunMethod("sharedInit", Array("hc"))
Dim authCache As JavaObject
authCache .InitializeNewInstance("java.util.concurrent.ConcurrentHashMap", Null)
Dim credentials As JavaObject
credentials.InitializeNewInstance("com.burgstaller.okhttp.digest.Credentials", Array(Username, Password))
Dim BasicAuth, DigestAuth As JavaObject
BasicAuth.InitializeNewInstance("com.burgstaller.okhttp.basic.BasicAuthenticator", Array(credentials))
DigestAuth.InitializeNewInstance("com.burgstaller.okhttp.digest.DigestAuthenticator", Array(credentials))
Dim auth As JavaObject
auth.InitializeNewInstance("com.burgstaller.okhttp.DispatchingAuthenticator$Builder", Null)
auth.RunMethod("with", Array("digest", DigestAuth))
auth.RunMethod("with", Array("basic", BasicAuth))
Dim CachingAuth As JavaObject
CachingAuth.InitializeNewInstance("com.burgstaller.okhttp.CachingAuthenticatorDecorator", Array(auth.RunMethod("build", Null), authCache))
Dim interceptor As JavaObject
interceptor.InitializeNewInstance("com.burgstaller.okhttp.AuthenticationCacheInterceptor", Array(authCache))
builder.RunMethod("authenticator", Array(CachingAuth))
builder.RunMethod("addInterceptor", Array(interceptor))
jo.SetField("client", builder.RunMethod("build", Null))
End Sub