diff --git a/mozilla/directory/java-sdk/ldapsp.mk b/mozilla/directory/java-sdk/ldapsp.mk new file mode 100644 index 00000000000..fbd03c0dbad --- /dev/null +++ b/mozilla/directory/java-sdk/ldapsp.mk @@ -0,0 +1,118 @@ +# -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# The contents of this file are subject to the Netscape Public License +# Version 1.0 (the "NPL"); you may not use this file except in +# compliance with the NPL. You may obtain a copy of the NPL at +# http://www.mozilla.org/NPL/ +# +# Software distributed under the NPL is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL +# for the specific language governing rights and limitations under the +# NPL. +# +# The Initial Developer of this code under the NPL is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All Rights +# Reserved. +# +# Makefile for the LDAP classes +# +# An optimized compile is done by default. You can specify "DEBUG=1" on +# the make line to generate debug symbols in the bytecode. +# +ARCH := $(shell uname -s) + +MCOM_ROOT=. +ifeq ($(ARCH), WINNT) + MOZ_DIR:=$(subst \,/,$(MOZ_SRC)) + BASEDIR:=$(MOZ_DIR)/mozilla/directory/java-sdk +else + ifeq ($(ARCH), WIN95) + MOZ_DIR:=$(subst \,/,$(MOZ_SRC)) + BASEDIR:=$(MOZ_DIR)/mozilla/directory/java-sdk + else + BASEDIR := $(shell cd $(MCOM_ROOT); pwd) + endif +endif +# Destination for class files and packages +CLASS_DEST=$(BASEDIR)/dist/classes + +# Set up the CLASSPATH automatically, +ifeq ($(ARCH), WINNT) + JDK := $(subst \,/,$(JAVA_HOME)) + JAR:=$(JDK)/bin/jar + SEP=; +else + ifeq ($(ARCH), WIN95) + JDK := $(subst \,/,$(JAVA_HOME)) + JAR:=$(JDK)/bin/jar + SEP=; + else + JDK := $(JAVA_HOME) + JAR:=$(JAVA_HOME)/bin/jar + SEP=: + endif +endif +JNDILIB:=$(BASEDIR)/ldapsp/lib/jndi.jar +JAVACLASSPATH:=$(CLASS_DEST)$(SEP)$(BASEDIR)/ldapsp$(SEP)$(JDKLIB)$(SEP)$(JNDILIB)$(SEP)$(CLASSPATH) + +SRCDIR=com/netscape/jndi/ldap +DISTDIR=$(MCOM_ROOT)/dist +CLASSDIR=$(MCOM_ROOT)/dist/classes +CLASSPACKAGEDIR=$(DISTDIR)/packages +#PACKAGENAME=jndi.zip +ifeq ($(DEBUG), full) +BASEPACKAGENAME=ldapsp_debug.jar +else +BASEPACKAGENAME=ldapsp.jar +endif +CLASSPACKAGE=$(CLASSPACKAGEDIR)/$(PACKAGENAME) +MANIFEST=$(BASEDIR)/ldapsp/manifest.mf + +ifndef JAVAC + ifdef JAVA_HOME + JDKBIN=$(JDK)/bin/ + endif + ifeq ($(DEBUG), 1) + JAVAC=$(JDKBIN)javac -g -classpath "$(JAVACLASSPATH)" + else + JAVAC=$(JDKBIN)javac -O -classpath "$(JAVACLASSPATH)" + endif +endif + +all: classes + +basics: $(DISTDIR) $(CLASSDIR) + +classes: JNDICLASSES + +basepackage: $(CLASSPACKAGEDIR) + cd $(DISTDIR)/classes; rm -f ../packages/$(BASEPACKAGENAME); $(JAR) cvfm ../packages/$(BASEPACKAGENAME) $(MANIFEST) com/netscape/jndi/ldap/*.class com/netscape/jndi/ldap/common/*.class com/netscape/jndi/ldap/schema/*.class com/netscape/jndi/ldap/controls/*.class + +MAIN: basics + cd ldapsp/$(SRCDIR); $(JAVAC) -d $(CLASS_DEST) *.java + +SCHEMA: basics + cd ldapsp/$(SRCDIR)/schema; $(JAVAC) -d $(CLASS_DEST) *.java + +COMMON: basics + cd ldapsp/$(SRCDIR)/common; $(JAVAC) -d $(CLASS_DEST) *.java + +CONTROLS: basics + cd ldapsp/$(SRCDIR)/controls; $(JAVAC) -d $(CLASS_DEST) *.java + + +JNDICLASSES: COMMON CONTROLS SCHEMA MAIN + +clean: + rm -rf $(DISTDIR)/classes/com/netscape/jndi/ldap + +$(CLASSPACKAGEDIR): + mkdir -p $@ + +$(DISTDIR): + mkdir -p $@ + +$(CLASSDIR): + mkdir -p $@ + diff --git a/mozilla/directory/java-sdk/ldapsp/Readme.html b/mozilla/directory/java-sdk/ldapsp/Readme.html new file mode 100644 index 00000000000..e4bdcc6842c --- /dev/null +++ b/mozilla/directory/java-sdk/ldapsp/Readme.html @@ -0,0 +1,541 @@ + + +
+ + + +The following sections are available in this document: +
Using Netscape Ldap Service Provider
+
Environment Properties
+
Working With Controls
+
What's Not Implemented
+
+
To use the service provider, you'll need to: +
(1) Add the provider and the jars it depends on in the classpath. For +example, on Windows NT the classpath should be set as follows: +
set classpath=%classpath%;ldapsp.jar;ldapjdk.jar;jndi.jar; +
Assuming that all the jars are available in the current directory. The
+listed jar files are:
+
+
| ldapsp.jar | + +Netscape LDAP Service Provider for JNDI | +
| ldapjdk.jar | + +Netscape Directory SDK for Java 3.1 | +
| jndi.jar | + +JNDI 1.2 beta1 | +
(2) Specify the Netscape LDAP provider as the provider in the context
+environment created for the initial context;
+
Hashtable env = new Hashtable();
+
env.put(Context.INITIAL_CONTEXT_FACTORY,
+
"com.netscape.jndi.ldap.LdapContextFactory");
+
env.put(...
+
...
+
DirContext ctx = new InitialDirContext(env);
+
(3) For storing of Java objects in a LDAP Directory, the JNDI +java object schema must be added to the directory. To enable the JNDI schema +copy the file jndi-object-schema.conf to your <server-root>/slapd-<id>/config +directory, and include the file into your <server-root>/slapd-<id>/config/ns-schema.conf +schema configuration file. +
For examples of using JNDI please go to the official JNDI site. +
Note: If a new property is added to the context environment, or an existing +property is changed after the initial context is created, the change will +be immediately visible unless the changed property pertains to the connection. +For changes related to connection, in order to take effect you'll need +to invoke LdapContext.reconnect(). +
The following table contains JNDI environment properties are relevant
+for the Netscape LDAP service provider. Properties not found in this table
+are silently ignored.
+
+
| Environment Property | + +Description | +
|---|---|
| java.naming.factory.initial | + +
+ This environment property is used to select the LDAP provider. To select +the Netscape LDAP provider "com.netscape.jndi.ldap.LdapContextFactory" +should be specified. + env.put(Context.INITIAL_CONTEXT_FACTORY, "com.netscape.jndi.ldap.LdapContextFactory"); |
+
| java.naming.provider.url | + +
+ Specifies LDAP server information. For example: + env.put(Context.PROVIDER_URL, "ldap://dilly.mcom.com:389"); + If it has not been set then the provider will attempt to access an LDAP +server at port 389 on the local host. |
+
| java.naming.ldap.version | + +
+ Specifies the protocol version for the provider. Two values are + possible: +
If this environment property has not been set then the provider will
+ |
+
| java.naming.security.authentication | + +
+ Specifies the authentication mechanism for the provider to use. + The following values are permitted for this property: +
set then the provider will use 'simple'. If neither have been set then +the provider will use anonymous bind. |
+
| java.naming.security.principal | + +
+ Specifies the DN of the principal to be authenticated. For example: + env.put(Context.SECURITY_PRINCIPAL, "cn=Directory manager"); + If this environment property has not been set then the provider
+ |
+
| java.naming.security.credentials | + +
+ Specifies the password of the principal to be authenticated. For example: + env.put(Context.SECURITY_CREDENTIALS, "secret"); |
+
| java.naming.security.protocol | + +
+ Specifies the security protocol for the provider to use. One +possible value is defined: ssl - use Secure Socket Layer + env.put(Context.SECURITY_PROTOCOL, "ssl"); + When this environment property has been set and the
+ |
+
| java.naming.ldap.factory.socket | + +Specifies the class name of a socket factory. This environment
+ property is used to override the default socket factory. For example: + env.put("java.naming.ldap.factory.socket", "crysec.SSL.SSLSocket"); + If the security protocol environment property has been set but
+this property has not been set, then this property's value is set to netscape.net.SSLSocket.
+See ldapjdk documentation for more information for connecting over SSL.
+ |
+
| java.naming.ldap.ssl.ciphers | + +Specifies the suite of ciphers used for SSL connections made through
+sockets created by the factory specified with java.naming.ldap.factory.socket.
+The value of this property is of type java.lang.Object. For example:
+ try {
+ |
+
| java.naming.batchsize | + +Specifies that search results are to be returned in batches. A setting +of zero indicates that the provider should block until all results have +been received. If this environment property has not been set then search +results are returned in batches of one. | +
| java.naming.ldap.maxresults | + +
+ The default maximum number of search results to be returned for +a search request. 0 means no limit. If not specified, the ldapjdk default +is 1000. This value can be overridden per request with the parameter SearchConstraints +in the DirContex.search() method. |
+
| java.naming.ldap.timelimit | + +The default maximum number of milliseconds to wait for a search operation +to complete. If 0, which is the ldapjdk default, there is no maximum time +limit for a search operation. This value can be overridden per request +with the parameter SearchConstraints in the DirContex.search() +method. | +
| java.naming.referral | + +
+ Specifies how referrals shall be handled by the provider. Three +possible values are defined: +
|
+
| java.naming.ldap.referral.limit | + +
+ Specifies the maximum number of referrals to follow in a chain of + referrals. A setting of zero indicates that there is no limit. The +default limit is 10. |
+
| java.naming.ldap.deleteRDN | + + Specifies whether the old RDN is removed during rename().
+ If the value is "true", the old RDN is removed; otherwise, + the RDN is not removed. The default value is true. |
+
| java.naming.ldap.derefAliases | + +
+ Specifies how aliases are dereferenced during search operations. + The possible values are: +
|
+
| java.naming.ldap.typesOnly | + +
+ Specifies whether only attribute types are to be returned during + searches and getAttributes(). Its possible values are "true" +or "false". The default is false. |
+
| java.naming.ldap.conntrol.connect | + +An array of Controls to be set on the LDAPConnection before +a connection attempt is made to the server. | +
| java.naming.ldap.attributes.binary | + +Specifies attributes that have binary syntax. It extends the provider's
+list of known binary attributes. Its value is a space separated list of
+attribute names.
+ env.put("java.naming.ldap.attributes.binary", "mpegVideo"); + In contrast to ldapjdk, JNDI does not provide for reading of attribute +values as either Strings or byte arrays. All attributes are returned as +Strings unless recognized as having binary syntax. The values of attributes +that have binary syntax are returned as byte arrays instead of Strings. + If this environment property has not been set then, by default, only +the following attributes are considered to have binary syntax: +
|
+
| java.naming.ldap.ref.separator | + +Specifies the character to use when encoding a RefAddr object in
+ the javaReferenceAddress attribute. This environment property should +be used to avoid a conflict in the case where the default separator +character appears in the components of a RefAddr object. + If unspecified, the default separator is the hash character '#'. |
+
Being implemented on the top of ldapjdk, the Netscape LDAP provider +simply exposes all of the ldapjdk controls as JNDI controls. Thus, the +control APIs are exactly the same as in ldapjdk. The only difference is +that for the LDAP provider controls class names start with "Ldap" +while in ldapjdk the class names start with "LDAP". For instance, the ldapjdk +control LDAPSortControl is LdapSortControl in the Netscape LDAP provider. +
Here is an example of how to use the LdapSortControl. Notice that you'll +need to obtain a LdapContext object as an initial context, because controls +are not part of the directory context (DirContext). That means that instead +of calling getInitialDirContext() you 'll need to call getInitialLdapContext(). +
import java.util.Hashtable;
+
import javax.naming.*;
+
import javax.naming.directory.*;
+
import javax.naming.ldap.*;
+
import com.netscape.jndi.ldap.controls.*;
+
public class SortReverseOrder { +
public static void main(String[] args) { +
Hashtable env = new Hashtable(5, 0.75f);
+
/*
+
* Specify the initial context implementation
+to use.
+
*/
+
env.put(Context.INITIAL_CONTEXT_FACTORY,
+
"com.netscape.jndi.ldap.LdapContextFactory");
+
/* Specify host and port to use for directory
+service */
+
//env.put(Context.PROVIDER_URL, "ldap://localhost:389");
+
LdapContext ctx = null;
+
try {
+
/* get a handle to an
+Initial DirContext */
+
ctx = new InitialLdapContext(env,
+null);
+
/* specify search constraints
+to search subtree */
+
SearchControls cons
+= new SearchControls();
+
cons.setSearchScope(SearchControls.SUBTREE_SCOPE);
+
cons.setReturningAttributes(new
+String[] { "sn" });
+
// specify sort control
+
ctx.setRequestControls(
+
+new
+Control[] {new LdapSortControl(
+
+
+new LdapSortKey[]{
+
+
+new LdapSortKey("sn", true,null)},Control.CRITICAL)});
+
/* search for all entries
+with surname of Jensen */
+
NamingEnumeration results
+
+= ctx.search("o=mcom.com", "(objectclass=person)", cons);
+
/* for each entry print
+out name + all attrs and values */
+
while (results != null
+&& results.hasMore()) {
+
+SearchResult si = (SearchResult)results.next();
+
+Attributes attrs = si.getAttributes();
+
+/* print each attribute */
+
+for (NamingEnumeration ae = attrs.getAll(); ae.hasMoreElements();) {
+
+Attribute attr = (Attribute)ae.next();
+
+String attrId = attr.getID();
+
+/* print each value */
+
+for (NamingEnumeration vals = attr.getAll(); vals.hasMore();
+
+System.out.println(attrId + ": " + vals.next()));
+
+}
+
+System.out.println();
+
}
+
}
+
catch (NamingException e) {
+
System.err.println("Search
+example failed.");
+
e.printStackTrace();
+
}
+
finally {
+
// cleanup
+
if (ctx != null) {
+
try
+{ ctx.close(); } catch (Exception e) {}
+
}
+
}
+
}
+
}
+
For full documenation on available controls and their interfaces, please +check the ldapjdk documentation. +
_sharedEnv. If a context wants to
+ * modified a shared property, it will create a separate table (_privateEnv)
+ * to make the modifications. This table overrides the values in the shared table.
+ *
+ * Note1: The class is not thread safe, it requires external synchronization
+ * Note2: The class does not provide enumaration. Call getAllProperties() and then
+ * use the standard Hashtable enumaration techniques.
+ */
+public class ShareableEnv implements Cloneable{
+
+ /**
+ * A special value that denotes a removed propety. Because shared property tables
+ * are read-only, a shared property is deleted in the curent context by assigning
+ * the REMOVED_PROPERTY value in the _modEnv table.
+ */
+ private static final Object REMOVED_PROPERTY = new Object();
+
+ /**
+ * A table of most recent environment modifications. These modifications are not
+ * shared until the current context is cloned, which moves _privateEnv to
+ * _sharedEnv
+ */
+ protected Hashtable m_privateEnv;
+
+ /**
+ * A set of environment propeties that have been changed in this Context and are
+ * shared with one or more child contexts. Read-only access.
+ */
+ protected Vector m_sharedEnv; // A vector of Hashtables
+
+ /**
+ * Shared environment inherited from the parent context
+ */
+ protected ShareableEnv m_parentEnv;
+
+ /**
+ * Index into parent _sharedEnv list. Designates all environment chnages
+ * in the parent context that are visible to this child context
+ */
+ protected int m_parentSharedEnvIdx = -1;
+
+ /**
+ * No-arg constructor is private
+ */
+ private ShareableEnv() {}
+
+ /**
+ * Constructor for non root Contexts
+ *
+ * @param parent A reference to the parent context environment
+ * @param parentSharedEnvIdx index into parent's shared environemnt list
+ */
+ public ShareableEnv(ShareableEnv parent, int parentSharedEnvIdx) {
+ m_parentEnv = parent;
+ m_parentSharedEnvIdx = parentSharedEnvIdx;
+ }
+
+ /**
+ * Constructor for the root context
+ *
+ * @param initialEnv a hashtable with environemnt properties
+ */
+ public ShareableEnv(Hashtable initialEnv) {
+ m_privateEnv = initialEnv;
+ }
+
+ /**
+ * Set the property value.
+ *
+ * @return the previous value of the specified property,
+ * or null if it did not exist before.
+ * @param prop property name
+ * @param val property value
+ */
+ public Object setProperty(String prop, Object val) {
+
+ // Need the current value to be returned
+ Object oldVal = getProperty(prop);
+
+ // Lazy create _privateEnv table
+ if (m_privateEnv == null) {
+ m_privateEnv = new Hashtable(5);
+ }
+
+ // Add/Modify property
+ m_privateEnv.put(prop, val);
+
+ return oldVal;
+ }
+
+ /**
+ * Get the property value.
+ *
+ * @return the object associated with the property name
+ * or null if property is not found
+ * @param prop property name
+ */
+ public Object getProperty(String prop) {
+
+ // First check most recent modifications
+ if (m_privateEnv != null) {
+ Object val = m_privateEnv.get(prop);
+ if (val != null) {
+ return (val == REMOVED_PROPERTY) ? null : val;
+ }
+ }
+
+ // Then try shared properties
+ if (m_sharedEnv != null) {
+ return getSharedProperty(m_sharedEnv.size()-1, prop);
+ }
+ else {
+ return getSharedProperty(-1, prop);
+ }
+ }
+
+ /**
+ * Get the property value for the specified _sharedEnv index
+ *
+ * @return the object associated with the property name
+ * @param envIdx start index in the shared environment list
+ * @param prop property name
+ */
+ private Object getSharedProperty(int envIdx, String prop) {
+
+ // Check first the frozen updtates list
+ if (envIdx >= 0) {
+ for (int i= envIdx; i >= 0; i--) {
+ Hashtable tab = (Hashtable) m_sharedEnv.elementAt(i);
+ Object val = tab.get(prop);
+ if (val != null) {
+ return (val == REMOVED_PROPERTY) ? null : val;
+ }
+ }
+ }
+
+ // Check the parent env context
+ if (m_parentSharedEnvIdx >= 0) {
+ return m_parentEnv.getSharedProperty(m_parentSharedEnvIdx, prop);
+ }
+
+ return null;
+ }
+
+ /**
+ * Remove property
+ *
+ * @return the previous value of the specified property,
+ * or null if it did not exist before.
+ * @param prop property name
+ */
+ public Object removeProperty(String prop) {
+
+ Object val = null;
+ // Is this a shared property ?
+ if (m_sharedEnv != null) {
+ val = getSharedProperty(m_sharedEnv.size()-1, prop);
+ }
+ else {
+ val = getSharedProperty(-1, prop);
+ }
+
+ if (val == null) { // Not a shared property, remove if physically
+ if (m_privateEnv != null) {
+ return m_privateEnv.remove(prop);
+ }
+ }
+ else { //A shared property, hide it
+ setProperty(prop, REMOVED_PROPERTY);
+ }
+ return val;
+ }
+
+ /**
+ * Create a table of all properties. First read all properties from the parent env,
+ * then merge the local updates. Notice that the data is processed in reverse order
+ * than in the getProperty method.
+ *
+ * @return a hashtable containing all properties visible in this context
+ */
+ public Hashtable getAllProperties() {
+ Hashtable res = null;
+
+ // First copy shared properties
+ if (m_sharedEnv != null) {
+ res = getAllSharedProperties(m_sharedEnv.size()-1);
+ }
+ else {
+ res = getAllSharedProperties(-1);
+ }
+
+ if (res == null) {
+ res = new Hashtable(51);
+ }
+
+ // Then apply private env
+ if (m_privateEnv != null) {
+ Hashtable tab = m_privateEnv;
+ for (Enumeration e = tab.keys(); e.hasMoreElements();) {
+ Object key = e.nextElement();
+ Object val = tab.get(key);
+ if (val != REMOVED_PROPERTY) {
+ res.put(key, val);
+ }
+ else {
+ res.remove(key);
+ }
+ }
+ }
+
+ return res;
+ }
+
+ /**
+ * Create a table of all shared properties for the given envIdx. First read all
+ * properties from the parent env, then merge the local environment.
+ *
+ * @return a hashtable containing all properties visible for the shared environment index
+ * @param envIdx start index in the shared environment list
+ */
+ private Hashtable getAllSharedProperties(int envIdx) {
+ Hashtable res = null;
+
+ // First copy parent env
+ if (m_parentEnv != null) {
+ res = m_parentEnv.getAllSharedProperties(m_parentSharedEnvIdx);
+ }
+
+ if (res == null) {
+ res = new Hashtable(51);
+ }
+
+ // Then copy _sharedEnv (older entries are processed before newer ones)
+ if (envIdx >= 0) {
+ for (int i= 0; i <= envIdx; i++) {
+ Hashtable tab = (Hashtable) m_sharedEnv.elementAt(i);
+ for (Enumeration e = tab.keys(); e.hasMoreElements();) {
+ Object key = e.nextElement();
+ Object val = tab.get(key);
+ if (val != REMOVED_PROPERTY) {
+ res.put(key, val);
+ }
+ else {
+ res.remove(key);
+ }
+ }
+ }
+ }
+ return res;
+ }
+
+ /**
+ * Freeze all environment changes changes in the current context. The "Freeze" is
+ * done by moving the _privateEnv table to _sharedEnv vector.
+ */
+ protected void freezeUpdates() {
+ if (m_privateEnv != null) {
+ // Lazy create _sharedEnv vector
+ if (m_sharedEnv == null) {
+ m_sharedEnv = new Vector();
+ }
+ m_sharedEnv.addElement(m_privateEnv);
+ m_privateEnv = null;
+ }
+ }
+
+ /**
+ * Clone ShareableEnv
+ *
+ * @return A "clone" of the current context environment
+ */
+ public Object clone() {
+
+ // First freeze updates for this context
+ freezeUpdates();
+
+ // If the context has been modified, then it is the parent of the clone
+ if (m_sharedEnv != null) {
+ return new ShareableEnv(this, m_sharedEnv.size()-1);
+ }
+
+ // No changes has been done to the inherited parent context. Pass the parent
+ // context to the clone
+ else {
+ return new ShareableEnv(m_parentEnv, m_parentSharedEnvIdx);
+ }
+ }
+
+ /**
+ * Return string representation of the object
+ *
+ * @return a string representation of the object
+ */
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append("ShareableEnv private=");
+ if (m_privateEnv != null) {
+ buf.append("(");
+ buf.append(m_privateEnv.size());
+ buf.append(")");
+ }
+ buf.append(" shared=");
+ if (m_sharedEnv != null) {
+ for (int i=0; i < m_sharedEnv.size(); i++) {
+ Hashtable tab = (Hashtable) m_sharedEnv.elementAt(i);
+ buf.append("(");
+ buf.append(tab.size());
+ buf.append(")");
+ }
+ }
+ buf.append(" parentIdx=");
+ buf.append(m_parentSharedEnvIdx);
+
+ return buf.toString();
+ }
+
+ /**
+ * Test program
+ */
+ public static void main(String[] args) {
+
+ ShareableEnv c0 = new ShareableEnv(null, -1); // c=context 0=level 0=index
+ System.err.println("c0.getProperty(p1)=" + c0.getProperty("p1"));
+ System.err.println("c0.getAllProperties()=" + c0.getAllProperties());
+ System.err.println("c0.setProperty(p1,vxxx)=" + c0.setProperty("p1", "vxxx"));
+ System.err.println("c0.setProperty(p2,v2)=" + c0.setProperty("p2", "v2"));
+ System.err.println("c0.setProperty(p3,v3)=" + c0.setProperty("p3", "v3"));
+ System.err.println("c0.setProperty(p1,v1)=" + c0.setProperty("p1", "v1"));
+ System.err.println("c0.getAllProperties()=" + c0.getAllProperties());
+
+ System.err.println("---");
+ ShareableEnv c01 = (ShareableEnv)c0.clone();
+ System.err.println("c01.getProperty(p1)=" + c01.getProperty("p1"));
+ System.err.println("c01.getAllProperties()=" + c01.getAllProperties());
+ System.err.println("c01.setProperty(p1,v1a)=" + c01.setProperty("p1", "v1a"));
+ System.err.println("c01.getProperty(p1)=" + c01.getProperty("p1"));
+ System.err.println("c01.removeProperty(p2)=" + c01.removeProperty("p2"));
+ System.err.println("c01.getProperty(p2)=" + c01.getProperty("p2"));
+ System.err.println("c01.setProperty(p11,v11a)=" + c01.setProperty("p11", "v11a"));
+ System.err.println("c01.getAllProperties()=" + c01.getAllProperties());
+
+ System.err.println("---");
+ ShareableEnv c02 = (ShareableEnv)c0.clone();
+ System.err.println("c02.getProperty(p1)=" + c02.getProperty("p1"));
+ System.err.println("c02.getAllProperties()=" + c02.getAllProperties());
+
+ System.err.println("---");
+ ShareableEnv c011 = (ShareableEnv)c01.clone();
+ System.err.println("c011.getProperty(p1)=" + c011.getProperty("p1"));
+ System.err.println("c011.getAllProperties()=" + c011.getAllProperties());
+ System.err.println("c011.setProperty(p1,v11b)=" + c011.setProperty("p1", "v11b"));
+ System.err.println("c011.getProperty(p1)=" + c011.getProperty("p1"));
+ System.err.println("c011.getAllProperties()=" + c011.getAllProperties());
+
+ System.err.println("---");
+ System.err.println("c01.getAllProperties()=" + c01.getAllProperties());
+ System.err.println("c01.removeProperty(p11)=" + c01.removeProperty("p11"));
+ System.err.println("c01.getAllProperties()=" + c01.getAllProperties());
+ System.err.println("c011.getAllProperties()=" + c011.getAllProperties());
+
+ System.err.println("---");
+ ShareableEnv c012 = (ShareableEnv)c01.clone();
+ System.err.println("c012.getAllProperties()=" + c012.getAllProperties());
+ System.err.println("c012.getProperty(p1)=" + c012.getProperty("p1"));
+
+ System.err.println("---");
+ System.err.println("c0="+c0);
+ System.err.println("c01="+c01);
+ System.err.println("c02="+c02);
+ System.err.println("c011="+c011);
+ System.err.println("c012="+c012);
+
+ }
+}
+
\ No newline at end of file
diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapEntryChangeControl.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapEntryChangeControl.java
new file mode 100644
index 00000000000..b07db150125
--- /dev/null
+++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapEntryChangeControl.java
@@ -0,0 +1,172 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1999 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+package com.netscape.jndi.ldap.controls;
+
+/**
+ * Represents an LDAP v3 server control that specifies information
+ * about a change to an entry in the directory. (The OID for this
+ * control is 2.16.840.1.113730.3.4.7.) You need to use this control in
+ * conjunction with a "persistent search" control (represented
+ * by LdapPersistentSearchControl object.
+ * + * + * To use persistent searching for change notification, you create a + * "persistent search" control that specifies the types of changes that + * you want to track. When an entry is changed, the server sends that + * entry back to your client and may include an "entry change notification" + * control that specifies additional information about the change. + *
+ *
+ * Typically, you use the getResponseControls method of
+ * the LDAPConnection object and the parseResponse
+ * method of the LdapPersistSearchControl object to get
+ * an LdapEntryChangeControl object.
+ *
+ *
+ * Once you retrieve an LdapEntryChangeControl object from
+ * the server, you can get the following additional information about
+ * the change made to the entry:
+ *
+ * + *
+ *
+ * @see com.netscape.jndi.ldap.controls.LdapPersistSearchControl
+ * @see com.netscape.jndi.ldap.LDAPConnection#getResponseControls
+ */
+
+import javax.naming.ldap.Control;
+import netscape.ldap.controls.*;
+
+public class LdapEntryChangeControl extends LDAPEntryChangeControl implements Control {
+
+ /**
+ * Constructs a new LdapEntryChangeControl object.
+ * This constructor is used by the NetscapeControlFactory
+ *
+ * @see com.netscape.jndi.ldap.LdapControl
+ * @see com.netscape.jndi.ldap.controls.LdapPersistSearchControl
+ */
+ LdapEntryChangeControl(boolean critical, byte[] value) {
+ m_critical = critical;
+ m_value = value;
+ }
+
+ /**
+ * Sets the change number (which identifies the record of the change
+ * in the server's change log) in this "entry change notification"
+ * control.
+ * @param num Change number that you want to set.
+ * @see com.netscape.jndi.ldap.controls.LdapEntryChangeControl#getChangeNumber
+ */
+ public void setChangeNumber(int num) {
+ super.setChangeNumber(num);
+ }
+
+ /**
+ * Sets the change type (which identifies the type of change
+ * that occurred) in this "entry change notification" control.
+ * @param num Change type that you want to set. This can be one of
+ * the following values:
+ *
+ * + *
LdapPersistSearchControl.ADD (a new entry was
+ * added to the directory)
+ * LdapPersistSearchControl.DELETE (an entry was
+ * removed from the directory)
+ * LdapPersistSearchControl.MODIFY (an entry was
+ * modified)
+ * LdapPersistSearchControl.MODDN (an entry was
+ * renamed)
+ * + * + * @see com.netscape.jndi.ldap.controls.LdapEntryChangeControl#getChangeType + */ + public void setChangeType(int num) { + super.setChangeType(num); + } + + /** + * Sets the previous DN of the entry (if the entry was renamed) + * in the "entry change notification control". + * @param dn The previous distinguished name of the entry. + * @see com.netscape.jndi.ldap.controls.LdapEntryChangeControl#getPreviousDN + */ + public void setPreviousDN(String dn) { + super.setPreviousDN(dn); + } + + /** + * Gets the change number, which identifies the record of the change + * in the server's change log. + * @return Change number identifying the change made. + * @see com.netscape.jndi.ldap.controls.LdapEntryChangeControl#setChangeNumber + */ + public int getChangeNumber() { + return super.getChangeNumber(); + } + + /** + * Gets the change type, which identifies the type of change + * that occurred. + * @returns Change type identifying the type of change that + * occurred. This can be one of the following values: + *
+ * + *
LdapPersistSearchControl.ADD (a new entry was
+ * added to the directory)
+ * LdapPersistSearchControl.DELETE (an entry was
+ * removed from the directory)
+ * LdapPersistSearchControl.MODIFY (an entry was
+ * modified)
+ * LdapPersistSearchControl.MODDN (an entry was
+ * renamed)
+ * + * + * @see com.netscape.jndi.ldap.controls.LdapEntryChangeControl#setChangeType + */ + public int getChangeType() { + return super.getChangeType(); + } + + /** + * Gets the previous DN of the entry (if the entry was renamed). + * @returns The previous distinguished name of the entry. + * @see com.netscape.jndi.ldap.controls.LdapEntryChangeControl#setPreviousDN + */ + public String getPreviousDN() { + return super.getPreviousDN(); + } + + /** + * Implements Control interface + */ + public byte[] getEncodedValue() { + return getValue(); + } +} + diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapPasswordExpiredControl.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapPasswordExpiredControl.java new file mode 100644 index 00000000000..569c4113e3f --- /dev/null +++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapPasswordExpiredControl.java @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ +package com.netscape.jndi.ldap.controls; + +import javax.naming.ldap.Control; +import netscape.ldap.controls.*; + +/** + * Represents an LDAP v3 server control that may be returned if a + * password has expired, and password policy is enabled on the server. + * The OID for this control is 2.16.840.1.113730.3.4.4. + *
+ */ + +public class LdapPasswordExpiredControl extends LDAPPasswordExpiredControl implements Control{ + + private String m_message; + /** + * This constractor is used by the NetscapeControlFactory + */ + LdapPasswordExpiredControl(boolean critical, byte[] value) throws Exception{ + m_value = value; + m_critical = critical; + m_message = new String(m_value, "UTF8"); + } + + /** + * Return string message passed in the control + * TODO what is the information in this string value ? + */ + public String getMessage() { + return m_message; + } + + /** + * Implements Control interface + */ + public byte[] getEncodedValue() { + return getValue(); + } +} diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapPasswordExpiringControl.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapPasswordExpiringControl.java new file mode 100644 index 00000000000..2a573a0a255 --- /dev/null +++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapPasswordExpiringControl.java @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ +package com.netscape.jndi.ldap.controls; + +import javax.naming.ldap.Control; +import netscape.ldap.controls.*; + +/** + * Represents an LDAP v3 server control that may be returned if a + * password is about to expire, and password policy is enabled on the server. + * The OID for this control is 2.16.840.1.113730.3.4.5. + *
+ */
+public class LdapPasswordExpiringControl extends LDAPPasswordExpiringControl implements Control {
+
+ //number of seconds before password expiration
+ int m_secondsToExpire = -1;
+
+ /**
+ * This constractor is used by the NetscapeControlFactory
+ */
+ LdapPasswordExpiringControl(boolean critical, byte[] value) throws Exception{
+ m_value = value;
+ m_critical = critical;
+ String msg = new String(m_value, "UTF8");
+ if (msg != null) {
+ m_secondsToExpire = Integer.parseInt(msg);
+ }
+ }
+
+ /**
+ * Return parsed number of seconds before password expires
+ */
+ public int getSecondsToExipre() {
+ return m_secondsToExpire;
+ }
+
+ /**
+ * Implements Control interface
+ */
+ public byte[] getEncodedValue() {
+ return getValue();
+ }
+}
diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapPersistSearchControl.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapPersistSearchControl.java
new file mode 100644
index 00000000000..32af3fa882a
--- /dev/null
+++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapPersistSearchControl.java
@@ -0,0 +1,194 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1999 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+package com.netscape.jndi.ldap.controls;
+
+import javax.naming.ldap.Control;
+import netscape.ldap.controls.*;
+
+/**
+ * Represents an LDAP v3 server control that specifies a persistent
+ * search (an ongoing search operation), which allows your LDAP client
+ * to get notification of changes to the directory. (The OID for this
+ * control is 2.16.840.1.113730.3.4.3.) You can use this control in
+ * conjunction with an "entry change notification" control (represented
+ * by LDAPEntryChangeControl object.
+ *
+ * + * To use persistent searching for change notification, you create a + * "persistent search" control that specifies the types of changes that + * you want to track. You include the control in a search request. + * If an entry in the directory is changed, the server determines if + * the entry matches the search criteria in your request and if the + * change is the type of change that you are tracking. If both of + * these are true, the server sends the entry to your client. + *
+ * + * The server can also include an "entry change notification" control + * with the entry. (The OID for this control is 2.16.840.1.113730.3.4.7.) + * This control contains additional information about the + * change made to the entry, including the type of change made, + * the change number (which corresponds to an item in the server's + * change log, if the server supports a change log), and, if the + * entry was renamed, the old DN of the entry. + *
+ *
+ * When constructing an LDAPPersistSearchControl object,
+ * you can specify the following information:
+ *
+ * + *
+ * @see com.netscape.jndi.ldap.controls.LDAPEntryChangeControl
+ */
+
+public class LdapPersistSearchControl extends LDAPPersistSearchControl implements Control {
+
+ /**
+ * Default constructor
+ */
+ public LdapPersistSearchControl() {
+ }
+
+ /**
+ * Constructs an LdapPersistSearchControl object
+ * that specifies a persistent search.
+ *
+ * @param changeTypes The change types to be monitored. You can perform
+ * a bitwise OR on any of the following values and specify the result as
+ * the change types:
+ *
LdapPersistSearchControl.ADD (to track new entries
+ * added to the directory)
+ * LdapPersistSearchControl.DELETE (to track entries
+ * removed from the directory)
+ * LdapPersistSearchControl.MODIFY (to track entries
+ * that have been modified)
+ * LdapPersistSearchControl.MODDN (to track entries
+ * that have been renamed)
+ * true if you do not want the server
+ * to return all existing entries in the directory that match the
+ * search criteria. (You just want the changed entries to be returned.)
+ * @param returnControls true you want the server to return
+ * entry change controls with each entry in the search results.
+ * @param isCritical true if this control is critical to
+ * the search operation (for example, if the server does not support
+ * this control, you may not want the server to perform the search
+ * at all.)
+ * @see com.netscape.jndi.ldap.controls.LdapEntryChangeControl
+ */
+ public LdapPersistSearchControl(int changeTypes, boolean changesOnly,
+ boolean returnControls, boolean isCritical) {
+ super(changeTypes, changesOnly, returnControls, isCritical);
+ }
+
+ /**
+ * Gets the change types monitored by this control.
+ * @return Integer representing the change types that you want monitored.
+ * This value can be the bitwise OR of ADD, DELETE, MODIFY,
+ * and/or MODDN. If the change type is unknown,
+ * this method returns -1.
+ * @see com.netscape.jndi.ldap.controls.LdapPersistSearchControl#setChangeTypes
+ */
+ public int getChangeTypes() {
+ return super.getChangeTypes();
+ }
+
+ /**
+ * Indicates whether you want the server to send any existing
+ * entries that already match the search criteria or only the
+ * entries that have changed.
+ * @return If true, the server returns only the
+ * entries that have changed. If false, the server
+ * also returns any existing entries that match the search criteria
+ * but have not changed.
+ * @see com.netscape.jndi.ldap.controls.LdapPersistSearchControl#setChangesOnly
+ */
+ public boolean getChangesOnly() {
+ return super.getChangesOnly();
+ }
+
+ /**
+ * Indicates whether or not the server includes an "entry change
+ * notification" control with each entry it sends back to the client
+ * during the persistent search.
+ * @return true if the server includes "entry change
+ * notification" controls with the entries it sends during the
+ * persistent search.
+ * @see com.netscape.jndi.ldap.controls.LdapEntryChangeControl
+ * @see com.netscape.jndi.ldap.controls.LdapPersistSearchControl#setReturnControls
+ */
+ public boolean getReturnControls() {
+ return super.getReturnControls();
+ }
+
+ /**
+ * Sets the change types that you want monitored by this control.
+ * @param types Integer representing the change types that you want monitored.
+ * This value can be the bitwise OR of ADD, DELETE, MODIFY,
+ * and/or MODDN.
+ * @see com.netscape.jndi.ldap.controls.LdapPersistSearchControl#getChangeTypes
+ */
+ public void setChangeTypes(int types) {
+ super.setChangeTypes(types);
+ }
+
+ /**
+ * Specifies whether you want the server to send any existing
+ * entries that already match the search criteria or only the
+ * entries that have changed.
+ * @param changesOnly If true, the server returns only the
+ * entries that have changed. If false, the server
+ * also returns any existing entries that match the search criteria
+ * but have not changed.
+ * @see com.netscape.jndi.ldap.controls.LdapPersistSearchControl#getChangesOnly
+ */
+ public void setChangesOnly(boolean changesOnly) {
+ super.setChangesOnly(changesOnly);
+ }
+
+ /**
+ * Specifies whether you want the server to include an "entry change
+ * notification" control with each entry it sends back to the client
+ * during the persistent search.
+ * @param returnControls If true, the server includes
+ * "entry change notification" controls with the entries it sends
+ * during the persistent search.
+ * @see com.netscape.jndi.ldap.controls.LdapEntryChangeControl
+ * @see com.netscape.jndi.ldap.controls.LdapPersistSearchControl#setReturnControls
+ */
+ public void setReturnControls(boolean returnControls) {
+ super.setReturnControls(returnControls);
+ }
+
+ /**
+ * Implements Control interface
+ */
+ public byte[] getEncodedValue() {
+ return getValue();
+ }
+}
diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapProxiedAuthControl.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapProxiedAuthControl.java
new file mode 100644
index 00000000000..ff5ed80b868
--- /dev/null
+++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapProxiedAuthControl.java
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1999 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+package com.netscape.jndi.ldap.controls;
+
+import javax.naming.ldap.Control;
+import netscape.ldap.controls.*;
+
+/**
+ * Represents an LDAP v3 server control that specifies that you want
+ * the server to use the specified DN's identity for this operation.
+ * (The OID for this control is 2.16.840.1.113730.3.4.12.)
+ *
+ *
+ * You can include the control in any request by constructing
+ * an LDAPSearchConstraints object and calling the
+ * setServerControls method. You can then pass this
+ * LDAPSearchConstraints object to the search
+ * or other request method of an LDAPConnection object.
+ *
+ * + * For example: + *
+ * ...
+ * LDAPConnection ld = new LDAPConnection();
+ * try {
+ * // Connect to server.
+ * ld.connect( 3, hostname, portnumber, "", "" );
+ *
+ * // Create a "critical" proxied auth server control using
+ * // the DN "uid=charlie,ou=people,o=acme.com".
+ * LDAPProxiedAuthControl ctrl =
+ * new LDAPProxiedAuthControl( "uid=charlie,ou=people,o=acme.com",
+ * true );
+ *
+ * // Create search constraints to use that control.
+ * LDAPSearchConstraints cons = new LDAPSearchConstraints();
+ * cons.setServerControls( sortCtrl );
+ *
+ * // Send the search request.
+ * LDAPSearchResults res = ld.search( "o=Airius.com",
+ * LDAPv3.SCOPE_SUB, "(cn=Barbara*)", null, false, cons );
+ *
+ * ...
+ *
+ *
+ *
+ *
+ * @see com.netscape.jndi.ldap.LdapSearchConstraints
+ * @see com.netscape.jndi.ldap.LdapSearchConstraints#setServerControls(LDAPControl)
+ */
+public class LdapProxiedAuthControl extends LDAPProxiedAuthControl implements Control {
+
+ /**
+ * Constructs an LdapProxiedAuthControl object with a
+ * DN to use as identity.
+ * @param dn DN to use as identity for execution of a request.
+ * @param critical true if the LDAP operation should be
+ * discarded when the server does not support this control (in other
+ * words, this control is critical to the LDAP operation).
+ */
+ public LdapProxiedAuthControl( String dn,
+ boolean critical) {
+ super( dn, critical);
+ }
+
+ /**
+ * Implements Control interface
+ */
+ public byte[] getEncodedValue() {
+ return getValue();
+ }
+
+}
+
diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapSortControl.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapSortControl.java
new file mode 100644
index 00000000000..23157a5fcc4
--- /dev/null
+++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapSortControl.java
@@ -0,0 +1,257 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+package com.netscape.jndi.ldap.controls;
+
+import javax.naming.ldap.Control;
+import netscape.ldap.controls.*;
+
+/**
+ * Represents an LDAP v3 server control that specifies that you want
+ * the server to return sorted search results. (The OID for this
+ * control is 1.2.840.113556.1.4.473.)
+ *
+ *
+ * When constructing an LDAPSortControl object, you can
+ * specify the order in which you want the results sorted.
+ * You can also specify whether or not this control is critical
+ * to the search operation.
+ *
+ *
+ * To specify the sort order, you construct an LDAPSortKey
+ * object and pass it to the LDAPSortControl constructor.
+ * The LDAPSortKey object represents a list of the attribute
+ * types used for sorting (a "sort key list").
+ *
+ *
+ * You can include the control in a search request by constructing
+ * an LDAPSearchConstraints object and calling the
+ * setServerControls method. You can then pass this
+ * LDAPSearchConstraints object to the search
+ * method of an LDAPConnection object.
+ *
+ * + * For example: + *
+ * ...
+ * LDAPConnection ld = new LDAPConnection();
+ * try {
+ * // Connect to server.
+ * ld.connect( 3, hostname, portnumber, "", "" );
+ *
+ * // Create a sort key that specifies the sort order.
+ * LDAPSortKey sortOrder = new LDAPSortKey( attrname );
+ *
+ * // Create a "critical" server control using that sort key.
+ * LDAPSortControl sortCtrl = new LDAPSortControl(sortOrder,true);
+ *
+ * // Create search constraints to use that control.
+ * LDAPSearchConstraints cons = new LDAPSearchConstraints();
+ * cons.setServerControls( sortCtrl );
+ *
+ * // Send the search request.
+ * LDAPSearchResults res = ld.search( "o=Airius.com",
+ * LDAPv3.SCOPE_SUB, "(cn=Barbara*)", null, false, cons );
+ *
+ * ...
+ *
+ *
+ *
+ * The LDAP server sends back a sort response control to indicate
+ * the result of the sorting operation. (The OID for this control
+ * is 1.2.840.113556.1.4.474.)
+ * + * + * This control contains: + *
+ * + *
+ *
+ * To parse this control, use the parseResponse method.
+ *
+ * + * The following table lists what kinds of results to expect from the + * LDAP server under different situations: + *
+ * + *
| Does the Server Support the Sorting Control? | + *Is the Sorting Control Marked As Critical? | + *Other Conditions | + *Results from LDAP Server | + *
|---|---|---|---|
| + * No + * | + *+ * Yes + * | + *+ * None + * | + *
+ *
|
+ *
| + * No + * | + *+ * None + * | + *
+ *
+ * |
+ * |
| + * Yes + * | + *+ * Yes + * | + *+ * The server cannot sort the results using the specified + * sort key list. + * | + *
+ *
|
+ *
| + * No + * | + *
+ *
|
+ * ||
| + * N/A (could either be marked as critical or not) + * | + *+ * The server successfully sorted the entries. + * | + *
+ *
|
+ * |
| + * The search itself failed (for any reason). + * | + *
+ *
|
+ *
+ * @see com.netscape.jndi.ldap.LdapSortKey
+ * @see com.netscape.jndi.ldap.LdapSearchConstraints
+ * @see com.netscape.jndi.ldap.LdapSearchConstraints#setServerControls(LDAPControl)
+ */
+public class LdapSortControl extends LDAPSortControl implements Control{
+ /**
+ * Constructs an LDAPSortControl object with a single
+ * sorting key.
+ * @param key A single attribute to sort by.
+ * @param critical true if the LDAP operation should be
+ * discarded when the server does not support this control (in other
+ * words, this control is critical to the LDAP operation).
+ * @see com.netscape.jndi.ldap.LdapSortKey
+ */
+ public LdapSortControl(LdapSortKey key,
+ boolean critical) {
+ super (key, critical);
+ }
+
+ /**
+ * Constructs an LDAPSortControl object with an array of
+ * sorting keys.
+ * @param keys The attributes to sort by.
+ * @param critical true if the LDAP operation should be
+ * discarded when the server does not support this control (in other
+ * words, this control is critical to the LDAP operation).
+ * @see com.netscape.jndi.ldap.LdapSortKey
+ */
+ public LdapSortControl(LdapSortKey[] keys,
+ boolean critical) {
+ super(keys, critical);
+ }
+
+
+ static LdapSortKey[] toSortKey(String[] keysIn) {
+ LdapSortKey[] keysOut = new LdapSortKey[keysIn.length];
+ for (int i=0; i < keysIn.length; i++) {
+ keysOut[i] = new LdapSortKey(keysIn[i]);
+ }
+ return keysOut;
+ }
+
+ public LdapSortControl(String[] keys,
+ boolean critical) {
+ super(toSortKey(keys), critical);
+ }
+
+
+ /**
+ * Implements Control interface
+ */
+ public byte[] getEncodedValue() {
+ return getValue();
+ }
+}
+
diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapSortKey.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapSortKey.java
new file mode 100644
index 00000000000..2adabe6f97e
--- /dev/null
+++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapSortKey.java
@@ -0,0 +1,124 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1999 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+package com.netscape.jndi.ldap.controls;
+
+import netscape.ldap.LDAPSortKey;
+
+/**
+ * Represents sorting instructions for a particular attribute.
+ *
+ */
+public class LdapSortKey extends LDAPSortKey{
+
+ /**
+ * Constructs a new LdapSortKey object that will
+ * sort based on the specified instructions.
+ * @param keyDescription A single attribute specification to sort by.
+ * If preceded by a hyphen ("-"), the attribute is sorted in reverse order.
+ * You can also specify the object ID (OID) of a matching rule after
+ * a colon (":"). For example:
+ *
+ *
"cn" (sort by the cn attribute) + *
"-cn" (sort by the cn attribute in
+ * reverse order) + *
"-cn:1.2.3.4" (sort by the cn
+ * attribute in reverse order and use the matching rule identified
+ * by the OID 1.2.3.4) + *
LdapSortKey object that will
+ * sort based on the specified attribute and sort order.
+ * @param key A single attribute to sort by. For example:
+ * + *
"cn" (sort by the cn attribute)
+ * "givenname" (sort by the givenname
+ * attribute)
+ * true, the sorting is done in
+ * descending order.
+ * @see com.netscape.jndi.ldap.controls.LdapPagedControl
+ * @see com.netscape.jndi.ldap.controls.LdapSortControl
+ * @see com.netscape.jndi.ldap.controls.LdapVirtualListControl
+ */
+ public LdapSortKey( String key,
+ boolean reverse) {
+ super(key,reverse);
+ }
+
+ /**
+ * Constructs a new LdapSortKey object that will
+ * sort based on the specified attribute, sort order, and matching
+ * rule.
+ * @param key A single attribute to sort by. For example:
+ * + *
"cn" (sort by the cn attribute)
+ * "givenname" (sort by the givenname
+ * attribute)
+ * true, the sorting is done in
+ * descending order.
+ * @param matchRule Object ID (OID) of the matching rule for
+ * the attribute (for example, 1.2.3.4).
+ * @see com.netscape.jndi.ldap.controls.LdapPagedControl
+ * @see com.netscape.jndi.ldap.controls.LdapSortControl
+ * @see com.netscape.jndi.ldap.controls.LdapVirtualListControl
+ */
+ public LdapSortKey( String key,
+ boolean reverse,
+ String matchRule) {
+ super(key, reverse, matchRule);
+ }
+
+ /**
+ * Returns the attribute to sort by.
+ * @return A single attribute to sort by.
+ */
+ public String getKey() {
+ return super.getKey();
+ }
+
+ /**
+ * Returns true if sorting is to be done in descending order.
+ * @return true if sorting is to be done in descending order.
+ */
+ public boolean getReverse() {
+ return super.getReverse();
+ }
+
+ /**
+ * Returns the object ID (OID) of the matching rule used for sorting.
+ * If no matching rule is specified, null is returned.
+ * @return The object ID (OID) of the matching rule, or null
+ * if the sorting instructions specify no matching rule.
+ */
+ public String getMatchRule() {
+ return super.getMatchRule();
+ }
+}
+
diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapSortResponseControl.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapSortResponseControl.java
new file mode 100644
index 00000000000..5ad9d9e796e
--- /dev/null
+++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapSortResponseControl.java
@@ -0,0 +1,223 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1999 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+package com.netscape.jndi.ldap.controls;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.Control;
+import netscape.ldap.LDAPControl;
+import netscape.ldap.LDAPException;
+import netscape.ldap.controls.*;
+import com.netscape.jndi.ldap.common.ExceptionMapper;
+
+/**
+ * The LDAP server sends back a sort response control to indicate
+ * the result of the sorting operation. (The OID for this control
+ * is 1.2.840.113556.1.4.474.)
+ * + * + * This control contains: + *
+ * + *
+ *
+ * To parse this control, use the parseResponse method.
+ *
+ * + * The following table lists what kinds of results to expect from the + * LDAP server under different situations: + *
+ * + *
| Does the Server Support the Sorting Control? | + *Is the Sorting Control Marked As Critical? | + *Other Conditions | + *Results from LDAP Server | + *
|---|---|---|---|
| + * No + * | + *+ * Yes + * | + *+ * None + * | + *
+ *
|
+ *
| + * No + * | + *+ * None + * | + *
+ *
+ * |
+ * |
| + * Yes + * | + *+ * Yes + * | + *+ * The server cannot sort the results using the specified + * sort key list. + * | + *
+ *
|
+ *
| + * No + * | + *
+ *
|
+ * ||
| + * N/A (could either be marked as critical or not) + * | + *+ * The server successfully sorted the entries. + * | + *
+ *
|
+ * |
| + * The search itself failed (for any reason). + * | + *
+ *
|
+ *
+ * @see com.netscape.jndi.ldap.LdapSortKey
+ * @see com.netscape.jndi.ldap.LdapSearchConstraints
+ * @see com.netscape.jndi.ldap.LdapSearchConstraints#setServerControls(LDAPControl)
+ */
+public class LdapSortResponseControl extends LDAPControl implements Control {
+
+ String m_failedAttribute;
+ int m_resultCode;
+ /**
+ * Constructs a new LdapEntryChangeControl object.
+ * This constructor is used by the NetscapeControlFactory
+ *
+ * @see com.netscape.jndi.ldap.controls.LdapPersistSearchControl
+ */
+ LdapSortResponseControl(boolean critical, byte[] value) {
+ super(LDAPSortControl.SORTRESPONSE, critical, value);
+ }
+
+ /**
+ * Set the first attribute type from the sort key list that
+ * resulted in an error
+ * This method is used by the NetscapeControlFactory
+ */
+ void setFailedAttribute(String attr) {
+ m_failedAttribute = attr;
+ }
+
+ /**
+ * Set the sort result code
+ * This method is used by the NetscapeControlFactory
+ */
+ void setResultCode(int code) {
+ m_resultCode = code;
+ }
+
+ /**
+ * Get the first attribute type from the sort key list that
+ * resulted in an error
+ */
+ public String getFailedAttribute() {
+ return m_failedAttribute;
+ }
+
+ /**
+ * Return the sort result code
+ */
+ public int getResultCode() {
+ return m_resultCode;
+ }
+
+ /**
+ * Return corresponding NamingException for the sort error code
+ */
+ public NamingException getSortException() {
+ if (m_resultCode == 0) { // success
+ return null;
+ }
+ return ExceptionMapper.getNamingException(
+ new LDAPException("Server Sort Failed", m_resultCode));
+ }
+ /**
+ * Implements Control interface
+ */
+ public byte[] getEncodedValue() {
+ return getValue();
+ }
+}
+
diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapStringControl.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapStringControl.java
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapStringControl.java
@@ -0,0 +1 @@
+
diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapVirtualListControl.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapVirtualListControl.java
new file mode 100644
index 00000000000..17f40f6ef2a
--- /dev/null
+++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapVirtualListControl.java
@@ -0,0 +1,147 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+package com.netscape.jndi.ldap.controls;
+
+import javax.naming.ldap.Control;
+import netscape.ldap.controls.*;
+
+/**
+ * Represents control data for returning paged results from a search.
+ *
+ *
+ * VirtualListViewRequest ::= SEQUENCE {
+ * beforeCount INTEGER,
+ * afterCount INTEGER,
+ * CHOICE {
+ * byIndex [0] SEQUENCE {
+ * index INTEGER,
+ * contentCount INTEGER }
+ * byFilter [1] jumpTo Substring }
+ *
+ *
+ */
+
+public class LdapVirtualListControl extends LDAPVirtualListControl implements Control {
+
+ /**
+ * Constructs a new LDAPVirtualListControl object. Use this
+ * constructor on an initial search operation, specifying the first
+ * entry to be matched, or the initial part of it.
+ * @param jumpTo An LDAP search expression defining the result set.
+ * @param beforeCount The number of results before the top/center to
+ * return per page.
+ * @param afterCount The number of results after the top/center to
+ * return per page.
+ */
+ public LdapVirtualListControl( String jumpTo, int beforeCount,
+ int afterCount ) {
+ super( jumpTo, beforeCount, afterCount);
+ }
+
+ /**
+ * Constructs a new LDAPVirtualListControl object. Use this
+ * constructor on a subsquent search operation, after we know the
+ * size of the virtual list, to fetch a subset.
+ * @param startIndex The index into the virtual list of an entry to
+ * return.
+ * @param beforeCount The number of results before the top/center to
+ * return per page.
+ * @param afterCount The number of results after the top/center to
+ * return per page.
+ */
+ public LdapVirtualListControl( int startIndex, int beforeCount,
+ int afterCount, int contentCount ) {
+ super( startIndex, beforeCount, afterCount, contentCount );
+ }
+
+ /**
+ * Sets the starting index, and the number of entries before and after
+ * to return. Apply this method to a control returned from a previous
+ * search, to specify what result range to return on the next search.
+ * @param startIndex The index into the virtual list of an entry to
+ * return.
+ * @param beforeCount The number of results before startIndex to
+ * return per page.
+ * @param afterCount The number of results after startIndex to
+ * return per page.
+ */
+ public void setRange( int startIndex, int beforeCount, int afterCount ) {
+ super.setRange(startIndex, beforeCount, afterCount);
+ }
+
+ /**
+ * Sets the search expression, and the number of entries before and after
+ * to return.
+ * @param jumpTo An LDAP search expression defining the result set.
+ * return.
+ * @param beforeCount The number of results before startIndex to
+ * return per page.
+ * @param afterCount The number of results after startIndex to
+ * return per page.
+ */
+ public void setRange( String jumpTo, int beforeCount, int afterCount ) {
+ super.setRange(jumpTo, beforeCount, afterCount);
+ }
+
+ /**
+ * Gets the size of the virtual result set.
+ * @return The size of the virtual result set, or -1 if not known.
+ */
+ public int getIndex() {
+ return super.getIndex();
+ }
+
+ /**
+ * Gets the size of the virtual result set.
+ * @return The size of the virtual result set, or -1 if not known.
+ */
+ public int getListSize() {
+ return super.getListSize();
+ }
+
+ /**
+ * Sets the size of the virtual result set.
+ * @param listSize The virtual result set size.
+ */
+ public void setListSize( int listSize ) {
+ super.setListSize(listSize);
+ }
+
+ /**
+ * Gets the number of results before the top/center to return per page.
+ * @return The number of results before the top/center to return per page.
+ */
+ public int getBeforeCount() {
+ return super.getBeforeCount();
+ }
+
+ /**
+ * Gets the number of results after the top/center to return per page.
+ * @return The number of results after the top/center to return per page.
+ */
+ public int getAfterCount() {
+ return super.getAfterCount();
+ }
+
+ /**
+ * Implements Control interface
+ */
+ public byte[] getEncodedValue() {
+ return getValue();
+ }
+}
diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapVirtualListResponseControl.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapVirtualListResponseControl.java
new file mode 100644
index 00000000000..15c8d86877d
--- /dev/null
+++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/LdapVirtualListResponseControl.java
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1999 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+package com.netscape.jndi.ldap.controls;
+
+import javax.naming.ldap.Control;
+import netscape.ldap.controls.*;
+
+
+/**
+ * Represents control data for returning paged results from a search.
+ *
+ *
+ *
+ * VirtualListViewResponse ::= SEQUENCE {
+ * firstPosition INTEGER,
+ * contentCount INTEGER,
+ * virtualListViewResult ENUMERATED {
+ * success (0),
+ * unwillingToPerform (53),
+ * insufficientAccessRights (50),
+ * operationsError (1),
+ * busy (51),
+ * timeLimitExceeded (3),
+ * adminLimitExceeded (11),
+ * sortControlMissing (60),
+ * indexRangeError (?),
+ * }
+ * }
+ *
+ */
+
+public class LdapVirtualListResponseControl extends LDAPVirtualListResponse implements Control{
+
+ /**
+ * Constructs a new LDAPVirtualListResponse object.
+ * @param value A BER encoded byte array.
+ * This constructor is used by the NetscapeControlFactory
+ */
+ LdapVirtualListResponseControl( byte[] value ) {
+ // The superclass constractor parses the byte[] value
+ // automatically. No need to call parseResponse
+ super(value);
+ }
+
+ /**
+ * Gets the size of the virtual result set.
+ * @return The size of the virtual result set, or -1 if not known.
+ */
+ public int getContentCount() {
+ return super.getContentCount();
+ }
+
+ /**
+ * Gets the index of the first entry returned.
+ * @return The index of the first entry returned.
+ */
+ public int getFirstPosition() {
+ return super.getFirstPosition();
+ }
+
+ /**
+ * Gets the result code.
+ * @return The result code.
+ */
+ public int getResultCode() {
+ return super.getResultCode();
+ }
+
+ /**
+ * Implements Control interface
+ */
+ public byte[] getEncodedValue() {
+ return getValue();
+ }
+}
diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/NetscapeControlFactory.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/NetscapeControlFactory.java
new file mode 100644
index 00000000000..6bb1c82fc4b
--- /dev/null
+++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/controls/NetscapeControlFactory.java
@@ -0,0 +1,142 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1999 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+package com.netscape.jndi.ldap.controls;
+
+
+/**
+ * Factory for creating controls. Only controls send by the direcory server
+ * are processed.
+ */
+
+import javax.naming.*;
+import javax.naming.ldap.*;
+import netscape.ldap.LDAPControl;
+import netscape.ldap.controls.*;
+import com.netscape.jndi.ldap.common.ExceptionMapper;
+
+public class NetscapeControlFactory extends ControlFactory {
+
+ // "1.2.840.113556.1.4.473" Sort Control (Request)
+ final static String REQ_SORT = LDAPSortControl.SORTREQUEST;
+
+ // "1.2.840.113556.1.4.474" Sort Control (Response)
+ final static String RSP_SORT = LDAPSortControl.SORTRESPONSE;
+
+ // "2.16.840.1.113730.3.4.2" ManageDSAIT Control
+ final static String REQ_MANAGEDSAIT = LDAPControl.MANAGEDSAIT;
+
+ // "2.16.840.1.113730.3.4.3" PersistentSearch Control
+ final static String REQ_PERSISTENTSEARCH = LDAPPersistSearchControl.PERSISTENTSEARCH;
+
+ // "2.16.840.1.113730.3.4.4" PasswordExpired Control
+ final static String RSP_PWDEXPIRED = LDAPPasswordExpiredControl.EXPIRED;
+
+ // "2.16.840.1.113730.3.4.5" PasswordExpiring Control
+ final static String RSP_PWDEXPIRING = LDAPPasswordExpiringControl.EXPIRING;
+
+ // "2.16.840.1.113730.3.4.7" EntryChanged Controle
+ final static String RSP_ENTRYCHANGED = LDAPEntryChangeControl.ENTRYCHANGED;
+
+ // "2.16.840.1.113730.3.4.9" Virtual List (Request)
+ final static String REQ_VIRTUALLIST = LDAPVirtualListControl.VIRTUALLIST;
+
+ // "2.16.840.1.113730.3.4.10" Virtual List (Response)
+ final static String RSP_VIRTUALLIST = LDAPVirtualListResponse.VIRTUALLISTRESPONSE;
+
+ // "2.16.840.1.113730.3.4.12" Proxed Authentication
+ final static String REQ_PROXIEDAUTH = LDAPProxiedAuthControl.PROXIEDAUTHREQUEST;
+
+
+ /**
+ * Implements abstract getControlInstance() from ConrolFactory
+ */
+ public Control getControlInstance(Control ctrl) throws NamingException {
+ if (ctrl == null) {
+ return null;
+ }
+ LDAPControl rawCtrl = new LDAPControl(
+ ctrl.getID(), ctrl.isCritical(), ctrl.getEncodedValue());
+ return getControlInstance(rawCtrl);
+ }
+
+ /**
+ * Create control using parseResponse() methods in ldapjdk controls
+ */
+ public static Control getControlInstance(LDAPControl rawCtrl) throws NamingException {
+ if (rawCtrl == null) {
+ return null;
+ }
+
+ try {
+ String ctrlID = rawCtrl.getID();
+
+ // Entry changed control is parsed by LDAPPersistSearchControl
+ if (ctrlID.equals(RSP_ENTRYCHANGED)) {
+ // First get ldapjdk object
+ LDAPEntryChangeControl ldapjdkCtrl =
+ LDAPPersistSearchControl.parseResponse(new LDAPControl[] {rawCtrl});
+ // then map it to a jndi object
+ if (ldapjdkCtrl != null) {
+ LdapEntryChangeControl ctrl = new LdapEntryChangeControl(
+ rawCtrl.isCritical(), rawCtrl.getValue());
+ ctrl.setChangeNumber(ldapjdkCtrl.getChangeNumber());
+ ctrl.setChangeType(ldapjdkCtrl.getChangeType());
+ ctrl.setPreviousDN(ldapjdkCtrl.getPreviousDN());
+ return ctrl;
+ }
+ }
+
+ // Password Expired control
+ else if(ctrlID.equals(RSP_PWDEXPIRED)) {
+ LdapPasswordExpiredControl ctrl = new LdapPasswordExpiredControl(
+ rawCtrl.isCritical(), rawCtrl.getValue());
+ }
+
+ // Password Expiring control
+ else if(ctrlID.equals(RSP_PWDEXPIRING)) {
+ LdapPasswordExpiringControl ctrl = new LdapPasswordExpiringControl(
+ rawCtrl.isCritical(), rawCtrl.getValue());
+ }
+
+ // Sort Response control
+ else if(ctrlID.equals(RSP_SORT)) {
+ // First parse the control
+ int[] resultCodes = new int[1];
+ String failedAttr = LDAPSortControl.parseResponse(
+ new LDAPControl[] {rawCtrl}, resultCodes);
+
+ LdapSortResponseControl ctrl = new LdapSortResponseControl(
+ rawCtrl.isCritical(), rawCtrl.getValue());
+ ctrl.setResultCode(resultCodes[0]);
+ ctrl.setFailedAttribute(failedAttr);
+ return ctrl;
+ }
+
+ // Virtual List Response control
+ else if(ctrlID.equals(RSP_VIRTUALLIST)) {
+ return new LdapVirtualListResponseControl(rawCtrl.getValue());
+ }
+
+ // No match try another ControlFactory
+ return null;
+ }
+ catch (Exception ex) {
+ throw ExceptionMapper.getNamingException(ex);
+ }
+ }
+}
diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/schema/SchemaAttribute.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/schema/SchemaAttribute.java
new file mode 100644
index 00000000000..af8ea990e82
--- /dev/null
+++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/schema/SchemaAttribute.java
@@ -0,0 +1,209 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1999 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+package com.netscape.jndi.ldap.schema;
+
+import javax.naming.*;
+import javax.naming.directory.*;
+import javax.naming.ldap.*;
+
+import netscape.ldap.*;
+import netscape.ldap.controls.*;
+
+import java.util.*;
+
+public class SchemaAttribute extends SchemaElement {
+
+ LDAPAttributeSchema m_ldapAttribute;
+
+ // Attribute IDs that are exposed through Netscape LdapJDK
+ private static String[] m_allAttrIds = {NUMERICOID, NAME, DESC, SYNTAX, SINGLEVALUE };
+
+ public SchemaAttribute(LDAPAttributeSchema ldapAttribute, SchemaManager schemaManager) {
+ super(schemaManager);
+ m_ldapAttribute = ldapAttribute;
+ m_path = ATTRDEF + "/" + m_ldapAttribute.getName();
+ }
+
+ public SchemaAttribute(Attributes attrs, SchemaManager schemaManager) throws NamingException {
+ super(schemaManager);
+ m_ldapAttribute = parseDefAttributes(attrs);
+ m_path = ATTRDEF + "/" + m_ldapAttribute.getName();
+ }
+
+ /**
+ * Parse Definition Attributes for a LDAP attribute
+ */
+ static LDAPAttributeSchema parseDefAttributes(Attributes attrs) throws NamingException {
+ String name="", oid="", desc="";
+ int syntax=-1;
+ boolean singleValued = false;
+
+ for (Enumeration attrEnum = attrs.getAll(); attrEnum.hasMoreElements(); ) {
+ Attribute attr = (Attribute) attrEnum.nextElement();
+ String attrName = attr.getID();
+ if (attrName.equals(NAME)) {
+ for (Enumeration valEnum = attr.getAll(); valEnum.hasMoreElements(); ) {
+ name = (String)valEnum.nextElement();
+ break;
+ }
+ }
+ else if (attrName.equals(NUMERICOID)) {
+ for (Enumeration valEnum = attr.getAll(); valEnum.hasMoreElements(); ) {
+ oid = (String)valEnum.nextElement();
+ break;
+ }
+ }
+ else if (attrName.equals(SYNTAX)) {
+ for (Enumeration valEnum = attr.getAll(); valEnum.hasMoreElements(); ) {
+ String syntaxString = (String)valEnum.nextElement();
+ syntax = syntaxStringToInt(syntaxString);
+ break;
+ }
+ }
+ else if (attrName.equals(DESC)) {
+ for (Enumeration valEnum = attr.getAll(); valEnum.hasMoreElements(); ) {
+ desc = (String)valEnum.nextElement();
+ break;
+ }
+ }
+ else if (attrName.equals(SINGLEVALUE)) {
+ for (Enumeration valEnum = attr.getAll(); valEnum.hasMoreElements(); ) {
+ String flag = (String)valEnum.nextElement();
+ if (flag.equals("true")) {
+ singleValued = true;
+ }
+ else if (flag.equals("false")) {
+ singleValued = false;
+ }
+ else {
+ throw new InvalidAttributeValueException(attrName);
+ }
+ break;
+ }
+ }
+ else if (attrName.equals(OBSOLETE) || attrName.equals(SUP) || attrName.equals(USAGE) ||
+ attrName.equals(EQUALITY) || attrName.equals(ORDERING) ||
+ attrName.equals(COLLECTIVE) || attrName.equals(NOUSERMOD)) {
+ ; //ignore
+ }
+ else {
+ throw new NamingException("Invalid schema attribute type for attribute definition " + attrName);
+ }
+ }
+
+ if (name.length() == 0 || oid.length() == 0 || syntax == -1) {
+ throw new NamingException("Incomplete schema attribute definition");
+ }
+
+ return new LDAPAttributeSchema(name, oid, desc, syntax, singleValued);
+ }
+
+
+ /**
+ * Exctract specified attributes from the ldapObjectClass
+ */
+ Attributes extractAttributeIds(String[] attrIds) throws NamingException{
+ Attributes attrs = new BasicAttributes();
+ for (int i = 0; i < attrIds.length; i++) {
+ if (attrIds[i].equals(NUMERICOID)) {
+ attrs.put(new BasicAttribute(NUMERICOID, m_ldapAttribute.getOID()));
+ }
+ else if (attrIds[i].equals(NAME)) {
+ attrs.put(new BasicAttribute(NAME, m_ldapAttribute.getName()));
+ }
+ else if (attrIds[i].equals(DESC)) {
+ attrs.put(new BasicAttribute(DESC, m_ldapAttribute.getDescription()));
+ }
+ else if (attrIds[i].equals(SYNTAX)) {
+ attrs.put(new BasicAttribute(SYNTAX, syntaxIntToString(m_ldapAttribute.getSyntax())));
+ }
+ else if (attrIds[i].equals(SINGLEVALUE)) {
+ attrs.put(new BasicAttribute(SINGLEVALUE,
+ (m_ldapAttribute.isSingleValued() ? "true" : "false")));
+ }
+ else {
+ // ignore other attrIds as not supported by Netscape LdapJDK APIs
+ }
+ }
+ return attrs;
+ }
+
+
+ /**
+ * DirContext Attribute Operations
+ */
+
+ public Attributes getAttributes(String name) throws NamingException {
+ if (name.length() != 0) { // no subcontexts
+ throw new NameNotFoundException(name); // no such object
+ }
+ return extractAttributeIds(m_allAttrIds);
+ }
+
+ public Attributes getAttributes(String name, String[] attrIds) throws NamingException {
+ if (name.length() != 0) { // no subcontexts
+ throw new NameNotFoundException(name); // no such object
+ }
+ return extractAttributeIds(attrIds);
+ }
+
+ public Attributes getAttributes(Name name) throws NamingException {
+ return getAttributes(name.toString());
+ }
+
+ public Attributes getAttributes(Name name, String[] attrIds) throws NamingException {
+ return getAttributes(name.toString(), attrIds);
+ }
+
+ public void modifyAttributes(String name, int mod_op, Attributes attrs) throws NamingException {
+ if (name.length() != 0) { // no subcontexts
+ throw new NameNotFoundException(name); // no such object
+ }
+ Attributes modAttrs = extractAttributeIds(m_allAttrIds);
+ modifySchemaElementAttrs(modAttrs, mod_op, attrs);
+ LDAPAttributeSchema modLdapAttribute = parseDefAttributes(modAttrs);
+ m_schemaMgr.modifyAttribute(m_ldapAttribute, modLdapAttribute);
+ m_ldapAttribute = modLdapAttribute;
+ }
+
+ public void modifyAttributes(String name, ModificationItem[] mods) throws NamingException {
+ if (name.length() != 0) { // no subcontexts
+ throw new NameNotFoundException(name); // no such object
+ }
+ Attributes modAttrs = extractAttributeIds(m_allAttrIds);
+ modifySchemaElementAttrs(modAttrs, mods);
+ LDAPAttributeSchema modLdapAttribute = parseDefAttributes(modAttrs);
+ m_schemaMgr.modifyAttribute(m_ldapAttribute, modLdapAttribute);
+ m_ldapAttribute = modLdapAttribute;
+ }
+
+ public void modifyAttributes(Name name, int mod_op, Attributes attrs) throws NamingException {
+ modifyAttributes(name.toString(), mod_op, attrs);
+ }
+
+ public void modifyAttributes(Name name, ModificationItem[] mods) throws NamingException {
+ modifyAttributes(name.toString(), mods);
+ }
+
+ /**
+ * Search operations are not implemented because of complexity. Ir will require
+ * to implement the full LDAP search filter sematics in the client. (The search
+ * filter sematics is implemented by the Directory server).
+ */
+
+}
diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/schema/SchemaAttributeContainer.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/schema/SchemaAttributeContainer.java
new file mode 100644
index 00000000000..a61bf8bc681
--- /dev/null
+++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/schema/SchemaAttributeContainer.java
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1999 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+package com.netscape.jndi.ldap.schema;
+
+import javax.naming.*;
+import javax.naming.directory.*;
+import javax.naming.ldap.*;
+
+import netscape.ldap.*;
+import netscape.ldap.controls.*;
+
+import java.util.*;
+
+public class SchemaAttributeContainer extends SchemaElementContainer {
+
+ public SchemaAttributeContainer(SchemaManager schemaMgr) throws NamingException{
+ super(schemaMgr, ATTRDEF);
+ }
+
+ /**
+ * Ldap entry operations
+ */
+
+ public DirContext createSchemaElement(String name, Attributes attrs) throws NamingException {
+ if (name.length() == 0) {
+ throw new NamingException("Empty name for schema objectclass");
+ }
+ LDAPAttributeSchema attr = SchemaAttribute.parseDefAttributes(attrs);
+ m_schemaMgr.createAttribute(attr);
+ return new SchemaAttribute(attr, m_schemaMgr);
+
+ }
+
+ public void removeSchemaElement(String name) throws NamingException {
+ if (name.length() == 0) {
+ throw new NamingException("Can not delete schema object container");
+ }
+ m_schemaMgr.removeAttribute(name);
+ }
+
+ /**
+ * List Operations
+ */
+
+ public NamingEnumeration getNameList(String name) throws NamingException {
+ SchemaDirContext schemaObj = (SchemaDirContext)lookup(name);
+ if (schemaObj == this) {
+ return new SchemaElementNameEnum(m_schemaMgr.getAttributeNames());
+ }
+ else {
+ throw new NotContextException(name);
+ }
+ }
+
+ public NamingEnumeration getBindingsList(String name) throws NamingException {
+ SchemaDirContext schemaObj = (SchemaDirContext)lookup(name);
+ if (schemaObj == this) {
+ return new SchemaElementBindingEnum(m_schemaMgr.getAttributes(), m_schemaMgr);
+ }
+ else {
+ throw new NotContextException(name);
+ }
+ }
+
+ /**
+ * Lookup Operations
+ */
+
+ public Object lookupSchemaElement(String name) throws NamingException {
+ if (name.length() == 0) {
+ return this;
+ }
+
+ // No caching; Always create a new object
+ LDAPAttributeSchema attr = m_schemaMgr.getAttribute(name);
+ if (attr == null) {
+ throw new NameNotFoundException(name);
+ }
+ return new SchemaAttribute(attr, m_schemaMgr);
+
+ }
+}
diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/schema/SchemaDirContext.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/schema/SchemaDirContext.java
new file mode 100644
index 00000000000..03ad4ce6c95
--- /dev/null
+++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/schema/SchemaDirContext.java
@@ -0,0 +1,160 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1999 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+package com.netscape.jndi.ldap.schema;
+
+import javax.naming.*;
+import javax.naming.directory.*;
+import javax.naming.ldap.*;
+
+import netscape.ldap.*;
+import netscape.ldap.controls.*;
+import com.netscape.jndi.ldap.common.DirContextAdapter;
+
+import java.util.*;
+
+public class SchemaDirContext extends DirContextAdapter {
+
+ public static final String CLASSDEF = "ClassDefinition";
+ public static final String ATTRDEF = "AttributeDefinition";
+ public static final String MRULEDEF = "MatchingRule";
+
+
+ String m_path;
+
+ public void close() throws NamingException {
+ ; //NOP
+ }
+
+ /**
+ * Name operations
+ */
+
+ public String composeName(String name, String prefix) throws NamingException {
+ return name + "," + prefix;
+ }
+
+ public Name composeName(Name name, Name prefix) throws NamingException {
+ String compoundName = composeName(name.toString(), prefix.toString());
+ return SchemaNameParser.getParser().parse(compoundName);
+ }
+
+ public String getNameInNamespace() throws NamingException {
+ return new String(m_path);
+ }
+
+ public NameParser getNameParser(String name) throws NamingException {
+ return SchemaNameParser.getParser();
+ }
+
+ public NameParser getNameParser(Name name) throws NamingException {
+ return SchemaNameParser.getParser();
+ }
+
+
+ /**
+ * Naming Bind operations
+ */
+
+ public void bind(String name, Object obj) throws NamingException {
+ if (obj instanceof DirContext) {
+ createSubcontext(name, ((DirContext)obj).getAttributes(""));
+ }
+ else {
+ throw new IllegalArgumentException("Can not bind this type of object");
+ }
+ }
+
+ public void bind(Name name, Object obj) throws NamingException {
+ bind(name.toString(), obj);
+ }
+
+ public void rebind(String name, Object obj) throws NamingException {
+ try {
+ bind(name, obj);
+ }
+ catch (NameAlreadyBoundException ex) {
+ unbind(name);
+ bind(name, obj);
+ }
+ }
+
+ public void rebind(Name name, Object obj) throws NamingException {
+ rebind(name.toString(), obj);
+ }
+
+ public void rename(String oldName, String newName) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ public void rename(Name oldName, Name newName) throws NamingException {
+ rename(oldName.toString(), newName.toString());
+ }
+
+ public void unbind(String name) throws NamingException {
+ // In ldap every entry is naming context
+ destroySubcontext(name);
+ }
+
+ public void unbind(Name name) throws NamingException {
+ // In ldap every entry is naming context
+ destroySubcontext(name);
+ }
+
+ /**
+ * Empty enumeration for list operations
+ */
+ class EmptyNamingEnumeration implements NamingEnumeration {
+
+ public Object next() throws NamingException{
+ throw new NoSuchElementException("EmptyNamingEnumeration");
+ }
+
+ public Object nextElement() {
+ throw new NoSuchElementException("EmptyNamingEnumeration");
+ }
+
+ public boolean hasMore() throws NamingException{
+ return false;
+ }
+
+ public boolean hasMoreElements() {
+ return false;
+ }
+
+ public void close() {}
+ }
+
+ static class SchemaObjectSubordinateNamePair {
+ SchemaDirContext schemaObj;
+ String subordinateName;
+
+ public SchemaObjectSubordinateNamePair(SchemaDirContext object, String subordinateName) {
+ this.schemaObj = object;
+ this.subordinateName = subordinateName;
+ }
+
+ public String toString() {
+ StringBuffer str = new StringBuffer("SchemaObjectSubordinateNamePair{obj:");
+ str.append(((schemaObj == null) ? "null" : schemaObj.toString()));
+ str.append(" name:");
+ str.append(subordinateName);
+ str.append("}");
+ return str.toString();
+ }
+ }
+}
diff --git a/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/schema/SchemaElement.java b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/schema/SchemaElement.java
new file mode 100644
index 00000000000..66c5f5c0b6a
--- /dev/null
+++ b/mozilla/directory/java-sdk/ldapsp/com/netscape/jndi/ldap/schema/SchemaElement.java
@@ -0,0 +1,213 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1999 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+package com.netscape.jndi.ldap.schema;
+
+import javax.naming.*;
+import javax.naming.directory.*;
+import javax.naming.ldap.*;
+
+import netscape.ldap.*;
+import netscape.ldap.controls.*;
+
+import java.util.*;
+
+public class SchemaElement extends SchemaDirContext {
+
+ SchemaManager m_schemaMgr;
+
+ // Attributes used to define schema elements
+ static final String NUMERICOID = "NUMERICOID";
+ static final String NAME = "NAME";
+ static final String DESC = "DESC";
+ static final String SYNTAX = "SYNTAX";
+ static final String SUP = "SUP";
+ static final String MUST = "MUST";
+ static final String MAY = "MAY";
+ static final String SINGLEVALUE = "SINGLE-VALUE";
+
+ // These attribute definition properties are not supported by LdapJDK and DS
+ // Accept them for the appropriate schema element, but ignore them
+ static final String OBSOLETE = "OBSOLETE";
+ static final String EQUALITY = "EQUALITY";
+ static final String ORDERING = "ORDERING";
+ static final String COLLECTIVE = "COLLECTIVE";
+ static final String NOUSERMOD = "NO-USER-MODIFICATION";
+ static final String USAGE = "USAGE";
+ static final String ABSTRACT = "ABSTRACT";
+ static final String STRUCTURAL = "STRUCTURAL";
+ static final String AUXILIARY = "AUXILIARY";
+
+
+ // Syntax string recognized by Netscape LdapJDK
+ static final String cisString = "1.3.6.1.4.1.1466.115.121.1.15";
+ static final String binaryString = "1.3.6.1.4.1.1466.115.121.1.5";
+ static final String telephoneString = "1.3.6.1.4.1.1466.115.121.1.50";
+ static final String cesString = "1.3.6.1.4.1.1466.115.121.1.26";
+ static final String intString = "1.3.6.1.4.1.1466.115.121.1.27";
+ static final String dnString = "1.3.6.1.4.1.1466.115.121.1.12";
+
+ SchemaElement(SchemaManager schemaMgr) {
+ m_schemaMgr = schemaMgr;
+ }
+
+ /**
+ * Map a syntax oid string to a constant recognized by LdapJDK
+ */
+ static int syntaxStringToInt(String syntax) throws NamingException{
+ if (syntax.equals(cisString)) {
+ return LDAPSchemaElement.cis;
+ }
+ else if (syntax.equals(cesString)) {
+ return LDAPSchemaElement.ces;
+ }
+ else if (syntax.equals(telephoneString)) {
+ return LDAPSchemaElement.telephone;
+ }
+ else if (syntax.equals(intString)) {
+ return LDAPSchemaElement.integer;
+ }
+ else if (syntax.equals(dnString)) {
+ return LDAPSchemaElement.dn;
+ }
+ else if (syntax.equals(binaryString)) {
+ return LDAPSchemaElement.binary;
+ }
+ else {
+ throw new InvalidAttributeValueException(syntax);
+ }
+ }
+
+ /**
+ * Map a syntax identifier to a oid string
+ */
+ static String syntaxIntToString(int syntax) throws NamingException{
+ if (syntax == LDAPSchemaElement.cis) {
+ return cisString;
+ }
+ else if (syntax == LDAPSchemaElement.ces) {
+ return cesString;
+ }
+ else if (syntax == LDAPSchemaElement.telephone) {
+ return telephoneString;
+ }
+ else if (syntax == LDAPSchemaElement.integer) {
+ return intString;
+ }
+ else if (syntax == LDAPSchemaElement.dn) {
+ return dnString;
+ }
+ else if (syntax == LDAPSchemaElement.binary) {
+ return binaryString;
+ }
+ else {
+ throw new InvalidAttributeValueException("Interanal error, unexpected syntax value " + syntax);
+ }
+ }
+
+ /**
+ * Convert string vector to an array
+ */
+ static String[] vectorToStringAry(Vector v) {
+ String[] ary = new String[v.size()];
+ for(int i=0; i