private static String computeBasicAuthentication(Realm realm) { return realm != null ? computeBasicAuthentication(realm.getPrincipal(), realm.getPassword(), realm.getCharset()) : null; }
authorizationHeader = computeBasicAuthentication(realm); break; case DIGEST:
public static String perRequestProxyAuthorizationHeader(Request request, Realm proxyRealm) { String proxyAuthorization = null; if (proxyRealm != null && proxyRealm.isUsePreemptiveAuth()) { switch (proxyRealm.getScheme()) { case BASIC: proxyAuthorization = computeBasicAuthentication(proxyRealm); break; case DIGEST: if (isNonEmpty(proxyRealm.getNonce())) { // update realm with request information proxyRealm = realm(proxyRealm) .setUri(request.getUri()) .setMethodName(request.getMethod()) .build(); proxyAuthorization = computeDigestAuthentication(proxyRealm); } break; case NTLM: case KERBEROS: case SPNEGO: // NTLM, KERBEROS and SPNEGO are only set on the first request with a connection, // see perConnectionProxyAuthorizationHeader break; default: throw new IllegalStateException("Invalid Authentication scheme " + proxyRealm.getScheme()); } } return proxyAuthorization; }
public static String computeBasicAuthentication(ProxyServer proxyServer) { return computeBasicAuthentication(proxyServer.getPrincipal(), proxyServer.getPassword(), proxyServer.getCharset()); }
public static String computeBasicAuthentication(Realm realm) { return computeBasicAuthentication(realm.getPrincipal(), realm.getPassword(), realm.getCharset()); }
public static String perRequestProxyAuthorizationHeader(Request request, ProxyServer proxyServer, Realm realm, boolean connect) { String proxyAuthorization = null; if (!connect && proxyServer != null && proxyServer.getScheme() == AuthScheme.BASIC) { proxyAuthorization = computeBasicAuthentication(proxyServer); } else if (realm != null && realm.getUsePreemptiveAuth() && realm.isTargetProxy()) { switch (realm.getScheme()) { case BASIC: proxyAuthorization = computeBasicAuthentication(realm); break; case DIGEST: if (isNonEmpty(realm.getNonce())) proxyAuthorization = computeDigestAuthentication(realm); break; case NTLM: case KERBEROS: case SPNEGO: // NTLM, KERBEROS and SPNEGO are only set on the first request, // see firstRequestOnlyAuthorizationHeader case NONE: break; default: throw new IllegalStateException("Invalid Authentication " + realm); } } return proxyAuthorization; }
public static String perRequestAuthorizationHeader(Request request, Realm realm) { String authorizationHeader = null; if (realm != null && realm.getUsePreemptiveAuth()) { switch (realm.getScheme()) { case BASIC: authorizationHeader = computeBasicAuthentication(realm); break; case DIGEST: if (isNonEmpty(realm.getNonce())) authorizationHeader = computeDigestAuthentication(realm); break; case NTLM: case KERBEROS: case SPNEGO: // NTLM, KERBEROS and SPNEGO are only set on the first request, // see firstRequestOnlyAuthorizationHeader case NONE: break; default: throw new IllegalStateException("Invalid Authentication " + realm); } } return authorizationHeader; } }