本文整理汇总了Java中org.apache.http.client.config.AuthSchemes.SPNEGO属性的典型用法代码示例。如果您正苦于以下问题:Java AuthSchemes.SPNEGO属性的具体用法?Java AuthSchemes.SPNEGO怎么用?Java AuthSchemes.SPNEGO使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.http.client.config.AuthSchemes
的用法示例。
在下文中一共展示了AuthSchemes.SPNEGO属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toApacheAuthenticationScheme
/**
* Convert the customer-facing authentication method into an apache-specific authentication method.
*/
private String toApacheAuthenticationScheme(ProxyAuthenticationMethod authenticationMethod) {
if (authenticationMethod == null) {
throw new IllegalStateException("The configured proxy authentication methods must not be null.");
}
switch (authenticationMethod) {
case NTLM: return AuthSchemes.NTLM;
case BASIC: return AuthSchemes.BASIC;
case DIGEST: return AuthSchemes.DIGEST;
case SPNEGO: return AuthSchemes.SPNEGO;
case KERBEROS: return AuthSchemes.KERBEROS;
default: throw new IllegalStateException("Unknown authentication scheme: " + authenticationMethod);
}
}
示例2: KerberosHttpClient
private KerberosHttpClient(String user, String password, String domain, String kdc) {
try {
File krb5Config = createKrb5Configuration(domain, kdc);
File loginConfig = createLoginConfiguration();
System.setProperty("java.security.auth.login.config", loginConfig.toURI().toString());
System.setProperty("java.security.krb5.conf", krb5Config.toURI().toString());
System.setProperty("sun.security.krb5.debug", "false");
//Change this property to true, if you want debug output.
System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
RegistryBuilder<AuthSchemeProvider> registryBuilder = RegistryBuilder.create();
String id = AuthSchemes.SPNEGO;
SPNegoSchemeFactory schemeFactory = new SPNegoSchemeFactory(SKIP_PORT_AT_KERBEROS_DATABASE_LOOKUP);
Lookup<AuthSchemeProvider> authSchemeRegistry = registryBuilder.register(id, schemeFactory).build();
client = HttpClients.custom().setDefaultAuthSchemeRegistry(authSchemeRegistry)
.setConnectionManager(createConnectionManager()).build();
httpContext = getHttpContext();
loginContext = getLoginContext(user, password);
//without it, authentication will be failed.
final Subject subject = loginContext.getSubject();
final HttpGet get = new HttpGet(KerberosBpmClient.this.rootUri);
Subject.doAs(subject, this.privilegedExecute(get, httpContext));
} catch (Exception e) {
logger.error("Can't create Kerberos client!");
e.printStackTrace();
throw new RuntimeException(e);
}
}
示例3: WindowsNegotiateScheme
public WindowsNegotiateScheme(final String scheme, final String servicePrincipalName) {
super();
this.scheme = (scheme == null) ? AuthSchemes.SPNEGO : scheme;
this.challenge = null;
this.continueNeeded = true;
this.servicePrincipalName = servicePrincipalName;
if (this.log.isDebugEnabled()) {
this.log.debug("Created WindowsNegotiateScheme using " + this.scheme);
}
}
示例4: create
@Override
public AuthScheme create(final HttpContext context) {
return new WindowsNegotiateScheme(AuthSchemes.SPNEGO, servicePrincipalName);
}
示例5: getSchemeName
@Override
public String getSchemeName() {
return AuthSchemes.SPNEGO;
}