当前位置: 首页>>代码示例>>Java>>正文


Java RequestorType类代码示例

本文整理汇总了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;
            }
        });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:HttpURLConnection.java

示例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 = "";
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:HttpCallerInfo.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:AuthenticatorAdapter.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:HttpCallerInfo.java

示例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);
        }
    });
}
 
开发者ID:B4dT0bi,项目名称:silvertunnel-ng,代码行数:21,代码来源:HttpURLConnection.java

示例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;
            }
        });
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:27,代码来源:HttpURLConnection.java

示例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;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:25,代码来源:AuthenticatorAdapter.java

示例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;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:26,代码来源:AuthenticatorAdapter.java

示例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);
				}
			});
}
 
开发者ID:rovemonteux,项目名称:silvertunnel-monteux,代码行数:24,代码来源:HttpURLConnection.java

示例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;
            }
        });
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:27,代码来源:HttpURLConnection.java

示例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;

}
 
开发者ID:NannanZ,项目名称:spdymcsclient,代码行数:22,代码来源:AuthenticatorAdapter.java

示例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;
}
 
开发者ID:NannanZ,项目名称:spdymcsclient,代码行数:23,代码来源:AuthenticatorAdapter.java

示例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);
            }
        });
}
 
开发者ID:sirvaliance,项目名称:netlib,代码行数:20,代码来源:HttpURLConnection.java

示例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!
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:JavaNetAuthenticator.java

示例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!
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:JavaNetAuthenticator.java


注:本文中的java.net.Authenticator.RequestorType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。