すべての環境で動作するが、Weblogic Server内からはMS Sharepointに対するJavaのNTLM認証があります。オーセンティケータ#getPasswordAuthenticationはWeblogicのntlmの代わりにbasicを返します
WLSでは、Authenticator#getPasswordAuthentication
は、 'ntlm'の代わりに 'basic'を返します。その行動の理由は何でしょうか?同じコードは、スタンドアロンで実行される場合、またはTomcat内から(同じJVMを使用して)うまく動作します。
関連するコードは次のように:
NtlmAuthenticator authenticator = new NtlmAuthenticator(configParameters.getNtlmUsername(),
configParameters.getNtlmPassword(), configParameters.getNtlmDomain());
log.info("JVM running with security manager enabled: {}", System.getSecurityManager() != null);
// requires NetPermission 'setDefaultAuthenticator' if security manager enabled
Authenticator.setDefault(authenticator);
public class NtlmAuthenticator extends Authenticator {
private char[] password;
private String userAuthentication;
public NtlmAuthenticator(String username, String password, String domain) {
userAuthentication = username;
if (StringUtils.isNotBlank(domain)) {
// According to
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa380525(v=vs.85).aspx
userAuthentication = domain + "\\" + username;
}
this.password = password.toCharArray();
}
@Override
public PasswordAuthentication getPasswordAuthentication() {
log.debug("Scheme: '{}'", getRequestingScheme());
return new PasswordAuthentication(userAuthentication, password);
}
}