org.apache.http.auth.AuthState.getState()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(14.2k)|赞(0)|评价(0)|浏览(78)

本文整理了Java中org.apache.http.auth.AuthState.getState()方法的一些代码示例,展示了AuthState.getState()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AuthState.getState()方法的具体详情如下:
包路径:org.apache.http.auth.AuthState
类名称:AuthState
方法名:getState

AuthState.getState介绍

暂无

代码示例

代码示例来源:origin: com.joyent.http-signature/apache-http-client-signature

@Override
public Queue<AuthOption> select(final Map<String, Header> challengeHeaders,
                final HttpHost authhost,
                final HttpResponse response,
                final HttpContext context) {
  final HttpClientContext httpClientContext = HttpClientContext.adapt(context);
  final AuthState state = httpClientContext.getTargetAuthState();
  final Queue<AuthOption> queue = new ArrayDeque<>();
  if (state == null || !state.getState().equals(AuthProtocolState.CHALLENGED)) {
    queue.add(authOption);
  } else {
    System.out.println("does this happen?");
  }
  return queue;
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient

public void process(final HttpRequest request, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(request, "HTTP request");
  Args.notNull(context, "HTTP context");
  final String method = request.getRequestLine().getMethod();
  if (method.equalsIgnoreCase("CONNECT")) {
    return;
  }
  if (request.containsHeader(AUTH.WWW_AUTH_RESP)) {
    return;
  }
  // Obtain authentication state
  final AuthState authState = (AuthState) context.getAttribute(
      ClientContext.TARGET_AUTH_STATE);
  if (authState == null) {
    this.log.debug("Target auth state not set in the context");
    return;
  }
  if (this.log.isDebugEnabled()) {
    this.log.debug("Target auth state: " + authState.getState());
  }
  process(authState, request, context);
}

代码示例来源:origin: Nextdoor/bender

@Override
public void process(final HttpRequest request, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(request, "HTTP request");
  Args.notNull(context, "HTTP context");
  final String method = request.getRequestLine().getMethod();
  if (method.equalsIgnoreCase("CONNECT")) {
    return;
  }
  if (request.containsHeader(AUTH.WWW_AUTH_RESP)) {
    return;
  }
  // Obtain authentication state
  final AuthState authState = (AuthState) context.getAttribute(
      ClientContext.TARGET_AUTH_STATE);
  if (authState == null) {
    this.log.debug("Target auth state not set in the context");
    return;
  }
  if (this.log.isDebugEnabled()) {
    this.log.debug("Target auth state: " + authState.getState());
  }
  process(authState, request, context);
}

代码示例来源:origin: com.hynnet/httpclient

public void process(final HttpRequest request, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(request, "HTTP request");
  Args.notNull(context, "HTTP context");
  final String method = request.getRequestLine().getMethod();
  if (method.equalsIgnoreCase("CONNECT")) {
    return;
  }
  if (request.containsHeader(AUTH.WWW_AUTH_RESP)) {
    return;
  }
  // Obtain authentication state
  final AuthState authState = (AuthState) context.getAttribute(
      ClientContext.TARGET_AUTH_STATE);
  if (authState == null) {
    this.log.debug("Target auth state not set in the context");
    return;
  }
  if (this.log.isDebugEnabled()) {
    this.log.debug("Target auth state: " + authState.getState());
  }
  process(authState, request, context);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

@Override
public void process(final HttpRequest request, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(request, "HTTP request");
  Args.notNull(context, "HTTP context");
  final String method = request.getRequestLine().getMethod();
  if (method.equalsIgnoreCase("CONNECT")) {
    return;
  }
  if (request.containsHeader(AUTH.WWW_AUTH_RESP)) {
    return;
  }
  // Obtain authentication state
  final AuthState authState = (AuthState) context.getAttribute(
      ClientContext.TARGET_AUTH_STATE);
  if (authState == null) {
    this.log.debug("Target auth state not set in the context");
    return;
  }
  if (this.log.isDebugEnabled()) {
    this.log.debug("Target auth state: " + authState.getState());
  }
  process(authState, request, context);
}

代码示例来源:origin: com.hynnet/httpclient

public void process(final HttpRequest request, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(request, "HTTP request");
  Args.notNull(context, "HTTP context");
  if (request.containsHeader(AUTH.PROXY_AUTH_RESP)) {
    return;
  }
  final HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute(
      ExecutionContext.HTTP_CONNECTION);
  if (conn == null) {
    this.log.debug("HTTP connection not set in the context");
    return;
  }
  final HttpRoute route = conn.getRoute();
  if (route.isTunnelled()) {
    return;
  }
  // Obtain authentication state
  final AuthState authState = (AuthState) context.getAttribute(
      ClientContext.PROXY_AUTH_STATE);
  if (authState == null) {
    this.log.debug("Proxy auth state not set in the context");
    return;
  }
  if (this.log.isDebugEnabled()) {
    this.log.debug("Proxy auth state: " + authState.getState());
  }
  process(authState, request, context);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

@Override
public void process(final HttpRequest request, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(request, "HTTP request");
  Args.notNull(context, "HTTP context");
  if (request.containsHeader(AUTH.PROXY_AUTH_RESP)) {
    return;
  }
  final HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute(
      ExecutionContext.HTTP_CONNECTION);
  if (conn == null) {
    this.log.debug("HTTP connection not set in the context");
    return;
  }
  final HttpRoute route = conn.getRoute();
  if (route.isTunnelled()) {
    return;
  }
  // Obtain authentication state
  final AuthState authState = (AuthState) context.getAttribute(
      ClientContext.PROXY_AUTH_STATE);
  if (authState == null) {
    this.log.debug("Proxy auth state not set in the context");
    return;
  }
  if (this.log.isDebugEnabled()) {
    this.log.debug("Proxy auth state: " + authState.getState());
  }
  process(authState, request, context);
}

代码示例来源:origin: Nextdoor/bender

@Override
public void process(final HttpRequest request, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(request, "HTTP request");
  Args.notNull(context, "HTTP context");
  if (request.containsHeader(AUTH.PROXY_AUTH_RESP)) {
    return;
  }
  final HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute(
      ExecutionContext.HTTP_CONNECTION);
  if (conn == null) {
    this.log.debug("HTTP connection not set in the context");
    return;
  }
  final HttpRoute route = conn.getRoute();
  if (route.isTunnelled()) {
    return;
  }
  // Obtain authentication state
  final AuthState authState = (AuthState) context.getAttribute(
      ClientContext.PROXY_AUTH_STATE);
  if (authState == null) {
    this.log.debug("Proxy auth state not set in the context");
    return;
  }
  if (this.log.isDebugEnabled()) {
    this.log.debug("Proxy auth state: " + authState.getState());
  }
  process(authState, request, context);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient

public void process(final HttpRequest request, final HttpContext context)
    throws HttpException, IOException {
  Args.notNull(request, "HTTP request");
  Args.notNull(context, "HTTP context");
  if (request.containsHeader(AUTH.PROXY_AUTH_RESP)) {
    return;
  }
  final HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute(
      ExecutionContext.HTTP_CONNECTION);
  if (conn == null) {
    this.log.debug("HTTP connection not set in the context");
    return;
  }
  final HttpRoute route = conn.getRoute();
  if (route.isTunnelled()) {
    return;
  }
  // Obtain authentication state
  final AuthState authState = (AuthState) context.getAttribute(
      ClientContext.PROXY_AUTH_STATE);
  if (authState == null) {
    this.log.debug("Proxy auth state not set in the context");
    return;
  }
  if (this.log.isDebugEnabled()) {
    this.log.debug("Proxy auth state: " + authState.getState());
  }
  process(authState, request, context);
}

代码示例来源:origin: ibinti/bugvm

public boolean isAuthenticationRequested(
    final HttpHost host,
    final HttpResponse response,
    final AuthenticationStrategy authStrategy,
    final AuthState authState,
    final HttpContext context) {
  if (authStrategy.isAuthenticationRequested(host, response, context)) {
    this.log.debug("Authentication required");
    if (authState.getState() == AuthProtocolState.SUCCESS) {
      authStrategy.authFailed(host, authState.getAuthScheme(), context);
    }
    return true;
  } else {
    switch (authState.getState()) {
    case CHALLENGED:
    case HANDSHAKE:
      this.log.debug("Authentication succeeded");
      authState.setState(AuthProtocolState.SUCCESS);
      authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
      break;
    case SUCCESS:
      break;
    default:
      authState.setState(AuthProtocolState.UNCHALLENGED);
    }
    return false;
  }
}

代码示例来源:origin: com.hynnet/httpclient

public boolean isAuthenticationRequested(
    final HttpHost host,
    final HttpResponse response,
    final AuthenticationStrategy authStrategy,
    final AuthState authState,
    final HttpContext context) {
  if (authStrategy.isAuthenticationRequested(host, response, context)) {
    this.log.debug("Authentication required");
    if (authState.getState() == AuthProtocolState.SUCCESS) {
      authStrategy.authFailed(host, authState.getAuthScheme(), context);
    }
    return true;
  } else {
    switch (authState.getState()) {
    case CHALLENGED:
    case HANDSHAKE:
      this.log.debug("Authentication succeeded");
      authState.setState(AuthProtocolState.SUCCESS);
      authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
      break;
    case SUCCESS:
      break;
    default:
      authState.setState(AuthProtocolState.UNCHALLENGED);
    }
    return false;
  }
}

代码示例来源:origin: Nextdoor/bender

public boolean isAuthenticationRequested(
    final HttpHost host,
    final HttpResponse response,
    final AuthenticationStrategy authStrategy,
    final AuthState authState,
    final HttpContext context) {
  if (authStrategy.isAuthenticationRequested(host, response, context)) {
    this.log.debug("Authentication required");
    if (authState.getState() == AuthProtocolState.SUCCESS) {
      authStrategy.authFailed(host, authState.getAuthScheme(), context);
    }
    return true;
  } else {
    switch (authState.getState()) {
    case CHALLENGED:
    case HANDSHAKE:
      this.log.debug("Authentication succeeded");
      authState.setState(AuthProtocolState.SUCCESS);
      authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
      break;
    case SUCCESS:
      break;
    default:
      authState.setState(AuthProtocolState.UNCHALLENGED);
    }
    return false;
  }
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient

public boolean isAuthenticationRequested(
    final HttpHost host,
    final HttpResponse response,
    final AuthenticationStrategy authStrategy,
    final AuthState authState,
    final HttpContext context) {
  if (authStrategy.isAuthenticationRequested(host, response, context)) {
    this.log.debug("Authentication required");
    if (authState.getState() == AuthProtocolState.SUCCESS) {
      authStrategy.authFailed(host, authState.getAuthScheme(), context);
    }
    return true;
  } else {
    switch (authState.getState()) {
    case CHALLENGED:
    case HANDSHAKE:
      this.log.debug("Authentication succeeded");
      authState.setState(AuthProtocolState.SUCCESS);
      authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
      break;
    case SUCCESS:
      break;
    default:
      authState.setState(AuthProtocolState.UNCHALLENGED);
    }
    return false;
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

public boolean isAuthenticationRequested(
    final HttpHost host,
    final HttpResponse response,
    final AuthenticationStrategy authStrategy,
    final AuthState authState,
    final HttpContext context) {
  if (authStrategy.isAuthenticationRequested(host, response, context)) {
    this.log.debug("Authentication required");
    if (authState.getState() == AuthProtocolState.SUCCESS) {
      authStrategy.authFailed(host, authState.getAuthScheme(), context);
    }
    return true;
  } else {
    switch (authState.getState()) {
    case CHALLENGED:
    case HANDSHAKE:
      this.log.debug("Authentication succeeded");
      authState.setState(AuthProtocolState.SUCCESS);
      authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
      break;
    case SUCCESS:
      break;
    default:
      authState.setState(AuthProtocolState.UNCHALLENGED);
    }
    return false;
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

public boolean isAuthenticationRequested(
    final HttpHost host,
    final HttpResponse response,
    final AuthenticationStrategy authStrategy,
    final AuthState authState,
    final HttpContext context) {
  if (authStrategy.isAuthenticationRequested(host, response, context)) {
    this.log.debug("Authentication required");
    if (authState.getState() == AuthProtocolState.SUCCESS) {
      authStrategy.authFailed(host, authState.getAuthScheme(), context);
    }
    return true;
  } else {
    switch (authState.getState()) {
    case CHALLENGED:
    case HANDSHAKE:
      this.log.debug("Authentication succeeded");
      authState.setState(AuthProtocolState.SUCCESS);
      authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
      break;
    case SUCCESS:
      break;
    default:
      authState.setState(AuthProtocolState.UNCHALLENGED);
    }
    return false;
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

if (targetState != null && targetState.getState() == AuthProtocolState.UNCHALLENGED) {
  final AuthScheme authScheme = authCache.get(target);
  if (authScheme != null) {
if (proxy != null && proxyState != null && proxyState.getState() == AuthProtocolState.UNCHALLENGED) {
  final AuthScheme authScheme = authCache.get(proxy);
  if (authScheme != null) {

代码示例来源:origin: com.joyent.http-signature/apache-http-client-signature

/**
 * Determines if the given HTTP response response represents
 * an authentication challenge that was sent back as a result
 * of authentication failure.
 *
 * @param authHost authentication host.
 * @param response HTTP response.
 * @param context  HTTP context.
 * @return {@code true} if user authentication is required,
 *                      {@code false} otherwise.
 */
@Override
public boolean isAuthenticationRequested(final HttpHost authHost,
                     final HttpResponse response,
                     final HttpContext context) {
  final StatusLine line = response.getStatusLine();
  final int code = line.getStatusCode();
  final HttpClientContext clientContext = HttpClientContext.adapt(context);
  final AuthState authState = clientContext.getTargetAuthState();
  final AuthProtocolState authProtocolState = authState.getState();
  if (code == HttpStatus.SC_UNAUTHORIZED) {
    if (authProtocolState.equals(AuthProtocolState.CHALLENGED)) {
      clientContext.getTargetAuthState().setState(AuthProtocolState.FAILURE);
      authFailed(authHost, authState.getAuthScheme(), context);
    }
    return true;
  }
  return clientContext.getTargetAuthState() == null;
}

代码示例来源:origin: ibinti/bugvm

AuthScheme authScheme = authState.getAuthScheme();
Credentials creds = authState.getCredentials();
switch (authState.getState()) { // TODO add UNCHALLENGED and HANDSHAKE cases
case FAILURE:
  return;

代码示例来源:origin: com.bugvm/bugvm-rt

AuthScheme authScheme = authState.getAuthScheme();
Credentials creds = authState.getCredentials();
switch (authState.getState()) { // TODO add UNCHALLENGED and HANDSHAKE cases
case FAILURE:
  return;

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

AuthScheme authScheme = authState.getAuthScheme();
Credentials creds = authState.getCredentials();
switch (authState.getState()) { // TODO add UNCHALLENGED and HANDSHAKE cases
case FAILURE:
  return;

相关文章