.setUri(request.getUri()) .setMethodName(request.getMethod()) .setUsePreemptiveAuth(true) .build(); RequestBuilder builder = new RequestBuilder(request);
.setUsePreemptiveAuth(true)// .parseProxyAuthenticateHeader(proxyAuthHeaders.get(0))// .build();
.setUsePreemptiveAuth(true)// .parseWWWAuthenticateHeader(authHeaders.get(0))// .build();
private Realm realm(boolean preemptive) { return (new Realm.RealmBuilder()).setPrincipal(user).setPassword(admin).setUsePreemptiveAuth(preemptive).build(); }
@Test(groups = { "standalone", "default_provider" }) public void basicAuthTestPreemtiveTest() throws Exception, ExecutionException, TimeoutException, InterruptedException { try (AsyncHttpClient client = getAsyncHttpClient(null)) { setUpServerNoAuth(); AsyncHttpClient.BoundRequestBuilder r = client.prepareGet(getTargetUrlNoAuth()) .setRealm((new Realm.RealmBuilder()).setScheme(AuthScheme.BASIC).setPrincipal(user).setPassword(admin).setUsePreemptiveAuth(true).build()); Future<Response> f = r.execute(); Response resp = f.get(3, TimeUnit.SECONDS); assertNotNull(resp); assertNotNull(resp.getHeader("X-Auth")); assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK); } finally { stopServerNoAuth(); } }
public Builder setRealmUsePreemptiveAuth(boolean usePreemptiveAuth) { realm().setUsePreemptiveAuth(usePreemptiveAuth); return this; }
public Builder setRealmUsePreemptiveAuth(boolean usePreemptiveAuth) { realm().setUsePreemptiveAuth(usePreemptiveAuth); return this; }
private Request auth(String username, String password, AuthScheme scheme) { this.setRealm((new RealmBuilder()).setScheme(scheme).setPrincipal(username).setPassword(password) .setUsePreemptiveAuth(true).build()); return this; }
public Builder setRealmUsePreemptiveAuth(boolean usePreemptiveAuth) { realm().setUsePreemptiveAuth(usePreemptiveAuth); return this; }
@Override public RequestBuilder withBasicAuth(final String username, final String password) { final Realm realm = new Realm.RealmBuilder(). setPrincipal(username). setPassword(password). setUsePreemptiveAuth(true). setScheme(Realm.AuthScheme.BASIC). build(); ningRequestBuilder.setRealm(realm); return this; }
private Realm getRealm( RemoteRepository repository, String credentialEncoding ) { Realm realm = null; Authentication a = repository.getAuthentication(); if ( a != null && a.getUsername() != null ) { realm = new Realm.RealmBuilder().setPrincipal( a.getUsername() ).setPassword( a.getPassword() ).setUsePreemptiveAuth( false ).setEnconding( credentialEncoding ).build(); } return realm; }
private WSRequest auth(String username, String password, AuthScheme scheme) { this.setRealm((new RealmBuilder()) .setScheme(scheme) .setPrincipal(username) .setPassword(password) .setUsePreemptiveAuth(true) .build()); return this; }
@Test public void preemptiveNTLMAuthTest() throws IOException, InterruptedException, ExecutionException { ntlmAuthTest(realmBuilderBase().setUsePreemptiveAuth(true)); } }
private Realm getRealm( RemoteRepository repository, String credentialEncoding ) { Realm realm = null; Authentication a = repository.getAuthentication(); if ( a != null && a.getUsername() != null ) { realm = new Realm.RealmBuilder().setPrincipal( a.getUsername() ).setPassword( a.getPassword() ).setUsePreemptiveAuth( false ).setEnconding( credentialEncoding ).build(); } return realm; }
private void doTest(boolean usePreemptiveAuth) throws UnknownHostException, InterruptedException, ExecutionException { try (AsyncHttpClient client = getAsyncHttpClient(new AsyncHttpClientConfig.Builder().build())) { Request request = new RequestBuilder("GET").setProxyServer(basicProxy()).setUrl(getTargetUrl()).setRealm( new Realm.RealmBuilder().setPrincipal("user").setPassword("passwd").setScheme(BASIC).setUsePreemptiveAuth(usePreemptiveAuth).build()).build(); Future<Response> responseFuture = client.executeRequest(request); Response response = responseFuture.get(); Assert.assertEquals(response.getStatusCode(), HttpServletResponse.SC_OK); Assert.assertTrue(getTargetUrl().endsWith(response.getHeader("target"))); } }
@Override public void preemptLogin(String username, String password) { if (username == null || password == null) { this.realm = null; } else { this.realm = new Realm.RealmBuilder() .setPrincipal(username) .setPassword(password) .setUsePreemptiveAuth(true) .build(); } }
.setUri(req.getUri()) .setMethodName(req.getMethod()) .setUsePreemptiveAuth(true) .parseWWWAuthenticateHeader(firstAuthHeader) .build();
public RealmBuilder clone(Realm clone) { return setRealmName(clone.getRealmName())// .setAlgorithm(clone.getAlgorithm())// .setMethodName(clone.getMethodName())// .setNc(clone.getNc())// .setNonce(clone.getNonce())// .setPassword(clone.getPassword())// .setPrincipal(clone.getPrincipal())// .setCharset(clone.getCharset())// .setOpaque(clone.getOpaque())// .setQop(clone.getQop())// .setScheme(clone.getScheme())// .setUri(clone.getUri())// .setUsePreemptiveAuth(clone.getUsePreemptiveAuth())// .setNtlmDomain(clone.getNtlmDomain())// .setNtlmHost(clone.getNtlmHost())// .setUseAbsoluteURI(clone.isUseAbsoluteURI())// .setOmitQuery(clone.isOmitQuery())// .setTargetProxy(clone.isTargetProxy()); }
public Builder setRealmUsePreemptiveAuth(boolean usePreemptiveAuth) { realm().setUsePreemptiveAuth(usePreemptiveAuth); return this; }