下面列出了org.apache.http.client.config.AuthSchemes#NTLM 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public Winrm4jTool(ConfigBag config) {
this.bag = checkNotNull(config, "config bag");
host = getRequiredConfig(config, PROP_HOST);
port = config.get(PROP_PORT);
useSecureWinrm = config.get(USE_HTTPS_WINRM);
authenticationScheme = config.get(USE_NTLM) ? AuthSchemes.NTLM : null;
computerName = Strings.isNonBlank(config.get(COMPUTER_NAME)) ? config.get(COMPUTER_NAME) : null;
user = getRequiredConfig(config, PROP_USER);
password = getRequiredConfig(config, PROP_PASSWORD);
execTries = getRequiredConfig(config, PROP_EXEC_TRIES);
execRetryDelay = getRequiredConfig(config, PROP_EXEC_RETRY_DELAY);
logCredentials = getRequiredConfig(config, LOG_CREDENTIALS);
operationTimeout = config.get(OPERATION_TIMEOUT);
retriesOfNetworkFailures = config.get(RETRIES_OF_NETWORK_FAILURES);
environment = config.get(ENVIRONMENT);
}
/**
* 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);
}
}
@Override
public AuthScheme create(final HttpContext context) {
return new BackportWindowsNegotiateScheme(AuthSchemes.NTLM, servicePrincipalName);
}