We have NTLM authentication from Java against MS Sharepoint working in all environments but from within Weblogic Server.
In WLS we see that Authenticator#getPasswordAuthentication
returns 'basic' instead of 'ntlm'. What could the reason for that behavior be? The same code works just fine if run standalone or from within Tomcat (using the same JVM).
The relevant code as follows:
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);
}
}