本文整理汇总了Java中java.net.Authenticator.RequestorType类的典型用法代码示例。如果您正苦于以下问题:Java RequestorType类的具体用法?Java RequestorType怎么用?Java RequestorType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RequestorType类属于java.net.Authenticator包,在下文中一共展示了RequestorType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: privilegedRequestPasswordAuthentication
import java.net.Authenticator.RequestorType; //导入依赖的package包/类
private static PasswordAuthentication
privilegedRequestPasswordAuthentication(
final String host,
final InetAddress addr,
final int port,
final String protocol,
final String prompt,
final String scheme,
final URL url,
final RequestorType authType) {
return java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<PasswordAuthentication>() {
public PasswordAuthentication run() {
if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
logger.finest("Requesting Authentication: host =" + host + " url = " + url);
}
PasswordAuthentication pass = Authenticator.requestPasswordAuthentication(
host, addr, port, protocol,
prompt, scheme, url, authType);
if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
logger.finest("Authentication returned: " + (pass != null ? pass.toString() : "null"));
}
return pass;
}
});
}
示例2: HttpCallerInfo
import java.net.Authenticator.RequestorType; //导入依赖的package包/类
/**
* Constructor an un-schemed object for site access.
*/
public HttpCallerInfo(URL url) {
this.url= url;
prompt = "";
host = url.getHost();
int p = url.getPort();
if (p == -1) {
port = url.getDefaultPort();
} else {
port = p;
}
InetAddress ia;
try {
ia = InetAddress.getByName(url.getHost());
} catch (Exception e) {
ia = null;
}
addr = ia;
protocol = url.getProtocol();
authType = RequestorType.SERVER;
scheme = "";
}
示例3: authenticate
import java.net.Authenticator.RequestorType; //导入依赖的package包/类
public Request authenticate(Proxy proxy, Response response) throws IOException {
List<Challenge> challenges = response.challenges();
Request request = response.request();
HttpUrl url = request.httpUrl();
int size = challenges.size();
for (int i = 0; i < size; i++) {
Challenge challenge = (Challenge) challenges.get(i);
if ("Basic".equalsIgnoreCase(challenge.getScheme())) {
PasswordAuthentication auth = java.net.Authenticator
.requestPasswordAuthentication(url.host(), getConnectToInetAddress(proxy,
url), url.port(), url.scheme(), challenge.getRealm(), challenge
.getScheme(), url.url(), RequestorType.SERVER);
if (auth != null) {
return request.newBuilder().header("Authorization", Credentials.basic(auth
.getUserName(), new String(auth.getPassword()))).build();
}
}
}
return null;
}
示例4: HttpCallerInfo
import java.net.Authenticator.RequestorType; //导入依赖的package包/类
/**
* Constructor an un-schemed object for site access.
*/
public HttpCallerInfo(URL url, Authenticator a) {
this.url= url;
prompt = "";
host = url.getHost();
int p = url.getPort();
if (p == -1) {
port = url.getDefaultPort();
} else {
port = p;
}
InetAddress ia;
try {
ia = InetAddress.getByName(url.getHost());
} catch (Exception e) {
ia = null;
}
addr = ia;
protocol = url.getProtocol();
authType = RequestorType.SERVER;
scheme = "";
authenticator = a;
}
示例5: privilegedRequestPasswordAuthentication
import java.net.Authenticator.RequestorType; //导入依赖的package包/类
/**
* privileged request password authentication.
*/
private static PasswordAuthentication privilegedRequestPasswordAuthentication(final String host,
final InetAddress addr,
final int port,
final String protocol,
final String prompt,
final String scheme,
final URL url,
final RequestorType authType) {
return java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<PasswordAuthentication>() {
@Override
public PasswordAuthentication run() {
return Authenticator.requestPasswordAuthentication(
host, addr, port, protocol, prompt, scheme,
url, authType);
}
});
}
示例6: privilegedRequestPasswordAuthentication
import java.net.Authenticator.RequestorType; //导入依赖的package包/类
private static PasswordAuthentication
privilegedRequestPasswordAuthentication(
final String host,
final InetAddress addr,
final int port,
final String protocol,
final String prompt,
final String scheme,
final URL url,
final RequestorType authType) {
return java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<>() {
public PasswordAuthentication run() {
if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
logger.finest("Requesting Authentication: host =" + host + " url = " + url);
}
PasswordAuthentication pass = Authenticator.requestPasswordAuthentication(
host, addr, port, protocol,
prompt, scheme, url, authType);
if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
logger.finest("Authentication returned: " + (pass != null ? pass.toString() : "null"));
}
return pass;
}
});
}
示例7: authenticate
import java.net.Authenticator.RequestorType; //导入依赖的package包/类
public final Request authenticate(Proxy paramProxy, Response paramResponse)
throws IOException
{
List localList = paramResponse.challenges();
Request localRequest = paramResponse.request;
URL localURL = localRequest.url();
int i = 0;
int j = localList.size();
while (i < j)
{
Challenge localChallenge = (Challenge)localList.get(i);
if ("Basic".equalsIgnoreCase(localChallenge.scheme))
{
PasswordAuthentication localPasswordAuthentication = java.net.Authenticator.requestPasswordAuthentication(localURL.getHost(), getConnectToInetAddress(paramProxy, localURL), localURL.getPort(), localURL.getProtocol(), localChallenge.realm, localChallenge.scheme, localURL, Authenticator.RequestorType.SERVER);
if (localPasswordAuthentication != null)
{
String str = Credentials.basic(localPasswordAuthentication.getUserName(), new String(localPasswordAuthentication.getPassword()));
return localRequest.newBuilder().header("Authorization", str).build();
}
}
i++;
}
return null;
}
示例8: authenticateProxy
import java.net.Authenticator.RequestorType; //导入依赖的package包/类
public final Request authenticateProxy(Proxy paramProxy, Response paramResponse)
throws IOException
{
List localList = paramResponse.challenges();
Request localRequest = paramResponse.request;
URL localURL = localRequest.url();
int i = 0;
int j = localList.size();
while (i < j)
{
Challenge localChallenge = (Challenge)localList.get(i);
if ("Basic".equalsIgnoreCase(localChallenge.scheme))
{
InetSocketAddress localInetSocketAddress = (InetSocketAddress)paramProxy.address();
PasswordAuthentication localPasswordAuthentication = java.net.Authenticator.requestPasswordAuthentication(localInetSocketAddress.getHostName(), getConnectToInetAddress(paramProxy, localURL), localInetSocketAddress.getPort(), localURL.getProtocol(), localChallenge.realm, localChallenge.scheme, localURL, Authenticator.RequestorType.PROXY);
if (localPasswordAuthentication != null)
{
String str = Credentials.basic(localPasswordAuthentication.getUserName(), new String(localPasswordAuthentication.getPassword()));
return localRequest.newBuilder().header("Proxy-Authorization", str).build();
}
}
i++;
}
return null;
}
示例9: privilegedRequestPasswordAuthentication
import java.net.Authenticator.RequestorType; //导入依赖的package包/类
/**
* privileged request password authentication.
*/
private static PasswordAuthentication privilegedRequestPasswordAuthentication(final String host,
final InetAddress addr,
final int port,
final String protocol,
final String prompt,
final String scheme,
final URL url,
final RequestorType authType)
{
return java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<PasswordAuthentication>()
{
@Override
public PasswordAuthentication run()
{
return Authenticator.requestPasswordAuthentication(
host, addr, port, protocol, prompt, scheme,
url, authType);
}
});
}
示例10: privilegedRequestPasswordAuthentication
import java.net.Authenticator.RequestorType; //导入依赖的package包/类
private static PasswordAuthentication
privilegedRequestPasswordAuthentication(
final String host,
final InetAddress addr,
final int port,
final String protocol,
final String prompt,
final String scheme,
final URL url,
final RequestorType authType) {
return java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<PasswordAuthentication>() {
public PasswordAuthentication run() {
if (logger.isLoggable(PlatformLogger.FINEST)) {
logger.finest("Requesting Authentication: host =" + host + " url = " + url);
}
PasswordAuthentication pass = Authenticator.requestPasswordAuthentication(
host, addr, port, protocol,
prompt, scheme, url, authType);
if (logger.isLoggable(PlatformLogger.FINEST)) {
logger.finest("Authentication returned: " + (pass != null ? pass.toString() : "null"));
}
return pass;
}
});
}
示例11: authenticate
import java.net.Authenticator.RequestorType; //导入依赖的package包/类
@Override public Request authenticate(Proxy proxy, Response response) throws IOException {
List<Challenge> challenges = response.challenges();
Request request = response.request();
URL url = request.url();
for (int i = 0, size = challenges.size(); i < size; i++) {
Challenge challenge = challenges.get(i);
if (!"Basic".equalsIgnoreCase(challenge.getScheme())) continue;
PasswordAuthentication auth = java.net.Authenticator.requestPasswordAuthentication(
url.getHost(), getConnectToInetAddress(proxy, url), url.getPort(), url.getProtocol(),
challenge.getRealm(), challenge.getScheme(), url, RequestorType.SERVER);
if (auth == null) continue;
String credential = Credentials.basic(auth.getUserName(), new String(auth.getPassword()));
return request.newBuilder()
.header("Authorization", credential)
.build();
}
return null;
}
示例12: authenticateProxy
import java.net.Authenticator.RequestorType; //导入依赖的package包/类
@Override public Request authenticateProxy(Proxy proxy, Response response) throws IOException {
List<Challenge> challenges = response.challenges();
Request request = response.request();
URL url = request.url();
for (int i = 0, size = challenges.size(); i < size; i++) {
Challenge challenge = challenges.get(i);
if (!"Basic".equalsIgnoreCase(challenge.getScheme())) continue;
InetSocketAddress proxyAddress = (InetSocketAddress) proxy.address();
PasswordAuthentication auth = java.net.Authenticator.requestPasswordAuthentication(
proxyAddress.getHostName(), getConnectToInetAddress(proxy, url), proxyAddress.getPort(),
url.getProtocol(), challenge.getRealm(), challenge.getScheme(), url,
RequestorType.PROXY);
if (auth == null) continue;
String credential = Credentials.basic(auth.getUserName(), new String(auth.getPassword()));
return request.newBuilder()
.header("Proxy-Authorization", credential)
.build();
}
return null;
}
示例13: privilegedRequestPasswordAuthentication
import java.net.Authenticator.RequestorType; //导入依赖的package包/类
private static PasswordAuthentication
privilegedRequestPasswordAuthentication(
final String host,
final InetAddress addr,
final int port,
final String protocol,
final String prompt,
final String scheme,
final URL url,
final RequestorType authType) {
return java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<PasswordAuthentication>() {
public PasswordAuthentication run() {
return Authenticator.requestPasswordAuthentication(
host, addr, port, protocol,
prompt, scheme, url, authType);
}
});
}
示例14: authenticate
import java.net.Authenticator.RequestorType; //导入依赖的package包/类
@Override public Request authenticate(Route route, Response response) throws IOException {
List<Challenge> challenges = response.challenges();
Request request = response.request();
HttpUrl url = request.url();
boolean proxyAuthorization = response.code() == 407;
Proxy proxy = route.proxy();
for (int i = 0, size = challenges.size(); i < size; i++) {
Challenge challenge = challenges.get(i);
if (!"Basic".equalsIgnoreCase(challenge.scheme())) continue;
PasswordAuthentication auth;
if (proxyAuthorization) {
InetSocketAddress proxyAddress = (InetSocketAddress) proxy.address();
auth = java.net.Authenticator.requestPasswordAuthentication(
proxyAddress.getHostName(), getConnectToInetAddress(proxy, url), proxyAddress.getPort(),
url.scheme(), challenge.realm(), challenge.scheme(), url.url(),
RequestorType.PROXY);
} else {
auth = java.net.Authenticator.requestPasswordAuthentication(
url.host(), getConnectToInetAddress(proxy, url), url.port(), url.scheme(),
challenge.realm(), challenge.scheme(), url.url(), RequestorType.SERVER);
}
if (auth != null) {
String credential = Credentials.basic(auth.getUserName(), new String(auth.getPassword()));
return request.newBuilder()
.header(proxyAuthorization ? "Proxy-Authorization" : "Authorization", credential)
.build();
}
}
return null; // No challenges were satisfied!
}
示例15: authenticate
import java.net.Authenticator.RequestorType; //导入依赖的package包/类
@Override public Request authenticate(Route route, Response response) throws IOException {
List<Challenge> challenges = response.challenges();
Request request = response.request();
HttpUrl url = request.url();
boolean proxyAuthorization = response.code() == 407;
Proxy proxy = route.proxy();
for (int i = 0, size = challenges.size(); i < size; i++) {
Challenge challenge = challenges.get(i);
if (!"Basic".equalsIgnoreCase(challenge.scheme())) continue;
PasswordAuthentication auth;
if (proxyAuthorization) {
InetSocketAddress proxyAddress = (InetSocketAddress) proxy.address();
auth = java.net.Authenticator.requestPasswordAuthentication(
proxyAddress.getHostName(), getConnectToInetAddress(proxy, url), proxyAddress.getPort(),
url.scheme(), challenge.realm(), challenge.scheme(), url.url(),
RequestorType.PROXY);
} else {
auth = java.net.Authenticator.requestPasswordAuthentication(
url.host(), getConnectToInetAddress(proxy, url), url.port(), url.scheme(),
challenge.realm(), challenge.scheme(), url.url(), RequestorType.SERVER);
}
if (auth != null) {
String credential = Credentials.basic(
auth.getUserName(), new String(auth.getPassword()), challenge.charset());
return request.newBuilder()
.header(proxyAuthorization ? "Proxy-Authorization" : "Authorization", credential)
.build();
}
}
return null; // No challenges were satisfied!
}