代码之家  ›  专栏  ›  技术社区  ›  johnwalker00

AuthenticationNotSupportedException:DIGEST-MD5(在WebSphere上)

  •  0
  • johnwalker00  · 技术社区  · 15 年前

    我在尝试从我的web服务中进行身份验证时遇到问题。这是失败的代码。

    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;
        }
    

    这段代码在AIX上使用IBM的1.5jvm对Active Directory起作用,但在WebSphere 6.1中运行时不在具有相同VM的同一台计算机上。

    我试图控制所有变量,到目前为止,看起来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)
    
    1 回复  |  直到 15 年前
        1
  •  2
  •   Steve H    15 年前

    这样其他人就可以从中受益: 修改文件:opt/IBM/WebSphere/AppServer/java/jre/lib/security/java.security 搜索security.provider并在其他提供程序的底部添加一行(如果它不在其中): security.provider.X=com.ibm.security.sasl.IBMSASL(其中X是上面行的下一个序号)

    我们也遇到了同样的问题,甚至与IBM一起打开了PMR(IBM仍然不知道如何修复)

    答案其实来自他们自己的联系: http://www.ibm.com/developerworks/java/jdk/security/50/secguides/saslDocs/ibm.sasl.provider.guide.html

    似乎这应该是默认的“开”。。。