com.squareup.okhttp.Credentials Java Examples

The following examples show how to use com.squareup.okhttp.Credentials. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OkHttpClientTransport.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
private Request createHttpProxyRequest(InetSocketAddress address, String proxyUsername,
    String proxyPassword) {
  HttpUrl tunnelUrl = new HttpUrl.Builder()
      .scheme("https")
      .host(address.getHostName())
      .port(address.getPort())
      .build();
  Request.Builder request = new Request.Builder()
      .url(tunnelUrl)
      .header("Host", tunnelUrl.host() + ":" + tunnelUrl.port())
      .header("User-Agent", userAgent);

  // If we have proxy credentials, set them right away
  if (proxyUsername != null && proxyPassword != null) {
    request.header("Proxy-Authorization", Credentials.basic(proxyUsername, proxyPassword));
  }
  return request.build();
}
 
Example #2
Source File: OkHttpClientTransport.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
private Request createHttpProxyRequest(InetSocketAddress address, String proxyUsername,
    String proxyPassword) {
  HttpUrl tunnelUrl = new HttpUrl.Builder()
      .scheme("https")
      .host(address.getHostName())
      .port(address.getPort())
      .build();
  Request.Builder request = new Request.Builder()
      .url(tunnelUrl)
      .header("Host", tunnelUrl.host() + ":" + tunnelUrl.port())
      .header("User-Agent", userAgent);

  // If we have proxy credentials, set them right away
  if (proxyUsername != null && proxyPassword != null) {
    request.header("Proxy-Authorization", Credentials.basic(proxyUsername, proxyPassword));
  }
  return request.build();
}
 
Example #3
Source File: MultiAuthenticator.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public Request authenticateProxy(Proxy proxy, Response response) throws IOException {
    String credential = Credentials.basic(proxyUsername, proxyPassword);
    return response.request()
            .newBuilder()
            .header("Proxy-Authorization", credential)
            .build();
}
 
Example #4
Source File: HttpBasicAuth.java    From nifi-swagger-client with Apache License 2.0 5 votes vote down vote up
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
    if (username == null && password == null) {
        return;
    }
    headerParams.put("Authorization", Credentials.basic(
        username == null ? "" : username,
        password == null ? "" : password));
}
 
Example #5
Source File: HttpBasicAuth.java    From swaggy-jenkins with MIT License 5 votes vote down vote up
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
    if (username == null && password == null) {
        return;
    }
    headerParams.put("Authorization", Credentials.basic(
        username == null ? "" : username,
        password == null ? "" : password));
}
 
Example #6
Source File: HttpBasicAuth.java    From nifi-api-client-java with Apache License 2.0 5 votes vote down vote up
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
    if (username == null && password == null) {
        return;
    }
    headerParams.put("Authorization", Credentials.basic(
        username == null ? "" : username,
        password == null ? "" : password));
}
 
Example #7
Source File: HttpBasicAuth.java    From swagger-aem with Apache License 2.0 5 votes vote down vote up
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
    if (username == null && password == null) {
        return;
    }
    headerParams.put("Authorization", Credentials.basic(
        username == null ? "" : username,
        password == null ? "" : password));
}
 
Example #8
Source File: HttpBasicAuth.java    From ariADDna with Apache License 2.0 5 votes vote down vote up
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
    if (username == null && password == null) {
        return;
    }
    headerParams.put("Authorization", Credentials.basic(
            username == null ? "" : username,
            password == null ? "" : password));
}
 
Example #9
Source File: HttpBasicAuth.java    From director-sdk with Apache License 2.0 5 votes vote down vote up
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
    if (username == null && password == null) {
        return;
    }
    headerParams.put("Authorization", Credentials.basic(
        username == null ? "" : username,
        password == null ? "" : password));
}
 
Example #10
Source File: HttpBasicAuth.java    From oxd with Apache License 2.0 5 votes vote down vote up
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
    if (username == null && password == null) {
        return;
    }
    headerParams.put("Authorization", Credentials.basic(
        username == null ? "" : username,
        password == null ? "" : password));
}
 
Example #11
Source File: ApiClient.java    From octodroid with MIT License 4 votes vote down vote up
public void authorization(String username, String password) {
    this.authorization = Credentials.basic(username, password);
}