OPENDJ-1631 CR-6864 Migrate server to SDK syntaxes
Replace server AttributeSyntax<T> class by SDK Syntax class
Update server syntaxes (still used, but for config only) to use
SDK syntaxes under the cover
1 files deleted
3 files added
131 files modified
| | |
| | | class Replace |
| | | |
| | | # All directories that contains java code |
| | | JAVA_DIRS = ["src/server", "src/quicksetup", "src/ads", "src/guitools", "tests/unit-tests-testng/src"] |
| | | JAVA_DIRS = ["src/main/java", "src/test/java"] |
| | | TOOLS_DIR = ["src/server/org/opends/server/tools", "src/quicksetup", "src/ads", "src/guitools", |
| | | "tests/unit-tests-testng/src/server/org/opends/server/tools" ] |
| | | SNMP_DIR = ["src/snmp/src"] |
| | | DSML_DIR = ["src/dsml/org"] |
| | | |
| | | # Replacement for syntaxes |
| | | SYNTAXES_TO_SDK = { |
| | | :dirs => JAVA_DIRS + SNMP_DIR, |
| | | :extensions => ["java"], |
| | | :stoplist => ["Syntax"], |
| | | :replacements => |
| | | [ |
| | | /import org.opends.server.api.AttributeSyntax;/, |
| | | 'import org.forgerock.opendj.ldap.schema.Syntax;', |
| | | |
| | | /package org.opends.server.api;/, |
| | | "package org.opends.server.api;\n\nimport org.forgerock.opendj.ldap.schema.Syntax;", |
| | | |
| | | /import org.opends.server.api.\*;/, |
| | | "import org.forgerock.opendj.ldap.schema.Syntax;\nimport org.opends.server.api.*;", |
| | | |
| | | /\bAttributeSyntax\b(<AttributeSyntaxCfg>)/, |
| | | "Syntax", |
| | | |
| | | /\bAttributeSyntax\b(<\w*>)?/, |
| | | "Syntax", |
| | | |
| | | /\bSyntax\b<\w*>/, |
| | | "Syntax", |
| | | |
| | | /\bSyntax\b<\?>/, |
| | | "Syntax", |
| | | |
| | | ] |
| | | } |
| | | |
| | | SYNTAXES_TO_SDK_SCM = { |
| | | :dirs => JAVA_DIRS, |
| | | :extensions => ["java"], |
| | | :whitelist => ["SchemaConfigManager"], |
| | | :replacements => |
| | | [ |
| | | /\b\w*Syntax\b\s+(\w+Syntax);/, |
| | | 'Syntax \1;', |
| | | |
| | | /\((\w*Syntax)\)\s*schema.getSyntax/m, |
| | | 'schema.getSyntax', |
| | | |
| | | /\w*Syntax.initializeSyntax\(null\);\s/, |
| | | '' |
| | | ] |
| | | } |
| | | |
| | | # Replacement for matching rules |
| | | MRULES_TO_SDK = { |
| | | :dirs => JAVA_DIRS + SNMP_DIR, |
| | |
| | | ] |
| | | } |
| | | |
| | | # Replacement for syntaxes |
| | | SYNTAX = { |
| | | :dirs => JAVA_DIRS + SNMP_DIR, |
| | | :extensions => ["java"], |
| | | :stoplist => ["Syntax"], |
| | | :replacements => |
| | | [ |
| | | |
| | | /import org.opends.server.api.AttributeSyntax;/, |
| | | 'import org.forgerock.opendj.ldap.schema.Syntax;', |
| | | |
| | | /package org.opends.server.api;/, |
| | | "package org.opends.server.api;\n\nimport org.forgerock.opendj.ldap.schema.Syntax;", |
| | | |
| | | /import org.opends.server.api.\*;/, |
| | | "import org.forgerock.opendj.ldap.schema.Syntax;\nimport org.opends.server.api.*;", |
| | | |
| | | /\bAttributeSyntax\b<[^>]+>/, |
| | | 'Syntax', |
| | | |
| | | /\bAttributeSyntax\b/, |
| | | 'Syntax' |
| | | ] |
| | | } |
| | | |
| | | # Replacement for attribute type |
| | | ATTRTYPE = { |
| | |
| | | |
| | | ############################### List of replacements to run ################################# |
| | | |
| | | REPLACEMENTS = [ MRULES_TO_SDK, MRULES_FACTORIES, MRULES_API_PACKAGE ] |
| | | REPLACEMENTS = [ SYNTAXES_TO_SDK, SYNTAXES_TO_SDK_SCM ] |
| | | |
| | | ################################### Processing methods ######################################## |
| | | |
| | |
| | | import org.opends.guitools.controlpanel.util.LowerCaseComparator; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Schema; |
| | | |
| | |
| | | * @param syntax the attribute syntax that the panel must display. |
| | | * @param schema the schema. |
| | | */ |
| | | public void update(AttributeSyntax<?> syntax, Schema schema) |
| | | public void update(Syntax syntax, Schema schema) |
| | | { |
| | | String n = syntax.getName(); |
| | | if (n == null) |
| | |
| | | import org.opends.guitools.controlpanel.util.LowerCaseComparator; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.guitools.controlpanel.util.ViewPositions; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.CommonSchemaElements; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | |
| | | TreeSet<String> syntaxNames = new TreeSet<>(lowerCaseComparator); |
| | | HashMap<String, AttributeSyntaxTreeNode> hmSyntaxes = new HashMap<>(); |
| | | for (AttributeSyntax<?> syntax : lastSchema.getSyntaxes().values()) |
| | | for (Syntax syntax : lastSchema.getSyntaxes().values()) |
| | | { |
| | | if (mustAdd(syntax)) |
| | | { |
| | |
| | | * @return <CODE>true</CODE> if the attribute syntax must be added and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | private boolean mustAdd(AttributeSyntax<?> syntax) |
| | | private boolean mustAdd(Syntax syntax) |
| | | { |
| | | String f = filter.getText().trim(); |
| | | if (f.length () > 0) |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeUsage; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | @Override |
| | | public void configurationChanged(ConfigurationChangeEvent ev) |
| | | { |
| | | ArrayList<AttributeSyntax<?>> newSyntaxes = new ArrayList<>(); |
| | | ArrayList<Syntax> newSyntaxes = new ArrayList<>(); |
| | | |
| | | final ServerDescriptor desc = ev.getNewDescriptor(); |
| | | Schema s = desc.getSchema(); |
| | |
| | | if (schemaChanged) |
| | | { |
| | | schema = s; |
| | | HashMap<String, AttributeSyntax<?>> syntaxNameMap = new HashMap<>(); |
| | | HashMap<String, Syntax> syntaxNameMap = new HashMap<>(); |
| | | for (String key : schema.getSyntaxes().keySet()) |
| | | { |
| | | AttributeSyntax<?> syntax = schema.getSyntax(key); |
| | | Syntax syntax = schema.getSyntax(key); |
| | | String name = syntax.getName(); |
| | | if (name == null) |
| | | { |
| | |
| | | getOID(), |
| | | getDescription(), |
| | | getSuperior(), |
| | | (AttributeSyntax<?>)syntax.getSelectedItem(), |
| | | (Syntax)syntax.getSelectedItem(), |
| | | getApproximateMatchingRule(), |
| | | getEqualityMatchingRule(), |
| | | getOrderingMatchingRule(), |
| | |
| | | |
| | | private void updateDefaultMatchingRuleNames() |
| | | { |
| | | AttributeSyntax<?> syn = (AttributeSyntax<?>)syntax.getSelectedItem(); |
| | | Syntax syn = (Syntax)syntax.getSelectedItem(); |
| | | if (syn != null) |
| | | { |
| | | MatchingRule[] rules = {syn.getApproximateMatchingRule(), |
| | |
| | | import org.opends.guitools.controlpanel.ui.components.TitlePanel; |
| | | import org.opends.guitools.controlpanel.util.LowerCaseComparator; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Schema; |
| | | |
| | |
| | | titlePanel.setDetails(LocalizableMessage.raw(n)); |
| | | name.setText(n); |
| | | oid.setText(matchingRule.getOID()); |
| | | AttributeSyntax<?> s = null; |
| | | Syntax s = null; |
| | | String syntaxOID = matchingRule.getSyntax().getOID(); |
| | | for (AttributeSyntax<?> candidate : schema.getSyntaxes().values()) |
| | | for (Syntax candidate : schema.getSyntaxes().values()) |
| | | { |
| | | if (candidate.getOID().equals(syntaxOID)) |
| | | { |
| | |
| | | import org.opends.guitools.controlpanel.ui.renderer.SchemaElementComboBoxCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.LowerCaseComparator; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | @Override |
| | | public void configurationChanged(ConfigurationChangeEvent ev) |
| | | { |
| | | ArrayList<AttributeSyntax<?>> newSyntaxes = new ArrayList<>(); |
| | | ArrayList<Syntax> newSyntaxes = new ArrayList<>(); |
| | | |
| | | final ServerDescriptor desc = ev.getNewDescriptor(); |
| | | Schema s = desc.getSchema(); |
| | |
| | | { |
| | | schema = s; |
| | | |
| | | HashMap<String, AttributeSyntax<?>> syntaxNameMap = new HashMap<>(); |
| | | HashMap<String, Syntax> syntaxNameMap = new HashMap<>(); |
| | | |
| | | for (String key : schema.getSyntaxes().keySet()) |
| | | { |
| | | AttributeSyntax<?> syntax = schema.getSyntax(key); |
| | | Syntax syntax = schema.getSyntax(key); |
| | | String name = syntax.getName(); |
| | | if (name == null) |
| | | { |
| | |
| | | { |
| | | for (int i=0; i<syntax.getModel().getSize(); i++) |
| | | { |
| | | AttributeSyntax<?> syn = |
| | | (AttributeSyntax<?>)syntax.getModel().getElementAt(i); |
| | | Syntax syn = (Syntax)syntax.getModel().getElementAt(i); |
| | | if ("DirectoryString".equals(syn.getName())) |
| | | { |
| | | syntax.setSelectedIndex(i); |
| | |
| | | return INFO_CTRL_PANEL_TYPE_MATCHING_RULE.get(); |
| | | } |
| | | |
| | | for (AttributeSyntax<?> attr : schema.getSyntaxes().values()) |
| | | for (Syntax attr : schema.getSyntaxes().values()) |
| | | { |
| | | if (name.equalsIgnoreCase(attr.getName())) |
| | | { |
| | |
| | | |
| | | private void updateDefaultMatchingRuleNames() |
| | | { |
| | | AttributeSyntax<?> syn = (AttributeSyntax<?>)syntax.getSelectedItem(); |
| | | Syntax syn = (Syntax)syntax.getSelectedItem(); |
| | | if (syn != null) |
| | | { |
| | | MatchingRule[] rules = {syn.getApproximateMatchingRule(), |
| | |
| | | getOID(), |
| | | getDescription(), |
| | | getSuperior(), |
| | | (AttributeSyntax<?>)syntax.getSelectedItem(), |
| | | (Syntax)syntax.getSelectedItem(), |
| | | getApproximateMatchingRule(), |
| | | getEqualityMatchingRule(), |
| | | getOrderingMatchingRule(), |
| | |
| | | import org.opends.guitools.controlpanel.event.SchemaElementSelectionListener; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | * @param syntax the attribute syntax. |
| | | * @param schema the schema. |
| | | */ |
| | | public void updateAttributeSyntax(AttributeSyntax<?> syntax, Schema schema) |
| | | public void updateAttributeSyntax(Syntax syntax, Schema schema) |
| | | { |
| | | attributeSyntaxPanel.update(syntax, schema); |
| | | schemaElementPanel = attributeSyntaxPanel; |
| | |
| | | import org.opends.guitools.controlpanel.ui.nodes.BasicNode; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase()); |
| | | if (attr != null) |
| | | { |
| | | AttributeSyntax<?> syntax = attr.getSyntax(); |
| | | Syntax syntax = attr.getSyntax(); |
| | | if (syntax != null) |
| | | { |
| | | isCertificate = syntax.getOID().equals( |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui.nodes; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | |
| | | |
| | | /** |
| | | * Class of the nodes that represent an attribute syntax in the 'Manage Schema' |
| | |
| | | public class AttributeSyntaxTreeNode extends SchemaElementTreeNode |
| | | { |
| | | private static final long serialVersionUID = 2439971368723239776L; |
| | | private AttributeSyntax<?> syntax; |
| | | private Syntax syntax; |
| | | |
| | | /** |
| | | * Constructor of the node. |
| | | * @param name the name of the node. |
| | | * @param syntax the attribute syntax. |
| | | */ |
| | | public AttributeSyntaxTreeNode(String name, AttributeSyntax<?> syntax) |
| | | public AttributeSyntaxTreeNode(String name, Syntax syntax) |
| | | { |
| | | super(name, syntax); |
| | | this.syntax = syntax; |
| | |
| | | * Returns the attribute syntax represented by this node. |
| | | * @return the attribute syntax represented by this node. |
| | | */ |
| | | public AttributeSyntax<?> getAttributeSyntax() |
| | | public Syntax getAttributeSyntax() |
| | | { |
| | | return syntax; |
| | | } |
| | |
| | | import javax.swing.JComboBox; |
| | | import javax.swing.JList; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.AttributeUsage; |
| | | import org.opends.server.types.CommonSchemaElements; |
| | |
| | | public Component getListCellRendererComponent(JList list, Object value, |
| | | int index, boolean isSelected, boolean cellHasFocus) |
| | | { |
| | | if (value instanceof AttributeSyntax<?>) |
| | | if (value instanceof Syntax) |
| | | { |
| | | String syntaxName = ((AttributeSyntax<?>)value).getName(); |
| | | String syntaxName = ((Syntax)value).getName(); |
| | | if (syntaxName == null) |
| | | { |
| | | value = ((AttributeSyntax<?>)value).getOID(); |
| | | value = ((Syntax)value).getOID(); |
| | | } |
| | | else |
| | | { |
| | |
| | | import java.util.Arrays; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | new ArrayList<AttributeType>(); |
| | | private final ArrayList<MatchingRule> matchingRulesToKeep = |
| | | new ArrayList<MatchingRule>(); |
| | | private final ArrayList<AttributeSyntax<?>> syntaxesToKeep = |
| | | new ArrayList<AttributeSyntax<?>>(); |
| | | private final ArrayList<Syntax> syntaxesToKeep = new ArrayList<>(); |
| | | |
| | | /** |
| | | * Constructor. |
| | |
| | | FileFilter ldifFiles = new FileFilter() |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean accept(File f) |
| | | { |
| | | boolean accept = false; |
| | |
| | | // initialize the server schema. |
| | | for (String schemaFile : fileNames) |
| | | { |
| | | SchemaConfigManager.loadSchemaFile(schema, schemaFile); |
| | | // no server context to pass |
| | | SchemaConfigManager.loadSchemaFile(null, schema, schemaFile); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | schema.registerMatchingRule(mr, true); |
| | | } |
| | | for (AttributeSyntax<?> syntax : syntaxesToKeep) |
| | | for (Syntax syntax : syntaxesToKeep) |
| | | { |
| | | schema.registerSyntax(syntax, true); |
| | | } |
| | |
| | | import org.opends.quicksetup.Installation; |
| | | import org.opends.quicksetup.ui.UIFactory; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.ClassLoaderProvider; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.api.ConfigHandler; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | * @param syntax the attribute syntax. |
| | | * @return the string representation of an attribute syntax. |
| | | */ |
| | | public static String getSyntaxText(AttributeSyntax<?> syntax) |
| | | public static String getSyntaxText(Syntax syntax) |
| | | { |
| | | String syntaxName = syntax.getName(); |
| | | String syntaxOID = syntax.getOID(); |
| | |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | |
| | | /** |
| | |
| | | mayInstantiate=false, |
| | | mayExtend=true, |
| | | mayInvoke=false) |
| | | @RemoveOnceSDKSchemaIsUsed("All descendants classes can be removed as well") |
| | | public abstract class AttributeSyntax<T extends AttributeSyntaxCfg> |
| | | { |
| | | /** |
| | |
| | | * |
| | | * @param configuration The configuration to use to initialize |
| | | * this attribute syntax. |
| | | * @param serverContext |
| | | * The server context. |
| | | * |
| | | * @throws ConfigException If an unrecoverable problem arises in |
| | | * the process of performing the |
| | |
| | | * related to the server |
| | | * configuration. |
| | | */ |
| | | public abstract void initializeSyntax(T configuration) |
| | | throws ConfigException, InitializationException; |
| | | public void initializeSyntax(T configuration, ServerContext serverContext) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | // not implemented |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns the SDK Syntax equivalent to this syntax. |
| | | * <p> |
| | | * This method allow smooth migration to SDK syntax. It will disappear |
| | | * once the the migration to SDK schema is complete, together with |
| | | * this class and all its implementation. |
| | | * |
| | | * @param schema |
| | | * Schema to use to retrieve the syntax |
| | | * |
| | | * @return the equivalent SDK syntax. |
| | | */ |
| | | public abstract Syntax getSDKSyntax(Schema schema); |
| | | |
| | | /** |
| | | * Indicates whether the provided configuration is acceptable for |
| | |
| | | * attributes with this syntax, or {@code null} if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public abstract MatchingRule getEqualityMatchingRule(); |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | * attributes with this syntax, or {@code null} if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public abstract MatchingRule getOrderingMatchingRule(); |
| | | |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | * substring matches will not be allowed for this type by |
| | | * default. |
| | | */ |
| | | public abstract MatchingRule getSubstringMatchingRule(); |
| | | |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | * approximate matches will not be allowed for this type by |
| | | * default. |
| | | */ |
| | | public abstract MatchingRule getApproximateMatchingRule(); |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | * @return {@code true} if the provided value is acceptable for use |
| | | * with this syntax, or {@code false} if not. |
| | | */ |
| | | public abstract boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason); |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | * |
| | | * @return {@code true} if this syntax required BER encoding. |
| | | */ |
| | | public abstract boolean isBEREncodingRequired(); |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | * |
| | | * @return {@code true} if this syntax is human readable. |
| | | */ |
| | | public abstract boolean isHumanReadable(); |
| | | |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The hash code for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public final int hashCode() |
| | | { |
| | | int hashCode = 0; |
| | |
| | | * @return {@code true} if the provided object is equal to this |
| | | * attribute syntax, or {@code false} if it is not. |
| | | */ |
| | | @Override |
| | | public final boolean equals(Object o) |
| | | { |
| | | if (this == o) |
| | |
| | | * @return A string representation of this attribute syntax in the |
| | | * format defined in RFC 2252. |
| | | */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.SchemaBackendCfg; |
| | | import org.opends.server.api.AlertGenerator; |
| | |
| | | import org.opends.server.schema.MatchingRuleUseSyntax; |
| | | import org.opends.server.schema.NameFormSyntax; |
| | | import org.opends.server.schema.ObjectClassSyntax; |
| | | import org.opends.server.schema.SchemaUpdater; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.BackupManager; |
| | | import org.opends.server.util.DynamicConstants; |
| | |
| | | */ |
| | | private String stripMinUpperBoundRegEx = "\\{\\d+\\}"; |
| | | |
| | | |
| | | private ServerContext serverContext; |
| | | |
| | | /** |
| | | * Creates a new backend with the provided information. All backend |
| | |
| | | @Override |
| | | public void configureBackend(SchemaBackendCfg cfg, ServerContext serverContext) throws ConfigException |
| | | { |
| | | this.serverContext = serverContext; |
| | | |
| | | // Make sure that a configuration entry was provided. If not, then we will |
| | | // not be able to complete initialization. |
| | | if (cfg == null) |
| | |
| | | LDAPSyntaxDescription lsd; |
| | | try |
| | | { |
| | | lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, newSchema, false); |
| | | lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, serverContext, newSchema, false, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | LDAPSyntaxDescription lsd; |
| | | try |
| | | { |
| | | lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, newSchema, false); |
| | | lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, serverContext, newSchema, false, true); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | throws DirectoryException |
| | | { |
| | | //Check if there is an existing syntax with this oid. |
| | | String oid = ldapSyntaxDesc.getLdapSyntaxDescriptionSyntax().getOID(); |
| | | String oid = ldapSyntaxDesc.getSyntax().getOID(); |
| | | |
| | | // We allow only unimplemented syntaxes to be substituted. |
| | | if(schema.getSyntax(oid) !=null) |
| | |
| | | message); |
| | | } |
| | | |
| | | LDAPSyntaxDescription existingLSD = |
| | | schema.getLdapSyntaxDescription(oid); |
| | | LDAPSyntaxDescription existingLSD = schema.getLdapSyntaxDescription(oid); |
| | | SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater(); |
| | | org.forgerock.opendj.ldap.schema.Schema newSchema = null; |
| | | |
| | | // If there is no existing lsd, then we're adding a new ldapsyntax. |
| | | // Otherwise, we're replacing an existing one. |
| | |
| | | { |
| | | schema.registerLdapSyntaxDescription(ldapSyntaxDesc, false); |
| | | addNewSchemaElement(modifiedSchemaFiles, ldapSyntaxDesc); |
| | | |
| | | // update schema NG |
| | | newSchema = schemaUpdater.getSchemaBuilder().buildSyntax(ldapSyntaxDesc.getSyntax()).addToSchema().toSchema(); |
| | | schemaUpdater.updateSchema(newSchema); |
| | | } |
| | | else |
| | | { |
| | | schema.deregisterLdapSyntaxDescription(existingLSD); |
| | | schema.registerLdapSyntaxDescription(ldapSyntaxDesc, false); |
| | | // update schema NG |
| | | SchemaBuilder schemaBuilder = schemaUpdater.getSchemaBuilder(); |
| | | schemaBuilder.removeSyntax(oid); |
| | | newSchema = schemaBuilder.buildSyntax(ldapSyntaxDesc.getSyntax()).addToSchema().toSchema(); |
| | | schemaUpdater.updateSchema(newSchema); |
| | | |
| | | schema.rebuildDependentElements(existingLSD); |
| | | replaceExistingSchemaElement(modifiedSchemaFiles, ldapSyntaxDesc, |
| | | existingLSD); |
| | | replaceExistingSchemaElement(modifiedSchemaFiles, ldapSyntaxDesc, existingLSD); |
| | | } |
| | | } |
| | | |
| | |
| | | Set<String> modifiedSchemaFiles) |
| | | throws DirectoryException |
| | | { |
| | | //See if the specified ldap syntax description is actually defined in the |
| | | //server schema. If not, then fail. Note that we are checking only the |
| | | //real part of the ldapsyntaxes attribute. A virtual value is not searched |
| | | // and hence never deleted. |
| | | String oid = ldapSyntaxDesc.getLdapSyntaxDescriptionSyntax().getOID(); |
| | | /* |
| | | * See if the specified ldap syntax description is actually defined in the |
| | | * server schema. If not, then fail. Note that we are checking only the real |
| | | * part of the ldapsyntaxes attribute. A virtual value is not searched and |
| | | * hence never deleted. |
| | | */ |
| | | String oid = ldapSyntaxDesc.getSyntax().getOID(); |
| | | LDAPSyntaxDescription removeLSD = schema.getLdapSyntaxDescription(oid); |
| | | |
| | | if (removeLSD == null || !removeLSD.equals(ldapSyntaxDesc)) |
| | |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | |
| | | // update schema NG |
| | | SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater(); |
| | | SchemaBuilder schemaBuilder = schemaUpdater.getSchemaBuilder(); |
| | | schemaBuilder.removeSyntax(oid); |
| | | schemaUpdater.updateSchema(schemaBuilder.toSchema()); |
| | | |
| | | schema.deregisterLdapSyntaxDescription(removeLSD); |
| | | String schemaFile = getSchemaFile(removeLSD); |
| | | if (schemaFile != null) |
| | |
| | | TreeSet<String> modifiedSchemaFiles = new TreeSet<String>(); |
| | | |
| | | // Get the attributeTypes attribute from the entry. |
| | | AttributeTypeSyntax attrTypeSyntax; |
| | | try |
| | | Syntax attrTypeSyntax = schema.getSyntax(SYNTAX_ATTRIBUTE_TYPE_OID); |
| | | if (attrTypeSyntax == null) |
| | | { |
| | | attrTypeSyntax = (AttributeTypeSyntax) |
| | | schema.getSyntax(SYNTAX_ATTRIBUTE_TYPE_OID); |
| | | if (attrTypeSyntax == null) |
| | | { |
| | | attrTypeSyntax = new AttributeTypeSyntax(); |
| | | attrTypeSyntax.initializeSyntax(null); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | attrTypeSyntax = new AttributeTypeSyntax(); |
| | | attrTypeSyntax = CoreSchema.getAttributeTypeDescriptionSyntax(); |
| | | } |
| | | |
| | | AttributeType attributeAttrType = |
| | | schema.getAttributeType(ATTR_ATTRIBUTE_TYPES_LC); |
| | | AttributeType attributeAttrType = schema.getAttributeType(ATTR_ATTRIBUTE_TYPES_LC); |
| | | if (attributeAttrType == null) |
| | | { |
| | | attributeAttrType = |
| | |
| | | |
| | | // loop on the objectClasses from the entry, search if they are |
| | | // already in the current schema, add them if not. |
| | | ObjectClassSyntax ocSyntax; |
| | | try |
| | | Syntax ocSyntax = schema.getSyntax(SYNTAX_OBJECTCLASS_OID); |
| | | if (ocSyntax == null) |
| | | { |
| | | ocSyntax = (ObjectClassSyntax) schema.getSyntax(SYNTAX_OBJECTCLASS_OID); |
| | | if (ocSyntax == null) |
| | | { |
| | | ocSyntax = new ObjectClassSyntax(); |
| | | ocSyntax.initializeSyntax(null); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | ocSyntax = new ObjectClassSyntax(); |
| | | ocSyntax = CoreSchema.getObjectClassDescriptionSyntax(); |
| | | } |
| | | |
| | | AttributeType objectclassAttrType = |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | |
| | | private long maxMatchingEntries = -1; |
| | | private final AtomicInteger hits = new AtomicInteger(); |
| | | |
| | | @Override |
| | | public int compareTo(FilterStats that) { |
| | | return this.hits.get() - that.hits.get(); |
| | | } |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeMonitorProvider(MonitorProviderCfg configuration) |
| | | throws ConfigException, InitializationException |
| | | { |
| | |
| | | * |
| | | * @return The name of this monitor provider. |
| | | */ |
| | | @Override |
| | | public String getMonitorInstanceName() |
| | | { |
| | | return name; |
| | |
| | | Class<?> returnType = method.getReturnType(); |
| | | if (returnType.equals(int.class) || returnType.equals(long.class)) |
| | | { |
| | | AttributeSyntax<?> integerSyntax = |
| | | DirectoryServer.getDefaultIntegerSyntax(); |
| | | Syntax integerSyntax = DirectoryServer.getDefaultIntegerSyntax(); |
| | | |
| | | // Remove the 'get' from the method name and add the prefix. |
| | | String attrName = attrPrefix + method.getName().substring(3); |
| | |
| | | * returned to the client if the corresponding monitor entry is |
| | | * requested. |
| | | */ |
| | | @Override |
| | | public List<Attribute> getMonitorData() |
| | | { |
| | | EnvironmentStats environmentStats = null; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.task; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | |
| | | private final boolean[] monthArray; |
| | | private final boolean[] weekdayArray; |
| | | |
| | | private final ServerContext serverContext; |
| | | |
| | | /** |
| | | * Creates a new recurring task based on the information in the provided |
| | | * entry. |
| | | * |
| | | * @param serverContext |
| | | * The server context. |
| | | * |
| | | * @param taskScheduler A reference to the task scheduler that may be |
| | | * used to schedule new tasks. |
| | | * @param recurringTaskEntry The entry containing the information to use to |
| | |
| | | * @throws DirectoryException If the provided entry does not contain a valid |
| | | * recurring task definition. |
| | | */ |
| | | public RecurringTask(TaskScheduler taskScheduler, Entry recurringTaskEntry) |
| | | public RecurringTask(ServerContext serverContext, TaskScheduler taskScheduler, Entry recurringTaskEntry) |
| | | throws DirectoryException |
| | | { |
| | | this.serverContext = serverContext; |
| | | this.taskScheduler = taskScheduler; |
| | | this.recurringTaskEntry = recurringTaskEntry; |
| | | this.recurringTaskEntryDN = recurringTaskEntry.getName(); |
| | |
| | | // provided entry. |
| | | try |
| | | { |
| | | task.initializeTaskInternal(taskScheduler, recurringTaskEntry); |
| | | task.initializeTaskInternal(serverContext, taskScheduler, recurringTaskEntry); |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | |
| | | taskStartTimeAttrType, nextTaskStartTime); |
| | | nextTaskEntry.replaceAttribute(nextTaskStartTimeAttr); |
| | | |
| | | nextTask.initializeTaskInternal(taskScheduler, nextTaskEntry); |
| | | nextTask.initializeTaskInternal(serverContext, taskScheduler, nextTaskEntry); |
| | | nextTask.initializeTask(); |
| | | } catch (Exception e) { |
| | | // Should not happen, debug log it otherwise. |
| | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.messages.Severity; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.LockManager.DNLock; |
| | | import org.opends.server.util.EMailMessage; |
| | |
| | | /** The scheduler with which this task is associated. */ |
| | | private TaskScheduler taskScheduler; |
| | | |
| | | private ServerContext serverContext; |
| | | |
| | | /** |
| | | * Returns the server context. |
| | | * |
| | | * @return the server context. |
| | | */ |
| | | protected ServerContext getServerContext() |
| | | { |
| | | return serverContext; |
| | | } |
| | | |
| | | /** |
| | | * Gets a message that identifies this type of task suitable for |
| | | * presentation to humans in monitoring tools. |
| | |
| | | * Performs generic initialization for this task based on the information in |
| | | * the provided task entry. |
| | | * |
| | | * @param serverContext |
| | | * The server context. |
| | | * @param taskScheduler The scheduler with which this task is associated. |
| | | * @param taskEntry The entry containing the task configuration. |
| | | * |
| | | * @throws InitializationException If a problem occurs while performing the |
| | | * initialization. |
| | | */ |
| | | public final void initializeTaskInternal(TaskScheduler taskScheduler, |
| | | public final void initializeTaskInternal(ServerContext serverContext, TaskScheduler taskScheduler, |
| | | Entry taskEntry) |
| | | throws InitializationException |
| | | { |
| | | this.serverContext = serverContext; |
| | | this.taskScheduler = taskScheduler; |
| | | this.taskEntry = taskEntry; |
| | | this.taskEntryDN = taskEntry.getName(); |
| | |
| | | */ |
| | | private TaskScheduler taskScheduler; |
| | | |
| | | |
| | | private ServerContext serverContext; |
| | | |
| | | /** |
| | | * Creates a new backend with the provided information. All backend |
| | |
| | | public void configureBackend(TaskBackendCfg cfg, ServerContext serverContext) throws ConfigException |
| | | { |
| | | Reject.ifNull(cfg); |
| | | this.serverContext = serverContext; |
| | | |
| | | final DN[] baseDNs = new DN[cfg.getBaseDN().size()]; |
| | | cfg.getBaseDN().toArray(baseDNs); |
| | |
| | | throws ConfigException, InitializationException |
| | | { |
| | | // Create the scheduler and initialize it from the backing file. |
| | | taskScheduler = new TaskScheduler(this); |
| | | taskScheduler = new TaskScheduler(serverContext, this); |
| | | taskScheduler.start(); |
| | | |
| | | |
| | |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.LockManager.DNLock; |
| | |
| | | /** The set of tasks that are currently running. */ |
| | | private TreeSet<Task> runningTasks; |
| | | |
| | | |
| | | private ServerContext serverContext; |
| | | |
| | | /** |
| | | * Creates a new task scheduler that will be used to ensure that tasks are |
| | | * invoked at the appropriate times. |
| | | * |
| | | * @param serverContext |
| | | * The server context |
| | | * @param taskBackend The task backend with which this scheduler is |
| | | * associated. |
| | | * |
| | | * @throws InitializationException If a problem occurs while initializing |
| | | * the scheduler from the backing file. |
| | | */ |
| | | public TaskScheduler(TaskBackend taskBackend) |
| | | public TaskScheduler(ServerContext serverContext, TaskBackend taskBackend) |
| | | throws InitializationException |
| | | { |
| | | super("Task Scheduler Thread"); |
| | | |
| | | this.serverContext = serverContext; |
| | | |
| | | this.taskBackend = taskBackend; |
| | | |
| | |
| | | // Perform the necessary internal and external initialization for the task. |
| | | try |
| | | { |
| | | task.initializeTaskInternal(this, entry); |
| | | task.initializeTaskInternal(serverContext, this, entry); |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | |
| | | public RecurringTask entryToRecurringTask(Entry entry) |
| | | throws DirectoryException |
| | | { |
| | | return new RecurringTask(this, entry); |
| | | return new RecurringTask(serverContext, this, entry); |
| | | } |
| | | |
| | | |
| | |
| | | import javax.management.MBeanAttributeInfo; |
| | | import javax.management.MBeanParameterInfo; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | * |
| | | * @return The attribute syntax for this configuration attribute. |
| | | */ |
| | | public AttributeSyntax<?> getSyntax() |
| | | public Syntax getSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultBooleanSyntax(); |
| | | } |
| | |
| | | import javax.management.MBeanAttributeInfo; |
| | | import javax.management.MBeanParameterInfo; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.types.Attribute; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | |
| | | * |
| | | * @return The attribute syntax for this configuration attribute. |
| | | */ |
| | | public abstract AttributeSyntax<?> getSyntax(); |
| | | public abstract Syntax getSyntax(); |
| | | |
| | | |
| | | |
| | |
| | | import javax.management.MBeanAttributeInfo; |
| | | import javax.management.MBeanParameterInfo; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | * |
| | | * @return The attribute syntax for this configuration attribute. |
| | | */ |
| | | public AttributeSyntax<?> getSyntax() |
| | | public Syntax getSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultStringSyntax(); |
| | | } |
| | |
| | | import javax.management.MBeanAttributeInfo; |
| | | import javax.management.MBeanParameterInfo; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | * |
| | | * @return The attribute syntax for this configuration attribute. |
| | | */ |
| | | public AttributeSyntax<?> getSyntax() |
| | | public Syntax getSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultIntegerSyntax(); |
| | | } |
| | |
| | | import javax.management.MBeanAttributeInfo; |
| | | import javax.management.MBeanParameterInfo; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | * |
| | | * @return The attribute syntax for this configuration attribute. |
| | | */ |
| | | public AttributeSyntax<?> getSyntax() |
| | | public Syntax getSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultStringSyntax(); |
| | | } |
| | |
| | | import javax.management.MBeanAttributeInfo; |
| | | import javax.management.MBeanParameterInfo; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | * |
| | | * @return The attribute syntax for this configuration attribute. |
| | | */ |
| | | public AttributeSyntax<?> getSyntax() |
| | | public Syntax getSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultStringSyntax(); |
| | | } |
| | |
| | | import javax.management.MBeanAttributeInfo; |
| | | import javax.management.MBeanParameterInfo; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | * |
| | | * @return The attribute syntax for this configuration attribute. |
| | | */ |
| | | public AttributeSyntax<?> getSyntax() |
| | | public Syntax getSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultStringSyntax(); |
| | | } |
| | |
| | | import javax.management.MBeanAttributeInfo; |
| | | import javax.management.MBeanParameterInfo; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | * |
| | | * @return The attribute syntax for this configuration attribute. |
| | | */ |
| | | public AttributeSyntax<?> getSyntax() |
| | | public Syntax getSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultStringSyntax(); |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | substringAssertion = |
| | | getSubstringMatchingRule().getSubstringAssertion(subInitial, subAny, subFinal); |
| | | MatchingRule rule = getSubstringMatchingRule(); |
| | | if (rule != null) |
| | | { |
| | | substringAssertion = rule.getSubstringAssertion(subInitial, subAny, subFinal); |
| | | } |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | |
| | | String className = syntaxConfiguration.getJavaClass(); |
| | | try |
| | | { |
| | | AttributeSyntax syntax = loadSyntax(className, syntaxConfiguration, |
| | | true); |
| | | |
| | | AttributeSyntax<?> syntax = loadSyntax(className, syntaxConfiguration, true); |
| | | try |
| | | { |
| | | serverContext.getSchema().registerSyntax(syntax, false); |
| | | Syntax sdkSyntax = syntax.getSDKSyntax(serverContext.getSchemaNG()); |
| | | serverContext.getSchema().registerSyntax(sdkSyntax, false); |
| | | syntaxes.put(syntaxConfiguration.dn(), syntax); |
| | | } |
| | | catch (DirectoryException de) |
| | |
| | | |
| | | try |
| | | { |
| | | serverContext.getSchema().registerSyntax(syntax, false); |
| | | Syntax sdkSyntax = syntax.getSDKSyntax(serverContext.getSchemaNG()); |
| | | serverContext.getSchema().registerSyntax(sdkSyntax, false); |
| | | syntaxes.put(configuration.dn(), syntax); |
| | | } |
| | | catch (DirectoryException de) |
| | |
| | | { |
| | | final ConfigChangeResult ccr = new ConfigChangeResult(); |
| | | |
| | | AttributeSyntax syntax = syntaxes.remove(configuration.dn()); |
| | | AttributeSyntax<?> syntax = syntaxes.remove(configuration.dn()); |
| | | if (syntax != null) |
| | | { |
| | | serverContext.getSchema().deregisterSyntax(syntax); |
| | | Syntax sdkSyntax = syntax.getSDKSyntax(serverContext.getSchemaNG()); |
| | | serverContext.getSchema().deregisterSyntax(sdkSyntax); |
| | | syntax.finalizeSyntax(); |
| | | } |
| | | |
| | |
| | | { |
| | | // If the syntax is currently enabled and the change would make it |
| | | // disabled, then only allow it if the syntax isn't already in use. |
| | | AttributeSyntax syntax = syntaxes.get(configuration.dn()); |
| | | AttributeSyntax<?> syntax = syntaxes.get(configuration.dn()); |
| | | if (syntax != null) |
| | | { |
| | | String oid = syntax.getOID(); |
| | |
| | | if (oid.equals(at.getSyntax().getOID())) |
| | | { |
| | | LocalizableMessage message = |
| | | WARN_CONFIG_SCHEMA_CANNOT_DISABLE_SYNTAX_IN_USE.get( |
| | | syntax.getName(), |
| | | at.getNameOrOID()); |
| | | WARN_CONFIG_SCHEMA_CANNOT_DISABLE_SYNTAX_IN_USE.get(syntax.getName(), at.getNameOrOID()); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | AttributeSyntaxCfg configuration) |
| | | public ConfigChangeResult applyConfigurationChange(AttributeSyntaxCfg configuration) |
| | | { |
| | | final ConfigChangeResult ccr = new ConfigChangeResult(); |
| | | |
| | | |
| | | // Get the existing syntax if it's already enabled. |
| | | AttributeSyntax existingSyntax = syntaxes.get(configuration.dn()); |
| | | AttributeSyntax<?> existingSyntax = syntaxes.get(configuration.dn()); |
| | | |
| | | |
| | | // If the new configuration has the syntax disabled, then disable it if it |
| | |
| | | { |
| | | if (existingSyntax != null) |
| | | { |
| | | serverContext.getSchema().deregisterSyntax(existingSyntax); |
| | | |
| | | AttributeSyntax syntax = syntaxes.remove(configuration.dn()); |
| | | Syntax sdkSyntax = existingSyntax.getSDKSyntax(serverContext.getSchemaNG()); |
| | | serverContext.getSchema().deregisterSyntax(sdkSyntax); |
| | | AttributeSyntax<?> syntax = syntaxes.remove(configuration.dn()); |
| | | if (syntax != null) |
| | | { |
| | | syntax.finalizeSyntax(); |
| | |
| | | return ccr; |
| | | } |
| | | |
| | | AttributeSyntax syntax = null; |
| | | AttributeSyntax<?> syntax = null; |
| | | try |
| | | { |
| | | syntax = loadSyntax(className, configuration, true); |
| | | |
| | | try |
| | | { |
| | | serverContext.getSchema().registerSyntax(syntax, false); |
| | | Syntax sdkSyntax = syntax.getSDKSyntax(serverContext.getSchemaNG()); |
| | | serverContext.getSchema().registerSyntax(sdkSyntax, false); |
| | | syntaxes.put(configuration.dn(), syntax); |
| | | } |
| | | catch (DirectoryException de) |
| | |
| | | * @throws InitializationException If a problem occurred while attempting to |
| | | * initialize the attribute syntax. |
| | | */ |
| | | private AttributeSyntax loadSyntax(String className, |
| | | private AttributeSyntax<?> loadSyntax(String className, |
| | | AttributeSyntaxCfg configuration, |
| | | boolean initialize) |
| | | throws InitializationException |
| | |
| | | |
| | | if (initialize) |
| | | { |
| | | syntax.initializeSyntax(configuration); |
| | | syntax.initializeSyntax(configuration, serverContext); |
| | | } |
| | | else |
| | | { |
| | |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.ldap.schema.SchemaOptions; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | import org.opends.server.admin.std.meta.GlobalCfgDefn; |
| | |
| | | import org.opends.server.admin.std.server.GlobalCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.api.AuthenticationPolicy; |
| | | import org.opends.server.schema.SchemaUpdater; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | |
| | | |
| | | |
| | | // Apply the configuration to the server. |
| | | applyGlobalConfiguration(globalConfig); |
| | | applyGlobalConfiguration(globalConfig, serverContext); |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * @param globalConfig The configuration settings to be applied. |
| | | */ |
| | | private static void applyGlobalConfiguration(GlobalCfg globalConfig) |
| | | private static void applyGlobalConfiguration(GlobalCfg globalConfig, ServerContext serverContext) |
| | | { |
| | | setCheckSchema(globalConfig.isCheckSchema()); |
| | | setDefaultPasswordPolicyDN(globalConfig.getDefaultPasswordPolicyDN()); |
| | |
| | | setMaxAllowedConnections(globalConfig.getMaxAllowedClientConnections()); |
| | | setMaxPersistentSearchLimit(globalConfig.getMaxPsearches()); |
| | | setMaxInternalBufferSize((int) globalConfig.getMaxInternalBufferSize()); |
| | | |
| | | // Update the "new" schema with configuration changes |
| | | SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater(); |
| | | SchemaBuilder schemaBuilder = schemaUpdater.getSchemaBuilder(); |
| | | boolean allowMalformedNames = globalConfig.isAllowAttributeNameExceptions(); |
| | | schemaBuilder.setOption(SchemaOptions.ALLOW_MALFORMED_NAMES_AND_OPTIONS, allowMalformedNames); |
| | | Schema schema = schemaBuilder.toSchema(); |
| | | if (!globalConfig.isCheckSchema()) |
| | | { |
| | | schema = schema.asNonStrictSchema(); |
| | | } |
| | | schemaUpdater.updateSchema(schema); |
| | | } |
| | | |
| | | private static AcceptRejectWarn convert(InvalidAttributeSyntaxBehavior invalidAttributeSyntaxBehavior) |
| | |
| | | { |
| | | final ConfigChangeResult ccr = new ConfigChangeResult(); |
| | | |
| | | applyGlobalConfiguration(configuration); |
| | | applyGlobalConfiguration(configuration, serverContext); |
| | | |
| | | return ccr; |
| | | } |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeUsage; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | |
| | | import org.opends.server.admin.ClassLoaderProvider; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | | import org.opends.server.admin.std.server.AlertHandlerCfg; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.admin.std.server.ConnectionHandlerCfg; |
| | | import org.opends.server.admin.std.server.CryptoManagerCfg; |
| | | import org.opends.server.admin.std.server.DirectoryStringAttributeSyntaxCfg; |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.admin.std.server.PasswordValidatorCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | |
| | | import org.opends.server.api.AccountStatusNotificationHandler; |
| | | import org.opends.server.api.AlertGenerator; |
| | | import org.opends.server.api.AlertHandler; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.api.AuthenticationPolicy; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.BackendInitializationListener; |
| | |
| | | import org.opends.server.monitors.ConnectionHandlerMonitor; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalConnectionHandler; |
| | | import org.opends.server.schema.AttributeTypeSyntax; |
| | | import org.opends.server.schema.BinarySyntax; |
| | | import org.opends.server.schema.BooleanEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.BooleanSyntax; |
| | | import org.opends.server.schema.CaseExactEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.CaseExactIA5EqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.CaseExactIA5SubstringMatchingRuleFactory; |
| | |
| | | import org.opends.server.schema.CaseIgnoreIA5SubstringMatchingRuleFactory; |
| | | import org.opends.server.schema.CaseIgnoreOrderingMatchingRuleFactory; |
| | | import org.opends.server.schema.CaseIgnoreSubstringMatchingRuleFactory; |
| | | import org.opends.server.schema.DirectoryStringSyntax; |
| | | import org.opends.server.schema.DistinguishedNameEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.DistinguishedNameSyntax; |
| | | import org.opends.server.schema.DoubleMetaphoneApproximateMatchingRuleFactory; |
| | | import org.opends.server.schema.GeneralizedTimeEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.GeneralizedTimeOrderingMatchingRuleFactory; |
| | | import org.opends.server.schema.GeneralizedTimeSyntax; |
| | | import org.opends.server.schema.IA5StringSyntax; |
| | | import org.opends.server.schema.IntegerEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.IntegerOrderingMatchingRuleFactory; |
| | | import org.opends.server.schema.IntegerSyntax; |
| | | import org.opends.server.schema.OIDSyntax; |
| | | import org.opends.server.schema.ObjectClassSyntax; |
| | | import org.opends.server.schema.ObjectIdentifierEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.OctetStringEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.OctetStringOrderingMatchingRuleFactory; |
| | |
| | | import org.opends.server.schema.SchemaUpdater; |
| | | import org.opends.server.schema.TelephoneNumberEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.TelephoneNumberSubstringMatchingRuleFactory; |
| | | import org.opends.server.schema.TelephoneNumberSyntax; |
| | | import org.opends.server.tools.ConfigureWindowsService; |
| | | import org.opends.server.types.AcceptRejectWarn; |
| | | import org.opends.server.types.AttributeType; |
| | |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | import org.opends.server.types.WritabilityMode; |
| | | import org.opends.server.util.ActivateOnceNewConfigFrameworkIsUsed; |
| | | import org.opends.server.util.ActivateOnceSDKSchemaIsUsed; |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.MultiOutputStream; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.opends.server.util.RuntimeInformation; |
| | | import org.opends.server.util.SetupUtils; |
| | | import org.opends.server.util.TimeThread; |
| | |
| | | private AccountStatusNotificationHandlerConfigManager accountStatusNotificationHandlerConfigManager; |
| | | |
| | | /** The default syntax to use for binary attributes. */ |
| | | private AttributeSyntax<AttributeSyntaxCfg> defaultBinarySyntax; |
| | | private Syntax defaultBinarySyntax; |
| | | /** The default syntax to use for Boolean attributes. */ |
| | | private AttributeSyntax<AttributeSyntaxCfg> defaultBooleanSyntax; |
| | | private Syntax defaultBooleanSyntax; |
| | | /** The default syntax to use for DN attributes. */ |
| | | private AttributeSyntax<AttributeSyntaxCfg> defaultDNSyntax; |
| | | private Syntax defaultDNSyntax; |
| | | /** The default syntax to use for integer attributes. */ |
| | | private AttributeSyntax<AttributeSyntaxCfg> defaultIntegerSyntax; |
| | | private Syntax defaultIntegerSyntax; |
| | | /** The default syntax to use for string attributes. */ |
| | | private AttributeSyntax<DirectoryStringAttributeSyntaxCfg> defaultStringSyntax; |
| | | private Syntax defaultStringSyntax; |
| | | |
| | | /** The default attribute syntax to use for attributes with no defined syntax. */ |
| | | private AttributeSyntax<DirectoryStringAttributeSyntaxCfg> defaultSyntax; |
| | | private Syntax defaultSyntax; |
| | | /** The attribute type used to reference the "objectclass" attribute. */ |
| | | private AttributeType objectClassAttributeType; |
| | | /** The authenticated users manager for the server. */ |
| | |
| | | /** The schema for the Directory Server. */ |
| | | private Schema schema; |
| | | |
| | | /** The schema for the Directory Server. */ |
| | | // TODO : temporary field to be removed once old schema is completely removed |
| | | /** |
| | | * The schema for the Directory Server. |
| | | * <p> |
| | | * This schema is synchronized indirectly to the existing schema, because |
| | | * syntaxes are defined in schemaNG (i.e, migrated to SDK classes) and there |
| | | * is currently no way to handle the SchemaOptions in the configuration (e.g. |
| | | * SchemaOptions.ALLOW_ZERO_LENGTH_DIRECTORY_STRINGS). |
| | | * Thus, configuration of the legacy syntaxes are kept, and any change related |
| | | * to them is synchronized with this schema. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed("'schema' field will then be a reference to a SDK schema") |
| | | private org.forgerock.opendj.ldap.schema.Schema schemaNG; |
| | | |
| | | /** The schema configuration manager for the Directory Server. */ |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public org.forgerock.opendj.ldap.schema.Schema getSchemaNG() |
| | | { |
| | | return directoryServer.schemaNG; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DirectoryEnvironmentConfig getEnvironment() |
| | | { |
| | | return directoryServer.environmentConfig; |
| | |
| | | return new SchemaUpdater() |
| | | { |
| | | @Override |
| | | public boolean updateSchema(SchemaBuilder schemaBuilder) |
| | | public boolean updateSchema(org.forgerock.opendj.ldap.schema.Schema schema) |
| | | { |
| | | schemaNG = schemaBuilder.toSchema(); |
| | | schemaNG = schema; |
| | | return true; |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * Bootstraps the appropriate Directory Server structures that may be needed |
| | | * by client-side tools. This is not intended for use in running the server |
| | | * itself. |
| | | * by both server and client-side tools. |
| | | */ |
| | | public static void bootstrapClient() |
| | | { |
| | |
| | | // Create the server schema and initialize and register a minimal set of |
| | | // matching rules and attribute syntaxes. |
| | | directoryServer.schema = new Schema(); |
| | | directoryServer.schemaNG = new SchemaBuilder("mainSchema").addSchema(CoreSchema.getInstance(), true).toSchema(); |
| | | directoryServer.bootstrapMatchingRules(); |
| | | directoryServer.bootstrapAttributeSyntaxes(); |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Initialize this server. |
| | | * Initializes this server. |
| | | * <p> |
| | | * Initialization involves the following steps: |
| | | * <ul> |
| | |
| | | * </ul> |
| | | * @throws InitializationException |
| | | */ |
| | | @ActivateOnceNewConfigFrameworkIsUsed("it will need adaptation to be activated before sdk schema is ready") |
| | | @ActivateOnceSDKSchemaIsUsed |
| | | private void initializeNG() throws InitializationException |
| | | { |
| | | serverManagementContext = ConfigurationBootstrapper.bootstrap(serverContext); |
| | |
| | | /** |
| | | * Initialize the schema of this server. |
| | | */ |
| | | @ActivateOnceSDKSchemaIsUsed |
| | | private void initializeSchemaNG() throws InitializationException |
| | | { |
| | | SchemaHandler schemaHandler = new SchemaHandler(); |
| | |
| | | */ |
| | | private void bootstrapAttributeSyntaxes() |
| | | { |
| | | initAndRegister(new AttributeTypeSyntax()); |
| | | defaultBinarySyntax = initAndRegister(new BinarySyntax()); |
| | | defaultBooleanSyntax = initAndRegister(new BooleanSyntax()); |
| | | defaultStringSyntax = initAndRegister(new DirectoryStringSyntax()); |
| | | defaultBinarySyntax = CoreSchema.getBinarySyntax(); |
| | | defaultBooleanSyntax = CoreSchema.getBooleanSyntax(); |
| | | defaultStringSyntax = CoreSchema.getDirectoryStringSyntax(); |
| | | defaultDNSyntax = CoreSchema.getDNSyntax(); |
| | | defaultIntegerSyntax = CoreSchema.getIntegerSyntax(); |
| | | defaultSyntax = defaultStringSyntax; |
| | | schema.registerDefaultSyntax(defaultSyntax); |
| | | defaultDNSyntax = initAndRegister(new DistinguishedNameSyntax()); |
| | | initAndRegister(new IA5StringSyntax()); |
| | | defaultIntegerSyntax = initAndRegister(new IntegerSyntax()); |
| | | initAndRegister(new GeneralizedTimeSyntax()); |
| | | initAndRegister(new ObjectClassSyntax()); |
| | | initAndRegister(new OIDSyntax()); |
| | | initAndRegister(new TelephoneNumberSyntax()); |
| | | |
| | | Syntax[] syntaxes = { |
| | | defaultBinarySyntax, defaultBooleanSyntax, defaultStringSyntax, defaultDNSyntax, defaultIntegerSyntax, |
| | | CoreSchema.getAttributeTypeDescriptionSyntax(), |
| | | CoreSchema.getIA5StringSyntax(), |
| | | CoreSchema.getGeneralizedTimeSyntax(), |
| | | CoreSchema.getObjectClassDescriptionSyntax(), |
| | | CoreSchema.getOIDSyntax(), |
| | | CoreSchema.getTelephoneNumberSyntax() |
| | | }; |
| | | for (Syntax syntax : syntaxes) |
| | | { |
| | | registerSyntax(syntax); |
| | | } |
| | | } |
| | | |
| | | |
| | | private <T extends AttributeSyntaxCfg> AttributeSyntax<T> initAndRegister( |
| | | AttributeSyntax<T> syntax) |
| | | private Syntax registerSyntax(Syntax syntax) |
| | | { |
| | | try |
| | | { |
| | | syntax.initializeSyntax(null); |
| | | directoryServer.schema.registerSyntax(syntax, true); |
| | | schema.registerSyntax(syntax, true); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | logger.error(ERR_CANNOT_BOOTSTRAP_SYNTAX, syntax.getClass().getName(), |
| | | stackTraceToSingleLineString(e)); |
| | | logger.error(ERR_CANNOT_BOOTSTRAP_SYNTAX, syntax.getClass().getName(), stackTraceToSingleLineString(e)); |
| | | } |
| | | return syntax; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the authenticated users manager for the Directory Server. |
| | | * |
| | |
| | | |
| | | if (directoryServer.objectClassAttributeType == null) |
| | | { |
| | | AttributeSyntax oidSyntax = |
| | | directoryServer.schema.getSyntax(SYNTAX_OID_NAME); |
| | | Syntax oidSyntax = directoryServer.schema.getSyntax(SYNTAX_OID_NAME); |
| | | if (oidSyntax == null) |
| | | { |
| | | try |
| | | { |
| | | OIDSyntax newOIDSyntax = new OIDSyntax(); |
| | | newOIDSyntax.initializeSyntax(null); |
| | | Syntax newOIDSyntax = CoreSchema.getOIDSyntax(); |
| | | oidSyntax = newOIDSyntax; |
| | | directoryServer.schema.registerSyntax(oidSyntax, true); |
| | | } |
| | |
| | | * |
| | | * @return The constructed attribute type definition. |
| | | */ |
| | | public static AttributeType getDefaultAttributeType(String name, |
| | | AttributeSyntax syntax) |
| | | public static AttributeType getDefaultAttributeType(String name, Syntax syntax) |
| | | { |
| | | String oid = toLowerCase(name) + "-oid"; |
| | | String definition = "( " + oid + " NAME '" + name + "' SYNTAX " + |
| | |
| | | * |
| | | * @return The set of attribute syntaxes defined in the Directory Server. |
| | | */ |
| | | public static ConcurrentMap<String, |
| | | AttributeSyntax<?>> getAttributeSyntaxes() |
| | | public static ConcurrentMap<String, Syntax> getAttributeSyntaxes() |
| | | { |
| | | return directoryServer.schema.getSyntaxes(); |
| | | } |
| | |
| | | * @return The default attribute syntax that should be used for attributes |
| | | * that are not defined in the server schema. |
| | | */ |
| | | public static AttributeSyntax getDefaultAttributeSyntax() |
| | | public static Syntax getDefaultAttributeSyntax() |
| | | { |
| | | return directoryServer.defaultSyntax; |
| | | } |
| | |
| | | * that are not defined in the server schema and are meant to store |
| | | * binary values. |
| | | */ |
| | | public static AttributeSyntax getDefaultBinarySyntax() |
| | | public static Syntax getDefaultBinarySyntax() |
| | | { |
| | | return directoryServer.defaultBinarySyntax; |
| | | } |
| | |
| | | * that are not defined in the server schema and are meant to store |
| | | * Boolean values. |
| | | */ |
| | | public static AttributeSyntax getDefaultBooleanSyntax() |
| | | public static Syntax getDefaultBooleanSyntax() |
| | | { |
| | | return directoryServer.defaultBooleanSyntax; |
| | | } |
| | |
| | | * that are not defined in the server schema and are meant to store |
| | | * DN values. |
| | | */ |
| | | public static AttributeSyntax getDefaultDNSyntax() |
| | | public static Syntax getDefaultDNSyntax() |
| | | { |
| | | return directoryServer.defaultDNSyntax; |
| | | } |
| | |
| | | * that are not defined in the server schema and are meant to store |
| | | * integer values. |
| | | */ |
| | | public static AttributeSyntax getDefaultIntegerSyntax() |
| | | public static Syntax getDefaultIntegerSyntax() |
| | | { |
| | | return directoryServer.defaultIntegerSyntax; |
| | | } |
| | |
| | | * that are not defined in the server schema and are meant to store |
| | | * string values. |
| | | */ |
| | | public static AttributeSyntax getDefaultStringSyntax() |
| | | public static Syntax getDefaultStringSyntax() |
| | | { |
| | | return directoryServer.defaultStringSyntax; |
| | | } |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.schema.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.LDIFReader; |
| | |
| | | // from that entry and parse them to initialize the server schema. |
| | | for (String schemaFile : fileNames) |
| | | { |
| | | loadSchemaFile(schema, schemaFile, false); |
| | | loadSchemaFile(serverContext, schema, schemaFile, false); |
| | | } |
| | | } |
| | | |
| | |
| | | /** |
| | | * Loads the contents of the specified schema file into the provided schema. |
| | | * |
| | | * @param serverContext |
| | | * The server context. |
| | | * |
| | | * @param schema The schema in which the contents of the schema file are |
| | | * to be loaded. |
| | | * @param schemaFile The name of the schema file to be loaded into the |
| | |
| | | * the schema elements that is not related |
| | | * to the server configuration. |
| | | */ |
| | | public static List<Modification> loadSchemaFile(Schema schema, |
| | | String schemaFile) |
| | | public static List<Modification> loadSchemaFile(ServerContext serverContext, Schema schema, String schemaFile) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | return loadSchemaFile(schema, schemaFile, true); |
| | | return loadSchemaFile(serverContext, schema, schemaFile, true); |
| | | } |
| | | |
| | | |
| | |
| | | * the schema elements that is not related |
| | | * to the server configuration. |
| | | */ |
| | | private static List<Modification> loadSchemaFile(Schema schema, |
| | | String schemaFile, |
| | | boolean failOnError) |
| | | throws ConfigException, InitializationException |
| | | private static List<Modification> loadSchemaFile(ServerContext serverContext, Schema schema, String schemaFile, |
| | | boolean failOnError) throws ConfigException, InitializationException |
| | | { |
| | | // Create an LDIF reader to use when reading the files. |
| | | String schemaDirPath = getSchemaDirectoryPath(); |
| | |
| | | } |
| | | } |
| | | |
| | | parseLdapSyntaxesDefinitions(schema, schemaFile, failOnError, |
| | | parseLdapSyntaxesDefinitions(serverContext, schema, schemaFile, failOnError, |
| | | ldapSyntaxList); |
| | | parseAttributeTypeDefinitions(schema, schemaFile, failOnError, attrList); |
| | | parseObjectclassDefinitions(schema, schemaFile, failOnError, ocList); |
| | |
| | | private static List<Attribute> getLdapSyntaxesAttributes(Schema schema, |
| | | Entry entry, List<Modification> mods) throws ConfigException |
| | | { |
| | | LDAPSyntaxDescriptionSyntax ldapSyntax; |
| | | try |
| | | Syntax syntax = schema.getSyntax(SYNTAX_LDAP_SYNTAX_OID); |
| | | if (syntax == null) |
| | | { |
| | | ldapSyntax = (LDAPSyntaxDescriptionSyntax) schema.getSyntax( |
| | | SYNTAX_LDAP_SYNTAX_OID); |
| | | if (ldapSyntax == null) |
| | | { |
| | | ldapSyntax = new LDAPSyntaxDescriptionSyntax(); |
| | | ldapSyntax.initializeSyntax(null); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | ldapSyntax = new LDAPSyntaxDescriptionSyntax(); |
| | | ldapSyntax.initializeSyntax(null); |
| | | syntax = CoreSchema.getLDAPSyntaxDescriptionSyntax(); |
| | | } |
| | | |
| | | AttributeType ldapSyntaxAttrType = getAttributeType( |
| | | schema, ATTR_LDAP_SYNTAXES, ATTR_LDAP_SYNTAXES_LC, ldapSyntax); |
| | | AttributeType ldapSyntaxAttrType = getAttributeType(schema, ATTR_LDAP_SYNTAXES, ATTR_LDAP_SYNTAXES_LC, syntax); |
| | | return createAddModifications(entry, mods, ldapSyntaxAttrType); |
| | | } |
| | | |
| | |
| | | Entry entry, List<Modification> mods) throws ConfigException, |
| | | InitializationException |
| | | { |
| | | AttributeTypeSyntax attrTypeSyntax; |
| | | try |
| | | Syntax syntax = schema.getSyntax(SYNTAX_ATTRIBUTE_TYPE_OID); |
| | | if (syntax == null) |
| | | { |
| | | attrTypeSyntax = (AttributeTypeSyntax) |
| | | schema.getSyntax(SYNTAX_ATTRIBUTE_TYPE_OID); |
| | | if (attrTypeSyntax == null) |
| | | { |
| | | attrTypeSyntax = new AttributeTypeSyntax(); |
| | | attrTypeSyntax.initializeSyntax(null); |
| | | } |
| | | syntax = CoreSchema.getAttributeTypeDescriptionSyntax(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | attrTypeSyntax = new AttributeTypeSyntax(); |
| | | attrTypeSyntax.initializeSyntax(null); |
| | | } |
| | | |
| | | AttributeType attributeAttrType = getAttributeType( |
| | | schema, ATTR_ATTRIBUTE_TYPES, ATTR_ATTRIBUTE_TYPES_LC, attrTypeSyntax); |
| | | schema, ATTR_ATTRIBUTE_TYPES, ATTR_ATTRIBUTE_TYPES_LC, syntax); |
| | | return createAddModifications(entry, mods, attributeAttrType); |
| | | } |
| | | |
| | |
| | | Entry entry, List<Modification> mods) throws ConfigException, |
| | | InitializationException |
| | | { |
| | | ObjectClassSyntax ocSyntax; |
| | | try |
| | | Syntax syntax = schema.getSyntax(SYNTAX_OBJECTCLASS_OID); |
| | | if (syntax == null) |
| | | { |
| | | ocSyntax = (ObjectClassSyntax) schema.getSyntax(SYNTAX_OBJECTCLASS_OID); |
| | | if (ocSyntax == null) |
| | | { |
| | | ocSyntax = new ObjectClassSyntax(); |
| | | ocSyntax.initializeSyntax(null); |
| | | } |
| | | syntax = CoreSchema.getObjectClassDescriptionSyntax(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | ocSyntax = new ObjectClassSyntax(); |
| | | ocSyntax.initializeSyntax(null); |
| | | } |
| | | |
| | | AttributeType objectclassAttrType = getAttributeType( |
| | | schema, ATTR_OBJECTCLASSES, ATTR_OBJECTCLASSES_LC, ocSyntax); |
| | | AttributeType objectclassAttrType = getAttributeType(schema, ATTR_OBJECTCLASSES, ATTR_OBJECTCLASSES_LC, syntax); |
| | | return createAddModifications(entry, mods, objectclassAttrType); |
| | | } |
| | | |
| | |
| | | Entry entry, List<Modification> mods) throws ConfigException, |
| | | InitializationException |
| | | { |
| | | NameFormSyntax nfSyntax; |
| | | try |
| | | Syntax syntax = schema.getSyntax(SYNTAX_NAME_FORM_OID); |
| | | if (syntax == null) |
| | | { |
| | | nfSyntax = (NameFormSyntax) schema.getSyntax(SYNTAX_NAME_FORM_OID); |
| | | if (nfSyntax == null) |
| | | { |
| | | nfSyntax = new NameFormSyntax(); |
| | | nfSyntax.initializeSyntax(null); |
| | | } |
| | | syntax = CoreSchema.getNameFormDescriptionSyntax(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | nfSyntax = new NameFormSyntax(); |
| | | nfSyntax.initializeSyntax(null); |
| | | } |
| | | |
| | | AttributeType nameFormAttrType = getAttributeType( |
| | | schema, ATTR_NAME_FORMS, ATTR_NAME_FORMS_LC, nfSyntax); |
| | | schema, ATTR_NAME_FORMS, ATTR_NAME_FORMS_LC, syntax); |
| | | return createAddModifications(entry, mods, nameFormAttrType); |
| | | } |
| | | |
| | |
| | | Entry entry, List<Modification> mods) throws ConfigException, |
| | | InitializationException |
| | | { |
| | | DITContentRuleSyntax dcrSyntax; |
| | | try |
| | | Syntax syntax = schema.getSyntax(SYNTAX_DIT_CONTENT_RULE_OID); |
| | | if (syntax == null) |
| | | { |
| | | dcrSyntax = (DITContentRuleSyntax) |
| | | schema.getSyntax(SYNTAX_DIT_CONTENT_RULE_OID); |
| | | if (dcrSyntax == null) |
| | | { |
| | | dcrSyntax = new DITContentRuleSyntax(); |
| | | dcrSyntax.initializeSyntax(null); |
| | | } |
| | | syntax = CoreSchema.getDITContentRuleDescriptionSyntax(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | dcrSyntax = new DITContentRuleSyntax(); |
| | | dcrSyntax.initializeSyntax(null); |
| | | } |
| | | |
| | | AttributeType dcrAttrType = getAttributeType( |
| | | schema, ATTR_DIT_CONTENT_RULES, ATTR_DIT_CONTENT_RULES_LC, dcrSyntax); |
| | | schema, ATTR_DIT_CONTENT_RULES, ATTR_DIT_CONTENT_RULES_LC, syntax); |
| | | return createAddModifications(entry, mods, dcrAttrType); |
| | | } |
| | | |
| | |
| | | Entry entry, List<Modification> mods) throws ConfigException, |
| | | InitializationException |
| | | { |
| | | DITStructureRuleSyntax dsrSyntax; |
| | | try |
| | | Syntax syntax = schema.getSyntax(SYNTAX_DIT_STRUCTURE_RULE_OID); |
| | | if (syntax == null) |
| | | { |
| | | dsrSyntax = (DITStructureRuleSyntax) |
| | | schema.getSyntax(SYNTAX_DIT_STRUCTURE_RULE_OID); |
| | | if (dsrSyntax == null) |
| | | { |
| | | dsrSyntax = new DITStructureRuleSyntax(); |
| | | dsrSyntax.initializeSyntax(null); |
| | | } |
| | | syntax = CoreSchema.getDITStructureRuleDescriptionSyntax(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | dsrSyntax = new DITStructureRuleSyntax(); |
| | | dsrSyntax.initializeSyntax(null); |
| | | } |
| | | |
| | | AttributeType dsrAttrType = getAttributeType( |
| | | schema, ATTR_DIT_STRUCTURE_RULES, ATTR_DIT_STRUCTURE_RULES_LC, dsrSyntax); |
| | | AttributeType dsrAttrType = getAttributeType(schema, ATTR_DIT_STRUCTURE_RULES, ATTR_DIT_STRUCTURE_RULES_LC, syntax); |
| | | return createAddModifications(entry, mods, dsrAttrType); |
| | | } |
| | | |
| | |
| | | Entry entry, List<Modification> mods) throws ConfigException, |
| | | InitializationException |
| | | { |
| | | MatchingRuleUseSyntax mruSyntax; |
| | | try |
| | | Syntax syntax = schema.getSyntax(SYNTAX_MATCHING_RULE_USE_OID); |
| | | if (syntax == null) |
| | | { |
| | | mruSyntax = (MatchingRuleUseSyntax) |
| | | schema.getSyntax(SYNTAX_MATCHING_RULE_USE_OID); |
| | | if (mruSyntax == null) |
| | | { |
| | | mruSyntax = new MatchingRuleUseSyntax(); |
| | | mruSyntax.initializeSyntax(null); |
| | | } |
| | | syntax = CoreSchema.getMatchingRuleUseDescriptionSyntax(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | mruSyntax = new MatchingRuleUseSyntax(); |
| | | mruSyntax.initializeSyntax(null); |
| | | } |
| | | |
| | | AttributeType mruAttrType = getAttributeType( |
| | | schema, ATTR_MATCHING_RULE_USE, ATTR_MATCHING_RULE_USE_LC, mruSyntax); |
| | | AttributeType mruAttrType = getAttributeType(schema, ATTR_MATCHING_RULE_USE, ATTR_MATCHING_RULE_USE_LC, syntax); |
| | | return createAddModifications(entry, mods, mruAttrType); |
| | | } |
| | | |
| | | private static AttributeType getAttributeType(Schema schema, String attrName, |
| | | String attrLowerName, AttributeSyntax<?> syntax) |
| | | String attrLowerName, Syntax syntax) |
| | | { |
| | | final AttributeType attrType = schema.getAttributeType(attrLowerName); |
| | | if (attrType != null) |
| | |
| | | } |
| | | |
| | | /** Parse the ldapsyntaxes definitions if there are any. */ |
| | | private static void parseLdapSyntaxesDefinitions(Schema schema, |
| | | private static void parseLdapSyntaxesDefinitions(ServerContext serverContext, Schema schema, |
| | | String schemaFile, boolean failOnError, List<Attribute> ldapSyntaxList) |
| | | throws ConfigException |
| | | { |
| | |
| | | LDAPSyntaxDescription syntaxDescription; |
| | | try |
| | | { |
| | | syntaxDescription = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, schema, false); |
| | | syntaxDescription = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, serverContext, schema, false, false); |
| | | setExtraProperty(syntaxDescription, SCHEMA_PROPERTY_FILENAME, null); |
| | | setSchemaFile(syntaxDescription, schemaFile); |
| | | } |
| | |
| | | // to trap them and log a warning. |
| | | try |
| | | { |
| | | schema.registerLdapSyntaxDescription( |
| | | syntaxDescription, failOnError); |
| | | schema.registerLdapSyntaxDescription(syntaxDescription, failOnError); |
| | | registerLdapSyntaxInSchemaNG(serverContext, syntaxDescription, failOnError); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | try |
| | | { |
| | | schema.registerLdapSyntaxDescription(syntaxDescription, true); |
| | | registerLdapSyntaxInSchemaNG(serverContext, syntaxDescription, true); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private static void registerLdapSyntaxInSchemaNG(ServerContext serverContext, LDAPSyntaxDescription syntaxDescription, |
| | | boolean overwrite) |
| | | { |
| | | SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater(); |
| | | Syntax.Builder builder = schemaUpdater.getSchemaBuilder() |
| | | .buildSyntax(syntaxDescription.getSyntax()); |
| | | SchemaBuilder schemaBuilder = overwrite ? builder.addToSchemaOverwrite() : builder.addToSchema(); |
| | | schemaUpdater.updateSchema(schemaBuilder.toSchema()); |
| | | } |
| | | |
| | | /** Parse the attribute type definitions if there are any. */ |
| | | private static void parseAttributeTypeDefinitions(Schema schema, |
| | | String schemaFile, boolean failOnError, List<Attribute> attrList) |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014 ForgeRock AS |
| | | * Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | // Take schema files into account (TODO : or load files using provider mechanism ?) |
| | | completeSchemaFromFiles(schemaBuilder); |
| | | |
| | | schemaUpdater.updateSchema(schemaBuilder); |
| | | schemaUpdater.updateSchema(schemaBuilder.toSchema()); |
| | | } |
| | | |
| | | /** |
| | |
| | | Schema getSchema(); |
| | | |
| | | /** |
| | | * Returns the new schema of the server (SDK schema). |
| | | * <p> |
| | | * This method will disappear once migration to new schema |
| | | * is finished. Meanwhile, it is necessary to keep both the |
| | | * legacy version and the new version. |
| | | * |
| | | * @return the new version of the schema |
| | | */ |
| | | org.forgerock.opendj.ldap.schema.Schema getSchemaNG(); |
| | | |
| | | /** |
| | | * Returns the schema updater, which provides |
| | | * a mean to update the server's current schema. |
| | | * |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.AlertGenerator; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.api.DiskSpaceMonitorHandler; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.api.ServerShutdownListener; |
| | |
| | | this.lowThreshold = lowThreshold; |
| | | } |
| | | |
| | | private Attribute attr(String name, AttributeSyntax<?> syntax, Object value) |
| | | private Attribute attr(String name, Syntax syntax, Object value) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType(name, syntax); |
| | | return Attributes.create(attrType, String.valueOf(value)); |
| New file |
| | |
| | | /* |
| | | * 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 legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at legal-notices/CDDLv1_0.txt. |
| | | * If applicable, add the following below this CDDL HEADER, with the |
| | | * fields enclosed by brackets "[]" replaced with your own identifying |
| | | * information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.monitors; |
| | | |
| | | |
| | | |
| | | import java.lang.reflect.Method; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.backends.jeb.DatabaseContainer; |
| | | import org.opends.server.backends.jeb.EntryContainer; |
| | | import org.opends.server.backends.jeb.Index; |
| | | import org.opends.server.backends.jeb.RootContainer; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | import com.sleepycat.je.DatabaseException; |
| | | import com.sleepycat.je.EnvironmentStats; |
| | | import com.sleepycat.je.JEVersion; |
| | | import com.sleepycat.je.StatsConfig; |
| | | import com.sleepycat.je.TransactionStats; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | |
| | | /** |
| | | * A monitor provider for a Berkeley DB JE environment. |
| | | * It uses reflection on the environment statistics object |
| | | * so that we don't need to keep a list of all the stats. |
| | | */ |
| | | public class DatabaseEnvironmentMonitor |
| | | extends MonitorProvider<MonitorProviderCfg> |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * Represents the statistical information kept for each search filter. |
| | | */ |
| | | private static class FilterStats implements Comparable<FilterStats> |
| | | { |
| | | private volatile LocalizableMessage failureReason = LocalizableMessage.EMPTY; |
| | | private long maxMatchingEntries = -1; |
| | | private final AtomicInteger hits = new AtomicInteger(); |
| | | |
| | | public int compareTo(FilterStats that) { |
| | | return this.hits.get() - that.hits.get(); |
| | | } |
| | | |
| | | private void update(int hitCount, LocalizableMessage failureReason) |
| | | { |
| | | this.hits.getAndAdd(hitCount); |
| | | this.failureReason = failureReason; |
| | | } |
| | | |
| | | private void update(int hitCount, long matchingEntries) |
| | | { |
| | | this.hits.getAndAdd(hitCount); |
| | | this.failureReason = LocalizableMessage.EMPTY; |
| | | synchronized(this) |
| | | { |
| | | if(matchingEntries > maxMatchingEntries) |
| | | { |
| | | maxMatchingEntries = matchingEntries; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * The name of this monitor instance. |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * The root container to be monitored. |
| | | */ |
| | | private RootContainer rootContainer; |
| | | |
| | | private int maxEntries = 1024; |
| | | private boolean filterUseEnabled; |
| | | private String startTimeStamp; |
| | | private final HashMap<SearchFilter, FilterStats> filterToStats = |
| | | new HashMap<SearchFilter, FilterStats>(); |
| | | private final AtomicInteger indexedSearchCount = new AtomicInteger(); |
| | | private final AtomicInteger unindexedSearchCount = new AtomicInteger(); |
| | | |
| | | /** |
| | | * Creates a new database environment monitor. |
| | | * @param name The monitor instance name. |
| | | * @param rootContainer A root container handle for the database to be |
| | | * monitored. |
| | | */ |
| | | public DatabaseEnvironmentMonitor(String name, RootContainer rootContainer) |
| | | { |
| | | this.name = name; |
| | | this.rootContainer = rootContainer; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeMonitorProvider(MonitorProviderCfg configuration) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the name of this monitor provider. It should be unique among all |
| | | * monitor providers, including all instances of the same monitor provider. |
| | | * |
| | | * @return The name of this monitor provider. |
| | | */ |
| | | public String getMonitorInstanceName() |
| | | { |
| | | return name; |
| | | } |
| | | |
| | | /** |
| | | * Creates monitor attribute values for a given JE statistics object, |
| | | * using reflection to call all the getter methods of the statistics object. |
| | | * The attribute type names of the created attribute values are derived from |
| | | * the names of the getter methods. |
| | | * @param monitorAttrs The monitor attribute values are inserted into this |
| | | * attribute list. |
| | | * @param stats The JE statistics object. |
| | | * @param attrPrefix A common prefix for the attribute type names of the |
| | | * monitor attribute values, to distinguish the attributes of one |
| | | * type of statistical object from another, and to avoid attribute name |
| | | * collisions. |
| | | */ |
| | | private void addAttributesForStatsObject(ArrayList<Attribute> monitorAttrs, |
| | | Object stats, String attrPrefix) |
| | | { |
| | | Class<?> c = stats.getClass(); |
| | | Method[] methods = c.getMethods(); |
| | | |
| | | // Iterate through all the statistic class methods. |
| | | for (Method method : methods) |
| | | { |
| | | // Invoke all the getters returning integer values. |
| | | if (method.getName().startsWith("get")) |
| | | { |
| | | Class<?> returnType = method.getReturnType(); |
| | | if (returnType.equals(int.class) || returnType.equals(long.class)) |
| | | { |
| | | Syntax integerSyntax = DirectoryServer.getDefaultIntegerSyntax(); |
| | | |
| | | // Remove the 'get' from the method name and add the prefix. |
| | | String attrName = attrPrefix + method.getName().substring(3); |
| | | |
| | | try |
| | | { |
| | | // Read the statistic. |
| | | Object statValue = method.invoke(stats); |
| | | |
| | | // Create an attribute from the statistic. |
| | | AttributeType attrType = |
| | | DirectoryServer.getDefaultAttributeType(attrName, |
| | | integerSyntax); |
| | | monitorAttrs.add(Attributes.create(attrType, String |
| | | .valueOf(statValue))); |
| | | |
| | | } catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Retrieves a set of attributes containing monitor data that should be |
| | | * returned to the client if the corresponding monitor entry is requested. |
| | | * |
| | | * @return A set of attributes containing monitor data that should be |
| | | * returned to the client if the corresponding monitor entry is |
| | | * requested. |
| | | */ |
| | | public ArrayList<Attribute> getMonitorData() |
| | | { |
| | | EnvironmentStats environmentStats = null; |
| | | TransactionStats transactionStats = null; |
| | | StatsConfig statsConfig = new StatsConfig(); |
| | | ArrayList<Attribute> monitorAttrs = new ArrayList<Attribute>(); |
| | | |
| | | try |
| | | { |
| | | environmentStats = rootContainer.getEnvironmentStats(statsConfig); |
| | | transactionStats = |
| | | rootContainer.getEnvironmentTransactionStats(statsConfig); |
| | | } catch (DatabaseException e) |
| | | { |
| | | logger.traceException(e); |
| | | return monitorAttrs; |
| | | } |
| | | |
| | | String jeVersion = JEVersion.CURRENT_VERSION.getVersionString(); |
| | | AttributeType versionType = |
| | | DirectoryServer.getDefaultAttributeType("JEVersion"); |
| | | monitorAttrs.add(Attributes.create(versionType, jeVersion)); |
| | | |
| | | addAttributesForStatsObject(monitorAttrs, environmentStats, "Environment"); |
| | | addAttributesForStatsObject(monitorAttrs, transactionStats, "Transaction"); |
| | | |
| | | AttributeBuilder needReindex = new AttributeBuilder("need-reindex"); |
| | | for(EntryContainer ec : rootContainer.getEntryContainers()) |
| | | { |
| | | List<DatabaseContainer> databases = new ArrayList<DatabaseContainer>(); |
| | | ec.listDatabases(databases); |
| | | for(DatabaseContainer dc : databases) |
| | | { |
| | | if(dc instanceof Index && !((Index)dc).isTrusted()) |
| | | { |
| | | needReindex.add(dc.getName()); |
| | | } |
| | | } |
| | | } |
| | | if(needReindex.size() > 0) |
| | | { |
| | | monitorAttrs.add(needReindex.toAttribute()); |
| | | } |
| | | |
| | | if(filterUseEnabled) |
| | | { |
| | | monitorAttrs.add(Attributes.create("filter-use-startTime", |
| | | startTimeStamp)); |
| | | AttributeBuilder builder = new AttributeBuilder("filter-use"); |
| | | |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | synchronized(filterToStats) |
| | | { |
| | | for(Map.Entry<SearchFilter, FilterStats> entry : |
| | | filterToStats.entrySet()) |
| | | { |
| | | entry.getKey().toString(stringBuilder); |
| | | stringBuilder.append(" hits:"); |
| | | stringBuilder.append(entry.getValue().hits.get()); |
| | | stringBuilder.append(" maxmatches:"); |
| | | stringBuilder.append(entry.getValue().maxMatchingEntries); |
| | | stringBuilder.append(" message:"); |
| | | stringBuilder.append(entry.getValue().failureReason); |
| | | builder.add(stringBuilder.toString()); |
| | | stringBuilder.setLength(0); |
| | | } |
| | | } |
| | | monitorAttrs.add(builder.toAttribute()); |
| | | monitorAttrs.add(Attributes.create("filter-use-indexed", |
| | | String.valueOf(indexedSearchCount.get()))); |
| | | monitorAttrs.add(Attributes.create("filter-use-unindexed", |
| | | String.valueOf(unindexedSearchCount.get()))); |
| | | } |
| | | |
| | | return monitorAttrs; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Updates the index filter statistics with this latest search filter |
| | | * and the reason why an index was not used. |
| | | * |
| | | * @param searchFilter The search filter that was evaluated. |
| | | * @param failureMessage The reason why an index was not used. |
| | | */ |
| | | public void updateStats(SearchFilter searchFilter, LocalizableMessage failureMessage) |
| | | { |
| | | if(!filterUseEnabled) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | FilterStats stats; |
| | | synchronized(filterToStats) |
| | | { |
| | | stats = filterToStats.get(searchFilter); |
| | | |
| | | |
| | | if(stats != null) |
| | | { |
| | | stats.update(1, failureMessage); |
| | | } |
| | | else |
| | | { |
| | | stats = new FilterStats(); |
| | | stats.update(1, failureMessage); |
| | | removeLowestHit(); |
| | | filterToStats.put(searchFilter, stats); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Updates the index filter statistics with this latest search filter |
| | | * and the number of entries matched by the index lookup. |
| | | * |
| | | * @param searchFilter The search filter that was evaluated. |
| | | * @param matchingEntries The number of entries matched by the successful |
| | | * index lookup. |
| | | */ |
| | | public void updateStats(SearchFilter searchFilter, long matchingEntries) |
| | | { |
| | | if(!filterUseEnabled) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | FilterStats stats; |
| | | synchronized(filterToStats) |
| | | { |
| | | stats = filterToStats.get(searchFilter); |
| | | |
| | | |
| | | if(stats != null) |
| | | { |
| | | stats.update(1, matchingEntries); |
| | | } |
| | | else |
| | | { |
| | | stats = new FilterStats(); |
| | | stats.update(1, matchingEntries); |
| | | removeLowestHit(); |
| | | filterToStats.put(searchFilter, stats); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Enable or disable index filter statistics gathering. |
| | | * |
| | | * @param enabled <code>true></code> to enable index filter statics gathering. |
| | | */ |
| | | public void enableFilterUseStats(boolean enabled) |
| | | { |
| | | if(enabled && !filterUseEnabled) |
| | | { |
| | | startTimeStamp = TimeThread.getGMTTime(); |
| | | indexedSearchCount.set(0); |
| | | unindexedSearchCount.set(0); |
| | | } |
| | | else if(!enabled) |
| | | { |
| | | filterToStats.clear(); |
| | | } |
| | | filterUseEnabled = enabled; |
| | | } |
| | | |
| | | /** |
| | | * Indicates if index filter statistics gathering is enabled. |
| | | * |
| | | * @return <code>true</code> If index filter statistics gathering is enabled. |
| | | */ |
| | | public boolean isFilterUseEnabled() |
| | | { |
| | | return filterUseEnabled; |
| | | } |
| | | |
| | | /** |
| | | * Sets the maximum number of search filters statistics entries to keep |
| | | * before ones with the least hits will be removed. |
| | | * |
| | | * @param maxEntries The maximum number of search filters statistics |
| | | * entries to keep |
| | | */ |
| | | public void setMaxEntries(int maxEntries) { |
| | | this.maxEntries = maxEntries; |
| | | } |
| | | |
| | | /** |
| | | * Updates the statistics counter to include an indexed search. |
| | | */ |
| | | public void updateIndexedSearchCount() |
| | | { |
| | | indexedSearchCount.getAndIncrement(); |
| | | } |
| | | |
| | | /** |
| | | * Updates the statistics counter to include an unindexed search. |
| | | */ |
| | | public void updateUnindexedSearchCount() |
| | | { |
| | | unindexedSearchCount.getAndIncrement(); |
| | | } |
| | | |
| | | private void removeLowestHit() |
| | | { |
| | | while(!filterToStats.isEmpty() && filterToStats.size() > maxEntries) |
| | | { |
| | | Iterator<Map.Entry<SearchFilter, FilterStats>> i = |
| | | filterToStats.entrySet().iterator(); |
| | | Map.Entry<SearchFilter, FilterStats> lowest = i.next(); |
| | | Map.Entry<SearchFilter, FilterStats> entry; |
| | | while(lowest.getValue().hits.get() > 1 && i.hasNext()) |
| | | { |
| | | entry = i.next(); |
| | | if(entry.getValue().hits.get() < lowest.getValue().hits.get()) |
| | | { |
| | | lowest = entry; |
| | | } |
| | | } |
| | | |
| | | filterToStats.remove(lowest.getKey()); |
| | | } |
| | | } |
| | | } |
| | |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeMonitorProvider(MonitorProviderCfg configuration) |
| | | throws ConfigException, InitializationException |
| | | { |
| | |
| | | * |
| | | * @return The name of this monitor provider. |
| | | */ |
| | | @Override |
| | | public String getMonitorInstanceName() |
| | | { |
| | | return "Work Queue"; |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void run() |
| | | { |
| | | int backlog = workQueue.size(); |
| | |
| | | * returned to the client if the corresponding monitor entry is |
| | | * requested. |
| | | */ |
| | | @Override |
| | | public ArrayList<Attribute> getMonitorData() |
| | | { |
| | | int backlog = workQueue.size(); |
| | |
| | | long opsSubmitted = workQueue.getOpsSubmitted(); |
| | | |
| | | ArrayList<Attribute> monitorAttrs = new ArrayList<Attribute>(); |
| | | AttributeSyntax<?> integerSyntax = DirectoryServer |
| | | .getDefaultIntegerSyntax(); |
| | | Syntax integerSyntax = DirectoryServer.getDefaultIntegerSyntax(); |
| | | |
| | | // The current backlog. |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType( |
| | |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeMonitorProvider(MonitorProviderCfg configuration) |
| | | throws ConfigException, InitializationException |
| | | { |
| | |
| | | * |
| | | * @return The name of this monitor provider. |
| | | */ |
| | | @Override |
| | | public String getMonitorInstanceName() |
| | | { |
| | | return "Work Queue"; |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void run() |
| | | { |
| | | int backlog = workQueue.size(); |
| | |
| | | * returned to the client if the corresponding monitor entry is |
| | | * requested. |
| | | */ |
| | | @Override |
| | | public ArrayList<Attribute> getMonitorData() |
| | | { |
| | | int backlog = workQueue.size(); |
| | |
| | | long rejectedQueueFull = workQueue.getOpsRejectedDueToQueueFull(); |
| | | |
| | | ArrayList<Attribute> monitorAttrs = new ArrayList<Attribute>(); |
| | | AttributeSyntax<?> integerSyntax = DirectoryServer |
| | | .getDefaultIntegerSyntax(); |
| | | Syntax integerSyntax = DirectoryServer.getDefaultIntegerSyntax(); |
| | | |
| | | // The current backlog. |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType( |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.authorization.dseecompat.Aci; |
| | | import org.opends.server.authorization.dseecompat.AciException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import org.opends.server.core.ServerContext; |
| | | |
| | | /** |
| | | * This class implements the access control information (aci) attribute syntax. |
| | |
| | | public class AciSyntax |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) throws ConfigException |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration, ServerContext serverContext) throws ConfigException |
| | | { |
| | | defaultEqualityMatchingRule = DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_IA5_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_CASE_IGNORE_IA5_OID, SYNTAX_ACI_NAME); |
| | | } |
| | | // Add the Aci syntax to the "new" schema |
| | | SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater(); |
| | | SchemaBuilder builder = schemaUpdater.getSchemaBuilder().buildSyntax(SYNTAX_ACI_OID) |
| | | .description(SYNTAX_ACI_DESCRIPTION) |
| | | .implementation(new AciSyntaxImpl()) |
| | | .addToSchema(); |
| | | schemaUpdater.updateSchema(builder.toSchema()); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_IA5_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_IA5_OID, SYNTAX_ACI_NAME); |
| | | } |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema) |
| | | { |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_ACI_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | return SYNTAX_ACI_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | // We don't have an orderingMatchingRule |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // we don't have an approximateMatchingRule |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, LocalizableMessageBuilder invalidReason) |
| | | { |
| | | try |
| | | { |
| | | Aci.decode(value, DN.rootDN()); |
| | | return true; |
| | | } |
| | | catch (AciException e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | logger.warn(e.getMessageObject()); |
| | | invalidReason.append(e.getMessageObject()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| New file |
| | |
| | | /* |
| | | * 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 legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at legal-notices/CDDLv1_0.txt. |
| | | * If applicable, add the following below this CDDL HEADER, with the |
| | | * fields enclosed by brackets "[]" replaced with your own identifying |
| | | * information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SyntaxImpl; |
| | | import org.opends.server.authorization.dseecompat.Aci; |
| | | import org.opends.server.authorization.dseecompat.AciException; |
| | | import org.opends.server.types.DN; |
| | | |
| | | /** |
| | | * Implementation of Access control information (aci) attribute syntax. |
| | | */ |
| | | final class AciSyntaxImpl implements SyntaxImpl { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | AciSyntaxImpl() { |
| | | // // nothing to do |
| | | } |
| | | |
| | | @Override |
| | | public String getApproximateMatchingRule() { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String getEqualityMatchingRule() { |
| | | return EMR_CASE_IGNORE_IA5_OID; |
| | | } |
| | | |
| | | @Override |
| | | public String getOrderingMatchingRule() { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String getSubstringMatchingRule() { |
| | | return SMR_CASE_IGNORE_IA5_OID; |
| | | } |
| | | |
| | | @Override |
| | | public String getName() { |
| | | return SYNTAX_ACI_NAME; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isHumanReadable() { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public boolean valueIsAcceptable(final Schema schema, final ByteSequence value, |
| | | final LocalizableMessageBuilder invalidReason) { |
| | | try |
| | | { |
| | | Aci.decode(value, DN.rootDN()); |
| | | return true; |
| | | } |
| | | catch (AciException e) |
| | | { |
| | | logger.traceException(e); |
| | | logger.warn(e.getMessageObject()); |
| | | invalidReason.append(e.getMessageObject()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.Option; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeUsage; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.SchemaOptions; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.AttributeTypeDescriptionAttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.CommonSchemaElements; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | /** |
| | | * This class defines the attribute type description syntax, which is used to |
| | |
| | | extends AttributeSyntax<AttributeTypeDescriptionAttributeSyntaxCfg> |
| | | implements |
| | | ConfigurationChangeListener<AttributeTypeDescriptionAttributeSyntaxCfg> { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * The reference to the configuration for this attribute type description |
| | |
| | | |
| | | |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** If true strip the suggested minimum upper bound from the syntax OID. */ |
| | | private static boolean stripMinimumUpperBound; |
| | | |
| | | private ServerContext serverContext; |
| | | |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void |
| | | initializeSyntax(AttributeTypeDescriptionAttributeSyntaxCfg configuration) |
| | | initializeSyntax(AttributeTypeDescriptionAttributeSyntaxCfg configuration, ServerContext serverContext) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE.get( |
| | | EMR_CASE_IGNORE_OID, SYNTAX_ATTRIBUTE_TYPE_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE.get( |
| | | OMR_CASE_IGNORE_OID, SYNTAX_ATTRIBUTE_TYPE_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE.get( |
| | | SMR_CASE_IGNORE_OID, SYNTAX_ATTRIBUTE_TYPE_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | this.serverContext = serverContext; |
| | | |
| | | // 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 |
| | |
| | | currentConfig = configuration; |
| | | currentConfig.addAttributeTypeDescriptionChangeListener(this); |
| | | stripMinimumUpperBound=configuration.isStripSyntaxMinUpperBound(); |
| | | updateNewSchema(); |
| | | } |
| | | |
| | | /** Update the option in new schema if it changes from current value. */ |
| | | private void updateNewSchema() |
| | | { |
| | | Option<Boolean> option = SchemaOptions.STRIP_UPPER_BOUND_FOR_ATTRIBUTE_TYPE; |
| | | if (isStripSyntaxMinimumUpperBound() != serverContext.getSchemaNG().getOption(option)) |
| | | { |
| | | SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater(); |
| | | schemaUpdater.updateSchema( |
| | | schemaUpdater.getSchemaBuilder().setOption(option, stripMinimumUpperBound).toSchema()); |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema) |
| | | { |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_ATTRIBUTE_TYPE_OID); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll use the decodeAttributeType method to determine if the value is |
| | | // acceptable. |
| | | try |
| | | { |
| | | decodeAttributeType(value, DirectoryServer.getSchema(), true); |
| | | return true; |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Decodes the contents of the provided ASN.1 octet string as an attribute |
| | | * type definition according to the rules of this syntax. Note that the |
| | |
| | | List<String> typeNames = new LinkedList<String>(); |
| | | String description = null; |
| | | AttributeType superiorType = null; |
| | | AttributeSyntax<?> syntax = DirectoryServer.getDefaultAttributeSyntax(); |
| | | Syntax syntax = DirectoryServer.getDefaultAttributeSyntax(); |
| | | MatchingRule approximateMatchingRule = null; |
| | | MatchingRule equalityMatchingRule = null; |
| | | MatchingRule orderingMatchingRule = null; |
| | |
| | | { |
| | | currentConfig = configuration; |
| | | stripMinimumUpperBound = configuration.isStripSyntaxMinUpperBound(); |
| | | |
| | | updateNewSchema(); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | |
| | | public static boolean isStripSyntaxMinimumUpperBound() { |
| | | return stripMinimumUpperBound; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.schema; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | |
| | | /** |
| | | * This class defines the auth password attribute syntax, which is defined in |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_AUTH_PASSWORD_EXACT_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_AUTH_PASSWORD_EXACT_NAME, SYNTAX_AUTH_PASSWORD_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_AUTH_PASSWORD_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | // There is no ordering matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | // There is no substring matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | try |
| | | { |
| | | decodeAuthPassword(value.toString()); |
| | | return true; |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Decodes the provided authentication password value into its component |
| | | * parts. |
| | | * |
| | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | /** |
| | | * This class defines the binary attribute syntax, which is essentially a byte |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OCTET_STRING_OID, SYNTAX_BINARY_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_OCTET_STRING_OID, SYNTAX_BINARY_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_OCTET_STRING_OID, SYNTAX_BINARY_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_BINARY_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | return SYNTAX_BINARY_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // All values will be acceptable for the binary syntax. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isHumanReadable() |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class defines the bit string attribute syntax, which is comprised of |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_BIT_STRING_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_BIT_STRING_OID, SYNTAX_BIT_STRING_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_BIT_STRING_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_BIT_STRING_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_BIT_STRING_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_BIT_STRING_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | // Ordering matches are not allowed by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | // Substring matches are not allowed by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // Approximate matches are not allowed by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | String valueString = value.toString().toUpperCase(); |
| | | |
| | | int length = valueString.length(); |
| | | if (length < 3) |
| | | { |
| | | invalidReason.append(WARN_ATTR_SYNTAX_BIT_STRING_TOO_SHORT.get(value)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | if ((valueString.charAt(0) != '\'') || |
| | | (valueString.charAt(length-2) != '\'') || |
| | | (valueString.charAt(length-1) != 'B')) |
| | | { |
| | | invalidReason.append(WARN_ATTR_SYNTAX_BIT_STRING_NOT_QUOTED.get(value)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | for (int i=1; i < (length-2); i++) |
| | | { |
| | | switch (valueString.charAt(i)) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | // These characters are fine. |
| | | break; |
| | | default: |
| | | invalidReason.append(WARN_ATTR_SYNTAX_BIT_STRING_INVALID_BIT.get( |
| | | value, valueString.charAt(i))); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then everything is fine. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | /** |
| | | * This class defines the Boolean attribute syntax, which only allows values of |
| | | * "TRUE" or "FALSE" (although this implementation is more flexible and will |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_BOOLEAN_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_BOOLEAN_OID, SYNTAX_BOOLEAN_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_BOOLEAN_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | // Ordering matches are not allowed by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | // Substring matches are not allowed by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // Approximate matches are not allowed by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | String valueString = value.toString().toUpperCase(); |
| | | |
| | | boolean returnValue = (valueString.equals("TRUE") || |
| | | valueString.equals("YES") || |
| | | valueString.equals("ON") || |
| | | valueString.equals("1") || |
| | | valueString.equals("FALSE") || |
| | | valueString.equals("NO") || |
| | | valueString.equals("OFF") || |
| | | valueString.equals("0")); |
| | | |
| | | if (! returnValue) |
| | | { |
| | | invalidReason.append(WARN_ATTR_SYNTAX_ILLEGAL_BOOLEAN.get(value)); |
| | | } |
| | | |
| | | return returnValue; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves an attribute value containing a representation of the provided |
| | | * boolean value. |
| | | * |
| | |
| | | { |
| | | return b ? ServerConstants.TRUE_VALUE : ServerConstants.FALSE_VALUE; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class defines the Certificate Exact Assertion attribute syntax, |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_CASE_IGNORE_OID, SYNTAX_CERTIFICATE_EXACT_ASSERTION_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_CASE_IGNORE_OID, SYNTAX_CERTIFICATE_EXACT_ASSERTION_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_CASE_IGNORE_OID, SYNTAX_CERTIFICATE_EXACT_ASSERTION_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_CERTIFICATE_EXACT_ASSERTION_OID); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_CERTIFICATE_EXACT_ASSERTION_NAME; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_CERTIFICATE_EXACT_ASSERTION_OID; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_CERTIFICATE_EXACT_ASSERTION_DESCRIPTION; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // Approximate matching will not be allowed by default. |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // This method will never be called because this syntax is only used |
| | | // within assertions. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class implements the certificate list attribute syntax. This should be |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OCTET_STRING_OID, SYNTAX_CERTLIST_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_OCTET_STRING_OID, SYNTAX_CERTLIST_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_OCTET_STRING_OID, SYNTAX_CERTLIST_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_CERTLIST_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_CERTLIST_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_CERTLIST_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_CERTLIST_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // All values will be acceptable for the certificate list syntax. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class implements the certificate pair attribute syntax. This should be |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OCTET_STRING_OID, SYNTAX_CERTPAIR_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_OCTET_STRING_OID, SYNTAX_CERTPAIR_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_OCTET_STRING_OID, SYNTAX_CERTPAIR_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_CERTPAIR_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_CERTPAIR_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_CERTPAIR_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_CERTPAIR_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // All values will be acceptable for the certificate pair syntax. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import java.io.IOException; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import java.util.List; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.CertificateAttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.Option; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaOptions; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.CertificateAttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.ServerContext; |
| | | |
| | | |
| | | /** |
| | |
| | | implements ConfigurationChangeListener<CertificateAttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** The current configuration. */ |
| | | private volatile CertificateAttributeSyntaxCfg config; |
| | | |
| | | private ServerContext serverContext; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(CertificateAttributeSyntaxCfg configuration) |
| | | @Override |
| | | public void initializeSyntax(CertificateAttributeSyntaxCfg configuration, ServerContext serverContext) |
| | | throws ConfigException |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CERTIFICATE_EXACT_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_CERTIFICATE_EXACT_OID, SYNTAX_CERTIFICATE_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_OCTET_STRING_OID, SYNTAX_CERTIFICATE_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_OCTET_STRING_OID, SYNTAX_CERTIFICATE_NAME); |
| | | } |
| | | |
| | | this.config = configuration; |
| | | this.serverContext = serverContext; |
| | | updateNewSchema(); |
| | | config.addCertificateChangeListener(this); |
| | | } |
| | | |
| | | /** Update the option in new schema if it changes from current value. */ |
| | | private void updateNewSchema() |
| | | { |
| | | Option<Boolean> option = SchemaOptions.ALLOW_MALFORMED_CERTIFICATES; |
| | | if (config.isStrictFormat() == serverContext.getSchemaNG().getOption(option)) |
| | | { |
| | | SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater(); |
| | | schemaUpdater.updateSchema( |
| | | schemaUpdater.getSchemaBuilder().setOption(option, !config.isStrictFormat()).toSchema()); |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_CERTIFICATE_OID); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | CertificateAttributeSyntaxCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | CertificateAttributeSyntaxCfg configuration) |
| | | { |
| | | this.config = configuration; |
| | | updateNewSchema(); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_CERTIFICATE_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_CERTIFICATE_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_CERTIFICATE_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Skip validation if strict validation is disabled. |
| | | if (!config.isStrictFormat()) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | // Validate the ByteSequence against the definitions of X.509, clause 7 |
| | | long x509Version=0; |
| | | ASN1Reader reader = ASN1.getReader(value); |
| | | try |
| | | { |
| | | // Certificate SIGNED SEQUENCE |
| | | if (!reader.hasNextElement() || |
| | | reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE) |
| | | { |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.readStartSequence(); |
| | | |
| | | // CertificateContent SEQUENCE |
| | | if (!reader.hasNextElement() || |
| | | reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE) |
| | | { |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.readStartSequence(); |
| | | |
| | | // Optional Version |
| | | if (reader.hasNextElement() && |
| | | reader.peekType() == (ASN1.TYPE_MASK_CONTEXT | ASN1.TYPE_MASK_CONSTRUCTED)) |
| | | { |
| | | reader.readStartExplicitTag(); |
| | | if (!reader.hasNextElement() || |
| | | reader.peekType() != ASN1.UNIVERSAL_INTEGER_TYPE) |
| | | { |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | x509Version=reader.readInteger(); |
| | | if (x509Version < 0 || x509Version >2) |
| | | { |
| | | // invalid Version specified |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_INVALID_VERSION |
| | | .get(x509Version)); |
| | | return false; |
| | | } |
| | | if (x509Version == 0) |
| | | { |
| | | // DEFAULT values shall not be included in DER encoded SEQUENCE |
| | | // (X.690, 11.5) |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_INVALID_DER.get()); |
| | | return false; |
| | | } |
| | | reader.readEndExplicitTag(); |
| | | } |
| | | |
| | | // serialNumber |
| | | if (!reader.hasNextElement() || |
| | | reader.peekType() != ASN1.UNIVERSAL_INTEGER_TYPE) |
| | | { |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.skipElement(); |
| | | |
| | | // signature AlgorithmIdentifier |
| | | if (!reader.hasNextElement() || |
| | | reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE) |
| | | { |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.skipElement(); |
| | | |
| | | // issuer name (SEQUENCE as of X.501, 9.2) |
| | | if (!reader.hasNextElement() || |
| | | reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE) |
| | | { |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.skipElement(); |
| | | |
| | | // validity (SEQUENCE) |
| | | if (!reader.hasNextElement() || |
| | | reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE) |
| | | { |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.skipElement(); |
| | | |
| | | // subject name (SEQUENCE as of X.501, 9.2) |
| | | if (!reader.hasNextElement() || |
| | | reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE) |
| | | { |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.skipElement(); |
| | | |
| | | // SubjectPublicKeyInfo (SEQUENCE) |
| | | if (!reader.hasNextElement() || |
| | | reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE) |
| | | { |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.skipElement(); |
| | | |
| | | // OPTIONAL issuerUniqueIdentifier |
| | | if (reader.hasNextElement() && |
| | | reader.peekType() == (ASN1.TYPE_MASK_CONTEXT + 1)) |
| | | { |
| | | if (x509Version < 1) |
| | | { |
| | | // only valid in v2 and v3 |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.skipElement(); |
| | | } |
| | | |
| | | // OPTIONAL subjectUniqueIdentifier |
| | | if (reader.hasNextElement() && |
| | | reader.peekType() == (ASN1.TYPE_MASK_CONTEXT + 2)) |
| | | { |
| | | if (x509Version < 1) |
| | | { |
| | | // only valid in v2 and v3 |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.skipElement(); |
| | | } |
| | | |
| | | // OPTIONAL extensions |
| | | if (reader.hasNextElement() && |
| | | reader.peekType() == ((ASN1.TYPE_MASK_CONTEXT|ASN1.TYPE_MASK_CONSTRUCTED) + 3)) |
| | | { |
| | | if (x509Version < 2) |
| | | { |
| | | // only valid in v3 |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.readStartExplicitTag(); // read Tag |
| | | if (!reader.hasNextElement() || |
| | | reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE) |
| | | { |
| | | // only valid in v3 |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.readEndExplicitTag(); // read end Tag |
| | | } |
| | | |
| | | // There should not be any further ASN.1 elements within this SEQUENCE |
| | | if (reader.hasNextElement()) |
| | | { |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.readEndSequence(); // End CertificateContent SEQUENCE |
| | | |
| | | // AlgorithmIdentifier SEQUENCE |
| | | if (!reader.hasNextElement() || |
| | | reader.peekType() != ASN1.UNIVERSAL_SEQUENCE_TYPE) |
| | | { |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.skipElement(); |
| | | |
| | | // ENCRYPTED HASH BIT STRING |
| | | if (!reader.hasNextElement() || |
| | | reader.peekType() != ASN1.UNIVERSAL_BIT_STRING_TYPE) |
| | | { |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.skipElement(); |
| | | |
| | | // There should not be any further ASN.1 elements within this SEQUENCE |
| | | if (reader.hasNextElement()) |
| | | { |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | reader.readEndSequence(); // End Certificate SEQUENCE |
| | | |
| | | // There should not be any further ASN.1 elements |
| | | if (reader.hasNextElement()) |
| | | { |
| | | invalidReason.append(ERR_SYNTAX_CERTIFICATE_NOTVALID.get()); |
| | | return false; |
| | | } |
| | | // End of the certificate |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | | invalidReason.append(e.getMessageObject()); |
| | | return false; |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | invalidReason.append(e.getMessage()); |
| | | return false; |
| | | } |
| | | |
| | | // The basic structure of the value is an X.509 certificate |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | updateSchemaFromConfiguration(currentSchemaBuilder, configuration); |
| | | |
| | | final boolean isUpdated = schemaUpdater.updateSchema(currentSchemaBuilder); |
| | | final boolean isUpdated = schemaUpdater.updateSchema(currentSchemaBuilder.toSchema()); |
| | | |
| | | // TODO : fix result code + log an error in case of failure |
| | | final ConfigChangeResult result = new ConfigChangeResult(); |
| | |
| | | package org.opends.server.schema; |
| | | |
| | | |
| | | import java.util.List; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.Option; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaOptions; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.CountryStringAttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.PrintableString.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import org.opends.server.core.ServerContext; |
| | | |
| | | /** |
| | | * This class defines the country string attribute syntax, which should be a |
| | |
| | | implements ConfigurationChangeListener<CountryStringAttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default approximate matching rule for this syntax. */ |
| | | private MatchingRule defaultApproximateMatchingRule; |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** The current configuration. */ |
| | | private volatile CountryStringAttributeSyntaxCfg config; |
| | | |
| | | private ServerContext serverContext; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(CountryStringAttributeSyntaxCfg configuration) |
| | | @Override |
| | | public void initializeSyntax(CountryStringAttributeSyntaxCfg configuration, ServerContext serverContext) |
| | | throws ConfigException |
| | | { |
| | | defaultApproximateMatchingRule = |
| | | DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID); |
| | | if (defaultApproximateMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_APPROXIMATE_MATCHING_RULE, |
| | | AMR_DOUBLE_METAPHONE_OID, SYNTAX_COUNTRY_STRING_NAME); |
| | | } |
| | | |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_CASE_IGNORE_OID, SYNTAX_COUNTRY_STRING_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_CASE_IGNORE_OID, SYNTAX_COUNTRY_STRING_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_CASE_IGNORE_OID, SYNTAX_COUNTRY_STRING_NAME); |
| | | } |
| | | |
| | | this.config = configuration; |
| | | this.serverContext = serverContext; |
| | | updateNewSchema(); |
| | | config.addCountryStringChangeListener(this); |
| | | } |
| | | |
| | | /** Update the option in new schema if it changes from current value. */ |
| | | private void updateNewSchema() |
| | | { |
| | | Option<Boolean> option = SchemaOptions.STRICT_FORMAT_FOR_COUNTRY_STRINGS; |
| | | if (config.isStrictFormat() != serverContext.getSchemaNG().getOption(option)) |
| | | { |
| | | SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater(); |
| | | schemaUpdater.updateSchema( |
| | | schemaUpdater.getSchemaBuilder().setOption(option, config.isStrictFormat()).toSchema()); |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_COUNTRY_STRING_OID); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | CountryStringAttributeSyntaxCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | CountryStringAttributeSyntaxCfg configuration) |
| | | { |
| | | this.config = configuration; |
| | | updateNewSchema(); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_COUNTRY_STRING_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_COUNTRY_STRING_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_COUNTRY_STRING_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | return defaultApproximateMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | String stringValue = value.toString(); |
| | | if (stringValue.length() != 2) |
| | | { |
| | | invalidReason.append( |
| | | ERR_ATTR_SYNTAX_COUNTRY_STRING_INVALID_LENGTH.get(stringValue)); |
| | | return false; |
| | | } |
| | | |
| | | if (config.isStrictFormat()) |
| | | { |
| | | // Check for a string containing [A-Z][A-Z] |
| | | if (stringValue.charAt(0) < 'A' || stringValue.charAt(0) > 'Z' || |
| | | stringValue.charAt(1) < 'A' || stringValue.charAt(1) > 'Z') |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_COUNTRY_NO_VALID_ISO_CODE.get(value)); |
| | | return false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // Just validate as string containing 2 printable characters |
| | | if ((! isPrintableCharacter(stringValue.charAt(0))) || |
| | | (! isPrintableCharacter(stringValue.charAt(1)))) |
| | | { |
| | | invalidReason.append( |
| | | ERR_ATTR_SYNTAX_COUNTRY_STRING_NOT_PRINTABLE.get(stringValue)); |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DITContentRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | /** |
| | | * This class implements the DIT content rule description syntax, which is used |
| | |
| | | public class DITContentRuleSyntax |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException, InitializationException |
| | | public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE.get( |
| | | EMR_CASE_IGNORE_OID, SYNTAX_DIT_CONTENT_RULE_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE.get( |
| | | OMR_CASE_IGNORE_OID, SYNTAX_DIT_CONTENT_RULE_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE.get( |
| | | SMR_CASE_IGNORE_OID, SYNTAX_DIT_CONTENT_RULE_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_DIT_CONTENT_RULE_OID); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | return SYNTAX_DIT_CONTENT_RULE_DESCRIPTION; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll use the decodeDITContentRule method to determine if the value is |
| | | // acceptable. |
| | | try |
| | | { |
| | | decodeDITContentRule(value, DirectoryServer.getSchema(), true); |
| | | return true; |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Decodes the contents of the provided ASN.1 octet string as a DIT content |
| | | * rule definition according to the rules of this syntax. Note that the |
| | |
| | | |
| | | return startPos; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DITStructureRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.NameForm; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | /** |
| | | * This class implements the DIT structure rule description syntax, which is |
| | |
| | | public class DITStructureRuleSyntax |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException, InitializationException |
| | | @Override |
| | | public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE.get( |
| | | EMR_CASE_IGNORE_OID, SYNTAX_DIT_STRUCTURE_RULE_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE.get( |
| | | OMR_CASE_IGNORE_OID, SYNTAX_DIT_STRUCTURE_RULE_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE.get( |
| | | SMR_CASE_IGNORE_OID, SYNTAX_DIT_STRUCTURE_RULE_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_DIT_STRUCTURE_RULE_OID); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_DIT_STRUCTURE_RULE_NAME; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_DIT_STRUCTURE_RULE_OID; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_DIT_STRUCTURE_RULE_DESCRIPTION; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll use the decodeDITStructureRule method to determine if the value is |
| | | // acceptable. |
| | | try |
| | | { |
| | | decodeDITStructureRule(value, DirectoryServer.getSchema(), true); |
| | | return true; |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Decodes the contents of the provided ASN.1 octet string as a DIT structure |
| | | * rule definition according to the rules of this syntax. Note that the |
| | |
| | | |
| | | return startPos; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import java.util.HashSet; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import java.util.StringTokenizer; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | /** |
| | | * This class defines the delivery method attribute syntax. This contains one |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * The set of values that may be used as delivery methods. |
| | | */ |
| | | private static final String[] ALLOWED_VALUES = |
| | | { |
| | | "any", |
| | | "mhs", |
| | | "physical", |
| | | "telex", |
| | | "teletex", |
| | | "g3fax", |
| | | "g4fax", |
| | | "ia5", |
| | | "videotex", |
| | | "telephone" |
| | | }; |
| | | |
| | | /** The hash set containing the allowed values. */ |
| | | private HashSet<String> allowedValues; |
| | | |
| | | /** The default approximate matching rule for this syntax. */ |
| | | private MatchingRule defaultApproximateMatchingRule; |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | allowedValues = new HashSet<String>(ALLOWED_VALUES.length); |
| | | for (String s : ALLOWED_VALUES) |
| | | { |
| | | allowedValues.add(s); |
| | | } |
| | | |
| | | defaultApproximateMatchingRule = |
| | | DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID); |
| | | if (defaultApproximateMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_APPROXIMATE_MATCHING_RULE, |
| | | AMR_DOUBLE_METAPHONE_OID, SYNTAX_DELIVERY_METHOD_NAME); |
| | | } |
| | | |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_CASE_IGNORE_OID, SYNTAX_DELIVERY_METHOD_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_CASE_IGNORE_OID, SYNTAX_DELIVERY_METHOD_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_CASE_IGNORE_OID, SYNTAX_DELIVERY_METHOD_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_DELIVERY_METHOD_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_DELIVERY_METHOD_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_DELIVERY_METHOD_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_DELIVERY_METHOD_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | return defaultApproximateMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | String stringValue = toLowerCase(value.toString()); |
| | | StringTokenizer tokenizer = new StringTokenizer(stringValue, " $"); |
| | | if (! tokenizer.hasMoreTokens()) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_DELIVERY_METHOD_NO_ELEMENTS.get(value)); |
| | | return false; |
| | | } |
| | | |
| | | while (tokenizer.hasMoreTokens()) |
| | | { |
| | | String token = tokenizer.nextToken(); |
| | | if (! allowedValues.contains(token)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_DELIVERY_METHOD_INVALID_ELEMENT.get(value, token)); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.Option; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaOptions; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.DirectoryStringAttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import org.opends.server.core.ServerContext; |
| | | |
| | | |
| | | /** |
| | |
| | | implements ConfigurationChangeListener<DirectoryStringAttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default approximate matching rule for this syntax. */ |
| | | private MatchingRule defaultApproximateMatchingRule; |
| | | |
| | | /** Indicates whether we will allow zero-length values. */ |
| | | private boolean allowZeroLengthValues; |
| | | |
| | | /** The reference to the configuration for this directory string syntax. */ |
| | | private DirectoryStringAttributeSyntaxCfg currentConfig; |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | private ServerContext serverContext; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(DirectoryStringAttributeSyntaxCfg configuration) |
| | | public void initializeSyntax(DirectoryStringAttributeSyntaxCfg configuration, ServerContext serverContext) |
| | | throws ConfigException |
| | | { |
| | | defaultApproximateMatchingRule = |
| | | DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID); |
| | | if (defaultApproximateMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_APPROXIMATE_MATCHING_RULE, |
| | | AMR_DOUBLE_METAPHONE_OID, SYNTAX_DIRECTORY_STRING_NAME); |
| | | } |
| | | |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_CASE_IGNORE_OID, SYNTAX_DIRECTORY_STRING_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_CASE_IGNORE_OID, SYNTAX_DIRECTORY_STRING_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_CASE_IGNORE_OID, SYNTAX_DIRECTORY_STRING_NAME); |
| | | } |
| | | |
| | | this.serverContext = serverContext; |
| | | |
| | | // 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 |
| | |
| | | currentConfig = configuration; |
| | | currentConfig.addDirectoryStringChangeListener(this); |
| | | allowZeroLengthValues = currentConfig.isAllowZeroLengthValues(); |
| | | updateNewSchema(); |
| | | } |
| | | |
| | | /** Update the option in new schema if it changes from current value. */ |
| | | private void updateNewSchema() |
| | | { |
| | | Option<Boolean> option = SchemaOptions.ALLOW_ZERO_LENGTH_DIRECTORY_STRINGS; |
| | | if (allowZeroLengthValues != serverContext.getSchemaNG().getOption(option)) |
| | | { |
| | | SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater(); |
| | | schemaUpdater.updateSchema( |
| | | schemaUpdater.getSchemaBuilder().setOption(option, allowZeroLengthValues).toSchema()); |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_DIRECTORY_STRING_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | return defaultApproximateMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | if (allowZeroLengthValues || (value.length() > 0)) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | invalidReason.append( |
| | | ERR_ATTR_SYNTAX_DIRECTORYSTRING_INVALID_ZEROLENGTH_VALUE.get()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether zero-length values will be allowed. This is technically |
| | | * forbidden by the LDAP specification, but it was allowed in earlier versions |
| | | * of the server, and the discussion of the directory string syntax in RFC |
| | |
| | | { |
| | | currentConfig = configuration; |
| | | allowZeroLengthValues = configuration.isAllowZeroLengthValues(); |
| | | updateNewSchema(); |
| | | |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class defines the distinguished name attribute syntax, which is used for |
| | |
| | | public class DistinguishedNameSyntax |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_DN_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_DN_OID, SYNTAX_DN_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_OID, SYNTAX_DN_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_DN_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | return SYNTAX_DN_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | // There is no ordering matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Use the DN code to make this determination. |
| | | try |
| | | { |
| | | DN.valueOf(value.toString()); |
| | | |
| | | return true; |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | invalidReason.append(ERR_ATTR_SYNTAX_DN_INVALID.get(value, e)); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | /** |
| | | * This class implements the enhanced guide attribute syntax, which may be used |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_OCTET_STRING_OID, SYNTAX_ENHANCED_GUIDE_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_OCTET_STRING_OID, SYNTAX_ENHANCED_GUIDE_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_OCTET_STRING_OID, SYNTAX_ENHANCED_GUIDE_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_ENHANCED_GUIDE_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_ENHANCED_GUIDE_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_ENHANCED_GUIDE_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_ENHANCED_GUIDE_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get a lowercase string version of the provided value. |
| | | String valueStr = toLowerCase(value.toString()); |
| | | |
| | | |
| | | // Find the position of the first octothorpe. It should denote the end of |
| | | // the objectclass. |
| | | int sharpPos = valueStr.indexOf('#'); |
| | | if (sharpPos < 0) |
| | | { |
| | | invalidReason.append( |
| | | ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_SHARP.get(valueStr)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Get the objectclass and see if it is a valid name or OID. |
| | | String ocName = valueStr.substring(0, sharpPos).trim(); |
| | | int ocLength = ocName.length(); |
| | | if (ocLength == 0) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_OC.get(valueStr)); |
| | | return false; |
| | | } |
| | | |
| | | if (! isValidSchemaElement(ocName, 0, ocLength, invalidReason)) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Find the last octothorpe and make sure it is followed by a valid scope. |
| | | int lastSharpPos = valueStr.lastIndexOf('#'); |
| | | if (lastSharpPos == sharpPos) |
| | | { |
| | | invalidReason.append( |
| | | ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_FINAL_SHARP.get(valueStr)); |
| | | return false; |
| | | } |
| | | |
| | | String scopeStr = valueStr.substring(lastSharpPos+1).trim(); |
| | | if (!scopeStr.equals("baseobject") |
| | | && !scopeStr.equals("onelevel") |
| | | && !scopeStr.equals("wholesubtree") |
| | | && !scopeStr.equals("subordinatesubtree")) |
| | | { |
| | | if (scopeStr.length() == 0) |
| | | { |
| | | invalidReason.append( |
| | | ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_SCOPE.get(valueStr)); |
| | | } |
| | | else |
| | | { |
| | | invalidReason.append( |
| | | ERR_ATTR_SYNTAX_ENHANCEDGUIDE_INVALID_SCOPE.get( |
| | | valueStr, scopeStr)); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Everything between the two octothorpes must be the criteria. Make sure |
| | | // it is valid. |
| | | String criteria = valueStr.substring(sharpPos+1, lastSharpPos).trim(); |
| | | int criteriaLength = criteria.length(); |
| | | if (criteriaLength == 0) |
| | | { |
| | | invalidReason.append( |
| | | ERR_ATTR_SYNTAX_ENHANCEDGUIDE_NO_CRITERIA.get(valueStr)); |
| | | return false; |
| | | } |
| | | |
| | | return GuideSyntax.criteriaIsValid(criteria, valueStr, invalidReason); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import java.util.HashSet; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | /** |
| | | * This class implements the facsimile telephone number attribute syntax, which |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * The set of allowed fax parameter values, formatted entirely in lowercase |
| | | * characters. |
| | | */ |
| | | public static final HashSet<String> ALLOWED_FAX_PARAMETERS = |
| | | new HashSet<String>(7); |
| | | |
| | | static |
| | | { |
| | | ALLOWED_FAX_PARAMETERS.add("twodimensional"); |
| | | ALLOWED_FAX_PARAMETERS.add("fineresolution"); |
| | | ALLOWED_FAX_PARAMETERS.add("unlimitedlength"); |
| | | ALLOWED_FAX_PARAMETERS.add("b4length"); |
| | | ALLOWED_FAX_PARAMETERS.add("a3width"); |
| | | ALLOWED_FAX_PARAMETERS.add("b4width"); |
| | | ALLOWED_FAX_PARAMETERS.add("uncompressed"); |
| | | } |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_CASE_IGNORE_OID, SYNTAX_FAXNUMBER_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_CASE_IGNORE_OID, SYNTAX_FAXNUMBER_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_OID, SYNTAX_FAXNUMBER_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_FAXNUMBER_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_FAXNUMBER_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_FAXNUMBER_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_FAXNUMBER_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get a lowercase string representation of the value and find its length. |
| | | String valueString = toLowerCase(value.toString()); |
| | | int valueLength = valueString.length(); |
| | | |
| | | |
| | | // The value must contain at least one character. |
| | | if (valueLength == 0) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_EMPTY.get()); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // The first character must be a printable string character. |
| | | char c = valueString.charAt(0); |
| | | if (! PrintableString.isPrintableCharacter(c)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_NOT_PRINTABLE.get(valueString, c, 0)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Continue reading until we find a dollar sign or the end of the string. |
| | | // Every intermediate character must be a printable string character. |
| | | int pos = 1; |
| | | for ( ; pos < valueLength; pos++) |
| | | { |
| | | c = valueString.charAt(pos); |
| | | if (c == '$') |
| | | { |
| | | pos++; |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | if (! PrintableString.isPrintableCharacter(c)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_NOT_PRINTABLE.get(valueString, c, pos)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (pos >= valueLength) |
| | | { |
| | | // We're at the end of the value, so it must be valid unless the last |
| | | // character was a dollar sign. |
| | | if (c == '$') |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_END_WITH_DOLLAR.get( |
| | | valueString)); |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | |
| | | // Continue reading until we find the end of the string. Each substring |
| | | // must be a valid fax parameter. |
| | | int paramStartPos = pos; |
| | | while (pos < valueLength) |
| | | { |
| | | c = valueString.charAt(pos++); |
| | | if (c == '$') |
| | | { |
| | | String paramStr = valueString.substring(paramStartPos, pos); |
| | | if (! ALLOWED_FAX_PARAMETERS.contains(paramStr)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_ILLEGAL_PARAMETER.get( |
| | | valueString, paramStr, paramStartPos, (pos-1))); |
| | | return false; |
| | | } |
| | | |
| | | paramStartPos = pos; |
| | | } |
| | | } |
| | | |
| | | |
| | | // We must be at the end of the value. Read the last parameter and make |
| | | // sure it is valid. |
| | | String paramStr = valueString.substring(paramStartPos); |
| | | if (! ALLOWED_FAX_PARAMETERS.contains(paramStr)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_ILLEGAL_PARAMETER.get( |
| | | valueString, paramStr, paramStartPos, (pos-1))); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then the value must be valid. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class implements the fax attribute syntax. This should be restricted to |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OCTET_STRING_OID, SYNTAX_FAX_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_OCTET_STRING_OID, SYNTAX_FAX_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_OCTET_STRING_OID, SYNTAX_FAX_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_FAX_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_FAX_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_FAX_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_FAX_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // All values will be acceptable for the fax syntax. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.GregorianCalendar; |
| | | import java.util.TimeZone; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | /** |
| | | * This class defines the generalized time attribute syntax, which is a way of |
| | |
| | | private static final TimeZone TIME_ZONE_UTC_OBJ = |
| | | TimeZone.getTimeZone(TIME_ZONE_UTC); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_GENERALIZED_TIME_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_GENERALIZED_TIME_OID, SYNTAX_GENERALIZED_TIME_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_GENERALIZED_TIME_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_GENERALIZED_TIME_OID, SYNTAX_GENERALIZED_TIME_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_CASE_IGNORE_OID, SYNTAX_GENERALIZED_TIME_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_GENERALIZED_TIME_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // Approximate matching will not be allowed by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | try |
| | | { |
| | | decodeGeneralizedTimeValue(value); |
| | | return true; |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the generalized time representation of the provided date. |
| | | * |
| | | * @param d The date to retrieve in generalized time form. |
| | |
| | | // time zone by using "GMT" followed by the offset. |
| | | return TimeZone.getTimeZone("GMT" + offSetStr); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OCTET_STRING_OID, SYNTAX_GUIDE_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_OCTET_STRING_OID, SYNTAX_GUIDE_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_OCTET_STRING_OID, SYNTAX_GUIDE_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_GUIDE_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_GUIDE_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_GUIDE_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_GUIDE_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get a lowercase string version of the provided value. |
| | | String valueStr = toLowerCase(value.toString()); |
| | | |
| | | |
| | | // Find the position of the octothorpe. If there isn't one, then the entire |
| | | // value should be the criteria. |
| | | int sharpPos = valueStr.indexOf('#'); |
| | | if (sharpPos < 0) |
| | | { |
| | | return criteriaIsValid(valueStr, valueStr, invalidReason); |
| | | } |
| | | |
| | | |
| | | // Get the objectclass and see if it is a valid name or OID. |
| | | String ocName = valueStr.substring(0, sharpPos).trim(); |
| | | int ocLength = ocName.length(); |
| | | if (ocLength == 0) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_GUIDE_NO_OC.get(valueStr)); |
| | | return false; |
| | | } |
| | | |
| | | return isValidSchemaElement(ocName, 0, ocLength, invalidReason) |
| | | // The rest of the value must be the criteria. |
| | | && criteriaIsValid(valueStr.substring(sharpPos+1), valueStr, invalidReason); |
| | | } |
| | | |
| | | /** |
| | | * Determines whether the provided string represents a valid criteria |
| | | * according to the guide syntax. |
| | | * |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | /** |
| | | * This class implements the IA5 string attribute syntax, which is simply a |
| | | * set of ASCII characters. By default, they will be treated in a |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default approximate matching rule for this syntax. */ |
| | | private MatchingRule defaultApproximateMatchingRule; |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultApproximateMatchingRule = |
| | | DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID); |
| | | if (defaultApproximateMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_APPROXIMATE_MATCHING_RULE, |
| | | AMR_DOUBLE_METAPHONE_OID, SYNTAX_IA5_STRING_NAME); |
| | | } |
| | | |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_IA5_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_CASE_IGNORE_IA5_OID, SYNTAX_IA5_STRING_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_CASE_IGNORE_OID, SYNTAX_IA5_STRING_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_IA5_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_CASE_IGNORE_IA5_OID, SYNTAX_IA5_STRING_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_IA5_STRING_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_IA5_STRING_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_IA5_STRING_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_IA5_STRING_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | return defaultApproximateMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We will allow any value that does not contain any non-ASCII characters. |
| | | // Empty values are acceptable as well. |
| | | byte b; |
| | | for (int i = 0; i < value.length(); i++) |
| | | { |
| | | b = value.byteAt(i); |
| | | if ((b & 0x7F) != b) |
| | | { |
| | | invalidReason.append(WARN_ATTR_SYNTAX_IA5_ILLEGAL_CHARACTER.get(value, b)); |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class defines the integer attribute syntax, which holds an |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing |
| | | * that should be done here is to invoke the default constructor for |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_INTEGER_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_INTEGER_OID, SYNTAX_INTEGER_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_INTEGER_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_INTEGER_OID, SYNTAX_INTEGER_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_EXACT_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_EXACT_OID, SYNTAX_INTEGER_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_INTEGER_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | return SYNTAX_INTEGER_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | String valueString = value.toString(); |
| | | int length = valueString.length(); |
| | | |
| | | if (length == 0) |
| | | { |
| | | invalidReason.append( |
| | | WARN_ATTR_SYNTAX_INTEGER_EMPTY_VALUE.get(valueString)); |
| | | return false; |
| | | } |
| | | else if (length == 1) |
| | | { |
| | | switch (valueString.charAt(0)) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | case '6': |
| | | case '7': |
| | | case '8': |
| | | case '9': |
| | | return true; |
| | | case '-': |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_DASH_NEEDS_VALUE |
| | | .get(valueString)); |
| | | return false; |
| | | default: |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER |
| | | .get(valueString, valueString.charAt(0), 0)); |
| | | return false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | boolean negative = false; |
| | | |
| | | switch (valueString.charAt(0)) |
| | | { |
| | | case '0': |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO |
| | | .get(valueString)); |
| | | return false; |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | case '6': |
| | | case '7': |
| | | case '8': |
| | | case '9': |
| | | // These are all fine. |
| | | break; |
| | | case '-': |
| | | // This is fine too. |
| | | negative = true; |
| | | break; |
| | | default: |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER |
| | | .get(valueString, valueString.charAt(0), 0)); |
| | | return false; |
| | | } |
| | | |
| | | switch (valueString.charAt(1)) |
| | | { |
| | | case '0': |
| | | // This is fine as long as the value isn't negative. |
| | | if (negative) |
| | | { |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO |
| | | .get(valueString)); |
| | | return false; |
| | | } |
| | | break; |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | case '6': |
| | | case '7': |
| | | case '8': |
| | | case '9': |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER |
| | | .get(valueString, valueString.charAt(1), 1)); |
| | | return false; |
| | | } |
| | | |
| | | for (int i=2; i < length; i++) |
| | | { |
| | | switch (valueString.charAt(i)) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | case '6': |
| | | case '7': |
| | | case '8': |
| | | case '9': |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | invalidReason.append(WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER |
| | | .get(valueString, valueString.charAt(i), i)); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import java.util.List; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.JPEGAttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.Option; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaOptions; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.JPEGAttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.ServerContext; |
| | | |
| | | /** |
| | | * This class implements the JPEG attribute syntax. This is actually |
| | |
| | | implements ConfigurationChangeListener<JPEGAttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** The current configuration for this JPEG syntax. */ |
| | | private volatile JPEGAttributeSyntaxCfg config; |
| | | |
| | | private ServerContext serverContext; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(JPEGAttributeSyntaxCfg configuration) |
| | | @Override |
| | | public void initializeSyntax(JPEGAttributeSyntaxCfg configuration, ServerContext serverContext) |
| | | throws ConfigException |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OCTET_STRING_OID, SYNTAX_JPEG_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_OCTET_STRING_OID, SYNTAX_JPEG_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_OCTET_STRING_OID, SYNTAX_JPEG_NAME); |
| | | } |
| | | |
| | | this.config = configuration; |
| | | this.serverContext = serverContext; |
| | | updateNewSchema(); |
| | | config.addJPEGChangeListener(this); |
| | | } |
| | | |
| | | /** Update the option in new schema if it changes from current value. */ |
| | | private void updateNewSchema() |
| | | { |
| | | Option<Boolean> option = SchemaOptions.ALLOW_MALFORMED_JPEG_PHOTOS; |
| | | if (config.isStrictFormat() == serverContext.getSchemaNG().getOption(option)) |
| | | { |
| | | SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater(); |
| | | schemaUpdater.updateSchema( |
| | | schemaUpdater.getSchemaBuilder().setOption(option, !config.isStrictFormat()).toSchema()); |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_JPEG_OID); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the common name for this attribute syntax. |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_JPEG_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_JPEG_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_JPEG_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // anything is acceptable if we're not strict. |
| | | if (!config.isStrictFormat()) |
| | | return true; |
| | | |
| | | /* JFIF files start: |
| | | * 0xff 0xd8 0xff 0xe0 LH LL 0x4a 0x46 0x49 0x46 ... |
| | | * SOI APP0 len "JFIF" |
| | | * |
| | | * Exif files (from most digital cameras) start: |
| | | * 0xff 0xd8 0xff 0xe1 LH LL 0x45 0x78 0x69 0x66 ... |
| | | * SOI APP1 len "Exif" |
| | | * |
| | | * So all legal values must be at least 10 bytes long |
| | | */ |
| | | if (value.length() < 10) |
| | | return false; |
| | | |
| | | if (value.byteAt(0) != (byte)0xff && value.byteAt(1) != (byte)0xd8) |
| | | return false; |
| | | |
| | | if (value.byteAt(2) == (byte)0xff && value.byteAt(3) == (byte)0xe0 && |
| | | value.byteAt(6) == 'J' && value.byteAt(7) == 'F' && |
| | | value.byteAt(8) == 'I' && value.byteAt(9) == 'F') |
| | | return true; |
| | | |
| | | if (value.byteAt(2) == (byte)0xff && value.byteAt(3) == (byte)0xe1 && |
| | | value.byteAt(6) == 'E' && value.byteAt(7) == 'x' && |
| | | value.byteAt(8) == 'i' && value.byteAt(9) == 'f') |
| | | return true; |
| | | |
| | | // No JFIF or Exif header found |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | JPEGAttributeSyntaxCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | JPEGAttributeSyntaxCfg configuration) |
| | | { |
| | | this.config = configuration; |
| | | updateNewSchema(); |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.regex.Pattern; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.CommonSchemaElements; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.LDAPSyntaxDescription; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class defines the LDAP syntax description syntax, which is used to |
| | | * hold attribute syntax definitions in the server schema. The format of this |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_CASE_IGNORE_OID, SYNTAX_LDAP_SYNTAX_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_CASE_IGNORE_OID, SYNTAX_LDAP_SYNTAX_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_OID, SYNTAX_LDAP_SYNTAX_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_LDAP_SYNTAX_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param value The byte sequence containing the value |
| | | * to decode (it does not need to be |
| | | * normalized). |
| | | * @param serverContext |
| | | * The server context. |
| | | * @param schema The schema to use to resolve references to |
| | | * other schema elements. |
| | | * @param allowUnknownElements Indicates whether to allow values that are |
| | |
| | | * should only be true when called by |
| | | * {@code valueIsAcceptable}. |
| | | * Not used for LDAP Syntaxes |
| | | * @param forDelete |
| | | * {@code true} if used for deletion. |
| | | * |
| | | * @return The decoded ldapsyntax definition. |
| | | * |
| | | * @throws DirectoryException If the provided value cannot be decoded as an |
| | | * ldapsyntax definition. |
| | | */ |
| | | public static LDAPSyntaxDescription decodeLDAPSyntax(ByteSequence value, |
| | | Schema schema, |
| | | boolean allowUnknownElements) throws DirectoryException |
| | | public static LDAPSyntaxDescription decodeLDAPSyntax(ByteSequence value, ServerContext serverContext, |
| | | Schema schema, boolean allowUnknownElements, boolean forDelete) throws DirectoryException |
| | | { |
| | | // Get string representations of the provided value using the provided form. |
| | | String valueStr = value.toString(); |
| | |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | else |
| | | { |
| | | oid = toLowerCase(valueStr.substring(oidStartPos, pos)); |
| | | } |
| | | |
| | | oid = toLowerCase(valueStr.substring(oidStartPos, pos)); |
| | | |
| | | // Skip over the space(s) after the OID. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | |
| | | // we get to the end of the value. But before we start, set default values |
| | | // for everything else we might need to know. |
| | | String description = null; |
| | | LDAPSyntaxDescriptionSyntax syntax = null; |
| | | HashMap<String,List<String>> extraProperties = |
| | | new LinkedHashMap<String,List<String>>(); |
| | | Syntax syntax = null; |
| | | HashMap<String,List<String>> extraProperties = new LinkedHashMap<String,List<String>>(); |
| | | boolean hasXSyntaxToken = false; |
| | | |
| | | while (true) |
| | |
| | | pos = readQuotedString(valueStr, descriptionBuffer, pos); |
| | | description = descriptionBuffer.toString(); |
| | | } |
| | | else if (lowerTokenName.equals("x-subst")) |
| | | { |
| | | if (hasXSyntaxToken) |
| | | { |
| | | // We've already seen syntax extension. More than 1 is not allowed |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_TOO_MANY_EXTENSIONS.get(valueStr); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | hasXSyntaxToken = true; |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readQuotedString(valueStr, woidBuffer, pos); |
| | | String syntaxOID = toLowerCase(woidBuffer.toString()); |
| | | AttributeSyntax<?> subSyntax = schema.getSyntax(syntaxOID); |
| | | if (subSyntax == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_LDAPSYNTAX_UNKNOWN_SYNTAX.get(oid, syntaxOID); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | syntax = new SubstitutionSyntax(subSyntax,valueStr,description,oid); |
| | | } |
| | | |
| | | else if(lowerTokenName.equals("x-pattern")) |
| | | { |
| | | if (hasXSyntaxToken) |
| | | { |
| | | // We've already seen syntax extension. More than 1 is not allowed |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_TOO_MANY_EXTENSIONS.get(valueStr); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | hasXSyntaxToken = true; |
| | | StringBuilder regexBuffer = new StringBuilder(); |
| | | pos = readQuotedString(valueStr, regexBuffer, pos); |
| | | String regex = regexBuffer.toString().trim(); |
| | | if(regex.length() == 0) |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_LDAPSYNTAX_REGEX_NO_PATTERN.get( |
| | | valueStr); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | |
| | | try |
| | | { |
| | | Pattern pattern = Pattern.compile(regex); |
| | | syntax = new RegexSyntax(pattern,valueStr,description,oid); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_LDAPSYNTAX_REGEX_INVALID_PATTERN.get |
| | | (valueStr,regex); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | } |
| | | else if(lowerTokenName.equals("x-enum")) |
| | | { |
| | | if (hasXSyntaxToken) |
| | | { |
| | | // We've already seen syntax extension. More than 1 is not allowed |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_TOO_MANY_EXTENSIONS.get(valueStr); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | hasXSyntaxToken = true; |
| | | LinkedList<String> values = new LinkedList<String>(); |
| | | pos = readExtraParameterValues(valueStr, values, pos); |
| | | |
| | | if (values.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_ENUM_NO_VALUES.get(valueStr); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | // Parse all enum values, check for uniqueness |
| | | LinkedList<ByteSequence> entries = new LinkedList<ByteSequence>(); |
| | | for (String v : values) |
| | | { |
| | | ByteString entry = ByteString.valueOf(v); |
| | | if (entries.contains(entry)) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | WARN_ATTR_SYNTAX_LDAPSYNTAX_ENUM_DUPLICATE_VALUE.get( |
| | | valueStr, entry,pos)); |
| | | } |
| | | entries.add(entry); |
| | | } |
| | | syntax = new EnumSyntax(entries, valueStr,description, oid); |
| | | } |
| | | else if (tokenName.matches("X\\-[_\\p{Alpha}-]+")) |
| | | { |
| | | // This must be a non-standard property and it must be followed by |
| | | // either a single value in single quotes or an open parenthesis |
| | | // followed by one or more values in single quotes separated by spaces |
| | | // followed by a close parenthesis. |
| | | List<String> valueList = new ArrayList<String>(); |
| | | pos = readExtraParameterValues(valueStr, valueList, pos); |
| | | extraProperties.put(tokenName, valueList); |
| | | } |
| | | else |
| | | { |
| | | // Unknown Token |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_LDAPSYNTAX_UNKNOWN_EXT.get( |
| | | valueStr, tokenName, pos); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | SchemaBuilder schemaBuilder = serverContext != null ? |
| | | serverContext.getSchemaUpdater().getSchemaBuilder() : new SchemaBuilder(CoreSchema.getInstance()); |
| | | |
| | | if (lowerTokenName.equals("x-subst")) |
| | | { |
| | | if (hasXSyntaxToken) |
| | | { |
| | | // We've already seen syntax extension. More than 1 is not allowed |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_TOO_MANY_EXTENSIONS.get(valueStr); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | hasXSyntaxToken = true; |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readQuotedString(valueStr, woidBuffer, pos); |
| | | String syntaxOID = toLowerCase(woidBuffer.toString()); |
| | | Syntax subSyntax = schema.getSyntax(syntaxOID); |
| | | if (subSyntax == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_LDAPSYNTAX_UNKNOWN_SYNTAX.get(oid, syntaxOID); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | syntax = forDelete ? schema.getSyntax(oid) : schemaBuilder.buildSyntax(oid) |
| | | .extraProperties("x-subst", syntaxOID) |
| | | .addToSchema().toSchema().getSyntax(oid); |
| | | } |
| | | |
| | | else if(lowerTokenName.equals("x-pattern")) |
| | | { |
| | | if (hasXSyntaxToken) |
| | | { |
| | | // We've already seen syntax extension. More than 1 is not allowed |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_TOO_MANY_EXTENSIONS.get(valueStr); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | hasXSyntaxToken = true; |
| | | StringBuilder regexBuffer = new StringBuilder(); |
| | | pos = readQuotedString(valueStr, regexBuffer, pos); |
| | | String regex = regexBuffer.toString().trim(); |
| | | if(regex.length() == 0) |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_LDAPSYNTAX_REGEX_NO_PATTERN.get( |
| | | valueStr); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | |
| | | try |
| | | { |
| | | syntax = forDelete ? schema.getSyntax(oid) : schemaBuilder.buildSyntax(oid) |
| | | .extraProperties("x-pattern", regex) |
| | | .addToSchema().toSchema().getSyntax(oid); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_LDAPSYNTAX_REGEX_INVALID_PATTERN.get |
| | | (valueStr,regex); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | } |
| | | else if(lowerTokenName.equals("x-enum")) |
| | | { |
| | | if (hasXSyntaxToken) |
| | | { |
| | | // We've already seen syntax extension. More than 1 is not allowed |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_TOO_MANY_EXTENSIONS.get(valueStr); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | hasXSyntaxToken = true; |
| | | LinkedList<String> values = new LinkedList<String>(); |
| | | pos = readExtraParameterValues(valueStr, values, pos); |
| | | |
| | | if (values.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_ENUM_NO_VALUES.get(valueStr); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | // Parse all enum values, check for uniqueness |
| | | List<String> entries = new LinkedList<>(); |
| | | for (String v : values) |
| | | { |
| | | ByteString entry = ByteString.valueOf(v); |
| | | if (entries.contains(entry)) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | WARN_ATTR_SYNTAX_LDAPSYNTAX_ENUM_DUPLICATE_VALUE.get( |
| | | valueStr, entry,pos)); |
| | | } |
| | | entries.add(v); |
| | | } |
| | | |
| | | syntax = forDelete ? schema.getSyntax(oid) : schemaBuilder |
| | | .addEnumerationSyntax(oid, description, true, entries.toArray(new String[0])) |
| | | .toSchema().getSyntax(oid); |
| | | } |
| | | else if (tokenName.matches("X\\-[_\\p{Alpha}-]+")) |
| | | { |
| | | // This must be a non-standard property and it must be followed by |
| | | // either a single value in single quotes or an open parenthesis |
| | | // followed by one or more values in single quotes separated by spaces |
| | | // followed by a close parenthesis. |
| | | List<String> valueList = new ArrayList<String>(); |
| | | pos = readExtraParameterValues(valueStr, valueList, pos); |
| | | extraProperties.put(tokenName, valueList); |
| | | } |
| | | else |
| | | { |
| | | // Unknown Token |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_LDAPSYNTAX_UNKNOWN_EXT.get( |
| | | valueStr, tokenName, pos); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | } |
| | | } |
| | | if (syntax == null) |
| | | { |
| | | // Create a plain Syntax. That seems to be required by export/import |
| | | // Schema backend. |
| | | syntax = new LDAPSyntaxDescriptionSyntax(); |
| | | // TODO : add localized message |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | | LocalizableMessage.raw("no LDAP syntax for:" + value)); |
| | | } |
| | | |
| | | CommonSchemaElements.checkSafeProperties(extraProperties); |
| | | |
| | | //Since we reached here it means everything is OK. |
| | | return new LDAPSyntaxDescription(valueStr,syntax, |
| | | description,extraProperties); |
| | | return new LDAPSyntaxDescription(valueStr, syntax, extraProperties); |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll use the decodeAttributeType method to determine if the value is |
| | | // acceptable. |
| | | try |
| | | { |
| | | decodeLDAPSyntax(value, DirectoryServer.getSchema(), true); |
| | | return true; |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Reads the next token name from the attribute syntax definition, skipping |
| | | * over any leading or trailing spaces, and appends it to the provided buffer. |
| | | * |
| | |
| | | |
| | | return startPos; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * This class provides a substitution mechanism where one unimplemented |
| | | * syntax can be substituted by another defined syntax. A substitution syntax |
| | | * is an LDAPSyntaxDescriptionSyntax with X-SUBST extension. |
| | | */ |
| | | private static class SubstitutionSyntax extends |
| | | LDAPSyntaxDescriptionSyntax |
| | | { |
| | | /** The syntax that will substitute the unimplemented syntax. */ |
| | | private AttributeSyntax<?> subSyntax; |
| | | |
| | | /** The description of this syntax. */ |
| | | private String description; |
| | | |
| | | /** The definition of this syntax. */ |
| | | private String definition; |
| | | |
| | | |
| | | /** The oid of this syntax. */ |
| | | private String oid; |
| | | |
| | | /** Creates a new instance of this syntax. */ |
| | | private SubstitutionSyntax(AttributeSyntax<?> subSyntax, |
| | | String definition, |
| | | String description, |
| | | String oid) |
| | | { |
| | | super(); |
| | | this.subSyntax = subSyntax; |
| | | this.definition = definition; |
| | | this.description = description; |
| | | this.oid = oid; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | // There is no name for a substitution syntax. |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return oid; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return description; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return definition; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | return subSyntax.valueIsAcceptable(value, invalidReason); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return subSyntax.getEqualityMatchingRule(); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return subSyntax.getOrderingMatchingRule(); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return subSyntax.getSubstringMatchingRule(); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | return subSyntax.getApproximateMatchingRule(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * This class provides a regex mechanism where a new syntax and its |
| | | * corresponding matching rules can be created on-the-fly. A regex |
| | | * syntax is an LDAPSyntaxDescriptionSyntax with X-PATTERN extension. |
| | | */ |
| | | private static class RegexSyntax extends |
| | | LDAPSyntaxDescriptionSyntax |
| | | { |
| | | /** The Pattern associated with the regex. */ |
| | | private Pattern pattern; |
| | | |
| | | /** The description of this syntax. */ |
| | | private String description; |
| | | |
| | | /** The oid of this syntax. */ |
| | | private String oid; |
| | | |
| | | /** The definition of this syntax. */ |
| | | private String definition; |
| | | |
| | | /** The equality matching rule. */ |
| | | private MatchingRule equalityMatchingRule; |
| | | |
| | | /** The substring matching rule. */ |
| | | private MatchingRule substringMatchingRule; |
| | | |
| | | /** The ordering matching rule. */ |
| | | private MatchingRule orderingMatchingRule; |
| | | |
| | | /** The approximate matching rule. */ |
| | | private MatchingRule approximateMatchingRule; |
| | | |
| | | |
| | | /** Creates a new instance of this syntax. */ |
| | | private RegexSyntax(Pattern pattern, |
| | | String definition, |
| | | String description, |
| | | String oid) |
| | | { |
| | | super(); |
| | | this.definition = definition; |
| | | this.pattern = pattern; |
| | | this.description = description; |
| | | this.oid = oid; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | // There is no name for a regex syntax. |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return oid; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return description; |
| | | } |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return definition; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | String strValue = value.toString(); |
| | | boolean matches = pattern.matcher(strValue).matches(); |
| | | if(!matches) |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_LDAPSYNTAX_REGEX_INVALID_VALUE.get( |
| | | strValue,pattern.pattern()); |
| | | invalidReason.append(message); |
| | | } |
| | | return matches; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | if(equalityMatchingRule == null) |
| | | { |
| | | //This has already been verified. |
| | | equalityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | } |
| | | return equalityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | if(orderingMatchingRule == null) |
| | | { |
| | | orderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | } |
| | | return orderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | if(substringMatchingRule == null) |
| | | { |
| | | substringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | } |
| | | return substringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | if(approximateMatchingRule == null) |
| | | { |
| | | approximateMatchingRule = |
| | | DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID); |
| | | } |
| | | return approximateMatchingRule; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * This class provides an enumeration-based mechanism where a new syntax |
| | | * and its corresponding matching rules can be created on-the-fly. An enum |
| | | * syntax is an LDAPSyntaxDescriptionSyntax with X-PATTERN extension. |
| | | */ |
| | | private static class EnumSyntax extends |
| | | LDAPSyntaxDescriptionSyntax |
| | | { |
| | | /** Set of read-only enum entries. */ |
| | | LinkedList<ByteSequence> entries; |
| | | |
| | | /** The description of this syntax. */ |
| | | private String description; |
| | | |
| | | /** The oid of this syntax. */ |
| | | private String oid; |
| | | |
| | | /** The equality matching rule. */ |
| | | private MatchingRule equalityMatchingRule; |
| | | |
| | | /** The substring matching rule. */ |
| | | private MatchingRule substringMatchingRule; |
| | | |
| | | /** The ordering matching rule. */ |
| | | private MatchingRule orderingMatchingRule; |
| | | |
| | | /** The approximate matching rule. */ |
| | | private MatchingRule approximateMatchingRule; |
| | | |
| | | /** The definition of this syntax. */ |
| | | private String definition; |
| | | |
| | | |
| | | /** Creates a new instance of this syntax. */ |
| | | private EnumSyntax(LinkedList<ByteSequence> entries, |
| | | String definition, |
| | | String description, |
| | | String oid) |
| | | { |
| | | super(); |
| | | this.entries = entries; |
| | | this.definition = definition; |
| | | this.description = description; |
| | | this.oid = oid; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | // There is no name for a enum syntax. |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return oid; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return definition; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return description; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void finalizeSyntax() |
| | | { |
| | | DirectoryServer.deregisterMatchingRule(orderingMatchingRule); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | //The value is acceptable if it belongs to the set. |
| | | boolean isAllowed = entries.contains(value); |
| | | if (!isAllowed) |
| | | { |
| | | invalidReason.append(WARN_ATTR_SYNTAX_LDAPSYNTAX_ENUM_INVALID_VALUE.get(value,oid)); |
| | | } |
| | | return isAllowed; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | if(equalityMatchingRule == null) |
| | | { |
| | | //This has already been verified. |
| | | equalityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | } |
| | | return equalityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | if (orderingMatchingRule == null) |
| | | { |
| | | /* |
| | | * It is not sufficient to build the enum matching rule alone here, we |
| | | * need to build enum syntax as well otherwise the schema is not valid. The |
| | | * enum matching rule is automatically built with the enum syntax by the |
| | | * builder. |
| | | */ |
| | | String[] enumerations = new String[entries.size()]; |
| | | Iterator<ByteSequence> it = entries.iterator(); |
| | | for (int i=0; i < entries.size(); i++) |
| | | { |
| | | enumerations[i] = it.next().toString(); |
| | | } |
| | | SchemaBuilder builder = new SchemaBuilder(CoreSchema.getInstance()).addEnumerationSyntax( |
| | | oid, getDescription(), true, enumerations); |
| | | orderingMatchingRule = builder.toSchema().getMatchingRule(OMR_OID_GENERIC_ENUM + "." + oid); |
| | | try |
| | | { |
| | | DirectoryServer.registerMatchingRule(orderingMatchingRule, false); |
| | | } |
| | | catch(DirectoryException de) |
| | | { |
| | | logger.error(de.getMessageObject()); |
| | | } |
| | | } |
| | | return orderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | if(substringMatchingRule == null) |
| | | { |
| | | substringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | } |
| | | return substringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | if(approximateMatchingRule == null) |
| | | { |
| | | approximateMatchingRule = |
| | | DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID); |
| | | } |
| | | return approximateMatchingRule; |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class implements the matching rule description syntax, which is used to |
| | |
| | | public class MatchingRuleSyntax |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_CASE_IGNORE_OID, SYNTAX_MATCHING_RULE_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_CASE_IGNORE_OID, SYNTAX_MATCHING_RULE_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_OID, SYNTAX_MATCHING_RULE_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_MATCHING_RULE_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | return SYNTAX_MATCHING_RULE_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get string representations of the provided value using the provided form |
| | | // and with all lowercase characters. |
| | | String valueStr = value.toString(); |
| | | String lowerStr = toLowerCase(valueStr); |
| | | |
| | | |
| | | // We'll do this a character at a time. First, skip over any leading |
| | | // whitespace. |
| | | int pos = 0; |
| | | int length = valueStr.length(); |
| | | while ((pos < length) && (valueStr.charAt(pos) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | | |
| | | if (pos >= length) |
| | | { |
| | | // This means that the value was empty or contained only whitespace. That |
| | | // is illegal. |
| | | |
| | | invalidReason.append(ERR_ATTR_SYNTAX_MR_EMPTY_VALUE.get()); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // The next character must be an open parenthesis. If it is not, then that |
| | | // is an error. |
| | | char c = valueStr.charAt(pos++); |
| | | if (c != '(') |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_MR_EXPECTED_OPEN_PARENTHESIS.get(valueStr, (pos-1), c)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Skip over any spaces immediately following the opening parenthesis. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | | |
| | | if (pos >= length) |
| | | { |
| | | // This means that the end of the value was reached before we could find |
| | | // the OID. Ths is illegal. |
| | | |
| | | invalidReason.append(ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | if (isDigit(c)) |
| | | { |
| | | // This must be a numeric OID. In that case, we will accept only digits |
| | | // and periods, but not consecutive periods. |
| | | boolean lastWasPeriod = false; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | { |
| | | if (c == '.') |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | | invalidReason.append( |
| | | ERR_ATTR_SYNTAX_MR_DOUBLE_PERIOD_IN_NUMERIC_OID.get( |
| | | valueStr, (pos-1))); |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | lastWasPeriod = true; |
| | | } |
| | | } |
| | | else if (! isDigit(c)) |
| | | { |
| | | // This must have been an illegal character. |
| | | invalidReason.append(ERR_ATTR_SYNTAX_MR_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos-1)); |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | lastWasPeriod = false; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // This must be a "fake" OID. In this case, we will only accept |
| | | // alphabetic characters, numeric digits, and the hyphen. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' ')) |
| | | { |
| | | if (isAlpha(c) || isDigit(c) || (c == '-') || |
| | | ((c == '_') && DirectoryServer.allowAttributeNameExceptions())) |
| | | { |
| | | // This is fine. It is an acceptable character. |
| | | } |
| | | else |
| | | { |
| | | // This must have been an illegal character. |
| | | invalidReason.append(ERR_ATTR_SYNTAX_MR_ILLEGAL_CHAR_IN_STRING_OID.get(valueStr, c, (pos-1))); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // If we're at the end of the value, then it isn't a valid matching rule |
| | | // description. Otherwise, parse out the OID. |
| | | if (pos >= length) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Skip over the space(s) after the OID. |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | | |
| | | if (pos >= length) |
| | | { |
| | | // This means that the end of the value was reached before we could find |
| | | // the OID. Ths is illegal. |
| | | |
| | | invalidReason.append(ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // At this point, we should have a pretty specific syntax that describes |
| | | // what may come next, but some of the components are optional and it would |
| | | // be pretty easy to put something in the wrong order, so we will be very |
| | | // flexible about what we can accept. Just look at the next token, figure |
| | | // out what it is and how to treat what comes after it, then repeat until |
| | | // we get to the end of the value. But before we start, set default values |
| | | // for everything else we might need to know. |
| | | ConcurrentHashMap<String,String> names = |
| | | new ConcurrentHashMap<String,String>(); |
| | | AttributeSyntax<?> syntax = null; |
| | | ConcurrentHashMap<String,CopyOnWriteArrayList<String>> extraProperties = |
| | | new ConcurrentHashMap<String,CopyOnWriteArrayList<String>>(); |
| | | |
| | | |
| | | while (true) |
| | | { |
| | | StringBuilder tokenNameBuffer = new StringBuilder(); |
| | | |
| | | try |
| | | { |
| | | pos = readTokenName(valueStr, tokenNameBuffer, pos); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | |
| | | String tokenName = tokenNameBuffer.toString(); |
| | | String lowerTokenName = toLowerCase(tokenName); |
| | | if (tokenName.equals(")")) |
| | | { |
| | | // We must be at the end of the value. If not, then that's a problem. |
| | | if (pos < length) |
| | | { |
| | | invalidReason.append( |
| | | ERR_ATTR_SYNTAX_MR_UNEXPECTED_CLOSE_PARENTHESIS.get( |
| | | valueStr, (pos-1))); |
| | | return false; |
| | | } |
| | | |
| | | break; |
| | | } |
| | | else if (lowerTokenName.equals("name")) |
| | | { |
| | | // This specifies the set of names for the matching rule. It may be a |
| | | // single name in single quotes, or it may be an open parenthesis |
| | | // followed by one or more names in single quotes separated by spaces. |
| | | c = valueStr.charAt(pos++); |
| | | if (c == '\'') |
| | | { |
| | | StringBuilder userBuffer = new StringBuilder(); |
| | | StringBuilder lowerBuffer = new StringBuilder(); |
| | | |
| | | try |
| | | { |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, |
| | | (pos-1)); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | |
| | | names.put(lowerBuffer.toString(), userBuffer.toString()); |
| | | } |
| | | else if (c == '(') |
| | | { |
| | | StringBuilder userBuffer = new StringBuilder(); |
| | | StringBuilder lowerBuffer = new StringBuilder(); |
| | | |
| | | try |
| | | { |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, |
| | | pos); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | |
| | | names.put(lowerBuffer.toString(), userBuffer.toString()); |
| | | |
| | | |
| | | while (true) |
| | | { |
| | | if (valueStr.charAt(pos) == ')') |
| | | { |
| | | // Skip over any spaces after the parenthesis. |
| | | pos++; |
| | | while ((pos < length) && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | | |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | userBuffer = new StringBuilder(); |
| | | lowerBuffer = new StringBuilder(); |
| | | |
| | | try |
| | | { |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, |
| | | lowerBuffer, pos); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | |
| | | names.put(lowerBuffer.toString(), userBuffer.toString()); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // This is an illegal character. |
| | | invalidReason.append(ERR_ATTR_SYNTAX_MR_ILLEGAL_CHAR.get(valueStr, c, (pos-1))); |
| | | return false; |
| | | } |
| | | } |
| | | else if (lowerTokenName.equals("desc")) |
| | | { |
| | | // This specifies the description for the matching rule. It is an |
| | | // arbitrary string of characters enclosed in single quotes. |
| | | StringBuilder descriptionBuffer = new StringBuilder(); |
| | | |
| | | try |
| | | { |
| | | pos = readQuotedString(valueStr, descriptionBuffer, pos); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | } |
| | | else if (lowerTokenName.equals("obsolete")) |
| | | { |
| | | // This indicates whether the matching rule should be considered |
| | | // obsolete. We do not need to do any more parsing for this token. |
| | | } |
| | | else if (lowerTokenName.equals("syntax")) |
| | | { |
| | | // This specifies the syntax for the matching rule. Read the next |
| | | // token, which should be the OID of the associated syntax. |
| | | StringBuilder oidBuffer = new StringBuilder(); |
| | | |
| | | try |
| | | { |
| | | pos = readWOID(lowerStr, oidBuffer, pos); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | |
| | | // See if the server recognizes that syntax. If not, then log a |
| | | // warning. |
| | | syntax = DirectoryServer.getSchema().getSyntax(oidBuffer.toString(), false); |
| | | if (syntax == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_MR_UNKNOWN_SYNTAX, valueStr, oidBuffer); |
| | | |
| | | syntax = DirectoryServer.getDefaultAttributeSyntax(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // This must be a non-standard property and it must be followed by |
| | | // either a single value in single quotes or an open parenthesis |
| | | // followed by one or more values in single quotes separated by spaces |
| | | // followed by a close parenthesis. |
| | | CopyOnWriteArrayList<String> valueList = |
| | | new CopyOnWriteArrayList<String>(); |
| | | |
| | | try |
| | | { |
| | | pos = readExtraParameterValues(valueStr, valueList, pos); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | |
| | | extraProperties.put(tokenName, valueList); |
| | | } |
| | | } |
| | | |
| | | |
| | | // Make sure that a syntax was specified. |
| | | if (syntax == null) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_MR_NO_SYNTAX.get(valueStr)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then the value is acceptable. |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * Reads the next token name from the matching rule definition, skipping over |
| | | * any leading or trailing spaces, and appends it to the provided buffer. |
| | | * |
| | | * @param valueStr The string representation of the matching rule |
| | | * definition. |
| | | * @param tokenName The buffer into which the token name will be written. |
| | | * @param startPos The position in the provided string at which to start |
| | | * reading the token name. |
| | | * |
| | | * @return The position of the first character that is not part of the token |
| | | * name or one of the trailing spaces after it. |
| | | * |
| | | * @throws DirectoryException If a problem is encountered while reading the |
| | | * token name. |
| | | */ |
| | | private static int readTokenName(String valueStr, StringBuilder tokenName, |
| | | int startPos) |
| | | throws DirectoryException |
| | | { |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = valueStr.length(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | | |
| | | if (startPos >= length) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // Read until we find the next space. |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | tokenName.append(c); |
| | | } |
| | | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | | |
| | | |
| | | // Return the position of the first non-space character after the token. |
| | | return startPos; |
| | | } |
| | | |
| | | /** |
| | | * Reads the value of a string enclosed in single quotes, skipping over the |
| | | * quotes and any leading or trailing spaces, and appending the string to the |
| | | * provided buffer. |
| | | * |
| | | * @param valueStr The user-provided representation of the matching rule |
| | | * definition. |
| | | * @param valueBuffer The buffer into which the user-provided representation |
| | | * of the value will be placed. |
| | | * @param startPos The position in the provided string at which to start |
| | | * reading the quoted string. |
| | | * |
| | | * @return The position of the first character that is not part of the quoted |
| | | * string or one of the trailing spaces after it. |
| | | * |
| | | * @throws DirectoryException If a problem is encountered while reading the |
| | | * quoted string. |
| | | */ |
| | | private static int readQuotedString(String valueStr, |
| | | StringBuilder valueBuffer, int startPos) |
| | | throws DirectoryException |
| | | { |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = valueStr.length(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | | |
| | | if (startPos >= length) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // The next character must be a single quote. |
| | | if (c != '\'') |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MR_EXPECTED_QUOTE_AT_POS.get(valueStr, startPos, c); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // Read until we find the closing quote. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | | } |
| | | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | | |
| | | |
| | | // If we're at the end of the value, then that's illegal. |
| | | if (startPos >= length) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // Return the position of the first non-space character after the token. |
| | | return startPos; |
| | | } |
| | | |
| | | /** |
| | | * Reads the value of a string enclosed in single quotes, skipping over the |
| | | * quotes and any leading or trailing spaces, and appending the string to the |
| | | * provided buffer. |
| | | * |
| | | * @param valueStr The user-provided representation of the matching rule |
| | | * definition. |
| | | * @param lowerStr The all-lowercase representation of the matching rule |
| | | * definition. |
| | | * @param userBuffer The buffer into which the user-provided representation |
| | | * of the value will be placed. |
| | | * @param lowerBuffer The buffer into which the all-lowercase representation |
| | | * of the value will be placed. |
| | | * @param startPos The position in the provided string at which to start |
| | | * reading the quoted string. |
| | | * |
| | | * @return The position of the first character that is not part of the quoted |
| | | * string or one of the trailing spaces after it. |
| | | * |
| | | * @throws DirectoryException If a problem is encountered while reading the |
| | | * quoted string. |
| | | */ |
| | | private static int readQuotedString(String valueStr, String lowerStr, |
| | | StringBuilder userBuffer, |
| | | StringBuilder lowerBuffer, int startPos) |
| | | throws DirectoryException |
| | | { |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = lowerStr.length(); |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | | |
| | | if (startPos >= length) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(lowerStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // The next character must be a single quote. |
| | | if (c != '\'') |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MR_EXPECTED_QUOTE_AT_POS.get(valueStr, startPos, c); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // Read until we find the closing quote. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) != '\'')) |
| | | { |
| | | lowerBuffer.append(c); |
| | | userBuffer.append(valueStr.charAt(startPos)); |
| | | startPos++; |
| | | } |
| | | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | startPos++; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | | |
| | | |
| | | // If we're at the end of the value, then that's illegal. |
| | | if (startPos >= length) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(lowerStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // Return the position of the first non-space character after the token. |
| | | return startPos; |
| | | } |
| | | |
| | | /** |
| | | * Reads the attribute type/objectclass description or numeric OID from the |
| | | * provided string, skipping over any leading or trailing spaces, and |
| | | * appending the value to the provided buffer. |
| | | * |
| | | * @param lowerStr The string from which the name or OID is to be read. |
| | | * @param woidBuffer The buffer into which the name or OID should be |
| | | * appended. |
| | | * @param startPos The position at which to start reading. |
| | | * |
| | | * @return The position of the first character after the name or OID that is |
| | | * not a space. |
| | | * |
| | | * @throws DirectoryException If a problem is encountered while reading the |
| | | * name or OID. |
| | | */ |
| | | private static int readWOID(String lowerStr, StringBuilder woidBuffer, |
| | | int startPos) |
| | | throws DirectoryException |
| | | { |
| | | // Skip over any spaces at the beginning of the value. |
| | | char c = '\u0000'; |
| | | int length = lowerStr.length(); |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | | |
| | | if (startPos >= length) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_TRUNCATED_VALUE.get(lowerStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // The next character must be either numeric (for an OID) or alphabetic (for |
| | | // an objectclass description). |
| | | if (isDigit(c)) |
| | | { |
| | | // This must be a numeric OID. In that case, we will accept only digits |
| | | // and periods, but not consecutive periods. |
| | | boolean lastWasPeriod = false; |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | if (c == '.') |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_DOUBLE_PERIOD_IN_NUMERIC_OID. |
| | | get(lowerStr, (startPos-1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | else |
| | | { |
| | | woidBuffer.append(c); |
| | | lastWasPeriod = true; |
| | | } |
| | | } |
| | | else if (! isDigit(c)) |
| | | { |
| | | // Technically, this must be an illegal character. However, it is |
| | | // possible that someone just got sloppy and did not include a space |
| | | // between the name/OID and a closing parenthesis. In that case, |
| | | // we'll assume it's the end of the value. What's more, we'll have |
| | | // to prematurely return to nasty side effects from stripping off |
| | | // additional characters. |
| | | if (c == ')') |
| | | { |
| | | return (startPos-1); |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR_IN_NUMERIC_OID.get( |
| | | lowerStr, c, (startPos - 1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | | woidBuffer.append(c); |
| | | lastWasPeriod = false; |
| | | } |
| | | } |
| | | } |
| | | else if (isAlpha(c)) |
| | | { |
| | | // This must be an objectclass description. In this case, we will only |
| | | // accept alphabetic characters, numeric digits, and the hyphen. |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' ')) |
| | | { |
| | | if (isAlpha(c) || isDigit(c) || (c == '-') || |
| | | ((c == '_') && DirectoryServer.allowAttributeNameExceptions())) |
| | | { |
| | | woidBuffer.append(c); |
| | | } |
| | | else |
| | | { |
| | | // Technically, this must be an illegal character. However, it is |
| | | // possible that someone just got sloppy and did not include a space |
| | | // between the name/OID and a closing parenthesis. In that case, |
| | | // we'll assume it's the end of the value. What's more, we'll have |
| | | // to prematurely return to nasty side effects from stripping off |
| | | // additional characters. |
| | | if (c == ')') |
| | | { |
| | | return (startPos-1); |
| | | } |
| | | |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR_IN_STRING_OID.get( |
| | | lowerStr, c, (startPos - 1)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_OBJECTCLASS_ILLEGAL_CHAR.get(lowerStr, c, startPos); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // Skip over any trailing spaces after the value. |
| | | while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | | |
| | | |
| | | // If we're at the end of the value, then that's illegal. |
| | | if (startPos >= length) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_TRUNCATED_VALUE.get(lowerStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // Return the position of the first non-space character after the token. |
| | | return startPos; |
| | | } |
| | | |
| | | /** |
| | | * Reads the value for an "extra" parameter. It will handle a single unquoted |
| | | * word (which is technically illegal, but we'll allow it), a single quoted |
| | | * string, or an open parenthesis followed by a space-delimited set of quoted |
| | | * strings or unquoted words followed by a close parenthesis. |
| | | * |
| | | * @param valueStr The string containing the information to be read. |
| | | * @param valueList The list of "extra" parameter values read so far. |
| | | * @param startPos The position in the value string at which to start |
| | | * reading. |
| | | * |
| | | * @return The "extra" parameter value that was read. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while attempting to read |
| | | * the value. |
| | | */ |
| | | private static int readExtraParameterValues(String valueStr, |
| | | CopyOnWriteArrayList<String> valueList, int startPos) |
| | | throws DirectoryException |
| | | { |
| | | // Skip over any leading spaces. |
| | | int length = valueStr.length(); |
| | | char c = '\u0000'; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | | |
| | | if (startPos >= length) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // Look at the next character. If it is a quote, then parse until the next |
| | | // quote and end. If it is an open parenthesis, then parse individual |
| | | // values until the close parenthesis and end. Otherwise, parse until the |
| | | // next space and end. |
| | | if (c == '\'') |
| | | { |
| | | // Parse until the closing quote. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | startPos++; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | | } |
| | | startPos++; |
| | | valueList.add(valueBuffer.toString()); |
| | | } |
| | | else if (c == '(') |
| | | { |
| | | startPos++; |
| | | // We're expecting a list of values. Quoted, space separated. |
| | | while (true) |
| | | { |
| | | // Skip over any leading spaces; |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | | |
| | | if (startPos >= length) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | |
| | | if (c == ')') |
| | | { |
| | | // This is the end of the list. |
| | | startPos++; |
| | | break; |
| | | } |
| | | else if (c == '(') |
| | | { |
| | | // This is an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_MR_ILLEGAL_CHAR.get(valueStr, c, startPos); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else if (c == '\'') |
| | | { |
| | | // We have a quoted string |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | startPos++; |
| | | while ((startPos < length) && |
| | | ((c = valueStr.charAt(startPos)) != '\'')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | | } |
| | | |
| | | valueList.add(valueBuffer.toString()); |
| | | startPos++; |
| | | } |
| | | else |
| | | { |
| | | //Consider unquoted string |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && |
| | | ((c = valueStr.charAt(startPos)) != ' ')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | | } |
| | | |
| | | valueList.add(valueBuffer.toString()); |
| | | } |
| | | |
| | | if (startPos >= length) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // Parse until the next space. |
| | | StringBuilder valueBuffer = new StringBuilder(); |
| | | while ((startPos < length) && ((c = valueStr.charAt(startPos)) != ' ')) |
| | | { |
| | | valueBuffer.append(c); |
| | | startPos++; |
| | | } |
| | | |
| | | valueList.add(valueBuffer.toString()); |
| | | } |
| | | |
| | | // Skip over any trailing spaces. |
| | | while ((startPos < length) && (valueStr.charAt(startPos) == ' ')) |
| | | { |
| | | startPos++; |
| | | } |
| | | |
| | | if (startPos >= length) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MR_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | return startPos; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.MatchingRuleUse; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | /** |
| | | * This class implements the matching rule use description syntax, which is used |
| | |
| | | public class MatchingRuleUseSyntax |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException, InitializationException |
| | | @Override |
| | | public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE.get( |
| | | EMR_CASE_IGNORE_OID, SYNTAX_MATCHING_RULE_USE_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE.get( |
| | | OMR_CASE_IGNORE_OID, SYNTAX_MATCHING_RULE_USE_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE.get( |
| | | SMR_CASE_IGNORE_OID, SYNTAX_MATCHING_RULE_USE_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_MATCHING_RULE_USE_OID); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_MATCHING_RULE_USE_NAME; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_MATCHING_RULE_USE_OID; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_MATCHING_RULE_USE_DESCRIPTION; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll use the decodeMatchingRuleUse method to determine if the value is |
| | | // acceptable. |
| | | try |
| | | { |
| | | decodeMatchingRuleUse(value, DirectoryServer.getSchema(), true); |
| | | return true; |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Decodes the contents of the provided ASN.1 octet string as a matching rule |
| | | * use definition according to the rules of this syntax. Note that the |
| | |
| | | |
| | | return startPos; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | /** |
| | | * This class implements the name and optional UID attribute syntax, which holds |
| | |
| | | public class NameAndOptionalUIDSyntax |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_UNIQUE_MEMBER_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_UNIQUE_MEMBER_OID, SYNTAX_NAME_AND_OPTIONAL_UID_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_CASE_IGNORE_OID, SYNTAX_NAME_AND_OPTIONAL_UID_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_NAME_AND_OPTIONAL_UID_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_NAME_AND_OPTIONAL_UID_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_NAME_AND_OPTIONAL_UID_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_NAME_AND_OPTIONAL_UID_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | // There is no ordering matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | String valueString = value.toString().trim(); |
| | | int valueLength = valueString.length(); |
| | | |
| | | |
| | | // See if the value contains the "optional uid" portion. If we think it |
| | | // does, then mark its location. |
| | | int dnEndPos = valueLength; |
| | | int sharpPos = -1; |
| | | if (valueString.endsWith("'B") || valueString.endsWith("'b")) |
| | | { |
| | | sharpPos = valueString.lastIndexOf("#'"); |
| | | if (sharpPos > 0) |
| | | { |
| | | dnEndPos = sharpPos; |
| | | } |
| | | } |
| | | |
| | | |
| | | // Take the DN portion of the string and try to normalize it. |
| | | try |
| | | { |
| | | DN.valueOf(valueString.substring(0, dnEndPos)); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | // We couldn't normalize the DN for some reason. The value cannot be |
| | | // acceptable. |
| | | |
| | | invalidReason.append(ERR_ATTR_SYNTAX_NAMEANDUID_INVALID_DN.get( |
| | | valueString, getExceptionMessage(e))); |
| | | return false; |
| | | } |
| | | |
| | | // If there is an "optional uid", then normalize it and make sure it only |
| | | // contains valid binary digits. |
| | | if (sharpPos > 0) |
| | | { |
| | | int endPos = valueLength - 2; |
| | | for (int i=sharpPos+2; i < endPos; i++) |
| | | { |
| | | char c = valueString.charAt(i); |
| | | if (c != '0' && c != '1') |
| | | { |
| | | invalidReason.append( |
| | | ERR_ATTR_SYNTAX_NAMEANDUID_ILLEGAL_BINARY_DIGIT.get(valueString, c, i)); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then the value is acceptable. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.NameForm; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | /** |
| | | * This class implements the name form description syntax, which is used to |
| | |
| | | public class NameFormSyntax |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException, InitializationException |
| | | public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE.get( |
| | | EMR_CASE_IGNORE_OID, SYNTAX_NAME_FORM_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE.get( |
| | | OMR_CASE_IGNORE_OID, SYNTAX_NAME_FORM_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE.get( |
| | | SMR_CASE_IGNORE_OID, SYNTAX_NAME_FORM_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_NAME_FORM_OID); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | return SYNTAX_NAME_FORM_DESCRIPTION; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll use the decodeNameForm method to determine if the value is |
| | | // acceptable. |
| | | try |
| | | { |
| | | decodeNameForm(value, DirectoryServer.getSchema(), true); |
| | | return true; |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Decodes the contents of the provided ASN.1 octet string as a name form |
| | | * definition according to the rules of this syntax. Note that the provided |
| | |
| | | |
| | | return startPos; |
| | | } |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | /** |
| | | * This class implements the numeric string attribute syntax, which may be hold |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_NUMERIC_STRING_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_NUMERIC_STRING_OID, SYNTAX_NUMERIC_STRING_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_NUMERIC_STRING_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_NUMERIC_STRING_OID, SYNTAX_NUMERIC_STRING_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_EXACT_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_NUMERIC_STRING_OID, SYNTAX_NUMERIC_STRING_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_NUMERIC_STRING_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_NUMERIC_STRING_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_NUMERIC_STRING_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_NUMERIC_STRING_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | String valueString = value.toString(); |
| | | int length = valueString.length(); |
| | | |
| | | |
| | | // It must have at least one digit or space. |
| | | if (length == 0) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_NUMERIC_STRING_EMPTY_VALUE.get()); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Iterate through the characters and make sure they are all digits or |
| | | // spaces. |
| | | for (int i=0; i < length; i++) |
| | | { |
| | | char c = valueString.charAt(i); |
| | | if (!isDigit(c) && c != ' ') |
| | | { |
| | | invalidReason.append(WARN_ATTR_SYNTAX_NUMERIC_STRING_ILLEGAL_CHAR.get(valueString, c, i)); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_OID_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OID_OID, SYNTAX_OID_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_OID, SYNTAX_OID_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_OID_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_OID_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_OID_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_OID_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | // There is no ordering matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | String lowerValue = toLowerCase(value.toString()); |
| | | return isValidSchemaElement(lowerValue, 0, lowerValue.length(), |
| | | invalidReason); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.CommonSchemaElements; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | /** |
| | | * This class implements the object class description syntax, which is used to |
| | |
| | | public class ObjectClassSyntax |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException, InitializationException |
| | | public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE.get( |
| | | EMR_CASE_IGNORE_OID, SYNTAX_OBJECTCLASS_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE.get( |
| | | OMR_CASE_IGNORE_OID, SYNTAX_OBJECTCLASS_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE.get( |
| | | SMR_CASE_IGNORE_OID, SYNTAX_OBJECTCLASS_NAME); |
| | | throw new InitializationException(message); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_OBJECTCLASS_OID); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | return SYNTAX_OBJECTCLASS_DESCRIPTION; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll use the decodeObjectClass method to determine if the value is |
| | | // acceptable. |
| | | try |
| | | { |
| | | decodeObjectClass(value, DirectoryServer.getSchema(), true); |
| | | return true; |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | invalidReason.append(de.getMessageObject()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Decodes the contents of the provided ASN.1 octet string as an objectclass |
| | | * definition according to the rules of this syntax. Note that the provided |
| | |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class implements the octet string attribute syntax, which is equivalent |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_OCTET_STRING_OID, SYNTAX_OCTET_STRING_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_OCTET_STRING_OID, SYNTAX_OCTET_STRING_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_OCTET_STRING_OID, SYNTAX_OCTET_STRING_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_OCTET_STRING_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_OCTET_STRING_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_OCTET_STRING_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_OCTET_STRING_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // All values will be acceptable for the octet string syntax. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class implements the other mailbox attribute syntax, which consists of a |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_LIST_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_CASE_IGNORE_LIST_OID, SYNTAX_OTHER_MAILBOX_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_LIST_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_CASE_IGNORE_LIST_OID, SYNTAX_OTHER_MAILBOX_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_OTHER_MAILBOX_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_OTHER_MAILBOX_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_OTHER_MAILBOX_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_OTHER_MAILBOX_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | // Ordering matching is not allowed by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // Approximate matching is not allowed by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Check to see if the provided value was null. If so, then that's not |
| | | // acceptable. |
| | | if (value == null) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_OTHER_MAILBOX_EMPTY_VALUE.get()); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Get the value as a string and determine its length. If it is empty, then |
| | | // that's not acceptable. |
| | | String valueString = value.toString(); |
| | | int valueLength = valueString.length(); |
| | | if (valueLength == 0) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_OTHER_MAILBOX_EMPTY_VALUE.get()); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Iterate through the characters in the vale until we find a dollar sign. |
| | | // Every character up to that point must be a printable string character. |
| | | int pos = 0; |
| | | for ( ; pos < valueLength; pos++) |
| | | { |
| | | char c = valueString.charAt(pos); |
| | | if (c == '$') |
| | | { |
| | | if (pos == 0) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_OTHER_MAILBOX_NO_MBTYPE.get( |
| | | valueString)); |
| | | return false; |
| | | } |
| | | |
| | | pos++; |
| | | break; |
| | | } |
| | | else if (! PrintableString.isPrintableCharacter(c)) |
| | | { |
| | | invalidReason.append( |
| | | ERR_ATTR_SYNTAX_OTHER_MAILBOX_ILLEGAL_MBTYPE_CHAR.get(valueString, c, pos)); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | // Make sure there is at least one character left for the mailbox. |
| | | if (pos >= valueLength) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_OTHER_MAILBOX_NO_MAILBOX.get( |
| | | valueString)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // The remaining characters in the value must be IA5 (ASCII) characters. |
| | | for ( ; pos < valueLength; pos++) |
| | | { |
| | | char c = valueString.charAt(pos); |
| | | if (c != (c & 0x7F)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_OTHER_MAILBOX_ILLEGAL_MB_CHAR.get(valueString, c, pos)); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then the value is OK. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class implements the postal address attribute syntax, which is a list of |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_CASE_IGNORE_OID, SYNTAX_DIRECTORY_STRING_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_CASE_IGNORE_OID, SYNTAX_DIRECTORY_STRING_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_POSTAL_ADDRESS_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_POSTAL_ADDRESS_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_POSTAL_ADDRESS_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_POSTAL_ADDRESS_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | // Ordering matching will not be allowed by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // Approximate matching will not be allowed by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We'll allow any value. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | /** |
| | | * This class implements the presentation address attribute syntax, which is |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default approximate matching rule for this syntax. */ |
| | | private MatchingRule defaultApproximateMatchingRule; |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultApproximateMatchingRule = |
| | | DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID); |
| | | if (defaultApproximateMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_APPROXIMATE_MATCHING_RULE, |
| | | AMR_DOUBLE_METAPHONE_OID, SYNTAX_PRESENTATION_ADDRESS_NAME); |
| | | } |
| | | |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_CASE_IGNORE_OID, SYNTAX_PRESENTATION_ADDRESS_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_CASE_IGNORE_OID, SYNTAX_PRESENTATION_ADDRESS_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_CASE_IGNORE_OID, SYNTAX_PRESENTATION_ADDRESS_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_PRESENTATION_ADDRESS_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_PRESENTATION_ADDRESS_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_PRESENTATION_ADDRESS_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_PRESENTATION_ADDRESS_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | return defaultApproximateMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We will accept any value for this syntax. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class implements the printable string attribute syntax, which is simply |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default approximate matching rule for this syntax. */ |
| | | private MatchingRule defaultApproximateMatchingRule; |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultApproximateMatchingRule = |
| | | DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID); |
| | | if (defaultApproximateMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_APPROXIMATE_MATCHING_RULE, |
| | | AMR_DOUBLE_METAPHONE_OID, SYNTAX_PRINTABLE_STRING_NAME); |
| | | } |
| | | |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_CASE_IGNORE_OID, SYNTAX_PRINTABLE_STRING_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_CASE_IGNORE_OID, SYNTAX_PRINTABLE_STRING_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_CASE_IGNORE_OID, SYNTAX_PRINTABLE_STRING_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_PRINTABLE_STRING_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_PRINTABLE_STRING_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_PRINTABLE_STRING_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_PRINTABLE_STRING_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | return defaultApproximateMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Check to see if the provided value was null. If so, then that's not |
| | | // acceptable. |
| | | if (value == null) |
| | | { |
| | | invalidReason.append(WARN_ATTR_SYNTAX_PRINTABLE_STRING_EMPTY_VALUE.get()); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Get the value as a string and determine its length. If it is empty, then |
| | | // that's not acceptable. |
| | | String valueString = value.toString(); |
| | | int valueLength = valueString.length(); |
| | | if (valueLength == 0) |
| | | { |
| | | invalidReason.append(WARN_ATTR_SYNTAX_PRINTABLE_STRING_EMPTY_VALUE.get()); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Iterate through all the characters and see if they are acceptable. |
| | | for (int i=0; i < valueLength; i++) |
| | | { |
| | | char c = valueString.charAt(i); |
| | | if (! PrintableString.isPrintableCharacter(c)) |
| | | { |
| | | invalidReason.append( |
| | | WARN_ATTR_SYNTAX_PRINTABLE_STRING_ILLEGAL_CHARACTER.get(valueString, c, i)); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then the value is OK. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class implements the protocol information attribute syntax, which is |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default approximate matching rule for this syntax. */ |
| | | private MatchingRule defaultApproximateMatchingRule; |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultApproximateMatchingRule = |
| | | DirectoryServer.getMatchingRule(AMR_DOUBLE_METAPHONE_OID); |
| | | if (defaultApproximateMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_APPROXIMATE_MATCHING_RULE, |
| | | AMR_DOUBLE_METAPHONE_OID, SYNTAX_PROTOCOL_INFORMATION_NAME); |
| | | } |
| | | |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_CASE_IGNORE_OID, SYNTAX_PROTOCOL_INFORMATION_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_CASE_IGNORE_OID, SYNTAX_PROTOCOL_INFORMATION_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_CASE_IGNORE_OID, SYNTAX_PROTOCOL_INFORMATION_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_PROTOCOL_INFORMATION_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_PROTOCOL_INFORMATION_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_PROTOCOL_INFORMATION_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_PROTOCOL_INFORMATION_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | return defaultApproximateMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We will accept any value for this syntax. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | |
| | | /** |
| | |
| | | SchemaBuilder getSchemaBuilder(); |
| | | |
| | | /** |
| | | * Update the current schema with the schema built from the |
| | | * provided schema builder. |
| | | * Replaces the current schema by the provided schema. |
| | | * |
| | | * @param schemaBuilder |
| | | * Builder representing the updated schema. |
| | | * @return {@code true} if the update succeeded, false otherwise |
| | | * @param schema |
| | | * the new schema |
| | | * @return {@code true} if the replacement succeeds, false otherwise |
| | | */ |
| | | boolean updateSchema(SchemaBuilder schemaBuilder); |
| | | boolean updateSchema(Schema schema); |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class defines the substring assertion attribute syntax, which contains |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_CASE_IGNORE_OID, SYNTAX_SUBSTRING_ASSERTION_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_CASE_IGNORE_OID, SYNTAX_SUBSTRING_ASSERTION_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_CASE_IGNORE_OID, SYNTAX_SUBSTRING_ASSERTION_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_SUBSTRING_ASSERTION_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_SUBSTRING_ASSERTION_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_SUBSTRING_ASSERTION_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_SUBSTRING_ASSERTION_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // Approximate matching will not be allowed by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get the string representation of the value and check its length. A |
| | | // zero-length value is acceptable. A one-length value is acceptable as |
| | | // long as it is not an asterisk. For all other lengths, just ensure that |
| | | // there are no consecutive wildcards. |
| | | String valueString = value.toString(); |
| | | int valueLength = valueString.length(); |
| | | if (valueLength == 0) |
| | | { |
| | | return true; |
| | | } |
| | | else if (valueLength == 1) |
| | | { |
| | | if (valueString.charAt(0) == '*') |
| | | { |
| | | invalidReason.append(WARN_ATTR_SYNTAX_SUBSTRING_ONLY_WILDCARD.get()); |
| | | |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (int i=1; i < valueLength; i++) |
| | | { |
| | | if ((valueString.charAt(i) == '*') && (valueString.charAt(i-1) == '*')) |
| | | { |
| | | invalidReason.append( |
| | | WARN_ATTR_SYNTAX_SUBSTRING_CONSECUTIVE_WILDCARDS.get( |
| | | valueString, i)); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.SubtreeSpecification; |
| | |
| | | public final class SubtreeSpecificationSyntax |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing |
| | | * that should be done here is to invoke the default constructor for |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException { |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration, ServerContext serverContext) |
| | | throws ConfigException |
| | | { |
| | | // Add the subtree specification syntax to the "new" schema |
| | | SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater(); |
| | | SchemaBuilder builder = schemaUpdater.getSchemaBuilder().buildSyntax(SYNTAX_SUBTREE_SPECIFICATION_OID) |
| | | .description(SYNTAX_SUBTREE_SPECIFICATION_DESCRIPTION) |
| | | .implementation(new SubtreeSpecificationSyntaxImpl()) |
| | | .addToSchema(); |
| | | schemaUpdater.updateSchema(builder.toSchema()); |
| | | } |
| | | |
| | | defaultEqualityMatchingRule = DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID); |
| | | if (defaultEqualityMatchingRule == null) { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_OCTET_STRING_OID, SYNTAX_SUBTREE_SPECIFICATION_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID); |
| | | if (defaultOrderingMatchingRule == null) { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_OCTET_STRING_OID, SYNTAX_SUBTREE_SPECIFICATION_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID); |
| | | if (defaultSubstringMatchingRule == null) { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_OCTET_STRING_OID, SYNTAX_SUBTREE_SPECIFICATION_NAME); |
| | | } |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_SUBTREE_SPECIFICATION_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if |
| | | * equality matches will not be allowed for this type by |
| | | * default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getEqualityMatchingRule() { |
| | | |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if |
| | | * ordering matches will not be allowed for this type by |
| | | * default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getOrderingMatchingRule() { |
| | | |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if |
| | | * substring matches will not be allowed for this type by |
| | | * default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getSubstringMatchingRule() { |
| | | |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used |
| | | * for attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if |
| | | * approximate matches will not be allowed for this type by |
| | | * default. |
| | | */ |
| | | @Override |
| | | public MatchingRule getApproximateMatchingRule() { |
| | | |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an |
| | | * attribute with this syntax. If it is not, then the reason may be |
| | | * appended to the provided buffer. |
| New file |
| | |
| | | /* |
| | | * 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 legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at legal-notices/CDDLv1_0.txt. |
| | | * If applicable, add the following below this CDDL HEADER, with the |
| | | * fields enclosed by brackets "[]" replaced with your own identifying |
| | | * information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SyntaxImpl; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.SubtreeSpecification; |
| | | |
| | | /** |
| | | * Implementation of the subtree specification attribute syntax, which is used |
| | | * to specify the scope of sub-entries (RFC 3672). |
| | | */ |
| | | final class SubtreeSpecificationSyntaxImpl implements SyntaxImpl |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SchemaConstants.SYNTAX_SUBTREE_SPECIFICATION_NAME; |
| | | } |
| | | |
| | | @Override |
| | | public String getEqualityMatchingRule() |
| | | { |
| | | return EMR_OCTET_STRING_OID; |
| | | } |
| | | |
| | | @Override |
| | | public String getOrderingMatchingRule() |
| | | { |
| | | return OMR_OCTET_STRING_OID; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getApproximateMatchingRule() |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getSubstringMatchingRule() |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean valueIsAcceptable(final Schema schema, final ByteSequence value, |
| | | final LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Use the subtree specification code to make this determination. |
| | | try |
| | | { |
| | | SubtreeSpecification.valueOf(DN.rootDN(), value.toString()); |
| | | |
| | | return true; |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | invalidReason.append(e.getMessageObject()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class implements the supported algorithm attribute syntax. This should |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_OCTET_STRING_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_OCTET_STRING_OID, SYNTAX_SUPPORTED_ALGORITHM_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_OCTET_STRING_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_OCTET_STRING_OID, SYNTAX_SUPPORTED_ALGORITHM_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_OCTET_STRING_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_OCTET_STRING_OID, SYNTAX_SUPPORTED_ALGORITHM_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_SUPPORTED_ALGORITHM_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_SUPPORTED_ALGORITHM_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_SUPPORTED_ALGORITHM_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_SUPPORTED_ALGORITHM_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // All values will be acceptable for the supported algorithm syntax. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.Option; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaOptions; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.TelephoneNumberAttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.core.ServerContext; |
| | | |
| | | /** |
| | | * This class implements the telephone number attribute syntax, which is defined |
| | |
| | | implements ConfigurationChangeListener<TelephoneNumberAttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** Indicates whether this matching rule should operate in strict mode. */ |
| | | private boolean strictMode; |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** The current configuration for this telephone number syntax. */ |
| | | private TelephoneNumberAttributeSyntaxCfg currentConfig; |
| | | |
| | | private ServerContext serverContext; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(TelephoneNumberAttributeSyntaxCfg configuration) |
| | | @Override |
| | | public void initializeSyntax(TelephoneNumberAttributeSyntaxCfg configuration, ServerContext serverContext) |
| | | throws ConfigException |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_TELEPHONE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_TELEPHONE_OID, SYNTAX_TELEPHONE_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_TELEPHONE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_TELEPHONE_OID, SYNTAX_TELEPHONE_NAME); |
| | | } |
| | | |
| | | this.serverContext = serverContext; |
| | | |
| | | // We may or may not have access to the config entry. If we do, then see if |
| | | // we should use the strict compliance mode. If not, just assume that we |
| | |
| | | currentConfig = configuration; |
| | | currentConfig.addTelephoneNumberChangeListener(this); |
| | | strictMode = currentConfig.isStrictFormat(); |
| | | updateNewSchema(); |
| | | } |
| | | } |
| | | |
| | | /** Update the option in new schema if it changes from current value. */ |
| | | private void updateNewSchema() |
| | | { |
| | | Option<Boolean> option = SchemaOptions.ALLOW_NON_STANDARD_TELEPHONE_NUMBERS; |
| | | if (strictMode == serverContext.getSchemaNG().getOption(option)) |
| | | { |
| | | SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater(); |
| | | schemaUpdater.updateSchema(schemaUpdater.getSchemaBuilder().setOption(option, !strictMode).toSchema()); |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_TELEPHONE_OID); |
| | | } |
| | | |
| | | /** |
| | | * Performs any finalization that may be necessary for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public void finalizeSyntax() |
| | | { |
| | | currentConfig.removeTelephoneNumberChangeListener(this); |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_TELEPHONE_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_TELEPHONE_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_TELEPHONE_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | // There is no ordering matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // No matter what, the value can't be empty or null. |
| | | String valueStr; |
| | | if ((value == null) || |
| | | ((valueStr = value.toString().trim()).length() == 0)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEPHONE_EMPTY.get()); |
| | | return false; |
| | | } |
| | | |
| | | int length = valueStr.length(); |
| | | |
| | | |
| | | if (strictMode) |
| | | { |
| | | // If the value does not start with a plus sign, then that's not |
| | | // acceptable. |
| | | if (valueStr.charAt(0) != '+') |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_TELEPHONE_NO_PLUS.get(valueStr); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Iterate through the remaining characters in the value. There must be |
| | | // at least one digit, and it must contain only valid digits and separator |
| | | // characters. |
| | | boolean digitSeen = false; |
| | | for (int i=1; i < length; i++) |
| | | { |
| | | char c = valueStr.charAt(i); |
| | | if (isDigit(c)) |
| | | { |
| | | digitSeen = true; |
| | | } |
| | | else if (! isSeparator(c)) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_TELEPHONE_ILLEGAL_CHAR.get(valueStr, c, i); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | if (! digitSeen) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_TELEPHONE_NO_DIGITS.get(valueStr); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then we'll consider it acceptable. |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | // If we are not in strict mode, then all non-empty values containing at |
| | | // least one digit will be acceptable. |
| | | for (int i=0; i < length; i++) |
| | | { |
| | | if (isDigit(valueStr.charAt(i))) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | // If we made it here, then we didn't find any digits. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_TELEPHONE_NO_DIGITS.get(valueStr); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided character is a valid separator for telephone |
| | | * number components when operating in strict mode. |
| | | * |
| | | * @param c The character for which to make the determination. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided character is a valid separator, |
| | | * or <CODE>false</CODE> if it is not. |
| | | */ |
| | | private boolean isSeparator(char c) |
| | | { |
| | | switch (c) |
| | | { |
| | | case ' ': |
| | | case '-': |
| | | return true; |
| | | default: |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | TelephoneNumberAttributeSyntaxCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | TelephoneNumberAttributeSyntaxCfg configuration) |
| | | { |
| | | currentConfig = configuration; |
| | | strictMode = configuration.isStrictFormat(); |
| | | updateNewSchema(); |
| | | |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import java.util.HashSet; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | /** |
| | | * This class implements the teletex terminal identifier attribute syntax, which |
| | | * contains a printable string (the terminal identifier) followed by zero or |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * The set of allowed fax parameter values, formatted entirely in lowercase |
| | | * characters. |
| | | */ |
| | | public static final HashSet<String> ALLOWED_TTX_PARAMETERS = |
| | | new HashSet<String>(5); |
| | | |
| | | static |
| | | { |
| | | ALLOWED_TTX_PARAMETERS.add("graphic"); |
| | | ALLOWED_TTX_PARAMETERS.add("control"); |
| | | ALLOWED_TTX_PARAMETERS.add("misc"); |
| | | ALLOWED_TTX_PARAMETERS.add("page"); |
| | | ALLOWED_TTX_PARAMETERS.add("private"); |
| | | } |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_CASE_IGNORE_OID, SYNTAX_TELETEX_TERM_ID_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, |
| | | OMR_CASE_IGNORE_OID, SYNTAX_TELETEX_TERM_ID_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, |
| | | SMR_CASE_IGNORE_OID, SYNTAX_TELETEX_TERM_ID_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_TELETEX_TERM_ID_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_TELETEX_TERM_ID_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_TELETEX_TERM_ID_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_TELETEX_TERM_ID_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get a lowercase string representation of the value and find its length. |
| | | String valueString = value.toString(); |
| | | int valueLength = valueString.length(); |
| | | |
| | | |
| | | // The value must contain at least one character. |
| | | if (valueLength == 0) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_EMPTY.get()); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // The first character must be a printable string character. |
| | | char c = valueString.charAt(0); |
| | | if (! PrintableString.isPrintableCharacter(c)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_NOT_PRINTABLE.get(valueString, c, 0)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Continue reading until we find a dollar sign or the end of the string. |
| | | // Every intermediate character must be a printable string character. |
| | | int pos = 1; |
| | | for ( ; pos < valueLength; pos++) |
| | | { |
| | | c = valueString.charAt(pos); |
| | | if (c == '$') |
| | | { |
| | | pos++; |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | if (! PrintableString.isPrintableCharacter(c)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_NOT_PRINTABLE.get(valueString, c, pos)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (pos >= valueLength) |
| | | { |
| | | // We're at the end of the value, so it must be valid unless the last |
| | | // character was a dollar sign. |
| | | if (c == '$') |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_END_WITH_DOLLAR.get( |
| | | valueString)); |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | |
| | | // Continue reading until we find the end of the string. Each substring |
| | | // must be a valid teletex terminal identifier parameter followed by a colon |
| | | // and the value. Dollar signs must be escaped |
| | | int paramStartPos = pos; |
| | | boolean escaped = false; |
| | | while (pos < valueLength) |
| | | { |
| | | if (escaped) |
| | | { |
| | | pos++; |
| | | continue; |
| | | } |
| | | |
| | | c = valueString.charAt(pos++); |
| | | if (c == '\\') |
| | | { |
| | | escaped = true; |
| | | continue; |
| | | } |
| | | else if (c == '$') |
| | | { |
| | | String paramStr = valueString.substring(paramStartPos, pos); |
| | | |
| | | int colonPos = paramStr.indexOf(':'); |
| | | if (colonPos < 0) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_PARAM_NO_COLON.get( |
| | | valueString)); |
| | | return false; |
| | | } |
| | | |
| | | String paramName = paramStr.substring(0, colonPos); |
| | | if (! ALLOWED_TTX_PARAMETERS.contains(paramName)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_ILLEGAL_PARAMETER.get( |
| | | valueString, paramName)); |
| | | return false; |
| | | } |
| | | |
| | | paramStartPos = pos; |
| | | } |
| | | } |
| | | |
| | | |
| | | // We must be at the end of the value. Read the last parameter and make |
| | | // sure it is valid. |
| | | String paramStr = valueString.substring(paramStartPos); |
| | | int colonPos = paramStr.indexOf(':'); |
| | | if (colonPos < 0) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_PARAM_NO_COLON.get( |
| | | valueString)); |
| | | return false; |
| | | } |
| | | |
| | | String paramName = paramStr.substring(0, colonPos); |
| | | if (! ALLOWED_TTX_PARAMETERS.contains(paramName)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELETEXID_ILLEGAL_PARAMETER.get( |
| | | valueString, paramName)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then the value must be valid. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class implements the telex number attribute syntax, which contains three |
| | |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | | * should be done here is to invoke the default constructor for the |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_CASE_IGNORE_OID, SYNTAX_TELEX_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_CASE_IGNORE_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_CASE_IGNORE_OID, SYNTAX_TELEX_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_OID, SYNTAX_TELEX_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_TELEX_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_TELEX_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_TELEX_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_TELEX_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get a string representation of the value and find its length. |
| | | String valueString = value.toString(); |
| | | int valueLength = valueString.length(); |
| | | |
| | | if (valueLength < 5) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_TOO_SHORT.get(valueString)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // The first character must be a printable string character. |
| | | char c = valueString.charAt(0); |
| | | if (! PrintableString.isPrintableCharacter(c)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_NOT_PRINTABLE.get(valueString, c, 0)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Continue reading until we find a dollar sign. Every intermediate |
| | | // character must be a printable string character. |
| | | int pos = 1; |
| | | for ( ; pos < valueLength; pos++) |
| | | { |
| | | c = valueString.charAt(pos); |
| | | if (c == '$') |
| | | { |
| | | pos++; |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | if (! PrintableString.isPrintableCharacter(c)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_ILLEGAL_CHAR.get(valueString, c, pos)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (pos >= valueLength) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_TRUNCATED.get(valueString)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // The next character must be a printable string character. |
| | | c = valueString.charAt(pos++); |
| | | if (! PrintableString.isPrintableCharacter(c)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_NOT_PRINTABLE.get(valueString, c, (pos-1))); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Continue reading until we find another dollar sign. Every intermediate |
| | | // character must be a printable string character. |
| | | for ( ; pos < valueLength; pos++) |
| | | { |
| | | c = valueString.charAt(pos); |
| | | if (c == '$') |
| | | { |
| | | pos++; |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | if (! PrintableString.isPrintableCharacter(c)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_ILLEGAL_CHAR.get(valueString, c, pos)); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (pos >= valueLength) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_TRUNCATED.get(valueString)); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // The next character must be a printable string character. |
| | | c = valueString.charAt(pos++); |
| | | if (! PrintableString.isPrintableCharacter(c)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_NOT_PRINTABLE.get(valueString, c, (pos-1))); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Continue reading until the end of the value. Every intermediate |
| | | // character must be a printable string character. |
| | | for ( ; pos < valueLength; pos++) |
| | | { |
| | | c = valueString.charAt(pos); |
| | | if (! PrintableString.isPrintableCharacter(c)) |
| | | { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_ILLEGAL_CHAR.get(valueString, c, pos)); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | // If we've gotten here, then we're at the end of the value and it is |
| | | // acceptable. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.TimeZone; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | /** |
| | | * This class implements the UTC time attribute syntax. This is very similar to |
| | |
| | | public class UTCTimeSyntax |
| | | extends AttributeSyntax<AttributeSyntaxCfg> |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * The lock that will be used to provide threadsafe access to the date |
| | | * formatter. |
| | | */ |
| | | private static Object dateFormatLock; |
| | | |
| | | /** |
| | | * The date formatter that will be used to convert dates into UTC time values. |
| | | * Note that all interaction with it must be synchronized. |
| | | */ |
| | | private static SimpleDateFormat dateFormat; |
| | | |
| | | /** |
| | | * The date formatter needs help converting 2-digit years. |
| | | */ |
| | | private static Date datum1900; |
| | | private static Date datum2000; |
| | | |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** The default substring matching rule for this syntax. */ |
| | | private MatchingRule defaultSubstringMatchingRule; |
| | | |
| | | /** |
| | | * Create the date formatter that will be used to construct and parse |
| | | * normalized UTC time values. |
| | | */ |
| | | static |
| | | { |
| | | dateFormat = new SimpleDateFormat(DATE_FORMAT_UTC_TIME); |
| | | dateFormat.setLenient(false); |
| | | dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); |
| | | |
| | | Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); |
| | | cal.clear(); |
| | | cal.set(1900, 0, 1); |
| | | datum1900 = cal.getTime(); |
| | | |
| | | cal.clear(); |
| | | cal.set(2000, 0, 1); |
| | | datum2000 = cal.getTime(); |
| | | |
| | | dateFormatLock = new Object(); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_GENERALIZED_TIME_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_GENERALIZED_TIME_OID, SYNTAX_UTC_TIME_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_GENERALIZED_TIME_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_GENERALIZED_TIME_OID, SYNTAX_UTC_TIME_NAME); |
| | | } |
| | | |
| | | defaultSubstringMatchingRule = |
| | | DirectoryServer.getMatchingRule(SMR_CASE_IGNORE_OID); |
| | | if (defaultSubstringMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_SUBSTRING_MATCHING_RULE, SMR_CASE_IGNORE_OID, SYNTAX_UTC_TIME_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_UTC_TIME_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_UTC_TIME_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_UTC_TIME_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_UTC_TIME_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | return defaultSubstringMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // Approximate matching will not be allowed by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // Get the value as a string and verify that it is at least long enough for |
| | | // "YYYYMMDDhhmmZ", which is the shortest allowed value. |
| | | String valueString = value.toString().toUpperCase(); |
| | | int length = valueString.length(); |
| | | if (length < 11) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_TOO_SHORT.get(valueString); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // The first two characters are the year, and they must be numeric digits |
| | | // between 0 and 9. |
| | | for (int i=0; i < 2; i++) |
| | | { |
| | | switch (valueString.charAt(i)) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | case '6': |
| | | case '7': |
| | | case '8': |
| | | case '9': |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_YEAR.get(valueString, valueString.charAt(i)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | // The next two characters are the month, and they must form the string |
| | | // representation of an integer between 01 and 12. |
| | | char m1 = valueString.charAt(2); |
| | | char m2 = valueString.charAt(3); |
| | | switch (m1) |
| | | { |
| | | case '0': |
| | | // m2 must be a digit between 1 and 9. |
| | | switch (m2) |
| | | { |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | case '6': |
| | | case '7': |
| | | case '8': |
| | | case '9': |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_MONTH.get( |
| | | valueString, valueString.substring(2, 4)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | break; |
| | | case '1': |
| | | // m2 must be a digit between 0 and 2. |
| | | switch (m2) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_MONTH.get( |
| | | valueString, valueString.substring(2, 4)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_MONTH.get( |
| | | valueString, valueString.substring(2, 4)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // The next two characters should be the day of the month, and they must |
| | | // form the string representation of an integer between 01 and 31. |
| | | // This doesn't do any validation against the year or month, so it will |
| | | // allow dates like April 31, or February 29 in a non-leap year, but we'll |
| | | // let those slide. |
| | | char d1 = valueString.charAt(4); |
| | | char d2 = valueString.charAt(5); |
| | | switch (d1) |
| | | { |
| | | case '0': |
| | | // d2 must be a digit between 1 and 9. |
| | | switch (d2) |
| | | { |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | case '6': |
| | | case '7': |
| | | case '8': |
| | | case '9': |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_DAY.get( |
| | | valueString, valueString.substring(4, 6)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | break; |
| | | case '1': |
| | | // Treated the same as '2'. |
| | | case '2': |
| | | // d2 must be a digit between 0 and 9. |
| | | switch (d2) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | case '6': |
| | | case '7': |
| | | case '8': |
| | | case '9': |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_DAY.get( |
| | | valueString, valueString.substring(4, 6)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | break; |
| | | case '3': |
| | | // d2 must be either 0 or 1. |
| | | switch (d2) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_DAY.get( |
| | | valueString, valueString.substring(4, 6)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_DAY.get(valueString, |
| | | valueString.substring(4, 6)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // The next two characters must be the hour, and they must form the string |
| | | // representation of an integer between 00 and 23. |
| | | char h1 = valueString.charAt(6); |
| | | char h2 = valueString.charAt(7); |
| | | switch (h1) |
| | | { |
| | | case '0': |
| | | // This is treated the same as '1'. |
| | | case '1': |
| | | switch (h2) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | case '6': |
| | | case '7': |
| | | case '8': |
| | | case '9': |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_HOUR.get( |
| | | valueString, valueString.substring(6, 8)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | break; |
| | | case '2': |
| | | // This must be a digit between 0 and 3. |
| | | switch (h2) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_HOUR.get( |
| | | valueString, valueString.substring(6, 8)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_HOUR.get(valueString, |
| | | valueString.substring(6, 8)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Next, there should be two digits comprising an integer between 00 and 59 |
| | | // for the minute. |
| | | m1 = valueString.charAt(8); |
| | | switch (m1) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | // There must be at least two more characters, and the next one must |
| | | // be a digit between 0 and 9. |
| | | if (length < 11) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, m1, 8); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | switch (valueString.charAt(9)) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | case '6': |
| | | case '7': |
| | | case '8': |
| | | case '9': |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_MINUTE.get( |
| | | valueString, valueString.substring(8, 10)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | break; |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, m1, 8); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // Next, there should be either two digits comprising an integer between 00 |
| | | // and 60 (for the second, including a possible leap second), a letter 'Z' |
| | | // (for the UTC specifier), or a plus or minus sign followed by four digits |
| | | // (for the UTC offset). |
| | | char s1 = valueString.charAt(10); |
| | | switch (s1) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | // There must be at least two more characters, and the next one must |
| | | // be a digit between 0 and 9. |
| | | if (length < 13) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, s1, 10); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | switch (valueString.charAt(11)) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | case '6': |
| | | case '7': |
| | | case '8': |
| | | case '9': |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_SECOND.get( |
| | | valueString, valueString.substring(10, 12)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | break; |
| | | case '6': |
| | | // There must be at least two more characters and the next one must be |
| | | // a 0. |
| | | if (length < 13) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, s1, 10); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | if (valueString.charAt(11) != '0') |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_SECOND.get( |
| | | valueString, valueString.substring(10, 12)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | break; |
| | | case 'Z': |
| | | // This is fine only if we are at the end of the value. |
| | | if (length == 11) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, s1, 10); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | case '+': |
| | | case '-': |
| | | // These are fine only if there are exactly four more digits that |
| | | // specify a valid offset. |
| | | if (length == 15) |
| | | { |
| | | return hasValidOffset(valueString, 11, invalidReason); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, s1, 10); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get(valueString, s1, 10); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // The last element should be either a letter 'Z' (for the UTC specifier), |
| | | // or a plus or minus sign followed by four digits (for the UTC offset). |
| | | switch (valueString.charAt(12)) |
| | | { |
| | | case 'Z': |
| | | // This is fine only if we are at the end of the value. |
| | | if (length == 13) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get( |
| | | valueString, valueString.charAt(12), 12); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | case '+': |
| | | case '-': |
| | | // These are fine only if there are four or two more digits that |
| | | // specify a valid offset. |
| | | if ((length == 17) || (length == 15)) |
| | | { |
| | | return hasValidOffset(valueString, 13, invalidReason); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get( |
| | | valueString, valueString.charAt(12), 12); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_CHAR.get( |
| | | valueString, valueString.charAt(12), 12); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided string contains a valid set of two or four |
| | | * UTC offset digits. The provided string must have either two or four |
| | | * characters from the provided start position to the end of the value. |
| | | * |
| | | * @param value The whole value, including the offset. |
| | | * @param startPos The position of the first character that is |
| | | * contained in the offset. |
| | | * @param invalidReason The buffer to which the invalid reason may be |
| | | * appended if the string does not contain a valid set |
| | | * of UTC offset digits. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided offset string is valid, or |
| | | * <CODE>false</CODE> if it is not. |
| | | */ |
| | | private boolean hasValidOffset(String value, int startPos, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | int offsetLength = value.length() - startPos; |
| | | if (offsetLength < 2) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_TOO_SHORT.get(value); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | // The first two characters must be an integer between 00 and 23. |
| | | switch (value.charAt(startPos)) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | switch (value.charAt(startPos+1)) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | case '6': |
| | | case '7': |
| | | case '8': |
| | | case '9': |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_OFFSET.get(value, |
| | | value.substring(startPos, |
| | | startPos+offsetLength)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | break; |
| | | case '2': |
| | | switch (value.charAt(startPos+1)) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_OFFSET.get(value, |
| | | value.substring(startPos, |
| | | startPos+offsetLength)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_OFFSET.get(value, |
| | | value.substring(startPos, |
| | | startPos+offsetLength)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // If there are two more characters, then they must be an integer between |
| | | // 00 and 59. |
| | | if (offsetLength == 4) |
| | | { |
| | | switch (value.charAt(startPos+2)) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | switch (value.charAt(startPos+3)) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | case '6': |
| | | case '7': |
| | | case '8': |
| | | case '9': |
| | | // These are all fine. |
| | | break; |
| | | default: |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_UTC_TIME_INVALID_OFFSET.get( |
| | | value,value.substring(startPos, |
| | | startPos+offsetLength)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | break; |
| | | default: |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_INVALID_OFFSET.get(value, |
| | | value.substring(startPos, |
| | | startPos+offsetLength)); |
| | | invalidReason.append(message); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves an attribute value containing a UTC time representation of the |
| | | * provided date. |
| | | * |
| | | * @param d The date for which to retrieve the UTC time value. |
| | | * |
| | | * @return The attribute value created from the date. |
| | | */ |
| | | public static ByteString createUTCTimeValue(Date d) |
| | | { |
| | | String valueString; |
| | | synchronized (dateFormatLock) |
| | | { |
| | | valueString = dateFormat.format(d); |
| | | } |
| | | return ByteString.valueOf(valueString); |
| | | } |
| | | |
| | | /** |
| | | * Decodes the provided normalized value as a UTC time value and |
| | | * retrieves a Java <CODE>Date</CODE> object containing its representation. |
| | | * |
| | | * @param normalizedValue The normalized UTC time value to decode to a |
| | | * Java <CODE>Date</CODE>. |
| | | * |
| | | * @return The Java <CODE>Date</CODE> created from the provided UTC time |
| | | * value. |
| | | * |
| | | * @throws DirectoryException If the provided value cannot be parsed as a |
| | | * valid UTC time string. |
| | | */ |
| | | public static Date decodeUTCTimeValue(ByteString normalizedValue) |
| | | throws DirectoryException |
| | | { |
| | | String valueString = normalizedValue.toString(); |
| | | |
| | | try |
| | | { |
| | | synchronized (dateFormatLock) |
| | | { |
| | | // RFC 3280 4.1.2.5.1. defines the datum we need to |
| | | // set for the parser. |
| | | switch (valueString.charAt(0)) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | // 00-49 |
| | | dateFormat.set2DigitYearStart(datum2000); |
| | | break; |
| | | case '5': |
| | | case '6': |
| | | case '7': |
| | | case '8': |
| | | case '9': |
| | | default: |
| | | // 50-99 |
| | | dateFormat.set2DigitYearStart(datum1900); |
| | | break; |
| | | } |
| | | return dateFormat.parse(valueString); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_UTC_TIME_CANNOT_PARSE.get(valueString, e); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, e); |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | |
| | | |
| | | /** |
| | | * This class implements the UUID syntax, which is defined in RFC 4530. |
| | |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** The default ordering matching rule for this syntax. */ |
| | | private MatchingRule defaultOrderingMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_UUID_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_UUID_OID, SYNTAX_UUID_NAME); |
| | | } |
| | | |
| | | defaultOrderingMatchingRule = |
| | | DirectoryServer.getMatchingRule(OMR_UUID_OID); |
| | | if (defaultOrderingMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_ORDERING_MATCHING_RULE, OMR_UUID_OID, SYNTAX_UUID_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_UUID_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_UUID_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_UUID_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_UUID_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | return defaultOrderingMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | // There is no substring matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We will only accept values that look like valid UUIDs. This means that |
| | | // all values must be in the form HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHH, |
| | | // where "H" represents a hexadecimal digit. First, make sure that the |
| | | // value is exactly 36 bytes long. |
| | | String valueString = value.toString(); |
| | | if (valueString.length() != 36) |
| | | { |
| | | invalidReason.append(WARN_ATTR_SYNTAX_UUID_INVALID_LENGTH.get(valueString, |
| | | valueString.length())); |
| | | return false; |
| | | } |
| | | |
| | | // Next, iterate through each character. Make sure that the 9th, 14th, |
| | | // 19th, and 24th characters are dashes and the rest are hex digits. |
| | | for (int i=0; i < 36; i++) |
| | | { |
| | | switch (i) |
| | | { |
| | | case 8: |
| | | case 13: |
| | | case 18: |
| | | case 23: |
| | | if (valueString.charAt(i) != '-') |
| | | { |
| | | invalidReason.append(WARN_ATTR_SYNTAX_UUID_EXPECTED_DASH.get( |
| | | valueString, i, valueString.charAt(i))); |
| | | return false; |
| | | } |
| | | break; |
| | | default: |
| | | switch (valueString.charAt(i)) |
| | | { |
| | | case '0': |
| | | case '1': |
| | | case '2': |
| | | case '3': |
| | | case '4': |
| | | case '5': |
| | | case '6': |
| | | case '7': |
| | | case '8': |
| | | case '9': |
| | | case 'a': |
| | | case 'b': |
| | | case 'c': |
| | | case 'd': |
| | | case 'e': |
| | | case 'f': |
| | | case 'A': |
| | | case 'B': |
| | | case 'C': |
| | | case 'D': |
| | | case 'E': |
| | | case 'F': |
| | | break; |
| | | default: |
| | | invalidReason.append(WARN_ATTR_SYNTAX_UUID_EXPECTED_HEX.get( |
| | | valueString, i, valueString.charAt(i))); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then the value is acceptable. |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | |
| | | /** |
| | | * This class defines an attribute syntax used for storing values that have been |
| | |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** The default equality matching rule for this syntax. */ |
| | | private MatchingRule defaultEqualityMatchingRule; |
| | | |
| | | /** |
| | | * Creates a new instance of this syntax. Note that the only thing that |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration) |
| | | throws ConfigException |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | defaultEqualityMatchingRule = |
| | | DirectoryServer.getMatchingRule(EMR_USER_PASSWORD_EXACT_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_USER_PASSWORD_EXACT_NAME, SYNTAX_USER_PASSWORD_NAME); |
| | | } |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_USER_PASSWORD_OID); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_USER_PASSWORD_NAME; |
| | |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_USER_PASSWORD_OID; |
| | |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_USER_PASSWORD_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default equality matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default equality matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if equality |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getEqualityMatchingRule() |
| | | { |
| | | return defaultEqualityMatchingRule; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default ordering matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default ordering matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if ordering |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getOrderingMatchingRule() |
| | | { |
| | | // There is no ordering matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default substring matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default substring matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if substring |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getSubstringMatchingRule() |
| | | { |
| | | // There is no substring matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default approximate matching rule that will be used for |
| | | * attributes with this syntax. |
| | | * |
| | | * @return The default approximate matching rule that will be used for |
| | | * attributes with this syntax, or <CODE>null</CODE> if approximate |
| | | * matches will not be allowed for this type by default. |
| | | */ |
| | | public MatchingRule getApproximateMatchingRule() |
| | | { |
| | | // There is no approximate matching rule by default. |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Indicates whether the provided value is acceptable for use in an attribute |
| | | * with this syntax. If it is not, then the reason may be appended to the |
| | | * provided buffer. |
| | | * |
| | | * @param value The value for which to make the determination. |
| | | * @param invalidReason The buffer to which the invalid reason should be |
| | | * appended. |
| | | * |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use with |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteSequence value, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | // We have to accept any value here because in many cases the value will not |
| | | // have been encoded by the time this method is called. |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * Decodes the provided user password value into its component parts. |
| | |
| | | && closingBracePos != value.length() - 1; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean isHumanReadable() |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | SchemaConfigManager.loadSchemaFile(schema, schemaFile); |
| | | SchemaConfigManager.loadSchemaFile(getServerContext(), schema, schemaFile); |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | |
| | | try |
| | | { |
| | | List<Modification> modList = |
| | | SchemaConfigManager.loadSchemaFile(schema, schemaFile); |
| | | SchemaConfigManager.loadSchemaFile(getServerContext(), schema, schemaFile); |
| | | for (Modification m : modList) |
| | | { |
| | | Attribute a = m.getAttribute(); |
| | |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.AttributeUsage; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | |
| | | private final MatchingRule approximateMatchingRule; |
| | | |
| | | /** The syntax for this attribute type. */ |
| | | private final AttributeSyntax<?> syntax; |
| | | private final Syntax syntax; |
| | | |
| | | /** The superior attribute type from which this attribute type inherits. */ |
| | | private final AttributeType superiorType; |
| | |
| | | Collection<String> typeNames, |
| | | String oid, String description, |
| | | AttributeType superiorType, |
| | | AttributeSyntax<?> syntax, |
| | | Syntax syntax, |
| | | AttributeUsage attributeUsage, |
| | | boolean isCollective, |
| | | boolean isNoUserModification, |
| | |
| | | Collection<String> typeNames, |
| | | String oid, String description, |
| | | AttributeType superiorType, |
| | | AttributeSyntax<?> syntax, |
| | | Syntax syntax, |
| | | MatchingRule approximateMatchingRule, |
| | | MatchingRule equalityMatchingRule, |
| | | MatchingRule orderingMatchingRule, |
| | |
| | | * |
| | | * @return The syntax for this attribute type. |
| | | */ |
| | | public AttributeSyntax<?> getSyntax() |
| | | public Syntax getSyntax() |
| | | { |
| | | return syntax; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock AS. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.api.AlertGenerator; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.api.ConfigHandler; |
| | | import org.opends.server.api.ExtendedOperationHandler; |
| | | import org.opends.server.api.InvokableComponent; |
| | |
| | | * @return The set of attribute syntaxes defined in the Directory |
| | | * Server. |
| | | */ |
| | | public static Map<String,AttributeSyntax<?>> |
| | | public static Map<String,Syntax> |
| | | getAttributeSyntaxes() |
| | | { |
| | | return DirectoryServer.getAttributeSyntaxes(); |
| | |
| | | * @return The default attribute syntax that should be used for |
| | | * attributes that are not defined in the server schema. |
| | | */ |
| | | public static AttributeSyntax getDefaultAttributeSyntax() |
| | | public static Syntax getDefaultAttributeSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultAttributeSyntax(); |
| | | } |
| | |
| | | * attributes that are not defined in the server schema and |
| | | * are meant to store binary values. |
| | | */ |
| | | public static AttributeSyntax getDefaultBinarySyntax() |
| | | public static Syntax getDefaultBinarySyntax() |
| | | { |
| | | return DirectoryServer.getDefaultBinarySyntax(); |
| | | } |
| | |
| | | * attributes that are not defined in the server schema and |
| | | * are meant to store Boolean values. |
| | | */ |
| | | public static AttributeSyntax getDefaultBooleanSyntax() |
| | | public static Syntax getDefaultBooleanSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultBooleanSyntax(); |
| | | } |
| | |
| | | * attributes that are not defined in the server schema and |
| | | * are meant to store DN values. |
| | | */ |
| | | public static AttributeSyntax getDefaultDNSyntax() |
| | | public static Syntax getDefaultDNSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultDNSyntax(); |
| | | } |
| | |
| | | * attributes that are not defined in the server schema and |
| | | * are meant to store integer values. |
| | | */ |
| | | public static AttributeSyntax getDefaultIntegerSyntax() |
| | | public static Syntax getDefaultIntegerSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultIntegerSyntax(); |
| | | } |
| | |
| | | * attributes that are not defined in the server schema and |
| | | * are meant to store string values. |
| | | */ |
| | | public static AttributeSyntax getDefaultStringSyntax() |
| | | public static Syntax getDefaultStringSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultStringSyntax(); |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import static org.forgerock.util.Reject.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.opends.server.schema.LDAPSyntaxDescriptionSyntax; |
| | | |
| | | import static org.forgerock.util.Reject.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | |
| | | /** |
| | | * This class defines a data structure for storing and interacting |
| | |
| | | private final String oid; |
| | | |
| | | /** The LDAPSyntaxDescritpionSyntax associated with this ldap syntax. */ |
| | | private LDAPSyntaxDescriptionSyntax descriptionSyntax; |
| | | private Syntax syntax; |
| | | |
| | | |
| | | |
| | |
| | | * @param definition The definition string used to create |
| | | * this ldap syntax. It must not be |
| | | * {@code null}. |
| | | * @param descriptionSyntax The ldap syntax description syntax |
| | | * @param syntax The ldap syntax description syntax |
| | | * associated with this ldap syntax. |
| | | * @param description The description for this ldap |
| | | * syntax. |
| | | * @param extraProperties A set of extra properties for this |
| | | * ldap syntax description. |
| | | */ |
| | | public LDAPSyntaxDescription(String definition, |
| | | LDAPSyntaxDescriptionSyntax descriptionSyntax, |
| | | String description, |
| | | Map<String,List<String>> extraProperties) |
| | | public LDAPSyntaxDescription(String definition, Syntax syntax, Map<String,List<String>> extraProperties) |
| | | { |
| | | ifNull(definition,descriptionSyntax); |
| | | ifNull(definition, syntax); |
| | | |
| | | this.descriptionSyntax = descriptionSyntax; |
| | | this.oid = descriptionSyntax.getOID(); |
| | | this.description = description; |
| | | this.syntax = syntax; |
| | | this.oid = syntax.getOID(); |
| | | this.description = syntax.getDescription(); |
| | | |
| | | int schemaFilePos = definition.indexOf(SCHEMA_PROPERTY_FILENAME); |
| | | if (schemaFilePos > 0) |
| | |
| | | try |
| | | { |
| | | int firstQuotePos = definition.indexOf('\'', schemaFilePos); |
| | | int secondQuotePos = definition.indexOf('\'', |
| | | firstQuotePos+1); |
| | | int secondQuotePos = definition.indexOf('\'', firstQuotePos+1); |
| | | |
| | | defStr = definition.substring(0, schemaFilePos).trim() + " " |
| | | + definition.substring(secondQuotePos+1).trim(); |
| | |
| | | this.definition = definition; |
| | | } |
| | | |
| | | |
| | | if ((extraProperties == null) || extraProperties.isEmpty()) |
| | | { |
| | | this.extraProperties = |
| | | new LinkedHashMap<String,List<String>>(0); |
| | | this.extraProperties = new LinkedHashMap<String,List<String>>(0); |
| | | } |
| | | else |
| | | { |
| | | this.extraProperties = |
| | | new LinkedHashMap<String,List<String>>(extraProperties); |
| | | this.extraProperties = new LinkedHashMap<String,List<String>>(extraProperties); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * @return The description syntax for this definition. |
| | | */ |
| | | public LDAPSyntaxDescriptionSyntax getLdapSyntaxDescriptionSyntax() |
| | | public Syntax getSyntax() |
| | | { |
| | | return descriptionSyntax; |
| | | return syntax; |
| | | } |
| | | |
| | | |
| | |
| | | return description; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns the oid. |
| | | * |
| | | * @return the oid |
| | | */ |
| | | public String getOID() |
| | | { |
| | | return oid; |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.std.server.DirectoryStringAttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SchemaConfigManager; |
| | |
| | | * The set of attribute syntaxes for this schema, mapped between the OID for |
| | | * the syntax and the syntax itself. |
| | | */ |
| | | private ConcurrentHashMap<String,AttributeSyntax<?>> syntaxes; |
| | | private ConcurrentHashMap<String,Syntax> syntaxes; |
| | | |
| | | /** |
| | | * The default attribute syntax to use for attributes with no defined syntax. |
| | | */ |
| | | private AttributeSyntax<DirectoryStringAttributeSyntaxCfg> defaultSyntax; |
| | | private Syntax defaultSyntax; |
| | | |
| | | /** |
| | | * The entire set of matching rules for this schema, mapped between the |
| | |
| | | { |
| | | attributeTypes = new ConcurrentHashMap<String,AttributeType>(); |
| | | objectClasses = new ConcurrentHashMap<String,ObjectClass>(); |
| | | syntaxes = new ConcurrentHashMap<String,AttributeSyntax<?>>(); |
| | | syntaxes = new ConcurrentHashMap<String,Syntax>(); |
| | | matchingRules = new ConcurrentHashMap<String,MatchingRule>(); |
| | | matchingRuleUses = |
| | | new ConcurrentHashMap<MatchingRule,MatchingRuleUse>(); |
| | |
| | | * |
| | | * @return The attribute syntax definitions for this schema. |
| | | */ |
| | | public ConcurrentHashMap<String,AttributeSyntax<?>> getSyntaxes() |
| | | public ConcurrentHashMap<String,Syntax> getSyntaxes() |
| | | { |
| | | return syntaxes; |
| | | } |
| | |
| | | * syntax is unknown and the caller has indicated that the default is |
| | | * acceptable, or <CODE>null</CODE> otherwise. |
| | | */ |
| | | public AttributeSyntax<?> getSyntax(String oid, boolean allowDefault) |
| | | public Syntax getSyntax(String oid, boolean allowDefault) |
| | | { |
| | | AttributeSyntax<?> syntax = getSyntax(oid); |
| | | Syntax syntax = getSyntax(oid); |
| | | if (syntax == null && allowDefault) |
| | | { |
| | | return getDefaultSyntax(); |
| | |
| | | * @return The requested attribute syntax, or <CODE>null</CODE> if |
| | | * no syntax is registered with the provided OID. |
| | | */ |
| | | public AttributeSyntax<?> getSyntax(String lowerName) |
| | | public Syntax getSyntax(String lowerName) |
| | | { |
| | | return syntaxes.get(lowerName); |
| | | } |
| | |
| | | * @return The default attribute syntax that should be used for attributes |
| | | * that are not defined in the server schema. |
| | | */ |
| | | public AttributeSyntax<?> getDefaultSyntax() |
| | | public Syntax getDefaultSyntax() |
| | | { |
| | | return defaultSyntax; |
| | | } |
| | |
| | | * The defautl syntax to use. |
| | | */ |
| | | public void registerDefaultSyntax( |
| | | AttributeSyntax<DirectoryStringAttributeSyntaxCfg> defaultSyntax) |
| | | Syntax defaultSyntax) |
| | | { |
| | | this.defaultSyntax = defaultSyntax; |
| | | } |
| | |
| | | * <CODE>overwriteExisting</CODE> flag |
| | | * is set to <CODE>false</CODE> |
| | | */ |
| | | public void registerSyntax(AttributeSyntax<?> syntax, |
| | | public void registerSyntax(Syntax syntax, |
| | | boolean overwriteExisting) |
| | | throws DirectoryException |
| | | { |
| | |
| | | String oid = toLowerCase(syntax.getOID()); |
| | | if (syntaxes.containsKey(oid)) |
| | | { |
| | | AttributeSyntax<?> conflictingSyntax = syntaxes.get(oid); |
| | | Syntax conflictingSyntax = syntaxes.get(oid); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_CONFLICTING_SYNTAX_OID. |
| | | get(syntax.getName(), oid, |
| | |
| | | * @param syntax The attribute syntax to deregister with this |
| | | * schema. |
| | | */ |
| | | public void deregisterSyntax(AttributeSyntax<?> syntax) |
| | | public void deregisterSyntax(Syntax syntax) |
| | | { |
| | | synchronized (syntaxes) |
| | | { |
| | |
| | | */ |
| | | synchronized (ldapSyntaxDescriptions) |
| | | { |
| | | String oid = toLowerCase(syntax.getLdapSyntaxDescriptionSyntax().getOID()); |
| | | String oid = toLowerCase(syntax.getSyntax().getOID()); |
| | | if (! overwriteExisting && ldapSyntaxDescriptions.containsKey(oid)) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | |
| | | //Register the attribute syntax with the schema. It will ensure |
| | | // syntax is available along with the other virtual values for |
| | | // ldapsyntaxes. |
| | | registerSyntax(syntax.getLdapSyntaxDescriptionSyntax(), overwriteExisting); |
| | | registerSyntax(syntax.getSyntax(), overwriteExisting); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | //Remove the real value. |
| | | ldapSyntaxDescriptions.remove( |
| | | toLowerCase(syntax.getLdapSyntaxDescriptionSyntax().getOID()), |
| | | toLowerCase(syntax.getSyntax().getOID()), |
| | | syntax); |
| | | |
| | | try |
| | | { |
| | | //Get rid of this from the virtual ldapsyntaxes. |
| | | deregisterSyntax(syntax.getLdapSyntaxDescriptionSyntax()); |
| | | syntax.getLdapSyntaxDescriptionSyntax().finalizeSyntax(); |
| | | deregisterSyntax(syntax.getSyntax()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | deregisterSyntax(syntax.getLdapSyntaxDescriptionSyntax()); |
| | | deregisterSyntax(syntax.getSyntax()); |
| | | } |
| | | } |
| | | } |
| | |
| | | * </pre> |
| | | * |
| | | * @see <a href="http://tools.ietf.org/html/rfc3672">RFC 3672 - |
| | | * Subentries inthe Lightweight Directory Access Protocol (LDAP) |
| | | * Subentries in the Lightweight Directory Access Protocol (LDAP) |
| | | * </a> |
| | | */ |
| | | @org.opends.server.types.PublicAPI( |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.api.AuthenticationPolicy; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.ClientConnection; |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | AttributeSyntax<?> syntax = a.getAttributeType().getSyntax(); |
| | | Syntax syntax = a.getAttributeType().getSyntax(); |
| | | if (syntax != null) |
| | | { |
| | | for (ByteString v : a) |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.util.Reject; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.api.AuthenticationPolicy; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.ClientConnection; |
| | |
| | | if (DirectoryServer.checkSchema() && !isSynchronizationOperation()) |
| | | { |
| | | AcceptRejectWarn syntaxPolicy = DirectoryServer.getSyntaxEnforcementPolicy(); |
| | | AttributeSyntax<?> syntax = attr.getAttributeType().getSyntax(); |
| | | Syntax syntax = attr.getAttributeType().getSyntax(); |
| | | |
| | | if (syntaxPolicy == AcceptRejectWarn.REJECT) |
| | | { |
| | |
| | | { |
| | | AcceptRejectWarn syntaxPolicy = DirectoryServer |
| | | .getSyntaxEnforcementPolicy(); |
| | | AttributeSyntax<?> syntax = attr.getAttributeType().getSyntax(); |
| | | Syntax syntax = attr.getAttributeType().getSyntax(); |
| | | |
| | | if (syntaxPolicy == AcceptRejectWarn.REJECT) |
| | | { |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server; |
| | | |
| | |
| | | import java.io.File; |
| | | |
| | | import org.forgerock.opendj.config.server.ServerManagementContext; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.opends.server.core.ConfigurationBootstrapper; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.schema.SchemaUpdater; |
| | |
| | | return serverContext; |
| | | } |
| | | |
| | | public ServerContextBuilder setSchemaDirectory(File path) |
| | | public ServerContextBuilder schemaDirectory(File path) |
| | | throws InitializationException |
| | | { |
| | | env.setSchemaDirectory(path); |
| | | return this; |
| | | } |
| | | |
| | | public ServerContextBuilder setConfigFile(File path) |
| | | public ServerContextBuilder schemaNG(Schema schema) |
| | | { |
| | | when(serverContext.getSchemaNG()).thenReturn(schema); |
| | | return this; |
| | | } |
| | | |
| | | public ServerContextBuilder configFile(File path) |
| | | throws InitializationException |
| | | { |
| | | env.setConfigFile(path); |
| | | return this; |
| | | } |
| | | |
| | | public ServerContextBuilder setSchemaUpdater(SchemaUpdater updater) |
| | | public ServerContextBuilder schemaUpdater(SchemaUpdater updater) |
| | | { |
| | | when(serverContext.getSchemaUpdater()).thenReturn(updater); |
| | | return this; |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** A mock for schema updater. */ |
| | | public static final class MockSchemaUpdater implements SchemaUpdater |
| | | { |
| | | private Schema schema; |
| | | |
| | | public MockSchemaUpdater(Schema schema) |
| | | { |
| | | this.schema = schema; |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateSchema(Schema schema) |
| | | { |
| | | this.schema = schema; |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public SchemaBuilder getSchemaBuilder() |
| | | { |
| | | return new SchemaBuilder(schema); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | public static void startServer() throws Exception |
| | | { |
| | | System.setProperty(PROPERTY_RUNNING_UNIT_TESTS, "true"); |
| | | try { |
| | | if (SERVER_STARTED) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | | |
| | | |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.DirectoryServerTestCase; |
| | |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | | |
| | | |
| | | import java.util.LinkedHashMap; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | | |
| | | |
| | | import static org.testng.Assert.assertEquals; |
| | | import static org.testng.Assert.assertFalse; |
| | | import static org.testng.Assert.assertNull; |
| | |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | | |
| | | |
| | | import java.util.Collection; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | | |
| | | |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Tests the behavior of schema backend when attribute type definitions |
| | | * are added without a space before closing parenthesis. |
| | | */ |
| | | @Test |
| | | public void testAddAttributeTypeNoSpaceBeforeParenthesis() throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | | "attributeTypes: ( test-oid1)", |
| | | "attributeTypes: ( test-oid2 NAME 'test2')", |
| | | "attributeTypes: ( test-oid3 NAME ('test3' 'test4'))", |
| | | "attributeTypes: ( test-oid4 DESC 'test')", |
| | | "attributeTypes: ( test-oid5 OBSOLETE)", |
| | | "attributeTypes: ( test-oid6 SUP test-oid4)", |
| | | "attributeTypes: ( test-oid7 EQUALITY caseIgnoreMatch)", |
| | | "attributeTypes: ( test-oid8 SINGLE-VALUE)", |
| | | "attributeTypes: ( test-oid9 COLLECTIVE)", |
| | | "attributeTypes: ( test-oid10 NO-USER-MODIFICATION USAGE directoryOperation)", |
| | | "attributeTypes: ( test-oid11 USAGE userApplications)", |
| | | "attributeTypes: (test-oid12 EQUALITY caseIgnoreMatch" + |
| | | " SUBSTR caseIgnoreSubstringsMatch)", |
| | | "attributeTypes: (test-oid13 EQUALITY caseIgnoreMatch ORDERING " + |
| | | " caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch " + |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.44 X-ORIGIN 'RFC 4519')"); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | } |
| | | |
| | | /** |
| | | * Tests to ensure that the schema subentry includes the lastmod attributes |
| | | * and that the modifiersName and modifyTimestamp attributes get updated when |
| | | * the schema is modified. |
| | |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.File; |
| | | import java.net.InetAddress; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | import org.assertj.core.api.Assertions; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | import org.opends.server.admin.std.server.PluggableBackendCfg; |
| | | import org.opends.server.api.Backend.BackendOperation; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.ConnectionHandler; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.BackupDirectory; |
| | | import org.opends.server.types.CancelRequest; |
| | | import org.opends.server.types.CancelResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DisconnectReason; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.IntermediateResponse; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.RestoreConfig; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.types.SearchResultReference; |
| | | import org.opends.server.workflowelement.localbackend.LocalBackendSearchOperation; |
| | | import org.testng.Reporter; |
| | | import org.testng.annotations.AfterClass; |
| | |
| | | throws InitializationException |
| | | { |
| | | final ServerContext context = aServerContext(). |
| | | setSchemaDirectory(new File(TestCaseUtils.getBuildRoot(), "resource/schema")). |
| | | setConfigFile(TestCaseUtils.getTestResource("config-small.ldif")). |
| | | schemaDirectory(new File(TestCaseUtils.getBuildRoot(), "resource/schema")). |
| | | configFile(TestCaseUtils.getTestResource("config-small.ldif")). |
| | | build(); |
| | | |
| | | final ConfigurationHandler configHandler = new ConfigurationHandler(context); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.opends.server.ServerContextBuilder.MockSchemaUpdater; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.schema.SchemaUpdater; |
| | | import org.opends.server.types.InitializationException; |
| | |
| | | @Test |
| | | public void testSchemaInitialization() throws Exception |
| | | { |
| | | MockSchemaUpdater schemaUpdater = new MockSchemaUpdater(); |
| | | MockSchemaUpdater schemaUpdater = new MockSchemaUpdater(Schema.getEmptySchema()); |
| | | initializeSchemaHandler(schemaUpdater); |
| | | |
| | | assertThat(schemaUpdater.getSchemaBuilder()).isNotNull(); |
| | |
| | | private void initializeSchemaHandler(SchemaUpdater updater) throws InitializationException, ConfigException |
| | | { |
| | | final ServerContext serverContext = aServerContext(). |
| | | setSchemaDirectory(new File(TestCaseUtils.getBuildRoot(), "resource/schema")). |
| | | setConfigFile(TestCaseUtils.getTestResource("config-small.ldif")). |
| | | setSchemaUpdater(updater). |
| | | schemaDirectory(new File(TestCaseUtils.getBuildRoot(), "resource/schema")). |
| | | configFile(TestCaseUtils.getTestResource("config-small.ldif")). |
| | | schemaUpdater(updater). |
| | | withConfigurationBootstrapped(). |
| | | build(); |
| | | |
| | |
| | | schemaHandler.initialize(serverContext); |
| | | } |
| | | |
| | | private static final class MockSchemaUpdater implements SchemaUpdater |
| | | { |
| | | private SchemaBuilder schemaBuilder; |
| | | |
| | | @Override |
| | | public boolean updateSchema(SchemaBuilder schemaBuilder) |
| | | { |
| | | this.schemaBuilder = schemaBuilder; |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public SchemaBuilder getSchemaBuilder() |
| | | { |
| | | return schemaBuilder; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2014 ForgeRock AS |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.ldap.schema.SchemaOptions; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public abstract class AttributeSyntaxTest extends SchemaTestCase |
| | | { |
| | | /** |
| | |
| | | * |
| | | * @return An instance of the attribute syntax that must be tested. |
| | | */ |
| | | protected abstract AttributeSyntax getRule(); |
| | | protected abstract AttributeSyntax<?> getRule(); |
| | | |
| | | /** |
| | | * Test the normalization and the approximate comparison. |
| | |
| | | throws Exception |
| | | { |
| | | // Make sure that the specified class can be instantiated as a task. |
| | | AttributeSyntax syntax = getRule(); |
| | | |
| | | SchemaBuilder schemaBuilder = new SchemaBuilder(Schema.getCoreSchema()); |
| | | schemaBuilder.setOption(SchemaOptions.STRICT_FORMAT_FOR_COUNTRY_STRINGS, true); |
| | | Schema schema = schemaBuilder.toSchema(); |
| | | Syntax syntax = getRule().getSDKSyntax(schema); |
| | | |
| | | LocalizableMessageBuilder reason = new LocalizableMessageBuilder(); |
| | | // test the valueIsAcceptable method |
| | |
| | | fail(syntax + ".valueIsAcceptable gave bad result for " + value + |
| | | "reason : " + reason); |
| | | |
| | | // call the getters |
| | | syntax.getApproximateMatchingRule(); |
| | | syntax.getDescription(); |
| | | syntax.getEqualityMatchingRule(); |
| | | syntax.getOID(); |
| | | syntax.getOrderingMatchingRule(); |
| | | syntax.getSubstringMatchingRule(); |
| | | syntax.getName(); |
| | | syntax.toString(); |
| | | } |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | /** |
| | | * Test the AttributeTypeSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public class AttributeTypeSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | |
| | | " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" + |
| | | " COLLECTIVE USAGE directoryOperation )", |
| | | true}, // Collective can be operational |
| | | {"(1.2.8.5 NAME 'testtype' DESC 'full type' OBSOLETE SUP cn " + |
| | | " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" + |
| | | " SUBSTR caseIgnoreSubstringsMatch" + |
| | | " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" + |
| | | " NO-USER-MODIFICATION USAGE directoryOperation )", |
| | | false}, // directoryOperation can't inherit from userApplications |
| | | {"(1.2.8.5 NAME 'testtype' DESC 'full type' OBSOLETE " + |
| | | " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" + |
| | | " SUBSTR caseIgnoreSubstringsMatch" + |
| | | " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE" + |
| | | " NO-USER-MODIFICATION USAGE userApplications )", |
| | | false}, // NO-USER-MODIFICATION can't have non-operational usage |
| | | {"(1.2.8.5 NAME 'testType' DESC 'full type' EQUALITY caseIgnoreMatch " + |
| | | " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'test' " + |
| | | " X-SCHEMA-FILE '33-test.ldif' X-NAME )", |
| | | false}, // X-NAME is invalid extension (no value) |
| | | {"(1.2.8.5 NAME 'testType' DESC 'full type' EQUALITY caseIgnoreMatch " + |
| | | " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'test' " + |
| | | " X-SCHEMA-FILE '../config.ldif' )", |
| | | false}, // X-SCHEMA-FILE is unsafe |
| | | {"(1.2.8.5 NAME 'testType' DESC 'full type' EQUALITY caseIgnoreMatch " + |
| | | " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'test' " + |
| | | " X-SCHEMA-FILE '..\\config.ldif' )", |
| | | false}, // X-SCHEMA-FILE is unsafe |
| | | }; |
| | | } |
| | | |
| | |
| | | |
| | | // Get a reference to the attribute type syntax implementation in the |
| | | // server. |
| | | AttributeTypeSyntax attrTypeSyntax = |
| | | (AttributeTypeSyntax) |
| | | DirectoryServer.getSchema().getSyntax("1.3.6.1.4.1.1466.115.121.1.3", false); |
| | | Syntax attrTypeSyntax = DirectoryServer.getSchema().getSyntax("1.3.6.1.4.1.1466.115.121.1.3", false); |
| | | assertNotNull(attrTypeSyntax); |
| | | |
| | | |
| | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.ldap.schema.SchemaOptions; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public abstract class BinaryAttributeSyntaxTest extends SchemaTestCase |
| | | { |
| | | /** |
| | |
| | | throws Exception |
| | | { |
| | | // Make sure that the specified class can be instantiated as a task. |
| | | AttributeSyntax syntax = getRule(); |
| | | SchemaBuilder schemaBuilder = new SchemaBuilder(Schema.getCoreSchema()); |
| | | schemaBuilder.setOption(SchemaOptions.ALLOW_MALFORMED_CERTIFICATES, false); |
| | | Schema schema = schemaBuilder.toSchema(); |
| | | Syntax syntax = getRule().getSDKSyntax(schema); |
| | | |
| | | LocalizableMessageBuilder reason = new LocalizableMessageBuilder(); |
| | | |
| | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | |
| | | /** |
| | | * Test the BitStringSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public class BitStringSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | |
| | | @Test(dataProvider= "acceptableValues") |
| | | public void testAcceptableValues(String value, Boolean result) throws Exception |
| | | { |
| | | BitStringSyntax syntax = new BitStringSyntax(); |
| | | syntax.initializeSyntax(null); |
| | | Syntax syntax = new BitStringSyntax().getSDKSyntax(CoreSchema.getInstance()); |
| | | |
| | | ByteString byteStringValue = ByteString.valueOf(value); |
| | | |
| | |
| | | fail(syntax + ".valueIsAcceptable gave bad result for " + value + |
| | | "reason : " + reason); |
| | | |
| | | // call the getters |
| | | syntax.getApproximateMatchingRule(); |
| | | syntax.getDescription(); |
| | | |
| | | syntax.getOID(); |
| | | syntax.getOrderingMatchingRule(); |
| | | syntax.getSubstringMatchingRule(); |
| | | syntax.getName(); |
| | | syntax.toString(); |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.ServerContextBuilder; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.admin.std.server.CertificateAttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | |
| | | /** |
| | | * Test the CertificateSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | @Test |
| | | public class CertificateSyntaxTest extends BinaryAttributeSyntaxTest |
| | | { |
| | | |
| | |
| | | CertificateSyntax syntax = new CertificateSyntax(); |
| | | CertificateAttributeSyntaxCfg cfg = new CertificateAttributeSyntaxCfg() |
| | | { |
| | | @Override |
| | | public DN dn() |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public void removeChangeListener( |
| | | ConfigurationChangeListener<AttributeSyntaxCfg> listener) |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public boolean isEnabled() |
| | | { |
| | | // Stub. |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void addChangeListener( |
| | | ConfigurationChangeListener<AttributeSyntaxCfg> listener) |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void removeCertificateChangeListener( |
| | | ConfigurationChangeListener<CertificateAttributeSyntaxCfg> listener) |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public boolean isStrictFormat() |
| | | { |
| | | return true; |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String getJavaClass() |
| | | { |
| | | // Stub. |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Class<? extends CertificateAttributeSyntaxCfg> configurationClass() |
| | | { |
| | | // Stub. |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void addCertificateChangeListener( |
| | | ConfigurationChangeListener<CertificateAttributeSyntaxCfg> listener) |
| | | { |
| | |
| | | |
| | | try |
| | | { |
| | | syntax.initializeSyntax(cfg); |
| | | Schema schema = Schema.getCoreSchema(); |
| | | ServerContext serverContext = ServerContextBuilder.aServerContext() |
| | | .schemaNG(schema) |
| | | .schemaUpdater(new ServerContextBuilder.MockSchemaUpdater(schema)).build(); |
| | | syntax.initializeSyntax(cfg, serverContext); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This Test Class tests various collation matching rules. |
| | | * Integration tests for collation matching rules. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public final class CollationMatchingRuleTest |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.testng.Assert.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.TelephoneNumberAttributeSyntaxCfgDefn; |
| | | import org.opends.server.admin.std.server.TelephoneNumberAttributeSyntaxCfg; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public class ConfigurableAttributeSyntaxTest extends SchemaTestCase |
| | | { |
| | | /** |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * Test the hasAcceptableConfiguration, applyNewConfiguration and |
| | | * valueIsAcceptable methods. |
| | | */ |
| | | @Test(dataProvider= "acceptableValues") |
| | | public void testAcceptableValues(ConfigEntry config, String oid, String value, |
| | | Boolean result) throws Exception |
| | | { |
| | | TelephoneNumberAttributeSyntaxCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | TelephoneNumberAttributeSyntaxCfgDefn.getInstance(), |
| | | config.getEntry()); |
| | | |
| | | TelephoneNumberSyntax syntax = |
| | | (TelephoneNumberSyntax) DirectoryServer.getSchema().getSyntax(oid, false); |
| | | |
| | | // apply the configuration. |
| | | ArrayList<LocalizableMessage> unacceptableReasons = new ArrayList<LocalizableMessage>(); |
| | | assertTrue(syntax.isConfigurationChangeAcceptable(configuration, |
| | | unacceptableReasons)); |
| | | ConfigChangeResult configResult = |
| | | syntax.applyConfigurationChange(configuration); |
| | | assertEquals(configResult.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | // check the syntax of the given value. |
| | | Boolean liveResult = syntax.valueIsAcceptable( |
| | | ByteString.valueOf(value), new LocalizableMessageBuilder()); |
| | | assertEquals(result, liveResult); |
| | | |
| | | // call the getters to increase code coverage... |
| | | syntax.getApproximateMatchingRule(); |
| | | syntax.getDescription(); |
| | | syntax.getEqualityMatchingRule(); |
| | | syntax.getOID(); |
| | | syntax.getOrderingMatchingRule(); |
| | | syntax.getSubstringMatchingRule(); |
| | | syntax.getName(); |
| | | syntax.toString(); |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.ServerContextBuilder; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.admin.std.server.CountryStringAttributeSyntaxCfg; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the CountryStringSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | @Test |
| | | public class CountryStringSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | |
| | | CountryStringSyntax syntax = new CountryStringSyntax(); |
| | | CountryStringAttributeSyntaxCfg cfg = new CountryStringAttributeSyntaxCfg() |
| | | { |
| | | @Override |
| | | public DN dn() |
| | | { |
| | | return null; |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void removeChangeListener(ConfigurationChangeListener<AttributeSyntaxCfg> listener) |
| | | { |
| | | // Stub. |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public boolean isEnabled() |
| | | { |
| | | // Stub. |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void addChangeListener( |
| | | ConfigurationChangeListener<AttributeSyntaxCfg> listener) |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void removeCountryStringChangeListener( |
| | | ConfigurationChangeListener<CountryStringAttributeSyntaxCfg> listener) |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public boolean isStrictFormat() |
| | | { |
| | | return true; |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public String getJavaClass() |
| | | { |
| | | // Stub. |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Class<? extends CountryStringAttributeSyntaxCfg> configurationClass() |
| | | { |
| | | // Stub. |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void addCountryStringChangeListener( |
| | | ConfigurationChangeListener<CountryStringAttributeSyntaxCfg> listener) |
| | | { |
| | |
| | | |
| | | try |
| | | { |
| | | syntax.initializeSyntax(cfg); |
| | | Schema schema = Schema.getCoreSchema(); |
| | | ServerContext serverContext = ServerContextBuilder.aServerContext() |
| | | .schemaNG(schema) |
| | | .schemaUpdater(new ServerContextBuilder.MockSchemaUpdater(schema)).build(); |
| | | syntax.initializeSyntax(cfg, serverContext); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the DITContentRuleSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | @Test |
| | | public class DITContentRuleSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | |
| | | return new Object [][] { |
| | | {"( 2.5.6.4 DESC 'content rule for organization' NOT " |
| | | + "( x121Address $ telexNumber ) )", true}, |
| | | {"( 2.5.6.4 NAME 'full rule' DESC 'rule with all possible fields' " |
| | | {"( 2.5.6.4 NAME 'fullrule' DESC 'rule with all possible fields' " |
| | | + " OBSOLETE" |
| | | + " AUX ( posixAccount )" |
| | | + " MUST ( cn $ sn )" |
| | | + " MAY ( dc )" |
| | | + " NOT ( x121Address $ telexNumber ) )" |
| | | , true}, |
| | | {"( 2.5.6.4 NAME 'full rule' DESC 'ommit parenthesis' " |
| | | {"( 2.5.6.4 NAME 'fullrule' DESC 'ommit parenthesis' " |
| | | + " OBSOLETE" |
| | | + " AUX posixAccount " |
| | | + " MUST cn " |
| | | + " MAY dc " |
| | | + " NOT x121Address )" |
| | | , true}, |
| | | {"( 2.5.6.4 NAME 'full rule' DESC 'use numeric OIDs' " |
| | | {"( 2.5.6.4 NAME 'fullrule' DESC 'use numeric OIDs' " |
| | | + " OBSOLETE" |
| | | + " AUX 1.3.6.1.1.1.2.0" |
| | | + " MUST cn " |
| | | + " MAY dc " |
| | | + " NOT x121Address )" |
| | | , true}, |
| | | {"( 2.5.6.4 NAME 'full rule' DESC 'illegal OIDs' " |
| | | {"( 2.5.6.4 NAME 'fullrule' DESC 'illegal OIDs' " |
| | | + " OBSOLETE" |
| | | + " AUX 2.5.6.." |
| | | + " MUST cn " |
| | | + " MAY dc " |
| | | + " NOT x121Address )" |
| | | , false}, |
| | | {"( 2.5.6.4 NAME 'full rule' DESC 'illegal OIDs' " |
| | | {"( 2.5.6.4 NAME 'fullrule' DESC 'illegal OIDs' " |
| | | + " OBSOLETE" |
| | | + " AUX 2.5.6.x" |
| | | + " MUST cn " |
| | | + " MAY dc " |
| | | + " NOT x121Address )" |
| | | , false}, |
| | | {"( 2.5.6.4 NAME 'full rule' DESC 'missing closing parenthesis' " |
| | | {"( 2.5.6.4 NAME 'fullrule' DESC 'missing closing parenthesis' " |
| | | + " OBSOLETE" |
| | | + " AUX posixAccount" |
| | | + " MUST cn " |
| | | + " MAY dc " |
| | | + " NOT x121Address" |
| | | , false}, |
| | | {"( 2.5.6.4 NAME 'full rule' DESC 'extra parameterss' " |
| | | {"( 2.5.6.4 NAME 'fullrule' DESC 'extra parameterss' " |
| | | + " MUST cn " |
| | | + "( this is an extra parameter )" |
| | | , true}, |
| | | + " this is an extra parameter )" |
| | | , false}, |
| | | |
| | | }; |
| | | } |
| | |
| | | import java.util.TimeZone; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | |
| | | /** |
| | | * Test the GeneralizedTimeSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public class GeneralizedTimeSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | |
| | | TreeSet<String> invalidOIDs = new TreeSet<String>(); |
| | | |
| | | Schema schema = DirectoryServer.getSchema(); |
| | | for (AttributeSyntax<?> as : schema.getSyntaxes().values()) |
| | | for (Syntax as : schema.getSyntaxes().values()) |
| | | { |
| | | if (! isNumericOID(as.getOID())) |
| | | { |
| | |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the GuideSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public class GuideSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the IA5StringSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public class IA5StringSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the IA5StringSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public class IntegerSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.admin.std.server.JPEGAttributeSyntaxCfg; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the JPEGSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | @Test |
| | | public class JPEGSyntaxTest extends BinaryAttributeSyntaxTest |
| | | { |
| | | |
| | |
| | | @Override |
| | | protected AttributeSyntax<?> getRule() |
| | | { |
| | | JPEGSyntax syntax = new JPEGSyntax(); |
| | | JPEGAttributeSyntaxCfg cfg = new JPEGAttributeSyntaxCfg() |
| | | { |
| | | public DN dn() |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | public void removeChangeListener(ConfigurationChangeListener<AttributeSyntaxCfg> listener) |
| | | { |
| | | // Stub. |
| | | } |
| | | |
| | | |
| | | |
| | | public boolean isEnabled() |
| | | { |
| | | // Stub. |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | public void addChangeListener( |
| | | ConfigurationChangeListener<AttributeSyntaxCfg> listener) |
| | | { |
| | | // Stub. |
| | | } |
| | | |
| | | |
| | | |
| | | public void removeJPEGChangeListener( |
| | | ConfigurationChangeListener<JPEGAttributeSyntaxCfg> listener) |
| | | { |
| | | // Stub. |
| | | } |
| | | |
| | | |
| | | |
| | | public boolean isStrictFormat() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | public String getJavaClass() |
| | | { |
| | | // Stub. |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | public Class<? extends JPEGAttributeSyntaxCfg> configurationClass() |
| | | { |
| | | // Stub. |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | public void addJPEGChangeListener( |
| | | ConfigurationChangeListener<JPEGAttributeSyntaxCfg> listener) |
| | | { |
| | | // Stub. |
| | | } |
| | | }; |
| | | |
| | | try |
| | | { |
| | | syntax.initializeSyntax(cfg); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | | // Should never happen. |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | return syntax; |
| | | return new JPEGSyntax(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | @DataProvider(name="acceptableValues") |
| | | public Object[][] createAcceptableValues() |
| | | { |
| | | String non_image = |
| | | "AAECAwQFBgcICQ=="; |
| | | String jfif_image = |
| | | "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDACMYGh4aFiMeHB4nJSMpNFc4NDAwNGpM" + |
| | | "UD9Xfm+EgnxveneLnMipi5S9lnd6ru2wvc7V4OLgh6f1//PZ/8jb4Nf/2wBDASUn" + |
| | |
| | | "anN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPE" + |
| | | "xcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwCC" + |
| | | "iiiuM9g//9k="; |
| | | String exif_image = |
| | | "/9j/4QD2RXhpZgAATU0AKgAAAAgACQESAAMAAAABAAEAAAEaAAUAAAABAAAAegEb" + |
| | | "AAUAAAABAAAAggEoAAMAAAABAAIAAAExAAIAAAAQAAAAigEyAAIAAAAUAAAAmgE8" + |
| | | "AAIAAAAOAAAArgITAAMAAAABAAEAAIdpAAQAAAABAAAAvAAAAAAASAAAAAEAAABI" + |
| | | "AAAAAQAAUXVpY2tUaW1lIDcuNy4xADIwMTI6MDg6MjAgMTI6MTE6MTIATWFjIE9T" + |
| | | "IFggMTAuOAAAApAAAAcAAAAEMDIyMJADAAIAAAAUAAAA2gAAAAAyMDEyOjA4OjIw" + |
| | | "IDEyOjEwOjA2AP/+AAxBcHBsZU1hcmsK/9sAQwAjGBoeGhYjHhweJyUjKTRXODQw" + |
| | | "MDRqTFA/V35vhIJ8b3p3i5zIqYuUvZZ3eq7tsL3O1eDi4Ien9f/z2f/I2+DX/9sA" + |
| | | "QwElJyc0LjRmODhm1496j9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX" + |
| | | "19fX19fX19fX19fX19fX19fX/8AAEQgAAQABAwEiAAIRAQMRAf/EAB8AAAEFAQEB" + |
| | | "AQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAE" + |
| | | "EQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2" + |
| | | "Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SV" + |
| | | "lpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn" + |
| | | "6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//E" + |
| | | "ALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkj" + |
| | | "M1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2Rl" + |
| | | "ZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5" + |
| | | "usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMR" + |
| | | "AD8AgooorjPYP//Z"; |
| | | String png_image = |
| | | "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAMAAAAoyzS7AAAABlBMVEX/JgAAAAAP" + |
| | | "IsinAAAACklEQVQImWNgAAAAAgAB9HFkpgAAAABJRU5ErkJggg=="; |
| | | |
| | | try |
| | | { |
| | | return new Object [][] { |
| | | {ByteString.wrap(Base64.decode(non_image)), false}, |
| | | {ByteString.wrap(Base64.decode(jfif_image)), true}, |
| | | {ByteString.wrap(Base64.decode(exif_image)), true}, |
| | | {ByteString.wrap(Base64.decode(png_image)), false} |
| | | }; |
| | | } |
| | | catch (Exception e) |
| | |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | /** |
| | | * Test the LDAPSyntaxDescriptionSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | @SuppressWarnings("javadoc") |
| | | public class LDAPSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | |
| | | {"( 2.5.4.3 DESC 'Test X-PATTERN Extensions' X-PATTERN '[0-9]+' X-SCHEMA-FILE '00-core.ldif' )", true}, |
| | | {"( 2.5.4.3 DESC 'Test X-ENUM Extensions' X-ENUM ( 'black' 'white' ) )", true}, |
| | | {"( 2.5.4.3 DESC 'Test X-ENUM Extensions' X-ENUM ( 'white' 'white' ) )", false}, |
| | | {"( 2.5.4.3 DESC 'Test X-ENUM Extensions' X-ENUM ( ) )", false}, |
| | | {"( 2.5.4.3 DESC 'Test X-ENUM Extensions' X-ENUM )", false}, |
| | | {"( 2.5.4.3 DESC 'Test X-ENUM Extensions' X-ENUM ( 'black' 'white' ) X-SCHEMA-FILE '00-core.ldif' )", true}, |
| | | {"( 2.5.4.3 DESC 'Test Too many Extensions' X-PATTERN '[0-9]+' X-SUBST '1.3.6.1.4.1.1466.115.121.1.15' )", false}, |
| | | {"( 2.5.4.3 DESC syntax description )", false}, |
| | | {"($%^*&!@ DESC 'syntax description' )", false}, |
| | | {"(temp-oid DESC 'syntax description' )", true}, |
| | |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the MatchingRuleSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | @Test |
| | | public class MatchingRuleSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | |
| | | public Object[][] createAcceptableValues() |
| | | { |
| | | return new Object [][] { |
| | | {"( 1.2.3.4 NAME 'full matching rule' " |
| | | {"( 1.2.3.4 NAME 'fullMatchingRule' " |
| | | + " DESC 'description of matching rule' OBSOLETE " |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 " |
| | | + " ( this is an extension ) )", true}, |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 )", true}, |
| | | {"( 1.2.3.4 NAME 'missing closing parenthesis' " |
| | | + " DESC 'description of matching rule' " |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 " |
| | | + " ( this is an extension ) ", false}, |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 ", false}, |
| | | }; |
| | | } |
| | | |
| | |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the MatchingRuleUseSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | @Test |
| | | public class MatchingRuleUseSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | |
| | | public Object[][] createAcceptableValues() |
| | | { |
| | | return new Object [][] { |
| | | {"( 2.5.13.10 NAME 'full matching rule' " |
| | | {"( 2.5.13.10 NAME 'fullMatchingRule' " |
| | | + " DESC 'description of matching rule' OBSOLETE " |
| | | + " APPLIES 2.5.4.3 " |
| | | + " ( this is an extension ) )", true}, |
| | | {"( 2.5.13.10 NAME 'missing closing parenthesis' " |
| | | + " APPLIES 2.5.4.3 )", true}, |
| | | {"( 2.5.13.10 NAME 'missingClosingParenthesis' " |
| | | + " DESC 'description of matching rule' " |
| | | + " SYNTAX 2.5.4.3 " |
| | | + " ( this is an extension ) ", false}, |
| | |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the OtherMailboxSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public class OtherMailboxSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the TelexNumberSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public class TelexSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | |
| | | package org.opends.server.schema; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the UUIDSyntax. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public class UUIDSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013-2014 ForgeRock AS |
| | | * Copyright 2013-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeUsage; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.schema.OIDSyntax; |
| | | |
| | | /** |
| | |
| | | public interface AttributeTypeConstants |
| | | { |
| | | |
| | | AttributeSyntax<?> OID_SYNTAX = new OIDSyntax(); |
| | | Syntax OID_SYNTAX = new OIDSyntax().getSDKSyntax(CoreSchema.getInstance()); |
| | | |
| | | AttributeType OBJECT_CLASS = new AttributeType( |
| | | "( 2.5.4.0 NAME 'objectClass' EQUALITY objectIdentifierMatch " |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeUsage; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.testng.Assert; |
| | |
| | | private AttributeType superiorType; |
| | | |
| | | /** The syntax for this attribute type. */ |
| | | private AttributeSyntax syntax; |
| | | private Syntax syntax; |
| | | |
| | | /** The approximate matching rule for this attribute type. */ |
| | | private MatchingRule approximateMatchingRule; |
| | |
| | | * @param syntax |
| | | * The syntax. |
| | | */ |
| | | public void setSyntax(AttributeSyntax syntax) { |
| | | public void setSyntax(Syntax syntax) { |
| | | this.syntax = syntax; |
| | | } |
| | | } |
| | |
| | | "testType", "1.2.3"); |
| | | AttributeType type = builder.getInstance(); |
| | | |
| | | AttributeSyntax syntax = DirectoryServer |
| | | Syntax syntax = DirectoryServer |
| | | .getDefaultAttributeSyntax(); |
| | | Assert.assertEquals(type.getApproximateMatchingRule(), syntax |
| | | .getApproximateMatchingRule()); |
| | |
| | | public void testConstructorMatchingRules() throws Exception { |
| | | AttributeTypeBuilder builder = new AttributeTypeBuilder( |
| | | "testType", "1.2.3"); |
| | | AttributeSyntax syntax = DirectoryServer.getDefaultStringSyntax(); |
| | | Syntax syntax = DirectoryServer.getDefaultStringSyntax(); |
| | | builder.setApproximateMatchingRule(syntax |
| | | .getApproximateMatchingRule()); |
| | | builder.setEqualityMatchingRule(syntax.getEqualityMatchingRule()); |
| | |
| | | public void testConstructorInheritsMatchingRules() throws Exception { |
| | | AttributeTypeBuilder builder = new AttributeTypeBuilder( |
| | | "parentType", "1.2.3"); |
| | | AttributeSyntax syntax = DirectoryServer.getDefaultStringSyntax(); |
| | | Syntax syntax = DirectoryServer.getDefaultStringSyntax(); |
| | | builder.setApproximateMatchingRule(syntax |
| | | .getApproximateMatchingRule()); |
| | | builder.setEqualityMatchingRule(syntax.getEqualityMatchingRule()); |
| | |
| | | { "ou=\\e5\\96\\b6\\e6\\a5\\ad\\e9\\83\\a8,o=Airius", |
| | | "ou=%E5%96%B6%E6%A5%AD%E9%83%A8,o=airius", |
| | | "ou=\u55b6\u696d\u90e8,o=Airius" }, |
| | | { "photo=\\ john \\ ,dc=com", "photo=%20%6A%6F%68%6E%20%20,dc=com", |
| | | { "photo=\\ john \\ ,dc=com", "photo=%20john%20%20,dc=com", |
| | | "photo=\\ john \\ ,dc=com" }, |
| | | { "AB-global=", "ab-global=", "AB-global=" }, |
| | | { "OU= Sales + CN = J. Smith ,DC=example,DC=net", |
| | |
| | | "1.3.6.1.4.1.1466.0=hi", "1.3.6.1.4.1.1466.0=\\04\\02Hi" }, |
| | | { "CN=Lu\\C4\\8Di\\C4\\87", "cn=luc%CC%8Cic%CC%81", "CN=Lu\u010di\u0107" }, |
| | | { "ou=\\e5\\96\\b6\\e6\\a5\\ad\\e9\\83\\a8", "ou=%E5%96%B6%E6%A5%AD%E9%83%A8", "ou=\u55b6\u696d\u90e8" }, |
| | | { "photo=\\ john \\ ", "photo=%20%6A%6F%68%6E%20%20", "photo=\\ john \\ " }, |
| | | { "photo=\\ john \\ ", "photo=%20john%20%20", "photo=\\ john \\ " }, |
| | | // { "AB-global=", "ab-global=", "AB-global=" }, |
| | | { "cn=John+a=", "a=+cn=john", "cn=John+a=" }, |
| | | { "OID.1.3.6.1.4.1.1466.0=#04024869", |