From ad0b870a9da22365561ff9c6d6d05fda23e7bdf8 Mon Sep 17 00:00:00 2001
From: dugan <dugan@localhost>
Date: Mon, 09 Jul 2007 22:54:35 +0000
Subject: [PATCH] Define the configuration option "ds-cfg-strip-syntax-minimum-upper-bound" to strip the suggested minimum upper bound value from the schema definition attribute type description syntax oid. For example:
---
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/AttributeTypeDescriptionAttributeSyntaxConfiguration.xml | 74 ++++++++++++++++++++++++
opendj-sdk/opends/resource/config/config.ldif | 1
opendj-sdk/opends/src/server/org/opends/server/schema/AttributeTypeSyntax.java | 91 ++++++++++++++++++++++++------
opendj-sdk/opends/resource/schema/02-config.ldif | 9 +++
4 files changed, 157 insertions(+), 18 deletions(-)
diff --git a/opendj-sdk/opends/resource/config/config.ldif b/opendj-sdk/opends/resource/config/config.ldif
index db6a9ed..e4dbc82 100644
--- a/opendj-sdk/opends/resource/config/config.ldif
+++ b/opendj-sdk/opends/resource/config/config.ldif
@@ -1433,6 +1433,7 @@
dn: cn=Attribute Type Description,cn=Syntaxes,cn=config
objectClass: top
objectClass: ds-cfg-attribute-syntax
+objectClass: ds-cfg-attribute-type-description-attribute-syntax
cn: Attribute Type Description
ds-cfg-syntax-class: org.opends.server.schema.AttributeTypeSyntax
ds-cfg-syntax-enabled: true
diff --git a/opendj-sdk/opends/resource/schema/02-config.ldif b/opendj-sdk/opends/resource/schema/02-config.ldif
index 4c40418..e3fd83d 100644
--- a/opendj-sdk/opends/resource/schema/02-config.ldif
+++ b/opendj-sdk/opends/resource/schema/02-config.ldif
@@ -1463,6 +1463,10 @@
attributeTypes: ( 1.3.6.1.4.1.26027.1.1.430
NAME 'ds-cfg-default-auth-password-storage-scheme'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'OpenDS Directory Server' )
+attributeTypes: ( 1.3.6.1.4.1.26027.1.1.435
+ NAME 'ds-cfg-strip-syntax-minimum-upper-bound'
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE
+ X-ORIGIN 'OpenDS Directory Server' )
objectClasses: ( 1.3.6.1.4.1.26027.1.2.1
NAME 'ds-cfg-access-control-handler' SUP top STRUCTURAL
MUST ( cn $ ds-cfg-acl-handler-class $ ds-cfg-acl-handler-enabled )
@@ -1479,6 +1483,11 @@
objectClasses: ( 1.3.6.1.4.1.26027.1.2.3 NAME 'ds-cfg-attribute-syntax'
SUP top STRUCTURAL MUST ( cn $ ds-cfg-syntax-class $ ds-cfg-syntax-enabled )
X-ORIGIN 'OpenDS Directory Server' )
+objectClasses: ( 1.3.6.1.4.1.26027.1.2.116
+ NAME 'ds-cfg-attribute-type-description-attribute-syntax'
+ SUP ds-cfg-attribute-syntax STRUCTURAL
+ MAY ( ds-cfg-strip-syntax-minimum-upper-bound )
+ X-ORIGIN 'OpenDS Directory Server' )
objectClasses: ( 1.3.6.1.4.1.26027.1.2.4
NAME 'ds-cfg-telephone-number-attribute-syntax'
SUP ds-cfg-attribute-syntax STRUCTURAL
diff --git a/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/AttributeTypeDescriptionAttributeSyntaxConfiguration.xml b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/AttributeTypeDescriptionAttributeSyntaxConfiguration.xml
new file mode 100644
index 0000000..c1560e4
--- /dev/null
+++ b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/AttributeTypeDescriptionAttributeSyntaxConfiguration.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+! CDDL HEADER START
+!
+! The contents of this file are subject to the terms of the
+! Common Development and Distribution License, Version 1.0 only
+! (the "License"). You may not use this file except in compliance
+! with the License.
+!
+! You can obtain a copy of the license at
+! trunk/opends/resource/legal-notices/OpenDS.LICENSE
+! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+! See the License for the specific language governing permissions
+! and limitations under the License.
+!
+! When distributing Covered Code, include this CDDL HEADER in each
+! file and include the License file at
+! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
+! add the following below this CDDL HEADER, with the fields enclosed
+! by brackets "[]" replaced with your own identifying information:
+! Portions Copyright [yyyy] [name of copyright owner]
+!
+! CDDL HEADER END
+!
+!
+! Portions Copyright 2007 Sun Microsystems, Inc.
+! -->
+
+<adm:managed-object name="attribute-type-description-attribute-syntax"
+plural-name="attribute-type-description-attribute-syntaxes"
+extends="attribute-syntax"
+package="org.opends.server.admin.std" abstract="false"
+xmlns:adm="http://www.opends.org/admin"
+xmlns:ldap="http://www.opends.org/admin-ldap">
+ <adm:synopsis>
+ <adm:user-friendly-plural-name />
+ describe the format of the directory schema attribute type definitions.
+ </adm:synopsis>
+
+ <adm:profile name="ldap">
+ <ldap:object-class>
+ <ldap:oid>11.3.6.1.4.1.26027.1.2.116</ldap:oid>
+ <ldap:name>ds-cfg-attribute-type-description-attribute-syntax</ldap:name>
+ <ldap:superior>ds-cfg-attribute-syntax</ldap:superior>
+ </ldap:object-class>
+ </adm:profile>
+
+ <adm:property name="strip-syntax-minimum-upper-bound" mandatory="false">
+ <adm:synopsis>
+ Indicate whether the suggested minimum upper bound appended
+ to an attribute's syntax OID in it's schema definition Attribute Type
+ Description is stripped off. When retrieving the server's schema, some API's
+ (JNDI) fail in their syntax lookup methods because they don't parse this value
+ correctly. This configuration option allows the server to be configured to
+ provide schema definitions these APIs can parse correctly.
+ </adm:synopsis>
+ <adm:default-behavior>
+ <adm:defined>
+ <adm:value>false</adm:value>
+ </adm:defined>
+ </adm:default-behavior>
+ <adm:syntax>
+ <adm:boolean />
+ </adm:syntax>
+ <adm:profile name="ldap">
+ <ldap:attribute>
+ <ldap:oid>1.3.6.1.4.1.26027.1.1.435</ldap:oid>
+ <ldap:name>ds-cfg-strip-syntax-minimum-upper-bound</ldap:name>
+ </ldap:attribute>
+ </adm:profile>
+ </adm:property>
+
+</adm:managed-object>
+
diff --git a/opendj-sdk/opends/src/server/org/opends/server/schema/AttributeTypeSyntax.java b/opendj-sdk/opends/src/server/org/opends/server/schema/AttributeTypeSyntax.java
index e617d02..1f24b3f 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/schema/AttributeTypeSyntax.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/schema/AttributeTypeSyntax.java
@@ -34,7 +34,8 @@
import java.util.LinkedList;
import java.util.List;
-import org.opends.server.admin.std.server.AttributeSyntaxCfg;
+import org.opends.server.admin.std.server.*;
+import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.api.ApproximateMatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.EqualityMatchingRule;
@@ -42,17 +43,10 @@
import org.opends.server.api.SubstringMatchingRule;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.AttributeType;
-import org.opends.server.types.AttributeUsage;
-import org.opends.server.types.ByteString;
-import org.opends.server.types.DirectoryException;
-import org.opends.server.types.InitializationException;
-import org.opends.server.types.ResultCode;
-import org.opends.server.types.Schema;
import static org.opends.server.loggers.debug.DebugLogger.*;
import org.opends.server.loggers.debug.DebugTracer;
-import org.opends.server.types.DebugLogLevel;
+import org.opends.server.types.*;
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.messages.SchemaMessages.*;
import static org.opends.server.schema.SchemaConstants.*;
@@ -67,14 +61,18 @@
* syntax is defined in RFC 2252.
*/
public class AttributeTypeSyntax
- extends AttributeSyntax<AttributeSyntaxCfg>
-{
+ extends AttributeSyntax<AttributeTypeDescriptionAttributeSyntaxCfg>
+ implements
+ ConfigurationChangeListener<AttributeTypeDescriptionAttributeSyntaxCfg> {
/**
* The tracer object for the debug logger.
*/
private static final DebugTracer TRACER = getTracer();
+ // The reference to the configuration for this attribute type description
+ // syntax.
+ private AttributeTypeDescriptionAttributeSyntaxCfg currentConfig;
// The default equality matching rule for this syntax.
@@ -86,7 +84,8 @@
// The default substring matching rule for this syntax.
private SubstringMatchingRule defaultSubstringMatchingRule;
-
+ // If true strip the suggested minimum upper bound from the syntax OID.
+ private static boolean stripMinimumUpperBound=false;
/**
* Creates a new instance of this syntax. Note that the only thing that
@@ -104,7 +103,8 @@
/**
* {@inheritDoc}
*/
- public void initializeSyntax(AttributeSyntaxCfg configuration)
+ public void
+ initializeSyntax(AttributeTypeDescriptionAttributeSyntaxCfg configuration)
throws ConfigException, InitializationException
{
defaultEqualityMatchingRule =
@@ -136,6 +136,19 @@
SYNTAX_ATTRIBUTE_TYPE_NAME);
throw new InitializationException(msgID, message);
}
+
+ // This syntax is one of the Directory Server's core syntaxes and therefore
+ // it may be instantiated at times without a configuration entry. If that
+ // is the case, then we'll exit now before doing anything that could require
+ // access to that entry.
+ if (configuration == null)
+ {
+ return;
+ }
+
+ currentConfig = configuration;
+ currentConfig.addAttributeTypeDescriptionChangeListener(this);
+ stripMinimumUpperBound=configuration.isStripSyntaxMinimumUpperBound();
}
@@ -656,13 +669,13 @@
// of characters that should be allowed in values of that type. This
// implementation will ignore any such length because it does not
// impose any practical limit on the length of attribute values.
- boolean inBrace = false;
boolean lastWasPeriod = false;
+ int leftBracePos=0;
StringBuilder oidBuffer = new StringBuilder();
while (pos < length)
{
c = lowerStr.charAt(pos++);
- if (inBrace)
+ if (leftBracePos != 0)
{
// The only thing we'll allow here will be numeric digits and the
// closing curly brace.
@@ -678,7 +691,18 @@
ResultCode.INVALID_ATTRIBUTE_SYNTAX, message,
msgID);
}
-
+ //If option ds-cfg-strip-syntax-minimum-upper-bound is true,
+ //remove minimum number specification (including braces) because
+ //it breaks some syntax retrieval APIs such as JNDI's
+ //getAttributeSyntaxDefinition().
+ if(stripMinimumUpperBound) {
+ String firstPart=
+ value.stringValue().substring(0,leftBracePos-1);
+ String secPart=value.stringValue().substring(pos);
+ StringBuilder tmpBuffer=
+ new StringBuilder(firstPart).append(secPart);
+ value.setValue(tmpBuffer.toString().getBytes());
+ }
break;
}
else if (! isDigit(c))
@@ -716,8 +740,10 @@
}
else if (c == '{')
{
- // It's the start of the length specification.
- inBrace = true;
+ // It's the start of the length specification. Keep an index
+ //to this character because the specification will need to be
+ //removed.
+ leftBracePos=pos;
}
else if (c == ' ')
{
@@ -1437,5 +1463,34 @@
return startPos;
}
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ConfigChangeResult applyConfigurationChange(
+ AttributeTypeDescriptionAttributeSyntaxCfg configuration)
+ {
+ currentConfig = configuration;
+ stripMinimumUpperBound = configuration.isStripSyntaxMinimumUpperBound();
+
+ return new ConfigChangeResult(ResultCode.SUCCESS, false);
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isConfigurationChangeAcceptable(
+ AttributeTypeDescriptionAttributeSyntaxCfg configuration,
+ List<String> unacceptableReasons)
+ {
+ // The configuration will always be acceptable.
+ return true;
+ }
+
+
}
--
Gitblit v1.10.0