2010-11-17 43 views
0

我遇到了嘗試從我的Web服務中進行身份驗證的問題。這是失敗的代碼。AuthenticationNotSupportedException:WebSphere上的DIGEST-MD5

private InitialDirContext callDirectory(String password, 
      String usernameWithoutDomain) throws NamingException 
    { 
     InitialDirContext ctx; 
     Hashtable<String, String> env = new Hashtable<String, String>(); 

     env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); 
     env.put(Context.PROVIDER_URL, _ldapUrl); 
     env.put(Context.SECURITY_AUTHENTICATION, "DIGEST-MD5"); 
     env.put(Context.SECURITY_PRINCIPAL, usernameWithoutDomain); 
     env.put(Context.SECURITY_CREDENTIALS, password); 
     ctx = new InitialDirContext(env); 
     return ctx; 
    } 

此代碼對使用IBM的1.5 JVM在AIX上的Active Directory,但不在同一臺機器使用相同的虛擬機上的WebSphere中運行6.1的時候。

我試圖控制所有變量,到目前爲止,它看起來像WebSphere阻止了DIGEST-MD5 LDAP身份驗證。任何想法爲什麼?

這裏是堆棧跟蹤:

javax.naming.AuthenticationNotSupportedException: DIGEST-MD5 
    at com.sun.jndi.ldap.sasl.LdapSasl.saslBind(LdapSasl.java:115) 
    at com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:229) 
    at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2652) 
    at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:298) 
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:190) 
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:208) 
    at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:151) 
    at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:81) 
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:679) 
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:259) 
    at javax.naming.InitialContext.init(InitialContext.java:235) 
    at javax.naming.InitialContext.<init>(InitialContext.java:209) 
    at security.ActiveDirectoryReader.openDirectoryContext(ActiveDirectoryReader.java:80) 

回答

2

以便其他人可以從中受益: 修改文件:/opt/IBM/WebSphere/AppServer/java/jre/lib/security/java.security 將搜索security.provider並在其他提供程序的底部添加一行(如果它尚未在其中): security.provider.X = com.ibm.security.sasl.IBMSASL(其中X是下一個數字按順序排列在上面)

我們有同樣的問題,甚至與IBM打開了一個PMR(誰還沒有知道如何解決)

答案實際上是從自己的鏈路來了: http://www.ibm.com/developerworks/java/jdk/security/50/secguides/saslDocs/ibm.sasl.provider.guide.html

看來這應該是「上」默認...

+0

感謝史蒂夫^ h!我能夠重現和修復這些精確的步驟。 – johnwalker00 2011-01-05 19:44:08