Java 类com.squareup.okhttp.OkAuthenticator 实例源码

项目:android-discourse    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 * and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode, RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url) throws IOException {
    String responseField;
    String requestField;
    if (responseCode == HTTP_UNAUTHORIZED) {
        responseField = "WWW-Authenticate";
        requestField = "Authorization";
    } else if (responseCode == HTTP_PROXY_AUTH) {
        responseField = "Proxy-Authenticate";
        requestField = "Proxy-Authorization";
    } else {
        throw new IllegalArgumentException(); // TODO: ProtocolException?
    }
    List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
    if (challenges.isEmpty()) {
        return false; // Could not find a challenge so end the request cycle.
    }
    Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH ? authenticator.authenticateProxy(proxy, url, challenges) : authenticator.authenticate(proxy, url, challenges);
    if (credential == null) {
        return false; // Could not satisfy the challenge so end the request cycle.
    }
    // Add authorization credentials, bypassing the already-connected check.
    successorRequestHeaders.set(requestField, credential.getHeaderValue());
    return true;
}
项目:platform_external_okhttp    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 * Returns a request for a subsequent attempt, or null if no further attempts
 * should be made.
 */
public static Request processAuthHeader(
    OkAuthenticator authenticator, Response response, Proxy proxy) throws IOException {
  String responseField;
  String requestField;
  if (response.code() == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (response.code() == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(response.headers(), responseField);
  if (challenges.isEmpty()) return null; // Could not find a challenge so end the request cycle.

  Request request = response.request();
  Credential credential = response.code() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, request.url(), challenges)
      : authenticator.authenticate(proxy, request.url(), challenges);
  if (credential == null) return null; // Couldn't satisfy the challenge so end the request cycle.

  // Add authorization credentials, bypassing the already-connected check.
  return request.newBuilder().header(requestField, credential.getHeaderValue()).build();
}
项目:LoRaWAN-Smart-Parking    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:LoRaWAN-Smart-Parking    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:smart-mirror-app    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:cordova-plugin-background-mode    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:multirotorstuff-vtx-calc    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:L.TileLayer.Cordova    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:cordova-android-tv    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:Cordova-Locale-Plugin    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:pubnub-rpi-smart-parking    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:IoTgo_Android_App    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:CanDoVS2015    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:krakn    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:krakn    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:krakn    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:krakn    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:krakn    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:posjs2    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:hustElectricity    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:Wetube    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:DemoArduinoAndroidCordovaBT    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:cordova-muse    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:MinWageCalc    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:hackmxdf-2015    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:bluemix-parking-meter    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:NgFileExplorer    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:CrossWalkAndroidStudio    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:CrossWalkAndroidStudio    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:gwt-material-phonegap    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:wototoplayer    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:NatuV1    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:RFIDPhonegapDemo    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:2048-5x5    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:SpotMyDive    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:pandacoinBalance    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:Angular-Firebase-Cordova-seed-with-simpleLogin    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:PicNik    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:cordovabrowser3    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}
项目:Cordova-Locale-Plugin    文件:HttpAuthenticator.java   
/**
 * React to a failed authorization response by looking up new credentials.
 *
 * @return true if credentials have been added to successorRequestHeaders
 *         and another request should be attempted.
 */
public static boolean processAuthHeader(OkAuthenticator authenticator, int responseCode,
    RawHeaders responseHeaders, RawHeaders successorRequestHeaders, Proxy proxy, URL url)
    throws IOException {
  String responseField;
  String requestField;
  if (responseCode == HTTP_UNAUTHORIZED) {
    responseField = "WWW-Authenticate";
    requestField = "Authorization";
  } else if (responseCode == HTTP_PROXY_AUTH) {
    responseField = "Proxy-Authenticate";
    requestField = "Proxy-Authorization";
  } else {
    throw new IllegalArgumentException(); // TODO: ProtocolException?
  }
  List<Challenge> challenges = parseChallenges(responseHeaders, responseField);
  if (challenges.isEmpty()) {
    return false; // Could not find a challenge so end the request cycle.
  }
  Credential credential = responseHeaders.getResponseCode() == HTTP_PROXY_AUTH
      ? authenticator.authenticateProxy(proxy, url, challenges)
      : authenticator.authenticate(proxy, url, challenges);
  if (credential == null) {
    return false; // Could not satisfy the challenge so end the request cycle.
  }
  // Add authorization credentials, bypassing the already-connected check.
  successorRequestHeaders.set(requestField, credential.getHeaderValue());
  return true;
}