/* * Copyright (c) 1999. Sun Microsystems. All rights reserved. * * Creates the schema for storing CORBA object references according * to draft-ryan-corba-schema-01.txt. After running this program, you * should verify that the schema has been updated correctly * by using the directory server's administration tool. If the * schema has not been properly updated, use the administration tool * to correct it. * * You should first turn off schema-checking at the directory server * before running this program. * * usage: * java [-Djava.naming.provider.url=] \ * CreateCorbaSchema [-h|-l|-s[n|n41]] [-n] [-p] [-a] * * -h Print the usage message * -l List the CORBA schema in the directory * -s[n] Update schema * (-sn means use the workaround for schema bugs in * pre-4.1 releases of Netscape Directory Server; * -sn41 means use the workaround for schema bugs in Netscape 4.1). * -n Use as the distinguished name for authentication * -p Use as the password for authentication * -a Use as the authentication mechanism. Default is "simple". * * If neither -s, -l, nor -h has been specified, the default is "-l". * * Here is an example. * The following updates the schema (using the workaround for pre-4.1 * Netscape schema bugs), logging in as "cn=directory manager" with the * password "secret". * #java CreateCorbaSchema -sn "-ncn=directory manager" -psecret * * @author Rosanna Lee */ import javax.naming.*; import javax.naming.directory.*; public class CreateCorbaSchema extends CreateJavaSchema{ private static String[] allAttrs = { "corbaIor", "corbaRepositoryId" }; private static String[] allOCs = { "corbaObject", "corbaObjectReference", "corbaContainer" }; public static void main(String[] args) { new CreateCorbaSchema().run(args, allAttrs, allOCs); } CreateCorbaSchema() { } /** * Add new attributes: * corbaIor * corbaRepositoryId */ protected void updateAttributes(DirContext attrRoot, String[] attrIDs) throws NamingException { /* Get rid of old attr IDs */ for (int i = 0; i < attrIDs.length; i++) { attrRoot.destroySubcontext(attrIDs[i]); } /* Add new and updated attr definitions */ // corbaIor Attributes attrs = new BasicAttributes(true); // ignore case attrs.put("NUMERICOID", "1.3.6.1.4.1.42.2.27.4.1.14"); attrs.put("NAME", "corbaIor"); attrs.put("DESC", "Stringified interoperable object reference of a CORBA object"); attrs.put("SYNTAX", "1.3.6.1.4.1.1466.115.121.1.26"); attrs.put("EQUALITY", "caseIgnoreIA5Match"); attrs.put("SINGLE-VALUE", "true"); attrRoot.createSubcontext("corbaIor", attrs); System.out.println("Created corbaIor attribute"); // corbaRepositoryId attrs = new BasicAttributes(true); attrs.put("NUMERICOID", "1.3.6.1.4.1.42.2.27.4.1.15"); attrs.put("NAME", "corbaRepositoryId"); attrs.put("DESC", "Repository ids of interfaces implemented by a CORBA object"); attrs.put("SYNTAX", "1.3.6.1.4.1.1466.115.121.1.15"); attrs.put("EQUALITY", "caseExactMatch"); attrRoot.createSubcontext("corbaRepositoryId", attrs); System.out.println("Created corbaRepositoryId 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]); } // corbaObject Attributes attrs = new BasicAttributes(true); attrs.put("NUMERICOID", "1.3.6.1.4.1.42.2.27.4.2.9"); attrs.put("NAME", "corbaObject"); attrs.put("DESC", "CORBA object representation"); attrs.put("SUP", "top"); attrs.put("ABSTRACT", "true"); Attribute optional = new BasicAttribute("MAY", "corbaRepositoryId"); optional.add("description"); attrs.put(optional); ocRoot.createSubcontext("corbaObject", attrs); System.out.println("Created corbaObject object class"); // corbaObjectReference attrs = new BasicAttributes(true); attrs.put("NUMERICOID", "1.3.6.1.4.1.42.2.27.4.2.11"); attrs.put("NAME", "corbaObjectReference"); attrs.put("DESC", "CORBA interoperable object reference"); attrs.put("SUP", "corbaObject"); attrs.put("AUXILIARY", "true"); Attribute corMust = new BasicAttribute("MUST", "corbaIor"); if (netscape41bug) { corMust.add("objectclass"); } if (netscapebug) { // Netscape ignores 'SUP' so we must add explicitly attrs.put(optional); } attrs.put(corMust); ocRoot.createSubcontext("corbaObjectReference", attrs); System.out.println("Created corbaObjectReference object class"); // corbaContainer attrs = new BasicAttributes(true); attrs.put("NUMERICOID", "1.3.6.1.4.1.42.2.27.4.2.10"); attrs.put("NAME", "corbaContainer"); attrs.put("DESC", "Container for a CORBA object"); attrs.put("SUP", "top"); attrs.put("STRUCTURAL", "true"); Attribute ccMust = new BasicAttribute("MUST", "cn"); if (netscape41bug) { ccMust.add("objectclass"); } attrs.put(ccMust); ocRoot.createSubcontext("corbaContainer", attrs); System.out.println("Created corbaContainer object class"); } protected void printUsage(String msg) { printUsageAux(msg, "CORBA"); } }