Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void proxy_test_auth2() throws IOException
- {
- String ntUsername = "andrshpa";
- String ntPassword = "12wedfik";
- String localMachineName = System.getenv("COMPUTERNAME");
- String domainName = System.getenv("USERDOMAIN");
- String proxyHost = "37.143.11.127";
- int proxyPort = 65233;
- NTCredentials ntCreds = new NTCredentials(ntUsername, ntPassword, localMachineName, domainName);
- CredentialsProvider credsProvider = new BasicCredentialsProvider();
- credsProvider.setCredentials( new AuthScope(proxyHost,proxyPort), ntCreds );
- CloseableHttpClient httpclient = HttpClients.custom()
- .setDefaultCredentialsProvider(credsProvider)
- .setProxy(new HttpHost(proxyHost, proxyPort))
- .setProxyAuthenticationStrategy(new ProxyAuthenticationStrategy())
- .build();
- try {
- HttpGet httpget = new HttpGet("http://control456.ru/sample/save_post_get.php");
- System.out.println("Executing request " + httpget.getRequestLine());
- // Pass local context as a parameter
- CloseableHttpResponse response = httpclient.execute(httpget);
- System.out.println(response.getStatusLine().toString());
- try {
- System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
- } finally {
- response.close();
- }
- } finally {
- httpclient.close();
- }
- HTTP/1.0 407 Proxy Authentication Required
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement