-
Bug
-
Resolution: Fixed
-
P2
-
7
-
b04
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2210488 | 7u2 | Weijun Wang | P2 | Resolved | Fixed | b06 |
Platform: Windows, Solaris
JDK: Oracle JDK7
(not reproducible on Sun's JDK6 as NTLMServer is not present there)
The com.sun.security.sasl.ntlm.NTLMServer implementaiton of method
http://download.java.net/jdk7/docs/api/javax/security/sasl/SaslClientFactory.html#createSaslClient%28java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.util.Map,%20javax.security.auth.callback.CallbackHandler%29
Throws "java.lang.NullPointerException: username/password cannot be null" instead of specified
Throws:
SaslException - If cannot create a SaslClient because of an error.
Please see the following code sample:
--------------------------------------------------------------------------------------------
package sasl;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.sasl.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
public class CreateSaslClient {
public static void main(String[] args) throws SaslException {
ArrayList<SaslClientFactory> list = Collections.list(Sasl.getSaslClientFactories());
for (SaslClientFactory clientFactory : list) {
System.err.println("clientFactory = " + clientFactory);
String[] mechanismNames = clientFactory.getMechanismNames(null);
if (mechanismNames.length == 1 && "NTLM".equals(mechanismNames[0])) {
System.err.println("Calling createSaslClient(..)");
clientFactory.createSaslClient(
new String[] {"NTLM"}, "abc", "ldap", "server", null, new CallbackHandler() {
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { }
});
}
}
}
}
--------------------------------------------------------------------------------------------
The output will look like:
clientFactory = com.sun.security.sasl.gsskerb.FactoryImpl@1fd9645
clientFactory = com.sun.security.sasl.ntlm.FactoryImpl@f00b97
Calling createSaslClient(..)
Exception in thread "main" java.lang.NullPointerException: username/password cannot be null
at com.sun.security.ntlm.Client.<init>(Client.java:79)
at com.sun.security.sasl.ntlm.NTLMClient.<init>(NTLMClient.java:163)
at com.sun.security.sasl.ntlm.FactoryImpl.createSaslClient(FactoryImpl.java:73)
at sasl.CreateSaslClient.main
JDK: Oracle JDK7
(not reproducible on Sun's JDK6 as NTLMServer is not present there)
The com.sun.security.sasl.ntlm.NTLMServer implementaiton of method
http://download.java.net/jdk7/docs/api/javax/security/sasl/SaslClientFactory.html#createSaslClient%28java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.util.Map,%20javax.security.auth.callback.CallbackHandler%29
Throws "java.lang.NullPointerException: username/password cannot be null" instead of specified
Throws:
SaslException - If cannot create a SaslClient because of an error.
Please see the following code sample:
--------------------------------------------------------------------------------------------
package sasl;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.sasl.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
public class CreateSaslClient {
public static void main(String[] args) throws SaslException {
ArrayList<SaslClientFactory> list = Collections.list(Sasl.getSaslClientFactories());
for (SaslClientFactory clientFactory : list) {
System.err.println("clientFactory = " + clientFactory);
String[] mechanismNames = clientFactory.getMechanismNames(null);
if (mechanismNames.length == 1 && "NTLM".equals(mechanismNames[0])) {
System.err.println("Calling createSaslClient(..)");
clientFactory.createSaslClient(
new String[] {"NTLM"}, "abc", "ldap", "server", null, new CallbackHandler() {
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { }
});
}
}
}
}
--------------------------------------------------------------------------------------------
The output will look like:
clientFactory = com.sun.security.sasl.gsskerb.FactoryImpl@1fd9645
clientFactory = com.sun.security.sasl.ntlm.FactoryImpl@f00b97
Calling createSaslClient(..)
Exception in thread "main" java.lang.NullPointerException: username/password cannot be null
at com.sun.security.ntlm.Client.<init>(Client.java:79)
at com.sun.security.sasl.ntlm.NTLMClient.<init>(NTLMClient.java:163)
at com.sun.security.sasl.ntlm.FactoryImpl.createSaslClient(FactoryImpl.java:73)
at sasl.CreateSaslClient.main
- backported by
-
JDK-2210488 NTML impl of SaslClientFactory throws NPE instead of SaslException
-
- Resolved
-