From 616e690d5b5f9f199f5701ce77848043806f5ab4 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Thu, 16 Jun 2011 18:07:06 +0000
Subject: [PATCH] Initial work for OPENDJ-155: Add support for OpenDJ extended matching rules and syntaxes
---
opendj-sdk/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/schema/package-info.java | 32 ++++++++
opendj-sdk/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/schema/Main.java | 150 +++++++++++++++++++++++++++++++++++++
2 files changed, 182 insertions(+), 0 deletions(-)
diff --git a/opendj-sdk/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/schema/Main.java b/opendj-sdk/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/schema/Main.java
new file mode 100644
index 0000000..94dead2
--- /dev/null
+++ b/opendj-sdk/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/schema/Main.java
@@ -0,0 +1,150 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opendj3/legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opendj3/legal-notices/CDDLv1_0.txt. If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ * Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ * Copyright 2009-2010 Sun Microsystems, Inc.
+ * Portions copyright 2011 ForgeRock AS
+ */
+
+package org.forgerock.opendj.examples.schema;
+
+
+
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.ldap.Connection;
+import org.forgerock.opendj.ldap.ErrorResultException;
+import org.forgerock.opendj.ldap.LDAPConnectionFactory;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.schema.*;
+
+
+
+/**
+ * An example client application which prints a summary of the schema on the
+ * named server as well as any warnings encountered while parsing the schema.
+ * This example takes the following command line parameters:
+ *
+ * <pre>
+ * <host> <port> <username> <password>
+ * </pre>
+ */
+public final class Main
+{
+ /**
+ * Main method.
+ *
+ * @param args
+ * The command line arguments: host, port, username, password.
+ */
+ public static void main(final String[] args)
+ {
+ if (args.length != 4)
+ {
+ System.err.println("Usage: host port username password");
+ System.exit(1);
+ }
+
+ // Parse command line arguments.
+ final String hostName = args[0];
+ final int port = Integer.parseInt(args[1]);
+ final String userName = args[2];
+ final String password = args[3];
+
+ // Connect and bind to the server.
+ final LDAPConnectionFactory factory = new LDAPConnectionFactory(
+ hostName, port);
+ Connection connection = null;
+
+ try
+ {
+ connection = factory.getConnection();
+ connection.bind(userName, password.toCharArray());
+
+ // Read the schema.
+ Schema schema = connection.readSchemaForRootDSE();
+
+ System.out.println("Attribute types");
+ for (AttributeType at : schema.getAttributeTypes())
+ {
+ System.out.println(" " + at.getNameOrOID());
+ }
+ System.out.println();
+
+ System.out.println("Object classes");
+ for (ObjectClass oc : schema.getObjectClasses())
+ {
+ System.out.println(" " + oc.getNameOrOID());
+ }
+ System.out.println();
+
+ System.out.println("Matching rules");
+ for (MatchingRule mr : schema.getMatchingRules())
+ {
+ System.out.println(" " + mr.getNameOrOID());
+ }
+ System.out.println();
+
+ System.out.println("Syntaxes");
+ for (Syntax s : schema.getSyntaxes())
+ {
+ System.out.println(" " + s.getDescription());
+ }
+ System.out.println();
+
+ // Etc...
+
+ System.out.println("WARNINGS");
+ for (LocalizableMessage m : schema.getWarnings())
+ {
+ System.out.println(" " + m.toString());
+ }
+ System.out.println();
+ }
+ catch (final ErrorResultException e)
+ {
+ System.err.println(e.getMessage());
+ System.exit(e.getResult().getResultCode().intValue());
+ return;
+ }
+ catch (final InterruptedException e)
+ {
+ System.err.println(e.getMessage());
+ System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
+ return;
+ }
+ finally
+ {
+ if (connection != null)
+ {
+ connection.close();
+ }
+ }
+ }
+
+
+
+ private Main()
+ {
+ // Not used.
+ }
+}
diff --git a/opendj-sdk/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/schema/package-info.java b/opendj-sdk/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/schema/package-info.java
new file mode 100755
index 0000000..6ea8a0c
--- /dev/null
+++ b/opendj-sdk/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/schema/package-info.java
@@ -0,0 +1,32 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opendj3/legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opendj3/legal-notices/CDDLv1_0.txt. If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ * Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ * Copyright 2011 ForgeRock AS
+ */
+
+/**
+ * An example client application which prints a summary of the schema on the
+ * named server as well as any warnings encountered while parsing the schema.
+ */
+package org.forgerock.opendj.examples.schema;
--
Gitblit v1.10.0