List of usage examples for org.apache.http.auth AuthScope ANY_PORT
int ANY_PORT
To view the source code for org.apache.http.auth AuthScope ANY_PORT.
Click Source Link
From source file:com.kms.core.io.HttpUtil_In.java
public static CloseableHttpClient getHttpClient(final String SoeID, final String Password, final int type) { CloseableHttpClient httpclient;/*from www . j ava 2s. c o m*/ // Auth Scheme final Registry<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create() .register(AuthSchemes.NTLM, new NTLMSchemeFactory()) .register(AuthSchemes.BASIC, new BasicSchemeFactory()) .register(AuthSchemes.DIGEST, new DigestSchemeFactory()) .register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory()) .register(AuthSchemes.KERBEROS, new KerberosSchemeFactory()).build(); // NTLM final CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), //AuthScope("localhost", 8080), new NTCredentials(SoeID, Password, "dummy", "APAC")); //new NTCredentials( SoeID, Password,"APACKR081WV058", "APAC" )); // ------------- cookie start ------------------------ // Auction // Create a local instance of cookie store final CookieStore cookieStore = new BasicCookieStore(); // Cookie . final BasicClientCookie cookie = new BasicClientCookie("songdal_view", "YES"); cookie.setVersion(0); cookie.setDomain(".scourt.go.kr"); cookie.setPath("/"); cookieStore.addCookie(cookie); // ------------- cookie end ------------------------ if (type == 0) // TYPE.AuctionInput { // HTTP Client httpclient = HttpClients.custom().setDefaultAuthSchemeRegistry(authSchemeRegistry) .setDefaultCredentialsProvider(credsProvider).build(); } else // SagunInput { // HTTP Client httpclient = HttpClients.custom().setDefaultAuthSchemeRegistry(authSchemeRegistry) .setDefaultCredentialsProvider(credsProvider).setDefaultCookieStore(cookieStore).build(); } return httpclient; }
From source file:info.ajaxplorer.client.http.AjxpHttpClient.java
public void refreshCredentials(String user, String pass) { this.getCredentialsProvider().setCredentials( new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM), new UsernamePasswordCredentials(user, pass)); }
From source file:org.apache.maven.wagon.providers.http.BasicAuthScopeTest.java
/** * Test AuthScope override for all values overridden with "ANY" *//*from w w w . ja v a 2s .c o m*/ @Test public void testGetScopeAllAny() { BasicAuthScope scope = new BasicAuthScope(); scope.setHost("ANY"); scope.setPort("ANY"); scope.setRealm("ANY"); AuthScope authScope = scope.getScope("original.host.com", 3456); Assert.assertEquals(AuthScope.ANY_HOST, authScope.getHost()); Assert.assertEquals(AuthScope.ANY_PORT, authScope.getPort()); Assert.assertEquals(AuthScope.ANY_REALM, authScope.getRealm()); }
From source file:org.cerberus.util.HTTPSession.java
/** * Start a HTTP Session with authorisation * * @param username//from w ww . j a v a2 s . co m * @param password */ public void startSession(String username, String password) { // Create your httpclient client = new DefaultHttpClient(); client.getParams().setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true); // Then provide the right credentials client.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials(username, password)); // Generate BASIC scheme object and stick it to the execution context basicAuth = new BasicScheme(); context = new BasicHttpContext(); context.setAttribute("preemptive-auth", basicAuth); // Add as the first (because of the zero) request interceptor // It will first intercept the request and preemptively initialize the authentication scheme if there is not client.addRequestInterceptor(new PreemptiveAuth(), 0); }
From source file:org.jugvale.peoplemanagement.client.service.RESTPersonService.java
private void createClient() { Credentials credentials = new UsernamePasswordCredentials(username, password); DefaultHttpClient httpClient = new DefaultHttpClient(new ThreadSafeClientConnManager()); httpClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), credentials);//from www .ja va2 s . co m client = new ResteasyClientBuilder().httpEngine(new ApacheHttpClient4Engine(httpClient)).build(); }
From source file:org.mule.jenkins.Helper.java
public void setClientInfo() { client.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials(user, password)); BasicScheme basicAuth = new BasicScheme(); context.setAttribute("preemptive-auth", basicAuth); client.addRequestInterceptor(new PreemptiveAuth(), 0); }
From source file:ca.sqlpower.enterprise.ClientSideSessionUtils.java
public static HttpClient createHttpClient(SPServerInfo serviceInfo, CookieStore cookieStore) { HttpParams params = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(params, 2000); DefaultHttpClient httpClient = new DefaultHttpClient(params); httpClient.setCookieStore(cookieStore); httpClient.getCredentialsProvider().setCredentials( new AuthScope(serviceInfo.getServerAddress(), AuthScope.ANY_PORT), new UsernamePasswordCredentials(serviceInfo.getUsername(), serviceInfo.getPassword())); return httpClient; }
From source file:org.dmfs.android.authenticator.handlers.BasicHttpClientAuthenticationHandler.java
@Override public void authenticate(AbstractHttpClient client) { // just set the credentials assuming that proper authentication schemes are registered with the AbstractHttpClient. CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, mAuthToken.getRealm()), new UsernamePasswordCredentials(mAuthToken.getUsername(), mAuthToken.getPassword())); client.setCredentialsProvider(credsProvider); }
From source file:org.gradle.internal.resource.transport.http.HttpClientConfigurer.java
private void configureCredentials(DefaultHttpClient httpClient, PasswordCredentials credentials) { String username = credentials.getUsername(); if (username != null && username.length() > 0) { useCredentials(httpClient, credentials, AuthScope.ANY_HOST, AuthScope.ANY_PORT); // Use preemptive authorisation if no other authorisation has been established httpClient.addRequestInterceptor(new PreemptiveAuth(new BasicScheme()), 0); }/*from w w w .j av a2s.c o m*/ }