本文整理了Java中org.apache.commons.httpclient.auth.AuthPolicy
类的一些代码示例,展示了AuthPolicy
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AuthPolicy
类的具体详情如下:
包路径:org.apache.commons.httpclient.auth.AuthPolicy
类名称:AuthPolicy
[英]Authentication policy class. The Authentication policy provides corresponding authentication scheme interfrace for a given type of authorization challenge.
The following specifications are provided:
代码示例来源:origin: commons-httpclient/commons-httpclient
AuthPolicy.AUTH_SCHEME_PRIORITY);
if (authPrefs == null || authPrefs.isEmpty()) {
authPrefs = AuthPolicy.getDefaultAuthPrefs();
authscheme = AuthPolicy.getAuthScheme(id);
} catch (IllegalStateException e) {
throw new AuthChallengeException(e.getMessage());
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Preemptively assigns Basic authentication scheme.
*/
public void setPreemptive() {
if (!this.preemptive) {
if (this.authScheme != null) {
throw new IllegalStateException("Authentication state already initialized");
}
this.authScheme = AuthPolicy.getAuthScheme(PREEMPTIVE_AUTH_SCHEME);
this.preemptive = true;
}
}
代码示例来源:origin: org.apache.abdera/abdera-client
/**
* Register a new authentication scheme.
*
* @param name
* @param scheme
*/
public static void registerScheme(String name, Class<? extends AuthScheme> scheme) {
AuthPolicy.registerAuthScheme(name, scheme);
}
代码示例来源:origin: org.apache.abdera/abdera-client
/**
* Configure the client to use the default authentication scheme settings
*/
public AbderaClient setAuthenticationSchemeDefaults() {
List authPrefs = AuthPolicy.getDefaultAuthPrefs();
client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
return this;
}
代码示例来源:origin: org.apache.abdera/abdera-client
/**
* Unregister a specific authentication scheme
*
* @param name The name of the authentication scheme (e.g. "basic", "digest", etc)
*/
public static void unregisterScheme(String name) {
AuthPolicy.unregisterAuthScheme(name);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient
/**
* Preemptively assigns Basic authentication scheme.
*/
public void setPreemptive() {
if (!this.preemptive) {
if (this.authScheme != null) {
throw new IllegalStateException("Authentication state already initialized");
}
this.authScheme = AuthPolicy.getAuthScheme(PREEMPTIVE_AUTH_SCHEME);
this.preemptive = true;
}
}
代码示例来源:origin: org.sonatype.nexus.restlight/nexus-restlight-test-harness
protected void setupAuthentication( final HttpClient client, final String user, final String password )
{
UsernamePasswordCredentials creds = new UsernamePasswordCredentials( user, password );
List<String> policies = new ArrayList<String>();
policies.add( NxBasicScheme.POLICY_NAME );
AuthPolicy.registerAuthScheme( NxBasicScheme.POLICY_NAME, NxBasicScheme.class );
client.getParams().setParameter( AuthPolicy.AUTH_SCHEME_PRIORITY, policies );
client.getState().setCredentials( AuthScope.ANY, creds );
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient
AuthPolicy.AUTH_SCHEME_PRIORITY);
if (authPrefs == null || authPrefs.isEmpty()) {
authPrefs = AuthPolicy.getDefaultAuthPrefs();
authscheme = AuthPolicy.getAuthScheme(id);
} catch (IllegalStateException e) {
throw new AuthChallengeException(e.getMessage());
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient
/**
* Preemptively assigns Basic authentication scheme.
*/
public void setPreemptive() {
if (!this.preemptive) {
if (this.authScheme != null) {
throw new IllegalStateException("Authentication state already initialized");
}
this.authScheme = AuthPolicy.getAuthScheme(PREEMPTIVE_AUTH_SCHEME);
this.preemptive = true;
}
}
代码示例来源:origin: mguessan/davmail
/**
* Enable NTLM authentication on http client
*
* @param httpClient HttpClient instance
*/
public static void addNTLM(HttpClient httpClient) {
// disable preemptive authentication
httpClient.getParams().setParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, false);
// register the jcifs based NTLMv2 implementation
AuthPolicy.registerAuthScheme(AuthPolicy.NTLM, NTLMv2Scheme.class);
ArrayList<String> authPrefs = new ArrayList<String>();
authPrefs.add(AuthPolicy.NTLM);
authPrefs.add(AuthPolicy.DIGEST);
authPrefs.add(AuthPolicy.BASIC);
httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
// make sure NTLM is always active
needNTLM = true;
// separate domain from username in credentials
AuthScope authScope = new AuthScope(null, -1);
NTCredentials credentials = (NTCredentials) httpClient.getState().getCredentials(authScope);
if (credentials != null && credentials.getDomain() == null) {
setCredentials(httpClient, credentials.getUserName(), credentials.getPassword());
}
}
代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient
AuthPolicy.AUTH_SCHEME_PRIORITY);
if (authPrefs == null || authPrefs.isEmpty()) {
authPrefs = AuthPolicy.getDefaultAuthPrefs();
authscheme = AuthPolicy.getAuthScheme(id);
} catch (IllegalStateException e) {
throw new AuthChallengeException(e.getMessage());
代码示例来源:origin: org.apache.commons/httpclient
/**
* Preemptively assigns Basic authentication scheme.
*/
public void setPreemptive() {
if (!this.preemptive) {
if (this.authScheme != null) {
throw new IllegalStateException("Authentication state already initialized");
}
this.authScheme = AuthPolicy.getAuthScheme(PREEMPTIVE_AUTH_SCHEME);
this.preemptive = true;
}
}
代码示例来源:origin: nextcloud/android-library
@Override
public void applyTo(OwnCloudClient client) {
AuthPolicy.registerAuthScheme(BearerAuthScheme.AUTH_POLICY, BearerAuthScheme.class);
List<String> authPrefs = new ArrayList<String>(1);
authPrefs.add(BearerAuthScheme.AUTH_POLICY);
client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
client.getParams().setAuthenticationPreemptive(true);
client.getParams().setCredentialCharset(OwnCloudCredentialsFactory.CREDENTIAL_CHARSET);
client.getState().setCredentials(
AuthScope.ANY,
new BearerCredentials(mAccessToken)
);
}
代码示例来源:origin: org.apache.commons/httpclient
AuthPolicy.AUTH_SCHEME_PRIORITY);
if (authPrefs == null || authPrefs.isEmpty()) {
authPrefs = AuthPolicy.getDefaultAuthPrefs();
authscheme = AuthPolicy.getAuthScheme(id);
} catch (IllegalStateException e) {
throw new AuthChallengeException(e.getMessage());
代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient
/**
* Preemptively assigns Basic authentication scheme.
*/
public void setPreemptive() {
if (!this.preemptive) {
if (this.authScheme != null) {
throw new IllegalStateException("Authentication state already initialized");
}
this.authScheme = AuthPolicy.getAuthScheme(PREEMPTIVE_AUTH_SCHEME);
this.preemptive = true;
}
}
代码示例来源:origin: mguessan/davmail
AuthPolicy.registerAuthScheme("Negotiate", SpNegoScheme.class);
ArrayList<String> authPrefs = new ArrayList<String>();
authPrefs.add("Negotiate");
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient
AuthPolicy.AUTH_SCHEME_PRIORITY);
if (authPrefs == null || authPrefs.isEmpty()) {
authPrefs = AuthPolicy.getDefaultAuthPrefs();
authscheme = AuthPolicy.getAuthScheme(id);
} catch (IllegalStateException e) {
throw new AuthChallengeException(e.getMessage());
内容来源于网络,如有侵权,请联系作者删除!