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

📄 createjavaschema.java

📁 java tutorial.sun公司官方出品。java入门书籍。最新版
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	attrs.put("NAME", "javaClassNames");	attrs.put("DESC", "Fully qualified Java class or interface name");	attrs.put("EQUALITY", "caseExactMatch");	attrs.put("SYNTAX", "1.3.6.1.4.1.1466.115.121.1.15");	attrRoot.createSubcontext("javaClassNames", attrs);	System.out.println("Created javaClassNames attribute");// javaFactory	attrs = new BasicAttributes(true);	attrs.put("NUMERICOID", "1.3.6.1.4.1.42.2.27.4.1.10");	attrs.put("NAME", "javaFactory");	attrs.put("DESC", "Fully qualified Java class name of a JNDI object factory");	attrs.put("EQUALITY", "caseExactMatch");	attrs.put("SYNTAX", "1.3.6.1.4.1.1466.115.121.1.15");	attrs.put("SINGLE-VALUE", "true");	attrRoot.createSubcontext("javaFactory", attrs);	System.out.println("Created javaFactory attribute");// javaReferenceAddress	attrs = new BasicAttributes(true);	attrs.put("NUMERICOID", "1.3.6.1.4.1.42.2.27.4.1.11");	attrs.put("NAME", "javaReferenceAddress");	attrs.put("DESC", "Addresses associated with a JNDI Reference");	attrs.put("EQUALITY", "caseExactMatch");	attrs.put("SYNTAX", "1.3.6.1.4.1.1466.115.121.1.15");	attrRoot.createSubcontext("javaReferenceAddress", attrs);	System.out.println("Created javaReferenceAddress attribute");// javaDoc	attrs = new BasicAttributes(true);	attrs.put("NUMERICOID", "1.3.6.1.4.1.42.2.27.4.1.12");	attrs.put("NAME", "javaDoc");	attrs.put("DESC", "The Java documentation for the class");	attrs.put("EQUALITY", "caseExactIA5Match");	attrs.put("SYNTAX", "1.3.6.1.4.1.1466.115.121.1.26");	attrRoot.createSubcontext("javaDoc", attrs);	System.out.println("Created javaDoc attribute");    }    // Object Classes    protected void updateObjectClasses(DirContext ocRoot, String[] ocIDs)	throws NamingException {	/* Get rid of old OCs - reverse order */	for (int i = ocIDs.length - 1; i >= 0; i--) {	    ocRoot.destroySubcontext(ocIDs[i]);	}// javaContainer	Attributes attrs = new BasicAttributes(true);	attrs.put("NUMERICOID", "1.3.6.1.4.1.42.2.27.4.2.1");	attrs.put("NAME", "javaContainer");	attrs.put("DESC", "Container for a Java object");	attrs.put("SUP", "top");	attrs.put("STRUCTURAL", "true");	Attribute jcMust = new BasicAttribute("MUST", "cn");	if (netscape41bug) {	    jcMust.add("objectClass");	}	attrs.put(jcMust);	ocRoot.createSubcontext("javaContainer", attrs);	System.out.println("Created javaContainer object class");// javaObject	attrs = new BasicAttributes(true);	attrs.put("NUMERICOID", "1.3.6.1.4.1.42.2.27.4.2.4");	attrs.put("NAME", "javaObject");	attrs.put("DESC", "Java object representation");	attrs.put("SUP", "top");	attrs.put("ABSTRACT", "true");	Attribute joMust = new BasicAttribute("MUST", "javaClassName");	if (netscape41bug) {	    joMust.add("objectClass");	}	attrs.put(joMust);	Attribute optional = new BasicAttribute("MAY", "javaCodebase");	optional.add("javaClassNames");	optional.add("javaDoc");	optional.add("description");	attrs.put(optional);	ocRoot.createSubcontext("javaObject", attrs);	System.out.println("Created javaObject object class");// javaSerializedObject	attrs = new BasicAttributes(true);	attrs.put("NUMERICOID", "1.3.6.1.4.1.42.2.27.4.2.5");	attrs.put("NAME",  "javaSerializedObject");	attrs.put("DESC", "Java serialized object");	attrs.put("SUP", "javaObject");	attrs.put("AUXILIARY", "true");	Attribute jsoMust = new BasicAttribute("MUST", "javaSerializedData");	if (netscape41bug) {	    jsoMust.add("objectClass");	}	if (netscapebug) {	    // Netscape ignores 'SUP' so we must add explicitly	    attrs.put(optional);	    jsoMust.add("javaClassName");	}	attrs.put(jsoMust);	ocRoot.createSubcontext("javaSerializedObject", attrs);	System.out.println("Created javaSerializedObject object class");// javaMarshalledObject	attrs = new BasicAttributes(true);	attrs.put("NUMERICOID", "1.3.6.1.4.1.42.2.27.4.2.8");	attrs.put("NAME",  "javaMarshalledObject");	attrs.put("DESC", "Java marshalled object");	attrs.put("SUP", "javaObject");	attrs.put("AUXILIARY", "true");	if (netscapebug) {	    // Netscape ignores 'SUP' so we must add explicitly	    attrs.put(optional);	}	attrs.put(jsoMust);  // re-use the MUST from javaSerializedObject	ocRoot.createSubcontext("javaMarshalledObject", attrs);	System.out.println("Created javaMarshalledObject object class");// javaNamingReference	attrs = new BasicAttributes(true);	attrs.put("NUMERICOID", "1.3.6.1.4.1.42.2.27.4.2.7");	attrs.put("NAME", "javaNamingReference");	attrs.put("DESC", "JNDI reference");	attrs.put("SUP", "javaObject");	attrs.put("AUXILIARY", "true");	if (netscapebug) {	    // Netscape ignores 'SUP' so we must add explicitly	    attrs.put("MUST",  "javaClassName" );	} else {	    optional = new BasicAttribute("MAY");	}	optional.add("javaReferenceAddress");	optional.add("javaFactory");	attrs.put(optional);	ocRoot.createSubcontext("javaNamingReference", attrs);	System.out.println("Created javaNamingReference object class");    }    /**     * Updates the Active Directory schema.     *     * Modification of the (RFC 2252) schema descriptions is not supported     * in Active Directory. Instead, the Active Directory (internal) schema     * must be modified.     */    private void updateADSchema(DirContext rootCtx) throws NamingException {System.out.println("[updating Active Directory schema ...]");	// acquire schema context	DirContext schemaCtx = getADSchema(rootCtx);	// insert attribute definitions	insertADAttributes(rootCtx, schemaCtx);	// insert object class definitions	insertADObjectClasses(rootCtx, schemaCtx);System.out.println("[update completed]\n");    }    /**     * Locates the Active Directory schema.     * @return A context for the root of the Active Directory schema.     */    private DirContext getADSchema(DirContext rootCtx) throws NamingException {System.out.println("  [locating the schema]");	String snc = "schemaNamingContext"; // DSE attribute	Attributes attrs =	    rootCtx.getAttributes("", new String[]{ snc });	return (DirContext) rootCtx.lookup((String) attrs.get(snc).get());    }    /**     * Inserts attribute definitions from RFC 2713 into the schema.     *     * This method maps the LDAP schema definitions in RFC 2713 onto the     * proprietary attributes required by the Active Directory schema.     *     * The resulting attribute definitions are identical to those of RFC 2713.     */    protected void insertADAttributes(DirContext rootCtx, DirContext schemaCtx)	throws NamingException {System.out.println("  [inserting new attribute definitions ...]");	String dn = schemaCtx.getNameInNamespace();	String attrID;	attrID = new String("javaClassName");	Attributes attrs1 = new BasicAttributes();	attrs1.put(new BasicAttribute("adminDescription", attrID));	attrs1.put(new BasicAttribute("attributeID",	    "1.3.6.1.4.1.42.2.27.4.1.6"));	attrs1.put(new BasicAttribute("attributeSyntax", "2.5.5.12"));	attrs1.put(new BasicAttribute("cn", attrID));	attrs1.put(new BasicAttribute("description",	    "Fully qualified name of distinguished Java class or interface"));	attrs1.put(new BasicAttribute("distinguishedName", "CN=" + attrID +	    "," + dn));	attrs1.put(new BasicAttribute("isSingleValued", "TRUE"));	attrs1.put(new BasicAttribute("lDAPDisplayName", attrID));	attrs1.put(new BasicAttribute("name", attrID));	attrs1.put(new BasicAttribute("objectCategory", "CN=Attribute-Schema," +	    dn));	attrs1.put(new BasicAttribute("objectClass", "attributeSchema"));	attrs1.put(new BasicAttribute("oMSyntax", "64"));	attrs1.put(new BasicAttribute("searchFlags", "0"));	attrs1.put(new BasicAttribute("systemOnly", "FALSE"));	schemaCtx.createSubcontext("cn=" + attrID, attrs1);System.out.println("    [" + attrID + "]");	attrID = new String("javaCodeBase");	Attributes attrs2 = new BasicAttributes();	attrs2.put(new BasicAttribute("adminDescription", attrID));	attrs2.put(new BasicAttribute("attributeID",	    "1.3.6.1.4.1.42.2.27.4.1.7"));	attrs2.put(new BasicAttribute("attributeSyntax", "2.5.5.5"));	attrs2.put(new BasicAttribute("cn", attrID));	attrs2.put(new BasicAttribute("description",	    "URL(s) specifying the location of class definition"));	attrs2.put(new BasicAttribute("distinguishedName", "CN=" + attrID +	    "," + dn));	attrs2.put(new BasicAttribute("isSingleValued", "FALSE"));	attrs2.put(new BasicAttribute("lDAPDisplayName", attrID));	attrs2.put(new BasicAttribute("name", attrID));	attrs2.put(new BasicAttribute("objectCategory", "CN=Attribute-Schema," +	    dn));	attrs2.put(new BasicAttribute("objectClass", "attributeSchema"));	attrs2.put(new BasicAttribute("oMSyntax", "22"));	attrs2.put(new BasicAttribute("searchFlags", "0"));	attrs2.put(new BasicAttribute("systemOnly", "FALSE"));	schemaCtx.createSubcontext("cn=" + attrID, attrs2);System.out.println("    [" + attrID + "]");	attrID = new String("javaSerializedData");	Attributes attrs3 = new BasicAttributes();	attrs3.put(new BasicAttribute("adminDescription", attrID));	attrs3.put(new BasicAttribute("attributeID",	    "1.3.6.1.4.1.42.2.27.4.1.8"));	attrs3.put(new BasicAttribute("attributeSyntax", "2.5.5.10"));	attrs3.put(new BasicAttribute("cn", attrID));	attrs3.put(new BasicAttribute("description",	    "Serialized form of a Java object"));	attrs3.put(new BasicAttribute("distinguishedName", "CN=" + attrID +	    "," + dn));	attrs3.put(new BasicAttribute("isSingleValued", "TRUE"));	attrs3.put(new BasicAttribute("lDAPDisplayName", attrID));	attrs3.put(new BasicAttribute("name", attrID));	attrs3.put(new BasicAttribute("objectCategory", "CN=Attribute-Schema," +	    dn));	attrs3.put(new BasicAttribute("objectClass", "attributeSchema"));	attrs3.put(new BasicAttribute("oMSyntax", "4"));	attrs3.put(new BasicAttribute("searchFlags", "0"));	attrs3.put(new BasicAttribute("systemOnly", "FALSE"));	schemaCtx.createSubcontext("cn=" + attrID, attrs3);System.out.println("    [" + attrID + "]");	attrID = new String("javaFactory");	Attributes attrs4 = new BasicAttributes();	attrs4.put(new BasicAttribute("adminDescription", attrID));	attrs4.put(new BasicAttribute("attributeID",	    "1.3.6.1.4.1.42.2.27.4.1.10"));	attrs4.put(new BasicAttribute("attributeSyntax", "2.5.5.12"));	attrs4.put(new BasicAttribute("cn", attrID));	attrs4.put(new BasicAttribute("description",	    "Fully qualified Java class name of a JNDI object factory"));	attrs4.put(new BasicAttribute("distinguishedName", "CN=" + attrID +	    "," + dn));	attrs4.put(new BasicAttribute("isSingleValued", "TRUE"));	attrs4.put(new BasicAttribute("lDAPDisplayName", attrID));	attrs4.put(new BasicAttribute("name", attrID));	attrs4.put(new BasicAttribute("objectCategory", "CN=Attribute-Schema," +	    dn));	attrs4.put(new BasicAttribute("objectClass", "attributeSchema"));	attrs4.put(new BasicAttribute("oMSyntax", "64"));	attrs4.put(new BasicAttribute("searchFlags", "0"));	attrs4.put(new BasicAttribute("systemOnly", "FALSE"));	schemaCtx.createSubcontext("cn=" + attrID, attrs4);System.out.println("    [" + attrID + "]");	attrID = new String("javaReferenceAddress");

⌨️ 快捷键说明

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