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

📄 ldap.java

📁 这是一个基于计算网格的web service。它用java编写。一旦安装完成
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* * Ldap.java * * Created on April 16, 2005, 11:59 AM */package jwsgrid.resourcemanager.priv;import javax.naming.*;import javax.naming.directory.*;import java.util.List;import java.util.Vector;import java.util.Hashtable;import java.util.Map;/** * * @author sean */public class Ldap {       ////////////////////////////////////////////////////////////////////////////    // public classes    //        public static class JobHostResult    {        private String wsAddr;        private String clusterId;                public JobHostResult()        {                    }                public JobHostResult( String wsAddr, String clusterId )        {            setWsAddr( wsAddr );            setClusterId( clusterId );        }                public void setWsAddr( String wsAddr )        {            this.wsAddr = wsAddr;        }                public void setClusterId( String clusterId )        {            this.clusterId = clusterId;        }                        public String getWsAddr() { return wsAddr; }        public String getClusterId() { return clusterId; }    }        ////////////////////////////////////////////////////////////////////////////    // public attributes    //        public static final String OBJ_JOBHOST = "jwsgridjobhost";    public static final String ATTR_CN = "cn";    public static final String ATTR_TOP = "top";    public static final String ATTR_JHCLUSTERID = "jhclusterid";    public static final String ATTR_JHRESERVED = "jhreserved";    public static final String ATTR_JHOS_NAME = "jhosname";    public static final String ATTR_JHOS_VERSION = "jhosversion";    public static final String ATTR_JHOS_ARCH = "jhosarch";    public static final String ATTR_JHCPU_VENDOR = "jhcpuvendor";    public static final String ATTR_JHCPU_MODEL = "jhcpumodel";    public static final String ATTR_JHCPU_SPEED = "jhcpuspeed";    public static final String ATTR_JHCPU_COUNT = "jhcpucount";    public static final String ATTR_JHCPU_USERTIME = "jhcpuusertime";    public static final String ATTR_JHCPU_IDLETIME = "jhcpuidletime";    public static final String ATTR_JHCPU_SYSTIME = "jhcpusystime";    public static final String ATTR_JHCPU_LOAD = "jhcpuload";    public static final String ATTR_JHMEM_TOTAL = "jhmemtotal";    public static final String ATTR_JHMEM_FREE = "jhmemfree";    public static final String ATTR_JHDISK_TOTAL = "jhdisktotal";    public static final String ATTR_JHDISK_FREE = "jhdiskfree";    public static final String ATTR_JHJOBTYPES = "jhjobtypes";        ////////////////////////////////////////////////////////////////////////////    // private attributes    //        private static final String LDAP_CONTEXTFACTORY = "com.sun.jndi.ldap.LdapCtxFactory";    private static final String JOBHOST_OBJFACTORY = "jwsgrid.resourcemanager.priv.LdapJobHostObjectFactory";    private static final String JOBHOST_STATEFACTORY = "jwsgrid.resourcemanager.priv.LdapJobHostStateFactory";        private static String providerUrl = "";    private static String directory = "";            ////////////////////////////////////////////////////////////////////////////    // public methods    //        /**     *     */    public static String generateLdif(             String host,             String domain,             String jwsGridOu,            String resMgrOu )     {        String http = "http://";        if ( host.startsWith( http ) )        {            host = host.substring( http.length(), host.length() );        }                if ( domain.startsWith( http ) )        {            domain = domain.substring( http.length(), domain.length() );        }                        //String directory = host + "." + domain;        //String dc = "dc=" + domain.replaceAll( "\\.", ",dc=" );               String ldif =                "dn: " + jwsGridOu + "," + domain + "\n" +                "ou: " + jwsGridOu + "\n" +                "objectClass: top\n" +                "objectClass: organizationalunit\n" +                "creatorsname: uid=admin,ou=administrators,ou=topologymanagement,o=netscaperoot\n" +                "modifiersname: uid=admin,ou=administrators,ou=topologymanagement,o=netscaperoot\n" +                "createtimestamp: 20050502005348Z\n" +                "modifytimestamp: 20050502005348Z\n" +                "nsuniqueid: 9452d681-1dd111b2-807e91c8-d98266ea\n" +                "parentid: 1\n" +                "entryid: 41\n" +                "entrydn: " + jwsGridOu.toLowerCase() + "," + domain + "\n" +                "numsubordinates: 1\n" +                "aci: (targetattr = \"*\") (version 3.0;acl \"public\";allow (all)(userdn = \"ldap:///anyone\");)\n" +                "hassubordinates: TRUE\n" +                "subschemasubentry: cn=schema\n" +                "\n" +                "dn: " + resMgrOu + "," + jwsGridOu + "," + domain + "\n" +                "ou: " + resMgrOu + "\n" +                "objectClass: top\n" +                "objectClass: organizationalunit\n" +                "creatorsname: uid=admin,ou=administrators,ou=topologymanagement,o=netscaperoot\n" +                "modifiersname: uid=admin,ou=administrators,ou=topologymanagement,o=netscaperoot\n" +                "createtimestamp: 20050502005358Z\n" +                "modifytimestamp: 20050502005358Z\n" +                "nsuniqueid: 9452d682-1dd111b2-807e91c8-d98266ea\n" +                "parentid: 41\n" +                "entryid: 42\n" +                "entrydn: " + resMgrOu.toLowerCase() + "," + jwsGridOu + "," + domain + "\n" +                "hassubordinates: FALSE\n" +                "numsubordinates: 0\n" +                "subschemasubentry: cn=schema\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhclusterid-oid\n" +                "   NAME 'jhclusterid'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhcpumodel-oid\n" +                "   NAME 'jhcpumodel'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhcpuid-oid\n" +                "   NAME 'jhcpuid'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.27\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhosversion-oid\n" +                "   NAME 'jhosversion'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhcpuvendor-oid\n" +                "   NAME 'jhcpuvendor'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhcpucount-oid\n" +                "   NAME 'jhcpucount'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.27\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhcpusystime-oid\n" +                "   NAME 'jhcpusystime'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.27\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhosname-oid\n" +                "   NAME 'jhosname'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhmemtotal-oid\n" +                "   NAME 'jhmemtotal'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.27\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhmemfree-oid\n" +                "   NAME 'jhmemfree'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.27\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhdisktotal-oid\n" +                "   NAME 'jhdisktotal'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.27\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhcpuspeed-oid\n" +                "   NAME 'jhcpuspeed'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.27\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhreserved-oid\n" +                "   NAME 'jhreserved'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhdiskfree-oid\n" +                "   NAME 'jhdiskfree'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.27\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhosarch-oid\n" +                "   NAME 'jhosarch'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhcpuusertime-oid\n" +                "   NAME 'jhcpuusertime'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.27\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhcpuidletime-oid\n" +                "   NAME 'jhcpuidletime'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.27\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                  "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhcpuload-oid\n" +                "   NAME 'jhcpuload'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.27\n" +                "   SINGLE-VALUE\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                                  "dn: cn=schema\n" +                "changetype: modify\n" +                "add: objectclasses\n" +                "objectClasses: ( 2.5.6.0\n" +                "   NAME 'top'\n" +                "   DESC 'Standard LDAP objectclass'\n" +                "   ABSTRACT\n" +                "   MUST objectClass\n" +                "   X-ORIGIN ( 'RFC 2256' 'user defined' )\n" +                "\n" +                    "dn: cn=schema\n" +                "changetype: modify\n" +                "add: attributetypes\n" +                "attributeTypes: ( jhjobtypes-oid\n" +                "   NAME 'jhjobtypes'\n" +                "   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n" +                                "dn: cn=schema\n" +                "changetype: modify\n" +                "add: objectclasses\n" +                "objectClasses: ( jwsgridjobhost-oid\n" +                "   NAME 'jwsgridjobhost'\n" +                "   DESC 'Standard LDAP objectclass'\n" +                "   SUP top\n" +                "   STRUCTURAL MUST ( cn $ jhcpucount $ jhcpuidletime $ jhcpumodel " +                        "$ jhcpuspeed $ jhcpusystime $ jhcpuusertime $ jhcpuvendor " +                        "$ jhdiskfree $ jhdisktotal $ jhmemfree $ jhmemtotal " +                        "$ jhosarch $ jhosname $ jhosversion $ jhcpuload " +                        "$ jhclusterid $ jhjobtypes )\n" +                "   MAY jhreserved\n" +                "   X-ORIGIN 'user-defined' )\n" +                "\n";                                         return ldif;    }        public static void setProviderUrl(             String host,             int port,             String domain,            String jwsGridDir )     {        if ( host.startsWith( "http://" ) )         {            String tmp = "http://";            host = host.substring( tmp.length(), host.length() );        }                providerUrl =                 "ldap://" + host + ":" + port + "/" + jwsGridDir + "," + domain;    }      

⌨️ 快捷键说明

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