AuthenticatorAdapter.java
3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.squareup.okhttp.internal.http;
import com.squareup.okhttp.Challenge;
import com.squareup.okhttp.Credentials;
import com.squareup.okhttp.HttpUrl;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Request.Builder;
import com.squareup.okhttp.Response;
import java.io.IOException;
import java.net.Authenticator.RequestorType;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.Proxy.Type;
import java.util.List;
public final class AuthenticatorAdapter
implements com.squareup.okhttp.Authenticator
{
public static final com.squareup.okhttp.Authenticator INSTANCE = new AuthenticatorAdapter();
private InetAddress getConnectToInetAddress(Proxy paramProxy, HttpUrl paramHttpUrl)
throws IOException
{
if ((paramProxy != null) && (paramProxy.type() != Proxy.Type.DIRECT)) {
return ((InetSocketAddress)paramProxy.address()).getAddress();
}
return InetAddress.getByName(paramHttpUrl.host());
}
public final Request authenticate(Proxy paramProxy, Response paramResponse)
throws IOException
{
List localList = paramResponse.challenges();
paramResponse = paramResponse.request();
HttpUrl localHttpUrl = paramResponse.httpUrl();
int j = localList.size();
int i = 0;
while (i < j)
{
Object localObject = (Challenge)localList.get(i);
if ("Basic".equalsIgnoreCase(((Challenge)localObject).getScheme()))
{
localObject = java.net.Authenticator.requestPasswordAuthentication(localHttpUrl.host(), getConnectToInetAddress(paramProxy, localHttpUrl), localHttpUrl.port(), localHttpUrl.scheme(), ((Challenge)localObject).getRealm(), ((Challenge)localObject).getScheme(), localHttpUrl.url(), Authenticator.RequestorType.SERVER);
if (localObject != null)
{
paramProxy = Credentials.basic(((PasswordAuthentication)localObject).getUserName(), new String(((PasswordAuthentication)localObject).getPassword()));
return paramResponse.newBuilder().header("Authorization", paramProxy).build();
}
}
i += 1;
}
return null;
}
public final Request authenticateProxy(Proxy paramProxy, Response paramResponse)
throws IOException
{
List localList = paramResponse.challenges();
paramResponse = paramResponse.request();
HttpUrl localHttpUrl = paramResponse.httpUrl();
int j = localList.size();
int i = 0;
while (i < j)
{
Object localObject = (Challenge)localList.get(i);
if ("Basic".equalsIgnoreCase(((Challenge)localObject).getScheme()))
{
InetSocketAddress localInetSocketAddress = (InetSocketAddress)paramProxy.address();
localObject = java.net.Authenticator.requestPasswordAuthentication(localInetSocketAddress.getHostName(), getConnectToInetAddress(paramProxy, localHttpUrl), localInetSocketAddress.getPort(), localHttpUrl.scheme(), ((Challenge)localObject).getRealm(), ((Challenge)localObject).getScheme(), localHttpUrl.url(), Authenticator.RequestorType.PROXY);
if (localObject != null)
{
paramProxy = Credentials.basic(((PasswordAuthentication)localObject).getUserName(), new String(((PasswordAuthentication)localObject).getPassword()));
return paramResponse.newBuilder().header("Proxy-Authorization", paramProxy).build();
}
}
i += 1;
}
return null;
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/okhttp/internal/http/AuthenticatorAdapter.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/