ntlmChallenge(ntlmHeader2, requestHeaders, realm, future); Realm newNtlmRealm2 = realm(realm) .setScheme(AuthScheme.NTLM) .setUsePreemptiveAuth(true) .build();
ntlmProxyChallenge(ntlmHeader2, requestHeaders, proxyRealm, future); Realm newNtlmRealm2 = realm(proxyRealm) .setScheme(AuthScheme.NTLM) .setUsePreemptiveAuth(true) .build();
private Zendesk(AsyncHttpClient client, String url, String username, String password) { this.logger = LoggerFactory.getLogger(Zendesk.class); this.closeClient = client == null; this.oauthToken = null; this.client = client == null ? new DefaultAsyncHttpClient() : client; this.url = url.endsWith("/") ? url + "api/v2" : url + "/api/v2"; if (username != null) { this.realm = new Realm.Builder(username, password) .setScheme(Realm.AuthScheme.BASIC) .setUsePreemptiveAuth(true) .build(); } else { if (password != null) { throw new IllegalStateException("Cannot specify token or password without specifying username"); } this.realm = null; } this.mapper = createMapper(); }
private synchronized AsyncHttpClient getAsyncHttpClient(Message message) { if (ahcclient == null) { DefaultAsyncHttpClientConfig.Builder builder = new DefaultAsyncHttpClientConfig.Builder(); AuthorizationPolicy ap = getEffectiveAuthPolicy(message); if (ap != null && (!StringUtils.isEmpty(ap.getAuthorizationType()) || !StringUtils.isEmpty(ap.getUserName()))) { Realm.Builder rb = new Realm.Builder(ap.getUserName(), ap.getPassword()); if (ap.getAuthorizationType() == null) { rb.setScheme(AuthScheme.BASIC); } else { rb.setScheme(AuthScheme.valueOf(ap.getAuthorizationType().toUpperCase())); } rb.setUsePreemptiveAuth(true); builder.setRealm(rb.build()); } AsyncHttpClientConfig config = builder.build(); ahcclient = new DefaultAsyncHttpClient(config); } return ahcclient; }
private synchronized AsyncHttpClient getAsyncHttpClient(Message message) { if (ahcclient == null) { DefaultAsyncHttpClientConfig.Builder builder = new DefaultAsyncHttpClientConfig.Builder(); AuthorizationPolicy ap = getEffectiveAuthPolicy(message); if (ap != null && (!StringUtils.isEmpty(ap.getAuthorizationType()) || !StringUtils.isEmpty(ap.getUserName()))) { Realm.Builder rb = new Realm.Builder(ap.getUserName(), ap.getPassword()); if (ap.getAuthorizationType() == null) { rb.setScheme(AuthScheme.BASIC); } else { rb.setScheme(AuthScheme.valueOf(ap.getAuthorizationType().toUpperCase())); } rb.setUsePreemptiveAuth(true); builder.setRealm(rb.build()); } AsyncHttpClientConfig config = builder.build(); ahcclient = new DefaultAsyncHttpClient(config); } return ahcclient; }
private void addAuth(BoundRequestBuilder requestBuilder) { if (credentials != null && credentials.getLogin() != null) { String password = Optional.ofNullable(credentials.getPassword()).orElse(""); Realm realm = new Realm.Builder(credentials.getLogin(), password).setUsePreemptiveAuth(true) .setScheme(Realm.AuthScheme.BASIC).build(); requestBuilder.setRealm(realm); } }
Realm auth(String username, String password, WSAuthScheme scheme) { Realm.AuthScheme authScheme = Realm.AuthScheme.valueOf(scheme.name()); return (new Realm.Builder(username, password)) .setScheme(authScheme) .setUsePreemptiveAuth(true) .build(); } }
public static Realm.Builder realm(Realm prototype) { return new Realm.Builder(prototype.getPrincipal(), prototype.getPassword()) .setRealmName(prototype.getRealmName()) .setAlgorithm(prototype.getAlgorithm()) .setNc(prototype.getNc()) .setNonce(prototype.getNonce()) .setCharset(prototype.getCharset()) .setOpaque(prototype.getOpaque()) .setQop(prototype.getQop()) .setScheme(prototype.getScheme()) .setUri(prototype.getUri()) .setUsePreemptiveAuth(prototype.isUsePreemptiveAuth()) .setNtlmDomain(prototype.getNtlmDomain()) .setNtlmHost(prototype.getNtlmHost()) .setUseAbsoluteURI(prototype.isUseAbsoluteURI()) .setOmitQuery(prototype.isOmitQuery()) .setServicePrincipalName(prototype.getServicePrincipalName()) .setUseCanonicalHostname(prototype.isUseCanonicalHostname()) .setCustomLoginConfig(prototype.getCustomLoginConfig()) .setLoginContextName(prototype.getLoginContextName()); }
public Builder parseWWWAuthenticateHeader(String headerLine) { setRealmName(match(headerLine, "realm")) .setNonce(match(headerLine, "nonce")) .setOpaque(match(headerLine, "opaque")) .setScheme(isNonEmpty(nonce) ? AuthScheme.DIGEST : AuthScheme.BASIC); String algorithm = match(headerLine, "algorithm"); if (isNonEmpty(algorithm)) { setAlgorithm(algorithm); } // FIXME qop is different with proxy? String rawQop = match(headerLine, "qop"); if (rawQop != null) { setQop(parseRawQop(rawQop)); } return this; }
public static Realm.Builder realm(AuthScheme scheme, String principal, String password) { return new Realm.Builder(principal, password) .setScheme(scheme); }
public Builder parseProxyAuthenticateHeader(String headerLine) { setRealmName(match(headerLine, "realm")) .setNonce(match(headerLine, "nonce")) .setOpaque(match(headerLine, "opaque")) .setScheme(isNonEmpty(nonce) ? AuthScheme.DIGEST : AuthScheme.BASIC); String algorithm = match(headerLine, "algorithm"); if (isNonEmpty(algorithm)) { setAlgorithm(algorithm); } // FIXME qop is different with proxy? setQop(match(headerLine, "qop")); return this; }