⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testmd5.java

📁 JNDI课件
💻 JAVA
字号:
package jndi;import javax.naming.*;import javax.naming.directory.*;import java.util.*;/*用于测试连接md5时指定强度 曾海2003-10sun one 的服务器,进directory server控制台,在data结点的password对话框中,把passowrdencryption改成明文,否则不认用户名*/import java.util.Hashtable;public class TestMd5 {  public TestMd5() {    Hashtable env = new Hashtable(11);    try {         DirContext ctx;         ctx=new InitialDirContext();         Attributes attrs = ctx.getAttributes(          "ldap://localhost:50028", new String[]{"supportedSASLMechanisms"});         Enumeration enu = attrs.getAll() ;         while(enu!=null && enu.hasMoreElements() ){               Attribute atr = (Attribute) enu.nextElement();               System.err.println("服务器,端口50028属性是"+ atr );               Enumeration ne  = atr.getAll() ;               while(ne!=null && ne.hasMoreElements() )                 System.err.println(" = "+ne.nextElement() );       }//while         ctx.close() ;         System.err.println("测试成功!") ;        env.put(Context.INITIAL_CONTEXT_FACTORY,   "com.sun.jndi.ldap.LdapCtxFactory");        env.put(Context.PROVIDER_URL, "ldap://localhost:50028");        env.put(Context.SECURITY_AUTHENTICATION, "DIGEST-MD5");        env.put(Context.SECURITY_PRINCIPAL, "dn:uid=ZHai,ou=groups,dc=jssvc,dc=com");        //试图对付realm领地        //env.put("java.naming.security.sasl.realm", "NetscapeRoot");          //必须用dn形式,否则根本没有任何结果。        env.put(Context.SECURITY_CREDENTIALS, "916");        //env.put("javax.security.sasl.qop", "auth-conf");//试图进行完整测试       ctx = new InitialDirContext(env);// generic failure,unable canonify user and get auxprops       System.err.println("用digest-md5安全连接成功!");       System.err.println(ctx.lookup("uid=ZHai,ou=groups,dc=jssvc,dc=com") ) ;          ctx.close();	} catch (NamingException e) { System.err.println("error!"); e.printStackTrace() ;};  }  public static void main(String[] args) {    TestMd5 testMd51 = new TestMd5();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -