Java Code Examples for org.apache.http.auth.AuthScope#ANY
The following examples show how to use
org.apache.http.auth.AuthScope#ANY .
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: UriStrategy.java From activemq-artemis with Apache License 2.0 | 6 votes |
protected void initAuthentication() { if (registration.getAuthenticationMechanism() != null) { if (registration.getAuthenticationMechanism().getType() instanceof BasicAuth) { BasicAuth basic = (BasicAuth) registration.getAuthenticationMechanism().getType(); UsernamePasswordCredentials creds = new UsernamePasswordCredentials(basic.getUsername(), basic.getPassword()); AuthScope authScope = new AuthScope(AuthScope.ANY); ((DefaultHttpClient) client).getCredentialsProvider().setCredentials(authScope, creds); localContext = new BasicHttpContext(); // Generate BASIC scheme object and stick it to the local execution context BasicScheme basicAuth = new BasicScheme(); localContext.setAttribute("preemptive-auth", basicAuth); // Add as the first request interceptor ((DefaultHttpClient) client).addRequestInterceptor(new PreemptiveAuth(), 0); executor.setHttpContext(localContext); } } }
Example 2
Source File: WebAuthentication.java From fess with Apache License 2.0 | 6 votes |
private AuthScope getAuthScope() { if (StringUtil.isBlank(getHostname())) { return AuthScope.ANY; } int p; if (getPort() == null) { p = AuthScope.ANY_PORT; } else { p = getPort(); } String r = getAuthRealm(); if (StringUtil.isBlank(r)) { r = AuthScope.ANY_REALM; } String s = getProtocolScheme(); if (StringUtil.isBlank(s) || Constants.NTLM.equals(s)) { s = AuthScope.ANY_SCHEME; } return new AuthScope(getHostname(), p, r, s); }
Example 3
Source File: AsyncHttpClient.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
public void setBasicAuth(String s, String s1, AuthScope authscope, boolean flag) { UsernamePasswordCredentials usernamepasswordcredentials = new UsernamePasswordCredentials(s, s1); CredentialsProvider credentialsprovider = c.getCredentialsProvider(); if (authscope == null) { authscope = AuthScope.ANY; } credentialsprovider.setCredentials(authscope, usernamepasswordcredentials); setAuthenticationPreemptive(flag); }
Example 4
Source File: SyncHttpClient.java From sealtalk-android with MIT License | 2 votes |
/** * Sets basic authentication for the request. Uses AuthScope.ANY. This is * the same as setBasicAuth('username','password',AuthScope.ANY) * * @param username * Basic Auth username * @param password * Basic Auth password */ public void setBasicAuth(String username, String password) { AuthScope scope = AuthScope.ANY; setBasicAuth(username, password, scope); }
Example 5
Source File: AsyncHttpClient.java From sealtalk-android with MIT License | 2 votes |
/** * Sets basic authentication for the request. Uses AuthScope.ANY. This is the same as * setBasicAuth('username','password',AuthScope.ANY) * * @param username Basic Auth username * @param password Basic Auth password */ public void setBasicAuth(String username, String password) { AuthScope scope = AuthScope.ANY; setBasicAuth(username, password, scope); }
Example 6
Source File: AsyncHttpClient.java From Roid-Library with Apache License 2.0 | 2 votes |
/** * Sets basic authentication for the request. Uses AuthScope.ANY. This is * the same as setBasicAuth('username','password',AuthScope.ANY) * * @param username * @param password */ public void setBasicAuth(String user, String pass) { AuthScope scope = AuthScope.ANY; setBasicAuth(user, pass, scope); }
Example 7
Source File: AsyncHttpClient.java From Libraries-for-Android-Developers with MIT License | 2 votes |
/** * Sets basic authentication for the request. Uses AuthScope.ANY. This is the same as * setBasicAuth('username','password',AuthScope.ANY) * * @param username Basic Auth username * @param password Basic Auth password */ public void setBasicAuth(String username, String password) { AuthScope scope = AuthScope.ANY; setBasicAuth(username, password, scope); }