| | |
| | | |
| | | ############################### List of replacements to run ################################# |
| | | |
| | | REPLACEMENTS = [ SYNTAXES_TO_SDK, SYNTAXES_TO_SDK_SCM ] |
| | | REPLACEMENTS = [ ATTRTYPE ] |
| | | |
| | | ################################### Processing methods ######################################## |
| | | |
| | |
| | | ! |
| | | ! |
| | | ! Copyright 2008 Sun Microsystems, Inc. |
| | | ! Portions copyright 2015-2016 ForgeRock AS |
| | | ! --> |
| | | <xsl:stylesheet version="1.0" xmlns:adm="http://www.opends.org/admin" |
| | | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
| | |
| | | Templates for processing attribute type properties. |
| | | --> |
| | | <xsl:template match="adm:attribute-type" mode="java-value-imports"> |
| | | <import>org.opends.server.types.AttributeType</import> |
| | | <import>org.forgerock.opendj.ldap.schema.AttributeType</import> |
| | | </xsl:template> |
| | | <xsl:template match="adm:attribute-type" mode="java-value-type"> |
| | | <xsl:value-of select="'AttributeType'" /> |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | |
| | | import javax.naming.directory.SearchResult; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS |
| | | * Portions Copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | /** |
| | | * The class used to describe the index configuration (the normal index: the one |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | |
| | | |
| | | import org.opends.guitools.controlpanel.util.ConfigFromDirContext; |
| | | import org.opends.quicksetup.UserData; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.opends.server.tools.tasks.TaskEntry; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.OpenDsException; |
| | |
| | | |
| | | private static boolean areAttributeTypesEqual(Schema schema1, Schema schema2) |
| | | { |
| | | final Map<String, AttributeType> attrs1 = schema1.getAttributeTypes(); |
| | | final Map<String, AttributeType> attrs2 = schema2.getAttributeTypes(); |
| | | final List<AttributeType> attrs1 = new ArrayList<>(schema1.getAttributeTypes()); |
| | | final List<AttributeType> attrs2 = new ArrayList<>(schema2.getAttributeTypes()); |
| | | if (attrs1.size() != attrs2.size()) |
| | | { |
| | | return false; |
| | | } |
| | | for (String name : attrs1.keySet()) |
| | | Collections.sort(attrs1); |
| | | Collections.sort(attrs2); |
| | | for (int i = 0; i < attrs1.size(); i++) |
| | | { |
| | | AttributeType attr1 = attrs1.get(name); |
| | | AttributeType attr2 = attrs2.get(name); |
| | | if (attr2 == null && !areAttributesEqual(attr1, attr2)) |
| | | AttributeType attr1 = attrs1.get(i); |
| | | AttributeType attr2 = attrs2.get(i); |
| | | if (attr2 == null || !areAttributesEqual(attr1, attr2)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | && attr1.isOperational() == attr2.isOperational() |
| | | && attr1.isSingleValue() == attr2.isSingleValue() |
| | | && areEqual(attr1.getApproximateMatchingRule(), attr2.getApproximateMatchingRule()) |
| | | && areEqual(getDefinitionWithFileName(attr1), getDefinitionWithFileName(attr2)) |
| | | && areEqual(new SomeSchemaElement(attr1).getDefinitionWithFileName(), |
| | | new SomeSchemaElement(attr2).getDefinitionWithFileName()) |
| | | && areEqual(attr1.getDescription(), attr2.getDescription()) |
| | | && areEqual(attr1.getEqualityMatchingRule(), attr2.getEqualityMatchingRule()) |
| | | && areEqual(attr1.getOrderingMatchingRule(), attr2.getOrderingMatchingRule()) |
| | |
| | | && areEqual(attr1.getSyntax(), attr2.getSyntax()) |
| | | && areEqual(attr1.getSyntax().getOID(), attr2.getSyntax().getOID()) |
| | | && areEqual(attr1.getExtraProperties().keySet(), attr2.getExtraProperties().keySet()) |
| | | && areEqual(toSet(attr1.getNormalizedNames()), toSet(attr2.getNormalizedNames())) |
| | | && areEqual(toSet(attr1.getUserDefinedNames()), toSet(attr2.getUserDefinedNames())); |
| | | && areEqual(toSet(attr1.getNames()), toSet(attr2.getNames())); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.guitools.controlpanel.task; |
| | | |
| | |
| | | import javax.naming.directory.ModificationItem; |
| | | import javax.swing.SwingUtilities; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg1; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.ui.ColorAndFontConstants; |
| | | import org.opends.guitools.controlpanel.ui.ProgressDialog; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.CommonSchemaElements; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ExistingFileBehavior; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.types.SchemaFileElement; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.opends.server.util.LDIFWriter; |
| | | import org.opends.server.util.StaticUtils; |
| | |
| | | */ |
| | | private void updateSchema() throws OpenDsException |
| | | { |
| | | final boolean[] isFirst = {true}; |
| | | final int totalNumber = ocsToDelete.size() + attrsToDelete.size(); |
| | | int numberDeleted = 0; |
| | | for (ObjectClass objectClass : ocsToDelete) |
| | | { |
| | | final ObjectClass fObjectclass = objectClass; |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | if (!isFirst[0]) |
| | | { |
| | | getProgressDialog().appendProgressHtml("<br><br>"); |
| | | } |
| | | isFirst[0] = false; |
| | | printEquivalentCommandToDelete(fObjectclass); |
| | | getProgressDialog().appendProgressHtml( |
| | | Utilities.getProgressWithPoints( |
| | | INFO_CTRL_PANEL_DELETING_OBJECTCLASS.get( |
| | | fObjectclass.getNameOrOID()), |
| | | ColorAndFontConstants.progressFont)); |
| | | } |
| | | }); |
| | | |
| | | if (isServerRunning()) |
| | | { |
| | | try |
| | | { |
| | | BasicAttribute attr = new BasicAttribute( |
| | | getSchemaFileAttributeName(objectClass)); |
| | | attr.add(getSchemaFileAttributeValue(objectClass)); |
| | | ModificationItem mod = |
| | | new ModificationItem(DirContext.REMOVE_ATTRIBUTE, attr); |
| | | getInfo().getDirContext().modifyAttributes( |
| | | ConfigConstants.DN_DEFAULT_SCHEMA_ROOT, |
| | | new ModificationItem[] { mod }); |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | | throw new OnlineUpdateException( |
| | | ERR_CTRL_PANEL_ERROR_UPDATING_SCHEMA.get(ne), ne); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | updateSchemaFile(objectClass); |
| | | } |
| | | numberDeleted ++; |
| | | final int fNumberDeleted = numberDeleted; |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | getProgressDialog().getProgressBar().setIndeterminate(false); |
| | | getProgressDialog().getProgressBar().setValue( |
| | | (fNumberDeleted * 100) / totalNumber); |
| | | getProgressDialog().appendProgressHtml( |
| | | Utilities.getProgressDone(ColorAndFontConstants.progressFont)); |
| | | } |
| | | }); |
| | | final SomeSchemaElement element = new SomeSchemaElement(objectClass); |
| | | deleteSchemaElement(element, numberDeleted, totalNumber, INFO_CTRL_PANEL_DELETING_OBJECTCLASS); |
| | | numberDeleted++; |
| | | } |
| | | |
| | | for (AttributeType attribute : attrsToDelete) |
| | | { |
| | | final AttributeType fAttribute = attribute; |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | if (!isFirst[0]) |
| | | { |
| | | getProgressDialog().appendProgressHtml("<br><br>"); |
| | | } |
| | | isFirst[0] = false; |
| | | printEquivalentCommandToDelete(fAttribute); |
| | | getProgressDialog().appendProgressHtml( |
| | | Utilities.getProgressWithPoints( |
| | | INFO_CTRL_PANEL_DELETING_ATTRIBUTE.get( |
| | | fAttribute.getNameOrOID()), |
| | | ColorAndFontConstants.progressFont)); |
| | | } |
| | | }); |
| | | |
| | | if (isServerRunning()) |
| | | { |
| | | try |
| | | { |
| | | BasicAttribute attr = new BasicAttribute( |
| | | getSchemaFileAttributeName(attribute)); |
| | | attr.add(getSchemaFileAttributeValue(attribute)); |
| | | ModificationItem mod = new ModificationItem( |
| | | DirContext.REMOVE_ATTRIBUTE, |
| | | attr); |
| | | getInfo().getDirContext().modifyAttributes( |
| | | ConfigConstants.DN_DEFAULT_SCHEMA_ROOT, |
| | | new ModificationItem[] { mod }); |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | | throw new OnlineUpdateException( |
| | | ERR_CTRL_PANEL_ERROR_UPDATING_SCHEMA.get(ne), ne); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | updateSchemaFile(attribute); |
| | | } |
| | | |
| | | numberDeleted ++; |
| | | final int fNumberDeleted = numberDeleted; |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | getProgressDialog().getProgressBar().setIndeterminate(false); |
| | | getProgressDialog().getProgressBar().setValue( |
| | | (fNumberDeleted * 100) / totalNumber); |
| | | getProgressDialog().appendProgressHtml( |
| | | Utilities.getProgressDone(ColorAndFontConstants.progressFont)); |
| | | } |
| | | }); |
| | | final SomeSchemaElement element = new SomeSchemaElement(attribute); |
| | | deleteSchemaElement(element, numberDeleted, totalNumber, INFO_CTRL_PANEL_DELETING_ATTRIBUTE); |
| | | numberDeleted++; |
| | | } |
| | | |
| | | if (!ocsToAdd.isEmpty() || !attrsToAdd.isEmpty()) |
| | |
| | | } |
| | | } |
| | | |
| | | private void deleteSchemaElement(final SomeSchemaElement element, final int numberDeleted, final int totalNumber, |
| | | final Arg1<Object> deletingElementMsg) throws OnlineUpdateException, OpenDsException |
| | | { |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | final boolean isFirst = numberDeleted == 0; |
| | | if (!isFirst) |
| | | { |
| | | getProgressDialog().appendProgressHtml("<br><br>"); |
| | | } |
| | | printEquivalentCommandToDelete(element); |
| | | getProgressDialog().appendProgressHtml( |
| | | Utilities.getProgressWithPoints( |
| | | deletingElementMsg.get(element.getNameOrOID()), ColorAndFontConstants.progressFont)); |
| | | } |
| | | }); |
| | | |
| | | if (isServerRunning()) |
| | | { |
| | | try |
| | | { |
| | | BasicAttribute attr = new BasicAttribute(getSchemaFileAttributeName(element)); |
| | | attr.add(getSchemaFileAttributeValue(element)); |
| | | ModificationItem mod = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, attr); |
| | | getInfo().getDirContext().modifyAttributes( |
| | | ConfigConstants.DN_DEFAULT_SCHEMA_ROOT, |
| | | new ModificationItem[] { mod }); |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | | throw new OnlineUpdateException(ERR_CTRL_PANEL_ERROR_UPDATING_SCHEMA.get(ne), ne); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | updateSchemaFile(element); |
| | | } |
| | | |
| | | final int fNumberDeleted = numberDeleted + 1; |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | getProgressDialog().getProgressBar().setIndeterminate(false); |
| | | getProgressDialog().getProgressBar().setValue((fNumberDeleted * 100) / totalNumber); |
| | | getProgressDialog().appendProgressHtml( |
| | | Utilities.getProgressDone(ColorAndFontConstants.progressFont)); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * Updates the schema file by deleting the provided schema element. |
| | | * @param schemaElement the schema element to be deleted. |
| | | * @throws OpenDsException if an error occurs. |
| | | */ |
| | | private void updateSchemaFile(CommonSchemaElements schemaElement) |
| | | private void updateSchemaFile(SomeSchemaElement schemaElement) |
| | | throws OpenDsException |
| | | { |
| | | String schemaFile = getSchemaFile(schemaElement); |
| | |
| | | * @param element the schema element. |
| | | * @return the schema file for a given schema element. |
| | | */ |
| | | private String getSchemaFile(SchemaFileElement element) |
| | | private String getSchemaFile(SomeSchemaElement element) |
| | | { |
| | | String schemaFile = CommonSchemaElements.getSchemaFile(element); |
| | | String schemaFile = element.getSchemaFile(); |
| | | if (schemaFile == null) |
| | | { |
| | | schemaFile = ConfigConstants.FILE_USER_SCHEMA_ELEMENTS; |
| | |
| | | * @return the attribute name in the schema entry that corresponds to the |
| | | * provided schema element. |
| | | */ |
| | | private String getSchemaFileAttributeName(CommonSchemaElements element) |
| | | private String getSchemaFileAttributeName(SomeSchemaElement element) |
| | | { |
| | | if (element instanceof AttributeType) |
| | | if (element.isAttributeType()) |
| | | { |
| | | return "attributeTypes"; |
| | | } |
| | |
| | | * @param element the schema element. |
| | | * @return the value in the schema file for the provided element. |
| | | */ |
| | | private String getSchemaFileAttributeValue(CommonSchemaElements element) |
| | | private String getSchemaFileAttributeValue(SomeSchemaElement element) |
| | | { |
| | | return element.toString(); |
| | | } |
| | |
| | | * progress dialog. |
| | | * @param element the schema element to be deleted. |
| | | */ |
| | | private void printEquivalentCommandToDelete(CommonSchemaElements element) |
| | | private void printEquivalentCommandToDelete(SomeSchemaElement element) |
| | | { |
| | | String schemaFile = getSchemaFile(element); |
| | | String attrName = getSchemaFileAttributeName(element); |
| | |
| | | if (!isServerRunning()) |
| | | { |
| | | LocalizableMessage msg; |
| | | if (element instanceof AttributeType) |
| | | if (element.isAttributeType()) |
| | | { |
| | | msg = INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_ATTRIBUTE_OFFLINE.get( |
| | | element.getNameOrOID(), schemaFile); |
| | |
| | | args); |
| | | |
| | | LocalizableMessage msg; |
| | | if (element instanceof AttributeType) |
| | | if (element.isAttributeType()) |
| | | { |
| | | msg = INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_ATTRIBUTE_ONLINE.get( |
| | | element.getNameOrOID()); |
| | |
| | | if (attr.equals(attrToDelete.getSuperiorType())) |
| | | { |
| | | isSuperior = true; |
| | | AttributeType newSuperior = attr.getSuperiorType(); |
| | | while (newSuperior != null && |
| | | providedAttrsToDelete.contains(newSuperior)) |
| | | { |
| | | newSuperior = newSuperior.getSuperiorType(); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | if (isSuperior) |
| | | { |
| | | ArrayList<String> allNames = new ArrayList<>(attrToDelete.getNormalizedNames()); |
| | | Map<String, List<String>> extraProperties = |
| | | cloneExtraProperties(attrToDelete); |
| | | return new AttributeType( |
| | | "", |
| | | attrToDelete.getPrimaryName(), |
| | | allNames, |
| | | attrToDelete.getOID(), |
| | | attrToDelete.getDescription(), |
| | | null, |
| | | attrToDelete.getSyntax(), |
| | | attrToDelete.getApproximateMatchingRule(), |
| | | attrToDelete.getEqualityMatchingRule(), |
| | | attrToDelete.getOrderingMatchingRule(), |
| | | attrToDelete.getSubstringMatchingRule(), |
| | | attrToDelete.getUsage(), |
| | | attrToDelete.isCollective(), |
| | | attrToDelete.isNoUserModification(), |
| | | attrToDelete.isObsolete(), |
| | | attrToDelete.isSingleValue(), |
| | | extraProperties); |
| | | // get a new attribute without the superior type |
| | | return SomeSchemaElement.changeSuperiorType(attrToDelete, null); |
| | | } |
| | | else |
| | | { |
| | |
| | | AttributeType attribute, Schema schema) |
| | | { |
| | | LinkedHashSet<AttributeType> children = new LinkedHashSet<>(); |
| | | for (AttributeType attr : schema.getAttributeTypes().values()) |
| | | for (AttributeType attr : schema.getAttributeTypes()) |
| | | { |
| | | if (attribute.equals(attr.getSuperiorType())) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.task; |
| | | |
| | |
| | | import javax.swing.SwingUtilities; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.ui.ColorAndFontConstants; |
| | | import org.opends.guitools.controlpanel.ui.ProgressDialog; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.types.Schema; |
| | |
| | | } |
| | | else if (oldAttribute.equals(attrToDelete.getSuperiorType())) |
| | | { |
| | | ArrayList<String> allNames = new ArrayList<>(attrToDelete.getNormalizedNames()); |
| | | Map<String, List<String>> extraProperties = |
| | | DeleteSchemaElementsTask.cloneExtraProperties(attrToDelete); |
| | | AttributeType newSuperior = newAttribute; |
| | | return new AttributeType( |
| | | "", |
| | | attrToDelete.getPrimaryName(), |
| | | allNames, |
| | | attrToDelete.getOID(), |
| | | attrToDelete.getDescription(), |
| | | newSuperior, |
| | | attrToDelete.getSyntax(), |
| | | attrToDelete.getApproximateMatchingRule(), |
| | | attrToDelete.getEqualityMatchingRule(), |
| | | attrToDelete.getOrderingMatchingRule(), |
| | | attrToDelete.getSubstringMatchingRule(), |
| | | attrToDelete.getUsage(), |
| | | attrToDelete.isCollective(), |
| | | attrToDelete.isNoUserModification(), |
| | | attrToDelete.isObsolete(), |
| | | attrToDelete.isSingleValue(), |
| | | extraProperties); |
| | | // get a new attribute with the new superior type |
| | | return SomeSchemaElement.changeSuperiorType(attrToDelete, newAttribute); |
| | | } |
| | | else |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.task; |
| | | |
| | |
| | | import org.opends.guitools.controlpanel.ui.ProgressDialog; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.types.Schema; |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.guitools.controlpanel.task; |
| | | |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.types.CommonSchemaElements.*; |
| | | |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.HashSet; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedHashSet; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.ui.ColorAndFontConstants; |
| | |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.CommonSchemaElements; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ExistingFileBehavior; |
| | |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.types.SchemaFileElement; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.opends.server.util.LDIFWriter; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | /** |
| | | * An abstract class used to re-factor some code between the different tasks |
| | |
| | | } |
| | | else |
| | | { |
| | | final List<String> attrNames = getElementsNameOrOID(attrsToAdd); |
| | | final List<String> ocNames = getElementsNameOrOID(ocsToAdd); |
| | | final List<String> attrNames = getElementsNameOrOID(attributeTypesToSchemaElements(attrsToAdd)); |
| | | final List<String> ocNames = getElementsNameOrOID(objectClassesToSchemaElements(ocsToAdd)); |
| | | if (ocNames.isEmpty()) |
| | | { |
| | | return INFO_CTRL_PANEL_NEW_ATTRIBUTES_TASK_DESCRIPTION.get(joinAsString(", ", attrNames)); |
| | |
| | | } |
| | | } |
| | | |
| | | private <T extends CommonSchemaElements> List<String> getElementsNameOrOID(final Collection<T> schemaElements) |
| | | private List<String> getElementsNameOrOID(final Collection<SomeSchemaElement> schemaElements) |
| | | { |
| | | final List<String> nameOrOIDs = new ArrayList<>(); |
| | | for (CommonSchemaElements schemaElement : schemaElements) |
| | | for (SomeSchemaElement schemaElement : schemaElements) |
| | | { |
| | | nameOrOIDs.add(schemaElement.getNameOrOID()); |
| | | } |
| | |
| | | private void updateSchemaOffline() throws OpenDsException |
| | | { |
| | | // Group the changes in the same schema file. |
| | | final Map<String, List<AttributeType>> hmAttrs = copy(attrsToAdd); |
| | | final Map<String, List<ObjectClass>> hmOcs = copy(ocsToAdd); |
| | | final Set<String> allFileNames = new LinkedHashSet<>(hmAttrs.keySet()); |
| | | allFileNames.addAll(hmOcs.keySet()); |
| | | final Map<String, List<SomeSchemaElement>> mapAttrs = copy(attributeTypesToSchemaElements(attrsToAdd)); |
| | | final Map<String, List<SomeSchemaElement>> mapClasses = copy(objectClassesToSchemaElements(ocsToAdd)); |
| | | final Set<String> allFileNames = new LinkedHashSet<>(mapAttrs.keySet()); |
| | | allFileNames.addAll(mapClasses.keySet()); |
| | | |
| | | for (String fileName : allFileNames) |
| | | { |
| | | List<AttributeType> attrs = get(hmAttrs, fileName); |
| | | List<ObjectClass> ocs = get(hmOcs, fileName); |
| | | List<AttributeType> attrs = schemaElementsToAttributeTypes(get(mapAttrs, fileName)); |
| | | List<ObjectClass> ocs = schemaElementsToObjectClasses(get(mapClasses, fileName)); |
| | | |
| | | if ("".equals(fileName)) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private <T extends SchemaFileElement> List<T> get(Map<String, List<T>> hmElems, String fileName) |
| | | private List<SomeSchemaElement> get(Map<String, List<SomeSchemaElement>> hmElems, String fileName) |
| | | { |
| | | List<T> elems = hmElems.get(fileName); |
| | | List<SomeSchemaElement> elems = hmElems.get(fileName); |
| | | if (elems != null) |
| | | { |
| | | return elems; |
| | |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | private <T extends SchemaFileElement> Map<String, List<T>> copy(Set<T> elemsToAdd) |
| | | private Map<String, List<SomeSchemaElement>> copy(Set<SomeSchemaElement> elemsToAdd) |
| | | { |
| | | Map<String, List<T>> hmElems = new LinkedHashMap<>(); |
| | | for (T elem : elemsToAdd) |
| | | Map<String, List<SomeSchemaElement>> hmElems = new LinkedHashMap<>(); |
| | | for (SomeSchemaElement elem : elemsToAdd) |
| | | { |
| | | String fileName = CommonSchemaElements.getSchemaFile(elem); |
| | | String fileName = elem.getSchemaFile(); |
| | | if (fileName == null) |
| | | { |
| | | fileName = ""; |
| | | } |
| | | List<T> elems = hmElems.get(fileName); |
| | | List<SomeSchemaElement> elems = hmElems.get(fileName); |
| | | if (elems == null) |
| | | { |
| | | elems = new ArrayList<>(); |
| | |
| | | |
| | | private void addAttributeOnline(final AttributeType attribute) throws OpenDsException |
| | | { |
| | | addSchemaElementOnline(attribute, INFO_CTRL_PANEL_CREATING_ATTRIBUTE_PROGRESS.get(attribute.getNameOrOID())); |
| | | addSchemaElementOnline(new SomeSchemaElement(attribute), |
| | | INFO_CTRL_PANEL_CREATING_ATTRIBUTE_PROGRESS.get(attribute.getNameOrOID())); |
| | | } |
| | | |
| | | private void addObjectClassOnline(final ObjectClass objectClass) throws OpenDsException |
| | | { |
| | | addSchemaElementOnline(objectClass, INFO_CTRL_PANEL_CREATING_OBJECTCLASS_PROGRESS.get(objectClass.getNameOrOID())); |
| | | addSchemaElementOnline(new SomeSchemaElement(objectClass), |
| | | INFO_CTRL_PANEL_CREATING_OBJECTCLASS_PROGRESS.get(objectClass.getNameOrOID())); |
| | | } |
| | | |
| | | private void addSchemaElementOnline(final CommonSchemaElements schemaElement, final LocalizableMessage progressMsg) |
| | | private void addSchemaElementOnline(final SomeSchemaElement schemaElement, final LocalizableMessage progressMsg) |
| | | throws OpenDsException |
| | | { |
| | | SwingUtilities.invokeLater(new Runnable() |
| | |
| | | }); |
| | | try |
| | | { |
| | | final BasicAttribute attr = new BasicAttribute(getAttributeName(schemaElement)); |
| | | final BasicAttribute attr = new BasicAttribute(schemaElement.getAttributeName()); |
| | | attr.add(getElementDefinition(schemaElement)); |
| | | final ModificationItem mod = new ModificationItem(DirContext.ADD_ATTRIBUTE, attr); |
| | | getInfo().getDirContext().modifyAttributes( |
| | |
| | | }); |
| | | } |
| | | |
| | | private String getValueOffline(CommonSchemaElements element) |
| | | private String getValueOffline(SomeSchemaElement element) |
| | | { |
| | | final Map<String, List<String>> props = element.getExtraProperties(); |
| | | List<String> previousValues = props.get(ServerConstants.SCHEMA_PROPERTY_FILENAME); |
| | | setExtraProperty(element, ServerConstants.SCHEMA_PROPERTY_FILENAME, null); |
| | | element.setExtraPropertySingleValue(null, ServerConstants.SCHEMA_PROPERTY_FILENAME, null); |
| | | String attributeWithoutFileDefinition = getElementDefinition(element); |
| | | |
| | | if (previousValues != null && !previousValues.isEmpty()) |
| | | { |
| | | element.setExtraProperty(ServerConstants.SCHEMA_PROPERTY_FILENAME, new ArrayList<String>(previousValues)); |
| | | element.setExtraPropertyMultipleValues(null, |
| | | ServerConstants.SCHEMA_PROPERTY_FILENAME, new ArrayList<String>(previousValues)); |
| | | } |
| | | return attributeWithoutFileDefinition; |
| | | } |
| | | |
| | | private String getElementDefinition(CommonSchemaElements element) |
| | | private String getElementDefinition(SomeSchemaElement element) |
| | | { |
| | | final List<String> names = new ArrayList<>(element.getNormalizedNames()); |
| | | if (element instanceof AttributeType) |
| | | final List<String> names = new ArrayList<>(); |
| | | for (final String name : element.getNames()) |
| | | { |
| | | return getAttributeTypeDefinition((AttributeType) element, names); |
| | | names.add(StaticUtils.toLowerCase(name)); |
| | | } |
| | | else if (element instanceof ObjectClass) |
| | | { |
| | | return getObjectClassDefinition((ObjectClass) element, names); |
| | | } |
| | | else |
| | | { |
| | | throw new IllegalArgumentException("Unsupported schema element: " + element.getClass().getName()); |
| | | } |
| | | return element.isAttributeType() |
| | | ? getAttributeTypeDefinition(element.getAttributeType(), names) |
| | | : getObjectClassDefinition(element.getObjectClass(), names); |
| | | } |
| | | |
| | | private String getAttributeTypeDefinition(final AttributeType attributeType, final List<String> names) |
| | |
| | | appendCollection(buffer, "NAME", names); |
| | | appendDescription(buffer, objectClass.getDescription()); |
| | | appendIfTrue(buffer, " OBSOLETE", objectClass.isObsolete()); |
| | | appendOIDs(buffer, "SUP", objectClass.getSuperiorClasses()); |
| | | appendOIDs(buffer, "SUP", objectClassesToSchemaElements(objectClass.getSuperiorClasses())); |
| | | appendIfNotNull(buffer, " ", objectClass.getObjectClassType()); |
| | | appendOIDs(buffer, "MUST", objectClass.getRequiredAttributes()); |
| | | appendOIDs(buffer, "MAY", objectClass.getOptionalAttributes()); |
| | | appendOIDs(buffer, "MUST", attributeTypesToSchemaElements(objectClass.getRequiredAttributes())); |
| | | appendOIDs(buffer, "MAY", attributeTypesToSchemaElements(objectClass.getOptionalAttributes())); |
| | | appendExtraProperties(buffer, objectClass.getExtraProperties()); |
| | | buffer.append(")"); |
| | | |
| | | return buffer.toString(); |
| | | } |
| | | |
| | | private <T extends CommonSchemaElements> void appendOIDs(final StringBuilder buffer, final String label, |
| | | final Collection<T> schemaElements) |
| | | private void appendOIDs(final StringBuilder buffer, final String label, |
| | | final Collection<SomeSchemaElement> schemaElements) |
| | | { |
| | | if (!schemaElements.isEmpty()) |
| | | { |
| | | final Iterator<T> iterator = schemaElements.iterator(); |
| | | final Iterator<SomeSchemaElement> iterator = schemaElements.iterator(); |
| | | final String firstOID = iterator.next().getOID(); |
| | | buffer.append(" ").append(label).append(" ( ").append(firstOID); |
| | | while (iterator.hasNext()) |
| | |
| | | } |
| | | } |
| | | |
| | | private Set<SomeSchemaElement> objectClassesToSchemaElements(final Collection<ObjectClass> classes) |
| | | { |
| | | Set<SomeSchemaElement> elements = new HashSet<>(); |
| | | for (ObjectClass objectClass : classes) |
| | | { |
| | | elements.add(new SomeSchemaElement(objectClass)); |
| | | } |
| | | return elements; |
| | | } |
| | | |
| | | private Set<SomeSchemaElement> attributeTypesToSchemaElements(final Collection<AttributeType> types) |
| | | { |
| | | Set<SomeSchemaElement> elements = new HashSet<>(); |
| | | for (AttributeType type : types) |
| | | { |
| | | elements.add(new SomeSchemaElement(type)); |
| | | } |
| | | return elements; |
| | | } |
| | | |
| | | private List<AttributeType> schemaElementsToAttributeTypes(final Collection<SomeSchemaElement> elements) |
| | | { |
| | | List<AttributeType> types = new ArrayList<>(); |
| | | for (SomeSchemaElement element : elements) |
| | | { |
| | | types.add(element.getAttributeType()); |
| | | } |
| | | return types; |
| | | } |
| | | |
| | | private List<ObjectClass> schemaElementsToObjectClasses(final Collection<SomeSchemaElement> elements) |
| | | { |
| | | List<ObjectClass> classes = new ArrayList<>(); |
| | | for (SomeSchemaElement element : elements) |
| | | { |
| | | classes.add(element.getObjectClass()); |
| | | } |
| | | return classes; |
| | | } |
| | | |
| | | private void appendIfTrue(final StringBuilder buffer, final String label, final boolean labelIsActive) |
| | | { |
| | | if (labelIsActive) |
| | |
| | | } |
| | | } |
| | | |
| | | private void printEquivalentCommandLineToAddOnline(CommonSchemaElements element) |
| | | private void printEquivalentCommandLineToAddOnline(SomeSchemaElement element) |
| | | { |
| | | List<String> args = new ArrayList<>(); |
| | | args.add("-a"); |
| | |
| | | args.add(getNoPropertiesFileArgument()); |
| | | |
| | | final String equivalentCmdLine = getEquivalentCommandLine(getCommandLinePath("ldapmodify"), args); |
| | | final String elementID = element.getNameOrOID(); |
| | | final LocalizableMessage msg = element instanceof AttributeType ? |
| | | INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_ATTRIBUTE_ONLINE.get(elementID) |
| | | : INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_OBJECTCLASS_ONLINE.get(elementID); |
| | | final StringBuilder sb = new StringBuilder(); |
| | | final String attName = getAttributeName(element); |
| | | sb.append(msg).append("<br><b>") |
| | | final String attName = element.getAttributeName(); |
| | | final String elementId = element.getNameOrOID(); |
| | | final LocalizableMessage message = element.isAttributeType() |
| | | ? INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_ATTRIBUTE_ONLINE.get(elementId) |
| | | : INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_OBJECTCLASS_ONLINE.get(elementId); |
| | | sb.append(message).append("<br><b>") |
| | | .append(equivalentCmdLine).append("<br>") |
| | | .append("dn: cn=schema<br>") |
| | | .append("changetype: modify<br>") |
| | |
| | | getProgressDialog().appendProgressHtml(Utilities.applyFont(sb.toString(), ColorAndFontConstants.progressFont)); |
| | | } |
| | | |
| | | private String getAttributeName(CommonSchemaElements element) |
| | | { |
| | | return element instanceof AttributeType ? ConfigConstants.ATTR_ATTRIBUTE_TYPES : ConfigConstants.ATTR_OBJECTCLASSES; |
| | | } |
| | | |
| | | private void updateSchemaOffline( |
| | | String file, final List<AttributeType> attributes, final List<ObjectClass> objectClasses) throws OpenDsException |
| | | { |
| | | final List<CommonSchemaElements> schemaElements = new ArrayList<CommonSchemaElements>(attributes); |
| | | schemaElements.addAll(objectClasses); |
| | | final List<SomeSchemaElement> schemaElements = |
| | | new ArrayList<SomeSchemaElement>(attributeTypesToSchemaElements(attributes)); |
| | | schemaElements.addAll(objectClassesToSchemaElements(objectClasses)); |
| | | if (file == null) |
| | | { |
| | | file = ConfigConstants.FILE_USER_SCHEMA_ELEMENTS; |
| | |
| | | updateSchemaUndefinedFile(fileName, schemaElements); |
| | | } |
| | | |
| | | for (CommonSchemaElements schemaElement : schemaElements) |
| | | for (SomeSchemaElement schemaElement : schemaElements) |
| | | { |
| | | notifyConfigurationElementCreated(schemaElement); |
| | | } |
| | |
| | | } |
| | | |
| | | private String equivalentCommandToAddOffline( |
| | | String schemaFile, boolean isSchemaFileDefined, List<CommonSchemaElements> schemaElements) |
| | | String schemaFile, boolean isSchemaFileDefined, List<SomeSchemaElement> schemaElements) |
| | | { |
| | | List<String> names = getElementsNameOrOID(schemaElements); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | for (CommonSchemaElements schemaElement : schemaElements) |
| | | for (SomeSchemaElement schemaElement : schemaElements) |
| | | { |
| | | sb.append(getAttributeName(schemaElement)).append(": ").append(getValueOffline(schemaElement)).append("<br>"); |
| | | sb.append(schemaElement.getAttributeName()).append(": ").append(getValueOffline(schemaElement)).append("<br>"); |
| | | } |
| | | sb.append("</b><br><br>"); |
| | | |
| | |
| | | * @throws OpenDsException |
| | | * if an error occurs updating the schema file. |
| | | */ |
| | | private void updateSchemaFile(String schemaFile, List<CommonSchemaElements> schemaElements) |
| | | private void updateSchemaFile(String schemaFile, List<SomeSchemaElement> schemaElements) |
| | | throws OpenDsException |
| | | { |
| | | try (final LDIFExportConfig exportConfig = new LDIFExportConfig(schemaFile, ExistingFileBehavior.OVERWRITE)) |
| | |
| | | } |
| | | } |
| | | |
| | | private void addElementsToEntry(List<CommonSchemaElements> schemaElements, Entry schemaEntry) |
| | | private void addElementsToEntry(List<SomeSchemaElement> schemaElements, Entry schemaEntry) |
| | | throws DirectoryException |
| | | { |
| | | for (CommonSchemaElements schemaElement : schemaElements) |
| | | for (SomeSchemaElement schemaElement : schemaElements) |
| | | { |
| | | final Modification mod = new Modification(ModificationType.ADD, |
| | | Attributes.create(getAttributeName(schemaElement).toLowerCase(), getValueOffline(schemaElement))); |
| | | Attributes.create(schemaElement.getAttributeName().toLowerCase(), getValueOffline(schemaElement))); |
| | | schemaEntry.applyModification(mod); |
| | | } |
| | | } |
| | | |
| | | private void updateSchemaUndefinedFile(String schemaFile, List<CommonSchemaElements> schemaElements) |
| | | private void updateSchemaUndefinedFile(String schemaFile, List<SomeSchemaElement> schemaElements) |
| | | throws OfflineUpdateException |
| | | { |
| | | try (LDIFExportConfig exportConfig = new LDIFExportConfig(schemaFile, ExistingFileBehavior.FAIL)) |
| | | { |
| | | List<String> lines = getSchemaEntryLines(); |
| | | for (final CommonSchemaElements schemaElement : schemaElements) |
| | | for (final SomeSchemaElement schemaElement : schemaElements) |
| | | { |
| | | lines.add(getAttributeName(schemaElement) + ": " + getValueOffline(schemaElement)); |
| | | lines.add(schemaElement.getAttributeName() + ": " + getValueOffline(schemaElement)); |
| | | } |
| | | for (String line : lines) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | |
| | | import org.opends.quicksetup.ui.CertificateDialog; |
| | | import org.opends.quicksetup.util.UIKeyStore; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.LDAPException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.quicksetup.Installation; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.OpenDsException; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | |
| | | import org.opends.quicksetup.Installation; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.opends.server.types.FilterType; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.OpenDsException; |
| | |
| | | configurationAttrNames.clear(); |
| | | customAttrNames.clear(); |
| | | |
| | | for (AttributeType attr : schema.getAttributeTypes().values()) |
| | | for (AttributeType attr : schema.getAttributeTypes()) |
| | | { |
| | | String name = attr.getPrimaryName(); |
| | | SomeSchemaElement element = new SomeSchemaElement(attr); |
| | | String name = attr.getNameOrOID(); |
| | | if (!isDefined(name)) |
| | | { |
| | | if (Utilities.isStandard(attr)) |
| | | if (Utilities.isStandard(element)) |
| | | { |
| | | standardAttrNames.add(name); |
| | | } |
| | | else if (Utilities.isConfiguration(attr)) |
| | | else if (Utilities.isConfiguration(element)) |
| | | { |
| | | configurationAttrNames.add(name); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage getTitle() |
| | | { |
| | | return INFO_CTRL_PANEL_ATTRIBUTE_SYNTAX_TITLE.get(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return usedByAttributes; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void configurationChanged(ConfigurationChangeEvent ev) |
| | | { |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void okClicked() |
| | | { |
| | | } |
| | |
| | | |
| | | MouseAdapter clickListener = new MouseAdapter() |
| | | { |
| | | @Override |
| | | public void mouseClicked(MouseEvent ev) |
| | | { |
| | | if (ev.getClickCount() == 1) |
| | |
| | | KeyAdapter keyListener = new KeyAdapter() |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void keyTyped(KeyEvent ev) |
| | | { |
| | | if (ev.getKeyChar() == KeyEvent.VK_SPACE || |
| | |
| | | |
| | | Comparator<String> lowerCaseComparator = new LowerCaseComparator(); |
| | | TreeSet<String> attributes = new TreeSet<>(lowerCaseComparator); |
| | | for (AttributeType attr : schema.getAttributeTypes().values()) |
| | | for (AttributeType attr : schema.getAttributeTypes()) |
| | | { |
| | | if (syntax == attr.getSyntax()) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | |
| | | import org.opends.guitools.controlpanel.util.LDAPEntryReader; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.OpenDsException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.Dimension; |
| | |
| | | import java.util.Collection; |
| | | import java.util.Comparator; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.guitools.controlpanel.browser.IconPool; |
| | |
| | | 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.types.AttributeType; |
| | | import org.opends.server.types.CommonSchemaElements; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | |
| | |
| | | |
| | | private JPopupMenu popup; |
| | | |
| | | private CommonSchemaElements lastCreatedElement; |
| | | private SomeSchemaElement lastCreatedElement; |
| | | |
| | | private final CategoryTreeNode attributes = new CategoryTreeNode(INFO_CTRL_PANEL_ATTRIBUTES_CATEGORY_NODE.get()); |
| | | private final CategoryTreeNode objectClasses = |
| | |
| | | { |
| | | if (mustAdd(oc)) |
| | | { |
| | | SomeSchemaElement element = new SomeSchemaElement(oc); |
| | | String name = oc.getPrimaryName(); |
| | | if (Utilities.isStandard(oc)) |
| | | if (Utilities.isStandard(element)) |
| | | { |
| | | standardOcNames.add(name); |
| | | hmStandardOcs.put(name, new StandardObjectClassTreeNode(name, oc)); |
| | | } |
| | | else if (Utilities.isConfiguration(oc)) |
| | | else if (Utilities.isConfiguration(element)) |
| | | { |
| | | configurationOcNames.add(name); |
| | | hmConfigurationOcs.put(name, new ConfigurationObjectClassTreeNode(name, oc)); |
| | |
| | | Map<String, ConfigurationAttributeTreeNode> hmConfigurationAttrs = new HashMap<>(); |
| | | Set<String> customAttrNames = new TreeSet<>(lowerCaseComparator); |
| | | Map<String, CustomAttributeTreeNode> hmCustomAttrs = new HashMap<>(); |
| | | for (AttributeType attr : lastSchema.getAttributeTypes().values()) |
| | | for (AttributeType attr : lastSchema.getAttributeTypes()) |
| | | { |
| | | SomeSchemaElement element = new SomeSchemaElement(attr); |
| | | if (mustAdd(attr)) |
| | | { |
| | | String name = attr.getPrimaryName(); |
| | | if (Utilities.isStandard(attr)) |
| | | String name = attr.getNameOrOID(); |
| | | if (Utilities.isStandard(element)) |
| | | { |
| | | standardAttrNames.add(name); |
| | | hmStandardAttrs.put(name, new StandardAttributeTreeNode(name, attr)); |
| | | } |
| | | else if (Utilities.isConfiguration(attr)) |
| | | else if (Utilities.isConfiguration(element)) |
| | | { |
| | | configurationAttrNames.add(name); |
| | | hmConfigurationAttrs.put(name, new ConfigurationAttributeTreeNode(name, attr)); |
| | |
| | | |
| | | Set<String> matchingRuleNames = new TreeSet<>(lowerCaseComparator); |
| | | Map<String, MatchingRuleTreeNode> hmMatchingRules = new HashMap<>(); |
| | | for (MatchingRule matchingRule : lastSchema.getMatchingRules().values()) |
| | | for (MatchingRule matchingRule : lastSchema.getMatchingRules()) |
| | | { |
| | | if (mustAdd(matchingRule)) |
| | | { |
| | |
| | | |
| | | Set<String> syntaxNames = new TreeSet<>(lowerCaseComparator); |
| | | Map<String, AttributeSyntaxTreeNode> hmSyntaxes = new HashMap<>(); |
| | | for (Syntax syntax : lastSchema.getSyntaxes().values()) |
| | | for (Syntax syntax : lastSchema.getSyntaxes()) |
| | | { |
| | | if (mustAdd(syntax)) |
| | | { |
| | |
| | | { |
| | | if (lastCreatedElement != null) |
| | | { |
| | | if (node instanceof CustomObjectClassTreeNode && lastCreatedElement instanceof ObjectClass) |
| | | { |
| | | if (name.equals(lastCreatedElement.getNameOrOID())) |
| | | { |
| | | newSelectionPath = new TreePath(node.getPath()); |
| | | lastCreatedElement = null; |
| | | } |
| | | } |
| | | else if (node instanceof CustomAttributeTreeNode && lastCreatedElement instanceof AttributeType |
| | | if (node instanceof CustomObjectClassTreeNode |
| | | && name.equals(lastCreatedElement.getNameOrOID())) |
| | | { |
| | | newSelectionPath = new TreePath(node.getPath()); |
| | |
| | | |
| | | private boolean mustAddAttributeName(AttributeType attr, String attrName) |
| | | { |
| | | return mustAdd(attrName, attr.getOID(), attr.getPrimaryName(), attr.getNormalizedNames()); |
| | | return mustAdd(attrName, attr.getOID(), attr.getNameOrOID(), new HashSet<String>(attr.getNames())); |
| | | } |
| | | |
| | | private boolean mustAddObjectClassName(ObjectClass oc, String ocName) |
| | | { |
| | | return mustAdd(ocName, oc.getOID(), oc.getPrimaryName(), oc.getNormalizedNames()); |
| | | return mustAdd(ocName, oc.getOID(), oc.getNameOrOID(), oc.getNormalizedNames()); |
| | | } |
| | | |
| | | private boolean mustAdd(String name, String oid, String primaryName, Set<String> names) |
| | | /** Provided names may not be normalized. */ |
| | | private boolean mustAdd(String name, String oid, String primaryNameOrOID, Set<String> names) |
| | | { |
| | | List<String> values = new ArrayList<>(names.size() + 2); |
| | | values.add(oid); |
| | | if (primaryName != null) |
| | | if (!primaryNameOrOID.equals(oid)) |
| | | { |
| | | values.add(primaryName); |
| | | values.add(primaryNameOrOID); |
| | | } |
| | | values.addAll(names); |
| | | for (String v : names) |
| | | { |
| | | values.add(toLowerCase(v)); |
| | | } |
| | | |
| | | return matchFilter(values, name, false); |
| | | } |
| | |
| | | private void configurationElementCreated(ConfigurationElementCreatedEvent ev) |
| | | { |
| | | Object o = ev.getConfigurationObject(); |
| | | if (o instanceof CommonSchemaElements) |
| | | if (o instanceof SomeSchemaElement) |
| | | { |
| | | lastCreatedElement = (CommonSchemaElements) o; |
| | | lastCreatedElement = (SomeSchemaElement) o; |
| | | } |
| | | } |
| | | |
| | |
| | | // Analyze attributes |
| | | for (AttributeType attribute : attrsToDelete) |
| | | { |
| | | for (AttributeType attr : schema.getAttributeTypes().values()) |
| | | for (AttributeType attr : schema.getAttributeTypes()) |
| | | { |
| | | if (attribute.equals(attr.getSuperiorType())) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.guitools.controlpanel.util.Utilities.*; |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.types.CommonSchemaElements.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.awt.Component; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeUsage; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | |
| | | 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.types.AttributeType; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.ServerConstants; |
| | |
| | | void update(AttributeType attr, Schema schema) |
| | | { |
| | | ignoreChangeEvents = true; |
| | | String n = attr.getPrimaryName(); |
| | | if (n == null) |
| | | { |
| | | n = ""; |
| | | } |
| | | String n = attr.getNameOrOID(); |
| | | titlePanel.setDetails(LocalizableMessage.raw(n)); |
| | | name.setText(n); |
| | | |
| | |
| | | lastAliases.addAll(someAliases); |
| | | this.aliases.setText(Utilities.getStringFromCollection(someAliases, ", ")); |
| | | |
| | | String sOrigin = Utilities.getOrigin(attr); |
| | | SomeSchemaElement element = new SomeSchemaElement(attr); |
| | | String sOrigin = Utilities.getOrigin(element); |
| | | if (sOrigin == null) |
| | | { |
| | | sOrigin = ""; |
| | | } |
| | | origin.setText(sOrigin); |
| | | |
| | | String sFile = getSchemaFile(attr); |
| | | String sFile = element.getSchemaFile(); |
| | | if (sFile == null) |
| | | { |
| | | sFile = ""; |
| | |
| | | |
| | | LowerCaseComparator lowerCase = new LowerCaseComparator(); |
| | | Map<String, Syntax> syntaxNameMap = new TreeMap<>(lowerCase); |
| | | for (String key : schema.getSyntaxes().keySet()) |
| | | for (Syntax syntax : schema.getSyntaxes()) |
| | | { |
| | | Syntax syntax = schema.getSyntax(key); |
| | | String name = syntax.getName(); |
| | | if (name == null) |
| | | { |
| | |
| | | updateComboBoxModel(newSyntaxes, (DefaultComboBoxModel) syntax.getModel()); |
| | | |
| | | Map<String, AttributeType> attributeNameMap = new TreeMap<>(lowerCase); |
| | | for (String key : schema.getAttributeTypes().keySet()) |
| | | for (AttributeType attr : schema.getAttributeTypes()) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(key); |
| | | attributeNameMap.put(attr.getNameOrOID(), attr); |
| | | } |
| | | List<Object> newParents = new ArrayList<>(); |
| | |
| | | updateComboBoxModel(newParents, (DefaultComboBoxModel) parent.getModel()); |
| | | |
| | | final Map<String, MatchingRule> matchingRuleNameMap = new TreeMap<>(lowerCase); |
| | | for (String key : schema.getMatchingRules().keySet()) |
| | | for (MatchingRule rule : schema.getMatchingRules()) |
| | | { |
| | | MatchingRule rule = schema.getMatchingRule(key); |
| | | matchingRuleNameMap.put(rule.getNameOrOID(), rule); |
| | | } |
| | | |
| | | final List<MatchingRule> availableMatchingRules = new ArrayList<>(matchingRuleNameMap.values()); |
| | | JComboBox[] combos = {approximate, equality, ordering, substring}; |
| | | for (JComboBox<LocalizableMessage> combo : combos) |
| | | for (JComboBox combo : combos) |
| | | { |
| | | final DefaultComboBoxModel<LocalizableMessage> model = (DefaultComboBoxModel) combo.getModel(); |
| | | final DefaultComboBoxModel model = (DefaultComboBoxModel) combo.getModel(); |
| | | final List<Object> el = new ArrayList<Object>(availableMatchingRules); |
| | | el.add(0, model.getSize() != 0 ? model.getElementAt(0) : NO_MATCHING_RULE); |
| | | updateComboBoxModel(el, model); |
| | |
| | | TreeSet<String> dependentClasses = new TreeSet<>(); |
| | | if (schema != null) |
| | | { |
| | | for (AttributeType attr : schema.getAttributeTypes().values()) |
| | | for (AttributeType attr : schema.getAttributeTypes()) |
| | | { |
| | | if (attribute.equals(attr.getSuperiorType())) |
| | | { |
| | |
| | | |
| | | private AttributeType getNewAttribute() |
| | | { |
| | | return new AttributeType("", getAttributeName(), |
| | | getAllNames(), |
| | | getOID(), |
| | | getDescription(), |
| | | getSuperior(), |
| | | (Syntax)syntax.getSelectedItem(), |
| | | getMatchingRule(approximate), |
| | | getMatchingRule(equality), |
| | | getMatchingRule(ordering), |
| | | getMatchingRule(substring), |
| | | (AttributeUsage)usage.getSelectedItem(), |
| | | collective.isSelected(), nonModifiable.isSelected(), |
| | | obsolete.isSelected(), singleValued.isSelected(), |
| | | getExtraProperties()); |
| | | return new SchemaBuilder().buildAttributeType(getOID()) |
| | | .names(getAllNames()) |
| | | .description(getDescription()) |
| | | .superiorType(getSuperior().getNameOrOID()) |
| | | .syntax(((Syntax) syntax.getSelectedItem()).getOID()) |
| | | .approximateMatchingRule(getMatchingRule(approximate).getNameOrOID()) |
| | | .equalityMatchingRule(getMatchingRule(equality).getNameOrOID()) |
| | | .orderingMatchingRule(getMatchingRule(ordering).getNameOrOID()) |
| | | .substringMatchingRule(getMatchingRule(substring).getNameOrOID()) |
| | | .usage((AttributeUsage)usage.getSelectedItem()) |
| | | .collective(collective.isSelected()) |
| | | .obsolete(obsolete.isSelected()) |
| | | .noUserModification(nonModifiable.isSelected()) |
| | | .singleValue(singleValued.isSelected()) |
| | | .extraProperties(getExtraProperties()) |
| | | .addToSchema() |
| | | .toSchema() |
| | | .getAttributeType(getOID()); |
| | | } |
| | | |
| | | private void updateDefaultMatchingRuleNames() |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.SortableListModel; |
| | |
| | | import org.opends.guitools.controlpanel.ui.components.TitlePanel; |
| | | import org.opends.guitools.controlpanel.ui.renderer.SchemaElementComboBoxCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.ServerConstants; |
| | |
| | | lastAliases.addAll(aliases); |
| | | this.aliases.setText(Utilities.getStringFromCollection(aliases, ", ")); |
| | | |
| | | String sOrigin = Utilities.getOrigin(oc); |
| | | String sOrigin = Utilities.getOrigin(new SomeSchemaElement(oc)); |
| | | if (sOrigin == null) |
| | | { |
| | | sOrigin = ""; |
| | |
| | | attributes.getSelectedList2() |
| | | }; |
| | | attributes.getAvailableListModel().clear(); |
| | | Collection<AttributeType> allAttrs = |
| | | schema.getAttributeTypes().values(); |
| | | Collection<AttributeType> allAttrs = schema.getAttributeTypes(); |
| | | attributes.getAvailableListModel().addAll(allAttrs); |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | |
| | | import org.opends.server.admin.std.client.BackendIndexCfgClient; |
| | | import org.opends.server.admin.std.client.PluggableBackendCfgClient; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.OpenDsException; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | |
| | | import org.opends.server.tools.tasks.TaskEntry; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | |
| | | import java.awt.event.KeyEvent; |
| | | import java.awt.event.MouseAdapter; |
| | | import java.awt.event.MouseEvent; |
| | | import java.util.Comparator; |
| | | import java.util.TreeSet; |
| | | |
| | | import javax.swing.DefaultListModel; |
| | |
| | | import org.opends.guitools.controlpanel.util.LowerCaseComparator; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | |
| | | oid.setText(matchingRule.getOID()); |
| | | Syntax s = null; |
| | | String syntaxOID = matchingRule.getSyntax().getOID(); |
| | | for (Syntax candidate : schema.getSyntaxes().values()) |
| | | for (Syntax candidate : schema.getSyntaxes()) |
| | | { |
| | | if (candidate.getOID().equals(syntaxOID)) |
| | | { |
| | |
| | | } |
| | | description.setText(n); |
| | | |
| | | Comparator<String> lowerCaseComparator = new LowerCaseComparator(); |
| | | TreeSet<String> attributes = new TreeSet<>(lowerCaseComparator); |
| | | for (AttributeType attr : schema.getAttributeTypes().values()) |
| | | TreeSet<String> attributes = new TreeSet<>(new LowerCaseComparator()); |
| | | for (AttributeType attr : schema.getAttributeTypes()) |
| | | { |
| | | if (matchingRule.equals(attr.getApproximateMatchingRule()) || |
| | | matchingRule.equals(attr.getEqualityMatchingRule()) || |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.schema.AttributeUsage; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationElementCreatedListener; |
| | |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.ServerConstants; |
| | |
| | | schema = s; |
| | | Map<String, Syntax> syntaxNameMap = new HashMap<>(); |
| | | |
| | | for (String key : schema.getSyntaxes().keySet()) |
| | | for (Syntax syntax : schema.getSyntaxes()) |
| | | { |
| | | Syntax syntax = schema.getSyntax(key); |
| | | String name = syntax.getName(); |
| | | if (name == null) |
| | | { |
| | |
| | | updateComboBoxModel(newSyntaxes, (DefaultComboBoxModel) syntax.getModel()); |
| | | |
| | | Map<String, AttributeType> attributeNameMap = new HashMap<>(); |
| | | for (String key : schema.getAttributeTypes().keySet()) |
| | | for (AttributeType attr : schema.getAttributeTypes()) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(key); |
| | | attributeNameMap.put(attr.getNameOrOID(), attr); |
| | | } |
| | | orderedKeys.clear(); |
| | |
| | | |
| | | final List<MatchingRule> availableMatchingRules = new ArrayList<>(); |
| | | final Map<String, MatchingRule> matchingRuleNameMap = new HashMap<>(); |
| | | for (String key : schema.getMatchingRules().keySet()) |
| | | for (MatchingRule rule : schema.getMatchingRules()) |
| | | { |
| | | MatchingRule rule = schema.getMatchingRule(key); |
| | | matchingRuleNameMap.put(rule.getNameOrOID(), rule); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | final JComboBox[] combos = { approximate, equality, ordering, substring }; |
| | | for (int i = 0; i < combos.length; i++) |
| | | for (JComboBox combo : combos) |
| | | { |
| | | final DefaultComboBoxModel model = (DefaultComboBoxModel) combos[i].getModel(); |
| | | final DefaultComboBoxModel model = (DefaultComboBoxModel) combo.getModel(); |
| | | final List<Object> el = new ArrayList<Object>(availableMatchingRules); |
| | | el.add(0, model.getSize() == 0 ? NO_MATCHING_RULE : model.getElementAt(0)); |
| | | updateComboBoxModel(el, model); |
| | |
| | | static LocalizableMessage getSchemaElementType(String name, Schema schema) |
| | | { |
| | | final String lowerCase = name.toLowerCase(); |
| | | if (schema.getAttributeType(lowerCase) != null) |
| | | if (schema.hasAttributeType(lowerCase)) |
| | | { |
| | | return INFO_CTRL_PANEL_TYPE_ATTRIBUTE.get(); |
| | | } |
| | |
| | | return INFO_CTRL_PANEL_TYPE_MATCHING_RULE.get(); |
| | | } |
| | | |
| | | for (Syntax attr : schema.getSyntaxes().values()) |
| | | for (Syntax attr : schema.getSyntaxes()) |
| | | { |
| | | if (name.equalsIgnoreCase(attr.getName())) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | for (MatchingRule rule : schema.getMatchingRules().values()) |
| | | for (MatchingRule rule : schema.getMatchingRules()) |
| | | { |
| | | String n = rule.getNameOrOID(); |
| | | if (n != null && n.equalsIgnoreCase(name)) |
| | |
| | | |
| | | private AttributeType getAttribute() |
| | | { |
| | | return new AttributeType("", |
| | | getAttributeName(), |
| | | getAllNames(), |
| | | getOID(), |
| | | getDescription(), |
| | | getSuperior(), |
| | | (Syntax) syntax.getSelectedItem(), |
| | | getApproximateMatchingRule(), |
| | | getEqualityMatchingRule(), |
| | | getOrderingMatchingRule(), |
| | | getSubstringMatchingRule(), |
| | | (AttributeUsage) usage.getSelectedItem(), |
| | | collective.isSelected(), |
| | | nonModifiable.isSelected(), |
| | | obsolete.isSelected(), |
| | | singleValued.isSelected(), |
| | | getExtraProperties()); |
| | | return new SchemaBuilder().buildAttributeType(getOID()) |
| | | .names(getAllNames()) |
| | | .description(getDescription()) |
| | | .superiorType(getSuperior().getNameOrOID()) |
| | | .syntax(((Syntax) syntax.getSelectedItem()).getOID()) |
| | | .approximateMatchingRule(getApproximateMatchingRule().getOID()) |
| | | .equalityMatchingRule(getEqualityMatchingRule().getOID()) |
| | | .orderingMatchingRule(getOrderingMatchingRule().getOID()) |
| | | .substringMatchingRule(getSubstringMatchingRule().getOID()) |
| | | .usage((AttributeUsage)usage.getSelectedItem()) |
| | | .collective(collective.isSelected()) |
| | | .obsolete(obsolete.isSelected()) |
| | | .noUserModification(nonModifiable.isSelected()) |
| | | .singleValue(singleValued.isSelected()) |
| | | .extraProperties(getExtraProperties()) |
| | | .addToSchema() |
| | | .toSchema() |
| | | .getAttributeType(getOID()); |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | |
| | | import org.opends.server.admin.std.client.PluggableBackendCfgClient; |
| | | import org.opends.server.admin.std.meta.BackendIndexCfgDefn; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.types.Schema; |
| | |
| | | TreeSet<String> standardAttrNames = new TreeSet<>(); |
| | | TreeSet<String> configurationAttrNames = new TreeSet<>(); |
| | | TreeSet<String> customAttrNames = new TreeSet<>(); |
| | | for (AttributeType attr : schema.getAttributeTypes().values()) |
| | | for (AttributeType attr : schema.getAttributeTypes()) |
| | | { |
| | | String name = attr.getPrimaryName(); |
| | | SomeSchemaElement element = new SomeSchemaElement(attr); |
| | | String name = attr.getNameOrOID(); |
| | | if (!indexExists(backend, name)) |
| | | { |
| | | if (Utilities.isStandard(attr)) |
| | | if (Utilities.isStandard(element)) |
| | | { |
| | | standardAttrNames.add(name); |
| | | } |
| | | else if (Utilities.isConfiguration(attr)) |
| | | else if (Utilities.isConfiguration(element)) |
| | | { |
| | | configurationAttrNames.add(name); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | |
| | | import org.opends.guitools.controlpanel.ui.renderer.SchemaElementComboBoxCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.ServerConstants; |
| | |
| | | attributes.getSelectedList2() |
| | | }; |
| | | attributes.getAvailableListModel().clear(); |
| | | Collection<AttributeType> allAttrs = |
| | | schema.getAttributeTypes().values(); |
| | | Collection<AttributeType> allAttrs = schema.getAttributeTypes(); |
| | | attributes.getAvailableListModel().addAll(allAttrs); |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Set; |
| | |
| | | import javax.swing.border.Border; |
| | | import javax.swing.border.EmptyBorder; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.guitools.controlpanel.event.SchemaElementSelectionEvent; |
| | | import org.opends.guitools.controlpanel.event.SchemaElementSelectionListener; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | |
| | |
| | | */ |
| | | protected Set<String> getAliases(AttributeType attr) |
| | | { |
| | | return getAliases(attr.getNormalizedNames(), attr.getPrimaryName()); |
| | | return getAliases(attr.getNames(), toLowerCase(attr.getNameOrOID())); |
| | | } |
| | | |
| | | /** |
| | |
| | | return getAliases(oc.getNormalizedNames(), oc.getPrimaryName()); |
| | | } |
| | | |
| | | private Set<String> getAliases(Set<String> names, String primaryName) |
| | | private Set<String> getAliases(Iterable<String> names, String primaryName) |
| | | { |
| | | Set<String> aliases = new LinkedHashSet<>(); |
| | | if (primaryName == null) |
| | |
| | | { |
| | | if (!name.equalsIgnoreCase(primaryName)) |
| | | { |
| | | aliases.add(name); |
| | | aliases.add(toLowerCase(name)); |
| | | } |
| | | } |
| | | return aliases; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | |
| | | import org.opends.guitools.controlpanel.ui.nodes.DndBrowserNodes; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.LDIFReader; |
| | |
| | | Schema schema = getInfo().getServerDescriptor().getSchema(); |
| | | if (schema != null) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(attrName.toLowerCase()); |
| | | if (attr != null) |
| | | if (schema.hasAttributeType(attrName.toLowerCase())) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(attrName.toLowerCase()); |
| | | isSingleValue = attr.isSingleValue(); |
| | | } |
| | | } |
| | |
| | | Schema schema = getInfo().getServerDescriptor().getSchema(); |
| | | if (schema != null) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(attrName.toLowerCase()); |
| | | if (attr != null) |
| | | if (schema.hasAttributeType(attrName.toLowerCase())) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(attrName.toLowerCase()); |
| | | List<Object> ocs = sr.getAttributeValues( |
| | | ServerConstants.OBJECTCLASS_ATTRIBUTE_TYPE_NAME); |
| | | for (Object o : ocs) |
| | |
| | | Schema schema = getInfo().getServerDescriptor().getSchema(); |
| | | if (schema != null) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(attrName.toLowerCase()); |
| | | if (attr != null) |
| | | if (schema.hasAttributeType(attrName.toLowerCase())) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(attrName.toLowerCase()); |
| | | // There is no name for a regex syntax. |
| | | String syntaxName = attr.getSyntax().getName(); |
| | | if (syntaxName!=null) { |
| | |
| | | { |
| | | String aName = |
| | | Utilities.getAttributeNameWithoutOptions(attrName); |
| | | AttributeType attr = |
| | | schema.getAttributeType(aName.toLowerCase()); |
| | | if (attr != null) |
| | | if (schema.hasAttributeType(aName.toLowerCase())) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(aName.toLowerCase()); |
| | | attributeTypes.add(attr); |
| | | attributeNames.add(attrName); |
| | | attributeValues.add(ByteString.valueOfUtf8((String) o)); |
| | |
| | | this.attrName = attrName; |
| | | } |
| | | |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | addBrowseClicked(attrName, tc); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | |
| | |
| | | */ |
| | | public void update(AttributeType attr, Schema schema) |
| | | { |
| | | String n = attr.getPrimaryName(); |
| | | if (n == null) |
| | | { |
| | | n = NOT_APPLICABLE.toString(); |
| | | } |
| | | String n = attr.getNameOrOID(); |
| | | titlePanel.setDetails(LocalizableMessage.raw(n)); |
| | | name.setText(n); |
| | | AttributeType superior = attr.getSuperiorType(); |
| | |
| | | } |
| | | else |
| | | { |
| | | n = superior.getPrimaryName(); |
| | | } |
| | | if (n == null) |
| | | { |
| | | n = NOT_APPLICABLE.toString(); |
| | | n = superior.getNameOrOID(); |
| | | } |
| | | parent.setText(n); |
| | | oid.setText(attr.getOID()); |
| | | origin.setText(StandardObjectClassPanel.getOrigin(attr).toString()); |
| | | origin.setText(StandardObjectClassPanel.getOrigin(new SomeSchemaElement(attr)).toString()); |
| | | n = attr.getDescription(); |
| | | if (n == null) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.CommonSchemaElements; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | import static org.opends.server.types.CommonSchemaElements.*; |
| | | |
| | | /** |
| | | * The panel that displays a standard object class definition. |
| | | * |
| | |
| | | * @param element the schema element. |
| | | * @return the message describing the schema element origin (file, RFC, etc.). |
| | | */ |
| | | static LocalizableMessage getOrigin(CommonSchemaElements element) |
| | | static LocalizableMessage getOrigin(SomeSchemaElement element) |
| | | { |
| | | LocalizableMessageBuilder returnValue = new LocalizableMessageBuilder(); |
| | | String fileName = getSchemaFile(element); |
| | | String fileName = element.getSchemaFile(); |
| | | String xOrigin = Utilities.getOrigin(element); |
| | | if (xOrigin != null) |
| | | { |
| | |
| | | name.setText(n); |
| | | parent.setText(getSuperiorText(oc)); |
| | | oid.setText(oc.getOID()); |
| | | origin.setText(getOrigin(oc).toString()); |
| | | origin.setText(getOrigin(new SomeSchemaElement(oc)).toString()); |
| | | n = oc.getDescription(); |
| | | if (n == null) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.opends.server.util.ServerConstants; |
| | |
| | | { |
| | | String aName = |
| | | Utilities.getAttributeNameWithoutOptions(attrName); |
| | | AttributeType attr = |
| | | schema.getAttributeType(aName.toLowerCase()); |
| | | if (attr != null) |
| | | if (schema.hasAttributeType(aName.toLowerCase())) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(aName.toLowerCase()); |
| | | attributeTypes.add(attr); |
| | | attributeNames.add(attrName); |
| | | attributeValues.add(ByteString.valueOfUtf8((String) o)); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | |
| | | import org.opends.guitools.controlpanel.ui.nodes.BasicNode; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | { |
| | | schemaReadOnlyAttributes.clear(); |
| | | schemaReadOnlyAttributesLowerCase.clear(); |
| | | for (AttributeType attr : schema.getAttributeTypes().values()) |
| | | for (AttributeType attr : schema.getAttributeTypes()) |
| | | { |
| | | if (attr.isNoUserModification()) |
| | | { |
| | |
| | | // Check all the attributes that we consider binaries. |
| | | if (schema != null) |
| | | { |
| | | AttributeType attr = schema.getAttributeType( |
| | | Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase()); |
| | | if (attr != null) |
| | | String attributeName = Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase(); |
| | | if (schema.hasAttributeType(attributeName)) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(attributeName); |
| | | Syntax syntax = attr.getSyntax(); |
| | | if (syntax != null) |
| | | { |
| | |
| | | attrName = Utilities.getAttributeNameWithoutOptions(attrName); |
| | | if (schema != null) |
| | | { |
| | | AttributeType attrType = schema.getAttributeType(attrName.toLowerCase()); |
| | | if (attrType != null) |
| | | if (schema.hasAttributeType(attrName.toLowerCase())) |
| | | { |
| | | AttributeType attrType = schema.getAttributeType(attrName.toLowerCase()); |
| | | isEditable = !attrType.isNoUserModification(); |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui.nodes; |
| | | |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | /** |
| | | * Class of the nodes that represent a configuration attribute in the 'Manage |
| | | * Schema' tree. |
| | | * |
| | | */ |
| | | /** Class of the nodes that represent a configuration attribute in the 'Manage Schema' tree. */ |
| | | public class ConfigurationAttributeTreeNode extends SchemaElementTreeNode |
| | | { |
| | | private static final long serialVersionUID = 428949987639862400L; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui.nodes; |
| | | |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | /** |
| | | * Class of the nodes that represent a custom attribute in the 'Manage |
| | | * Schema' tree. |
| | | * |
| | | */ |
| | | /** Class of the nodes that represent a custom attribute in the 'Manage Schema' tree. */ |
| | | public class CustomAttributeTreeNode extends SchemaElementTreeNode |
| | | { |
| | | private static final long serialVersionUID = -9198486156950262507L; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui.nodes; |
| | | |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | /** |
| | | * Class of the nodes that represent a standard attribute in the 'Manage |
| | | * Schema' tree. |
| | | * |
| | | */ |
| | | /** Class of the nodes that represent a standard attribute in the 'Manage Schema' tree. */ |
| | | public class StandardAttributeTreeNode extends SchemaElementTreeNode |
| | | { |
| | | private static final long serialVersionUID = -3439217150360205524L; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.util; |
| | | |
| | |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.BackupDirectory; |
| | | import org.opends.server.types.CanceledOperationException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.util; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRuleImpl; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.replication.plugin.HistoricalCsnOrderingMatchingRuleImpl; |
| | | import org.opends.server.schema.AciSyntax; |
| | | import org.opends.server.schema.AttributeTypeSyntax; |
| | | import org.opends.server.schema.LDAPSyntaxDescriptionSyntax; |
| | | import org.opends.server.schema.ObjectClassSyntax; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.schema.SubtreeSpecificationSyntax; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.LDAPSyntaxDescription; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | /** Class used to retrieve the schema from the schema files. */ |
| | |
| | | for (AttributeSyntax<?> syntax : syntaxes) |
| | | { |
| | | final ServerContext serverContext = DirectoryServer.getInstance().getServerContext(); |
| | | if (!serverContext.getSchemaNG().hasSyntax(syntax.getOID())) |
| | | final org.forgerock.opendj.ldap.schema.Schema schemaNG = serverContext.getSchemaNG(); |
| | | if (!schemaNG.hasSyntax(syntax.getOID())) |
| | | { |
| | | syntax.initializeSyntax(null, serverContext); |
| | | } |
| | | schema.registerSyntax(syntax.getSDKSyntax(serverContext.getSchemaNG()), true); |
| | | schema.registerSyntax(syntax.getSDKSyntax(schemaNG), true); |
| | | } |
| | | } |
| | | |
| | |
| | | final MatchingRuleImpl impl) |
| | | throws InitializationException, ConfigException, DirectoryException |
| | | { |
| | | final org.forgerock.opendj.ldap.schema.Schema schemaNG = schema.getSchemaNG(); |
| | | final MatchingRule matchingRule; |
| | | if (CoreSchema.getInstance().hasMatchingRule(name)) |
| | | if (schemaNG.hasMatchingRule(name)) |
| | | { |
| | | matchingRule = CoreSchema.getInstance().getMatchingRule(name); |
| | | matchingRule = schemaNG.getMatchingRule(name); |
| | | } |
| | | else |
| | | { |
| | | matchingRule = new SchemaBuilder(CoreSchema.getInstance()).buildMatchingRule(oid) |
| | | matchingRule = new SchemaBuilder(schemaNG).buildMatchingRule(oid) |
| | | .names(name) |
| | | .syntaxOID(syntaxOID) |
| | | .implementation(impl) |
| | |
| | | switch (schemaAttr) |
| | | { |
| | | case ConfigConstants.ATTR_ATTRIBUTE_TYPES_LC: |
| | | schema.registerAttributeType(AttributeTypeSyntax.decodeAttributeType(sb, schema, false), true); |
| | | schema.registerAttributeType(sb.toString(), null, true); |
| | | break; |
| | | case ConfigConstants.ATTR_OBJECTCLASSES_LC: |
| | | schema.registerObjectClass(ObjectClassSyntax.decodeObjectClass(sb, schema, false), true); |
| | |
| | | { |
| | | try |
| | | { |
| | | final LDAPSyntaxDescription syntaxDesc = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax( |
| | | sb, DirectoryServer.getInstance().getServerContext(), schema, false, false); |
| | | schema.registerLdapSyntaxDescription(syntaxDesc, true); |
| | | schema.registerLdapSyntaxDescription(sb.toString(), true); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.guitools.controlpanel.util; |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SchemaConfigManager; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | } |
| | | for (String name : ATTRIBUTES_TO_KEEP) |
| | | { |
| | | AttributeType attr = sc.getAttributeType(name.toLowerCase()); |
| | | if (attr != null) |
| | | if (sc.hasAttributeType(name)) |
| | | { |
| | | attributesToKeep.add(attr); |
| | | attributesToKeep.add(sc.getAttributeType(name)); |
| | | } |
| | | } |
| | | matchingRulesToKeep.addAll(sc.getMatchingRules().values()); |
| | | syntaxesToKeep.addAll(sc.getSyntaxes().values()); |
| | | matchingRulesToKeep.addAll(sc.getMatchingRules()); |
| | | syntaxesToKeep.addAll(sc.getSyntaxes()); |
| | | } |
| | | |
| | | private static String getSchemaDirectoryPath() |
| | |
| | | // initialize the server schema. |
| | | for (String schemaFile : fileNames) |
| | | { |
| | | // no server context to pass |
| | | SchemaConfigManager.loadSchemaFile(null, schema, schemaFile); |
| | | SchemaConfigManager.loadSchemaFile(schema, schemaFile); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | protected Schema getBaseSchema() throws DirectoryException |
| | | { |
| | | Schema schema = new Schema(); |
| | | // start from default schema |
| | | Schema schema = new Schema(org.forgerock.opendj.ldap.schema.Schema.getDefaultSchema()); |
| | | for (MatchingRule mr : matchingRulesToKeep) |
| | | { |
| | | schema.registerMatchingRule(mr, true); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.util; |
| | | |
| | | import static org.opends.admin.ads.util.ConnectionUtils.*; |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.quicksetup.Installation.*; |
| | | import static org.opends.server.types.CommonSchemaElements.*; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.*; |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.CommonSchemaElements; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.types.SchemaFileElement; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | |
| | | * @return <CODE>true</CODE> if the provided schema element is part of the |
| | | * standard and <CODE>false</CODE> otherwise. |
| | | */ |
| | | public static boolean isStandard(SchemaFileElement fileElement) |
| | | public static boolean isStandard(SomeSchemaElement fileElement) |
| | | { |
| | | final String fileName = getSchemaFile(fileElement); |
| | | final String fileName = fileElement.getSchemaFile(); |
| | | if (fileName != null) |
| | | { |
| | | return contains(standardSchemaFileNames, fileName) || fileName.toLowerCase().contains("-rfc"); |
| | | } |
| | | else if (fileElement instanceof CommonSchemaElements) |
| | | String xOrigin = getOrigin(fileElement); |
| | | if (xOrigin != null) |
| | | { |
| | | String xOrigin = getOrigin(fileElement); |
| | | if (xOrigin != null) |
| | | { |
| | | return contains(standardSchemaOrigins, xOrigin) || xOrigin.startsWith("RFC ") || xOrigin.startsWith("draft-"); |
| | | } |
| | | return contains(standardSchemaOrigins, xOrigin) || xOrigin.startsWith("RFC ") || xOrigin.startsWith("draft-"); |
| | | } |
| | | return false; |
| | | } |
| | |
| | | * @return <CODE>true</CODE> if the provided schema element is part of the |
| | | * configuration and <CODE>false</CODE> otherwise. |
| | | */ |
| | | public static boolean isConfiguration(SchemaFileElement fileElement) |
| | | public static boolean isConfiguration(SomeSchemaElement fileElement) |
| | | { |
| | | String fileName = getSchemaFile(fileElement); |
| | | String fileName = fileElement.getSchemaFile(); |
| | | if (fileName != null) |
| | | { |
| | | return contains(configurationSchemaFileNames, fileName); |
| | | } |
| | | else if (fileElement instanceof CommonSchemaElements) |
| | | String xOrigin = getOrigin(fileElement); |
| | | if (xOrigin != null) |
| | | { |
| | | String xOrigin = getOrigin(fileElement); |
| | | if (xOrigin != null) |
| | | { |
| | | return contains(configurationSchemaOrigins, xOrigin); |
| | | } |
| | | return contains(configurationSchemaOrigins, xOrigin); |
| | | } |
| | | return false; |
| | | } |
| | |
| | | * @param element the schema element. |
| | | * @return the origin of the provided schema element. |
| | | */ |
| | | public static String getOrigin(SchemaFileElement element) |
| | | public static String getOrigin(SomeSchemaElement element) |
| | | { |
| | | return CommonSchemaElements.getSingleValueProperty( |
| | | element, ServerConstants.SCHEMA_PROPERTY_ORIGIN); |
| | | return element.getOrigin(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static boolean hasImageSyntax(String attrName, Schema schema) |
| | | { |
| | | attrName = Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase(); |
| | | attrName = Utilities.getAttributeNameWithoutOptions(attrName); |
| | | if ("photo".equals(attrName)) |
| | | { |
| | | return true; |
| | | } |
| | | // Check all the attributes that we consider binaries. |
| | | if (schema != null) |
| | | if (schema != null && schema.hasAttributeType(attrName)) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(attrName); |
| | | if (attr != null) |
| | | { |
| | | String syntaxOID = attr.getSyntax().getOID(); |
| | | return SchemaConstants.SYNTAX_JPEG_OID.equals(syntaxOID); |
| | | } |
| | | String syntaxOID = attr.getSyntax().getOID(); |
| | | return SchemaConstants.SYNTAX_JPEG_OID.equals(syntaxOID); |
| | | } |
| | | return false; |
| | | } |
| | |
| | | if (schema != null) |
| | | { |
| | | attrName = Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase(); |
| | | AttributeType attr = schema.getAttributeType(attrName); |
| | | if (attr != null) |
| | | if (schema.hasAttributeType(attrName)) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(attrName); |
| | | return contains(oids, attr.getSyntax().getOID()); |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.Requests; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | |
| | | import java.util.EnumSet; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | /** Attribute type property definition. */ |
| | | public final class AttributeTypePropertyDefinition extends |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | |
| | | import org.opends.server.admin.std.meta.RootCfgDefn; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import java.net.InetAddress; |
| | | |
| | | import org.forgerock.opendj.ldap.AddressMask; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.authorization.dseecompat.Aci; |
| | | |
| | | |
| | | /** |
| | | * A visitor of property values, in the style of the visitor design |
| | | * pattern. Classes implementing this interface can query a property a |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.admin.server; |
| | | |
| | |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | 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; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | |
| | | /** |
| | | * This class defines the set of methods and structures that must be |
| | | * implemented by a Directory Server module that implements an |
| | | * attribute syntax. |
| | | * |
| | | * @param <T> The type of configuration handled by this attribute |
| | | * syntax. |
| | | * @param <T> The type of configuration handled by this attribute syntax. |
| | | */ |
| | | @org.opends.server.types.PublicAPI( |
| | | stability=org.opends.server.types.StabilityLevel.VOLATILE, |
| | |
| | | public abstract class AttributeSyntax<T extends AttributeSyntaxCfg> |
| | | { |
| | | /** |
| | | * Initializes this attribute syntax based on the information in the |
| | | * provided configuration entry. |
| | | * Initializes this attribute syntax based on the information in the provided configuration entry. |
| | | * |
| | | * @param configuration The configuration to use to initialize |
| | | * this attribute syntax. |
| | | * @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 |
| | | * initialization. |
| | | * |
| | | * @throws InitializationException If a problem occurs during |
| | | * initialization that is not |
| | | * related to the server |
| | | * configuration. |
| | | * The server context. |
| | | * @throws ConfigException |
| | | * If an unrecoverable problem arises in the process of performing the initialization. |
| | | * @throws DirectoryException |
| | | * If an unrecoverable problem arises in the process of performing the initialization. |
| | | * @throws InitializationException |
| | | * If a problem occurs during initialization that is not related to the server |
| | | * configuration. |
| | | */ |
| | | public void initializeSyntax(T configuration, ServerContext serverContext) |
| | | throws ConfigException, InitializationException |
| | | throws ConfigException, DirectoryException, InitializationException |
| | | { |
| | | // not implemented |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.api; |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.TimeThread; |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.api; |
| | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.GeneralizedTime; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.monitors.BackendMonitor; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.BackupDirectory; |
| | | import org.opends.server.types.CanceledOperationException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | |
| | | import org.opends.server.core.PluginConfigManager; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.CancelRequest; |
| | | import org.opends.server.types.CancelResult; |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | |
| | | import java.util.Set; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.concurrent.locks.Lock; |
| | | import java.util.concurrent.locks.ReadWriteLock; |
| | | import java.util.concurrent.locks.ReentrantReadWriteLock; |
| | | |
| | | import net.jcip.annotations.GuardedBy; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequenceReader; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Attributes; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteSequenceReader; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | |
| | | /** |
| | | * This class provides a utility for interacting with compressed representations |
| | |
| | | mayInvoke = false) |
| | | public class CompressedSchema |
| | | { |
| | | /** Maps attribute description to ID. */ |
| | | private final List<Entry<AttributeType, Set<String>>> adDecodeMap = new CopyOnWriteArrayList<>(); |
| | | /** Maps ID to attribute description. */ |
| | | private final Map<Entry<AttributeType, Set<String>>, Integer> adEncodeMap = new ConcurrentHashMap<>(); |
| | | /** The map between encoded representations and object class sets. */ |
| | | private final List<Map<ObjectClass, String>> ocDecodeMap = new CopyOnWriteArrayList<>(); |
| | | /** The map between object class sets and encoded representations. */ |
| | | private final Map<Map<ObjectClass, String>, Integer> ocEncodeMap = new ConcurrentHashMap<>(); |
| | | /** Encloses all the encode and decode mappings for attribute and object classes. */ |
| | | private static final class Mappings |
| | | { |
| | | /** Maps encoded representation's ID to its attribute description (the List's index is the ID). */ |
| | | private final List<Entry<AttributeType, Set<String>>> adDecodeMap = new CopyOnWriteArrayList<>(); |
| | | /** Maps attribute description to its encoded representation's ID. */ |
| | | private final Map<Entry<AttributeType, Set<String>>, Integer> adEncodeMap; |
| | | /** Maps encoded representation's ID to its object class (the List's index is the ID). */ |
| | | private final List<Map<ObjectClass, String>> ocDecodeMap = new CopyOnWriteArrayList<>(); |
| | | /** Maps object class to its encoded representation's ID. */ |
| | | private final Map<Map<ObjectClass, String>, Integer> ocEncodeMap; |
| | | |
| | | private Mappings() |
| | | { |
| | | this.adEncodeMap = new ConcurrentHashMap<>(); |
| | | this.ocEncodeMap = new ConcurrentHashMap<>(); |
| | | } |
| | | |
| | | private Mappings(int adEncodeMapSize, int ocEncodeMapSize) |
| | | { |
| | | this.adEncodeMap = new ConcurrentHashMap<>(adEncodeMapSize); |
| | | this.ocEncodeMap = new ConcurrentHashMap<>(ocEncodeMapSize); |
| | | } |
| | | } |
| | | |
| | | private final ServerContext serverContext; |
| | | /** Lock to update the maps. */ |
| | | final ReadWriteLock lock = new ReentrantReadWriteLock(); |
| | | private final Lock exclusiveLock = lock.writeLock(); |
| | | private final Lock sharedLock = lock.readLock(); |
| | | |
| | | /** Schema used to build the compressed information. */ |
| | | @GuardedBy("lock") |
| | | private Schema schemaNG; |
| | | @GuardedBy("lock") |
| | | private Mappings mappings = new Mappings(); |
| | | |
| | | /** |
| | | * Creates a new empty instance of this compressed schema. |
| | | * |
| | | * @param serverContext |
| | | * The server context. |
| | | */ |
| | | public CompressedSchema(ServerContext serverContext) |
| | | { |
| | | this.serverContext = serverContext; |
| | | } |
| | | |
| | | private Mappings getMappings() |
| | | { |
| | | sharedLock.lock(); |
| | | try |
| | | { |
| | | return mappings; |
| | | } |
| | | finally |
| | | { |
| | | sharedLock.unlock(); |
| | | } |
| | | } |
| | | |
| | | private Mappings reloadMappingsIfSchemaChanged(boolean force) |
| | | { |
| | | // @RemoveOnceSDKSchemaIsUsed remove the "force" parameter |
| | | sharedLock.lock(); |
| | | boolean shared = true; |
| | | try |
| | | { |
| | | Schema currentSchema = serverContext.getSchemaNG(); |
| | | if (force || schemaNG != currentSchema) |
| | | { |
| | | sharedLock.unlock(); |
| | | exclusiveLock.lock(); |
| | | shared = false; |
| | | |
| | | currentSchema = serverContext.getSchemaNG(); |
| | | if (force || schemaNG != currentSchema) |
| | | { |
| | | // build new maps from existing ones |
| | | Mappings newMappings = new Mappings(mappings.adEncodeMap.size(), mappings.ocEncodeMap.size()); |
| | | reloadAttributeTypeMaps(mappings, newMappings); |
| | | reloadObjectClassesMap(mappings, newMappings); |
| | | |
| | | mappings = newMappings; |
| | | schemaNG = currentSchema; |
| | | } |
| | | } |
| | | return mappings; |
| | | } |
| | | finally |
| | | { |
| | | (shared ? sharedLock : exclusiveLock).unlock(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Reload the attribute types maps. This should be called when schema has changed, because some |
| | | * types may be out dated. |
| | | */ |
| | | private void reloadAttributeTypeMaps(Mappings mappings, Mappings newMappings) |
| | | { |
| | | for (Entry<Entry<AttributeType, Set<String>>, Integer> entry : mappings.adEncodeMap.entrySet()) |
| | | { |
| | | Entry<AttributeType, Set<String>> ad = entry.getKey(); |
| | | Integer id = entry.getValue(); |
| | | loadAttributeToMaps(id, ad.getKey().getNameOrOID(), ad.getValue(), newMappings); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Reload the object classes maps. This should be called when schema has changed, because some |
| | | * classes may be out dated. |
| | | */ |
| | | private void reloadObjectClassesMap(Mappings mappings, Mappings newMappings) |
| | | { |
| | | for (Entry<Map<ObjectClass, String>, Integer> entry : mappings.ocEncodeMap.entrySet()) |
| | | { |
| | | Map<ObjectClass, String> ocMap = entry.getKey(); |
| | | Integer id = entry.getValue(); |
| | | loadObjectClassesToMaps(id, ocMap.values(), newMappings, false); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Decodes the contents of the provided array as an attribute at the current |
| | |
| | | throws DirectoryException |
| | | { |
| | | // First decode the encoded attribute description id. |
| | | final int length = reader.readBERLength(); |
| | | final byte[] idBytes = new byte[length]; |
| | | reader.readBytes(idBytes); |
| | | final int id = decodeId(idBytes); |
| | | final int id = decodeId(reader); |
| | | |
| | | // Look up the attribute description. |
| | | Entry<AttributeType, Set<String>> ad = adDecodeMap.get(id); |
| | | // Before returning the attribute, make sure that the attribute type is not stale. |
| | | final Mappings mappings = reloadMappingsIfSchemaChanged(false); |
| | | final Entry<AttributeType, Set<String>> ad = mappings.adDecodeMap.get(id); |
| | | if (ad == null) |
| | | { |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | ERR_COMPRESSEDSCHEMA_UNRECOGNIZED_AD_TOKEN.get(id)); |
| | | } |
| | | |
| | | // Before returning the attribute, make sure that the attribute type is not |
| | | // stale. |
| | | AttributeType attrType = ad.getKey(); |
| | | Set<String> options = ad.getValue(); |
| | | if (attrType.isDirty()) |
| | | { |
| | | ad = loadAttribute(idBytes, attrType.getNameOrOID(), options); |
| | | attrType = ad.getKey(); |
| | | options = ad.getValue(); |
| | | } |
| | | |
| | | // Determine the number of values for the attribute. |
| | | final int numValues = reader.readBERLength(); |
| | | |
| | | // For the common case of a single value with no options, generate |
| | | // less garbage. |
| | | // For the common case of a single value with no options, generate less garbage. |
| | | if (numValues == 1 && options.isEmpty()) |
| | | { |
| | | final int valueLength = reader.readBERLength(); |
| | | final ByteSequence valueBytes = reader.readByteSequence(valueLength); |
| | | return Attributes.create(attrType, valueBytes.toByteString()); |
| | | return Attributes.create(attrType, readValue(reader)); |
| | | } |
| | | else |
| | | { |
| | |
| | | builder.setOptions(options); |
| | | for (int i = 0; i < numValues; i++) |
| | | { |
| | | final int valueLength = reader.readBERLength(); |
| | | final ByteSequence valueBytes = reader.readByteSequence(valueLength); |
| | | builder.add(valueBytes.toByteString()); |
| | | builder.add(readValue(reader)); |
| | | } |
| | | return builder.toAttribute(); |
| | | } |
| | | } |
| | | |
| | | |
| | | private ByteString readValue(final ByteSequenceReader reader) |
| | | { |
| | | return reader.readByteSequence(reader.readBERLength()).toByteString(); |
| | | } |
| | | |
| | | /** |
| | | * Decodes an object class set from the provided byte string. |
| | |
| | | final ByteSequenceReader reader) throws DirectoryException |
| | | { |
| | | // First decode the encoded object class id. |
| | | final int length = reader.readBERLength(); |
| | | final byte[] idBytes = new byte[length]; |
| | | reader.readBytes(idBytes); |
| | | final int id = decodeId(idBytes); |
| | | final int id = decodeId(reader); |
| | | |
| | | // Look up the object classes. |
| | | final Map<ObjectClass, String> ocMap = ocDecodeMap.get(id); |
| | | if (ocMap != null) |
| | | final Mappings mappings = getMappings(); |
| | | Map<ObjectClass, String> ocMap = mappings.ocDecodeMap.get(id); |
| | | if (ocMap == null) |
| | | { |
| | | // Before returning the object classes, make sure that none of them are |
| | | // stale. |
| | | for (final ObjectClass oc : ocMap.keySet()) |
| | | { |
| | | if (oc.isDirty()) |
| | | { |
| | | // Found at least one object class which is dirty so refresh them. |
| | | return loadObjectClasses(idBytes, ocMap.values()); |
| | | } |
| | | } |
| | | return ocMap; |
| | | } |
| | | else |
| | | { |
| | | // @RemoveOnceSDKSchemaIsUsed remove this first check (check is performed again later) |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | ERR_COMPRESSEDSCHEMA_UNKNOWN_OC_TOKEN.get(id)); |
| | | } |
| | | // Before returning the object classes, make sure that none of them are stale. |
| | | boolean forceReload = isAnyObjectClassDirty(ocMap.keySet()); |
| | | final Mappings newMappings = reloadMappingsIfSchemaChanged(forceReload); |
| | | if (mappings != newMappings) |
| | | { |
| | | ocMap = newMappings.ocDecodeMap.get(id); |
| | | if (ocMap == null) |
| | | { |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | ERR_COMPRESSEDSCHEMA_UNKNOWN_OC_TOKEN.get(id)); |
| | | } |
| | | } |
| | | return ocMap; |
| | | } |
| | | |
| | | |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | private boolean isAnyObjectClassDirty(Set<ObjectClass> objectClasses) |
| | | { |
| | | for (final ObjectClass oc : objectClasses) |
| | | { |
| | | if (oc.isDirty()) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Encodes the information in the provided attribute to a byte array. |
| | |
| | | // Re-use or allocate a new ID. |
| | | final AttributeType type = attribute.getAttributeType(); |
| | | final Set<String> options = attribute.getOptions(); |
| | | final Entry<AttributeType, Set<String>> ad = new SimpleImmutableEntry<>(type, options); |
| | | |
| | | // Use double checked locking to avoid lazy registration races. |
| | | Integer id = adEncodeMap.get(ad); |
| | | if (id == null) |
| | | { |
| | | synchronized (adEncodeMap) |
| | | { |
| | | id = adEncodeMap.get(ad); |
| | | if (id == null) |
| | | { |
| | | id = adDecodeMap.size(); |
| | | adDecodeMap.add(ad); |
| | | adEncodeMap.put(ad, id); |
| | | storeAttribute(encodeId(id), type.getNameOrOID(), options); |
| | | } |
| | | } |
| | | } |
| | | int id = getAttributeId(new SimpleImmutableEntry<>(type, options)); |
| | | |
| | | // Encode the attribute. |
| | | final byte[] idBytes = encodeId(id); |
| | |
| | | } |
| | | } |
| | | |
| | | private int getAttributeId(final Entry<AttributeType, Set<String>> ad) throws DirectoryException |
| | | { |
| | | // avoid lazy registration races |
| | | boolean shared = true; |
| | | sharedLock.lock(); |
| | | try |
| | | { |
| | | Integer id = mappings.adEncodeMap.get(ad); |
| | | if (id != null) |
| | | { |
| | | return id; |
| | | } |
| | | |
| | | sharedLock.unlock(); |
| | | exclusiveLock.lock(); |
| | | shared = false; |
| | | |
| | | id = mappings.adEncodeMap.get(ad); |
| | | if (id == null) |
| | | { |
| | | id = mappings.adDecodeMap.size(); |
| | | mappings.adDecodeMap.add(ad); |
| | | mappings.adEncodeMap.put(ad, id); |
| | | storeAttribute(encodeId(id), ad.getKey().getNameOrOID(), ad.getValue()); |
| | | } |
| | | return id; |
| | | } |
| | | finally |
| | | { |
| | | (shared ? sharedLock : exclusiveLock).unlock(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Encodes the provided set of object classes to a byte array. If the same set |
| | |
| | | final Map<ObjectClass, String> objectClasses) throws DirectoryException |
| | | { |
| | | // Re-use or allocate a new ID. |
| | | // Use double checked locking to avoid lazy registration races. |
| | | Integer id = ocEncodeMap.get(objectClasses); |
| | | if (id == null) |
| | | { |
| | | synchronized (ocEncodeMap) |
| | | { |
| | | id = ocEncodeMap.get(objectClasses); |
| | | if (id == null) |
| | | { |
| | | id = ocDecodeMap.size(); |
| | | ocDecodeMap.add(objectClasses); |
| | | ocEncodeMap.put(objectClasses, id); |
| | | storeObjectClasses(encodeId(id), objectClasses.values()); |
| | | } |
| | | } |
| | | } |
| | | int id = getObjectClassId(objectClasses); |
| | | |
| | | // Encode the object classes. |
| | | final byte[] idBytes = encodeId(id); |
| | |
| | | builder.appendBytes(idBytes); |
| | | } |
| | | |
| | | private int getObjectClassId(final Map<ObjectClass, String> objectClasses) throws DirectoryException |
| | | { |
| | | // avoid lazy registration races |
| | | boolean shared = true; |
| | | sharedLock.lock(); |
| | | try |
| | | { |
| | | Integer id = mappings.ocEncodeMap.get(objectClasses); |
| | | if (id != null) |
| | | { |
| | | return id; |
| | | } |
| | | |
| | | sharedLock.unlock(); |
| | | exclusiveLock.lock(); |
| | | shared = false; |
| | | |
| | | id = mappings.ocEncodeMap.get(objectClasses); |
| | | if (id == null) |
| | | { |
| | | id = mappings.ocDecodeMap.size(); |
| | | mappings.ocDecodeMap.add(objectClasses); |
| | | mappings.ocEncodeMap.put(objectClasses, id); |
| | | storeObjectClasses(encodeId(id), objectClasses.values()); |
| | | } |
| | | return id; |
| | | } |
| | | finally |
| | | { |
| | | (shared ? sharedLock : exclusiveLock).unlock(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns a view of the encoded attributes in this compressed schema which |
| | | * can be used for saving the entire content to disk. The iterator returned by |
| | | * this method is not thread safe. |
| | | * Returns a view of the encoded attributes in this compressed schema which can be used for saving |
| | | * the entire content to disk. |
| | | * <p> |
| | | * The iterator returned by this method is not thread safe. |
| | | * |
| | | * @return A view of the encoded attributes in this compressed schema. |
| | | */ |
| | | protected final Iterable<Entry<byte[], |
| | | Entry<String, |
| | | Collection<String>>>> getAllAttributes() |
| | | protected final Iterable<Entry<byte[], Entry<String, Collection<String>>>> getAllAttributes() |
| | | { |
| | | return new Iterable<Entry<byte[], Entry<String, Collection<String>>>>() |
| | | { |
| | | |
| | | @Override |
| | | public Iterator<Entry<byte[], |
| | | Entry<String, Collection<String>>>> iterator() |
| | | public Iterator<Entry<byte[], Entry<String, Collection<String>>>> iterator() |
| | | { |
| | | return new Iterator<Entry<byte[], Entry<String, Collection<String>>>>() |
| | | { |
| | | private int id = 0; |
| | | |
| | | |
| | | private int id; |
| | | private List<Entry<AttributeType, Set<String>>> adDecodeMap = getMappings().adDecodeMap; |
| | | |
| | | @Override |
| | | public boolean hasNext() |
| | |
| | | return id < adDecodeMap.size(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Entry<byte[], Entry<String, Collection<String>>> next() |
| | | { |
| | |
| | | .getKey().getNameOrOID(), ad.getValue())); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void remove() |
| | | { |
| | |
| | | }; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns a view of the encoded object classes in this compressed schema |
| | | * which can be used for saving the entire content to disk. The iterator |
| | | * returned by this method is not thread safe. |
| | | * Returns a view of the encoded object classes in this compressed schema which can be used for |
| | | * saving the entire content to disk. |
| | | * <p> |
| | | * The iterator returned by this method is not thread safe. |
| | | * |
| | | * @return A view of the encoded object classes in this compressed schema. |
| | | */ |
| | | protected final Iterable<Entry<byte[], |
| | | Collection<String>>> getAllObjectClasses() |
| | | protected final Iterable<Entry<byte[], Collection<String>>> getAllObjectClasses() |
| | | { |
| | | return new Iterable<Entry<byte[], Collection<String>>>() |
| | | { |
| | | |
| | | @Override |
| | | public Iterator<Entry<byte[], Collection<String>>> iterator() |
| | | { |
| | | return new Iterator<Map.Entry<byte[], Collection<String>>>() |
| | | { |
| | | private int id = 0; |
| | | private int id; |
| | | private final List<Map<ObjectClass, String>> ocDecodeMap = getMappings().ocDecodeMap; |
| | | |
| | | @Override |
| | | public boolean hasNext() |
| | |
| | | final byte[] encodedAttribute, final String attributeName, |
| | | final Collection<String> attributeOptions) |
| | | { |
| | | final AttributeType type = DirectoryServer.getAttributeTypeOrDefault(toLowerCase(attributeName)); |
| | | final int id = decodeId(encodedAttribute); |
| | | return loadAttributeToMaps(id, attributeName, attributeOptions, getMappings()); |
| | | } |
| | | |
| | | /** |
| | | * Loads an attribute into provided encode and decode maps, given its id, name, and options. |
| | | * |
| | | * @param id |
| | | * the id computed on the attribute. |
| | | * @param attributeName |
| | | * The user provided attribute type name. |
| | | * @param attributeOptions |
| | | * The non-null but possibly empty set of attribute options. |
| | | * @param mappings |
| | | * attribute description encodeMap and decodeMap maps id to entry |
| | | * @return The attribute type description. |
| | | */ |
| | | private Entry<AttributeType, Set<String>> loadAttributeToMaps(final int id, final String attributeName, |
| | | final Collection<String> attributeOptions, final Mappings mappings) |
| | | { |
| | | final AttributeType type = DirectoryServer.getAttributeTypeOrDefault(attributeName); |
| | | final Set<String> options = getOptions(attributeOptions); |
| | | final Entry<AttributeType, Set<String>> ad = new SimpleImmutableEntry<>(type, options); |
| | | final int id = decodeId(encodedAttribute); |
| | | synchronized (adEncodeMap) |
| | | exclusiveLock.lock(); |
| | | try |
| | | { |
| | | adEncodeMap.put(ad, id); |
| | | if (id < adDecodeMap.size()) |
| | | mappings.adEncodeMap.put(ad, id); |
| | | if (id < mappings.adDecodeMap.size()) |
| | | { |
| | | adDecodeMap.set(id, ad); |
| | | mappings.adDecodeMap.set(id, ad); |
| | | } |
| | | else |
| | | { |
| | | // Grow the decode array. |
| | | while (id > adDecodeMap.size()) |
| | | while (id > mappings.adDecodeMap.size()) |
| | | { |
| | | adDecodeMap.add(null); |
| | | mappings.adDecodeMap.add(null); |
| | | } |
| | | adDecodeMap.add(ad); |
| | | mappings.adDecodeMap.add(ad); |
| | | } |
| | | return ad; |
| | | } |
| | | return ad; |
| | | finally |
| | | { |
| | | exclusiveLock.unlock(); |
| | | } |
| | | } |
| | | |
| | | private Set<String> getOptions(final Collection<String> attributeOptions) |
| | |
| | | final byte[] encodedObjectClasses, |
| | | final Collection<String> objectClassNames) |
| | | { |
| | | final int id = decodeId(encodedObjectClasses); |
| | | return loadObjectClassesToMaps(id, objectClassNames, mappings, true); |
| | | } |
| | | |
| | | /** |
| | | * Loads a set of object classes into provided encode and decode maps, given the id and set of |
| | | * names. |
| | | * |
| | | * @param id |
| | | * the id computed on the object classes set. |
| | | * @param objectClassNames |
| | | * The user provided set of object class names. |
| | | * @param mappings |
| | | * .ocEncodeMap maps id to entry |
| | | * @param mappings |
| | | * .ocDecodeMap maps entry to id |
| | | * @param sync |
| | | * indicates if update of maps should be synchronized |
| | | * @return The object class set. |
| | | */ |
| | | private final Map<ObjectClass, String> loadObjectClassesToMaps(int id, final Collection<String> objectClassNames, |
| | | Mappings mappings, boolean sync) |
| | | { |
| | | final LinkedHashMap<ObjectClass, String> ocMap = new LinkedHashMap<>(objectClassNames.size()); |
| | | for (final String name : objectClassNames) |
| | | { |
| | |
| | | final ObjectClass oc = DirectoryServer.getObjectClass(lowerName, true); |
| | | ocMap.put(oc, name); |
| | | } |
| | | final int id = decodeId(encodedObjectClasses); |
| | | synchronized (ocEncodeMap) |
| | | if (sync) |
| | | { |
| | | ocEncodeMap.put(ocMap, id); |
| | | if (id < ocDecodeMap.size()) |
| | | exclusiveLock.lock(); |
| | | try |
| | | { |
| | | ocDecodeMap.set(id, ocMap); |
| | | updateObjectClassesMaps(id, mappings, ocMap); |
| | | } |
| | | else |
| | | finally |
| | | { |
| | | // Grow the decode array. |
| | | while (id > ocDecodeMap.size()) |
| | | { |
| | | ocDecodeMap.add(null); |
| | | } |
| | | ocDecodeMap.add(ocMap); |
| | | exclusiveLock.unlock(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | updateObjectClassesMaps(id, mappings, ocMap); |
| | | } |
| | | return ocMap; |
| | | } |
| | | |
| | | |
| | | private void updateObjectClassesMaps(int id, Mappings mappings, LinkedHashMap<ObjectClass, String> ocMap) |
| | | { |
| | | mappings.ocEncodeMap.put(ocMap, id); |
| | | if (id < mappings.ocDecodeMap.size()) |
| | | { |
| | | mappings.ocDecodeMap.set(id, ocMap); |
| | | } |
| | | else |
| | | { |
| | | // Grow the decode array. |
| | | while (id > mappings.ocDecodeMap.size()) |
| | | { |
| | | mappings.ocDecodeMap.add(null); |
| | | } |
| | | mappings.ocDecodeMap.add(ocMap); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Persists the provided encoded attribute. The default implementation is to |
| | |
| | | // Do nothing by default. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Persists the provided encoded object classes. The default implementation is |
| | | * to do nothing. Calls to this method are synchronized, so implementations |
| | |
| | | // Do nothing by default. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Decodes the provided encoded schema element ID. |
| | | * |
| | |
| | | return id - 1; // Subtract 1 to compensate for old behavior. |
| | | } |
| | | |
| | | |
| | | private int decodeId(final ByteSequenceReader reader) |
| | | { |
| | | final int length = reader.readBERLength(); |
| | | final byte[] idBytes = new byte[length]; |
| | | reader.readBytes(idBytes); |
| | | return decodeId(idBytes); |
| | | } |
| | | |
| | | /** |
| | | * Encodes the provided schema element ID. |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPClientConnection; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Entry; |
| | | |
| | |
| | | //Check if the aclRightsInfo attribute was requested. |
| | | if(hasAttrMask(mask,ACL_RIGHTS_INFO)) { |
| | | //Build the attribute type. |
| | | String typeStr= |
| | | aclRightsInfoAttrLogsStr + ";" + rightStr + ";" + |
| | | aType.getPrimaryName(); |
| | | String typeStr = aclRightsInfoAttrLogsStr + ";" + rightStr + ";" + aType.getNameOrOID(); |
| | | AttributeType attributeType = DirectoryServer.getAttributeTypeOrDefault(typeStr); |
| | | Attribute attr = Attributes.create(attributeType, container.getEvalSummary()); |
| | | // The attribute type might have already been added, probably |
| | |
| | | String attrStr="NULL"; |
| | | if(aType != null) |
| | | { |
| | | attrStr=aType.getPrimaryName(); |
| | | attrStr = aType.getNameOrOID(); |
| | | } |
| | | if(evalCtx.getTargAttrFiltersAciName() != null) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.api.Group; |
| | | |
| | | import java.net.InetAddress; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | * Portions Copyright 2013 Manuel Gaupp |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.workflowelement.localbackend.*; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.*; |
| | | import org.opends.server.workflowelement.localbackend.LocalBackendSearchOperation; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Entry; |
| | | import java.util.List; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | import java.util.regex.Pattern; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | import org.opends.server.api.Group; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.GroupManager; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | import java.util.regex.Matcher; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.LDAPURL; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.SearchFilter; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | /** |
| | | * A class representing an ACI's targetattr keyword. |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.AccessControlMessages.*; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.AccessControlMessages.*; |
| | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends; |
| | | |
| | |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.schema.GeneralizedTimeSyntax; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.backends; |
| | | |
| | |
| | | import org.opends.server.replication.server.changelog.file.ECLMultiDomainDBCursor; |
| | | import org.opends.server.replication.server.changelog.file.MultiDomainDBCursor; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.BackupDirectory; |
| | |
| | | { |
| | | return filter.getFilterType() == filterType |
| | | && filter.getAttributeType() != null |
| | | && filter.getAttributeType().getPrimaryName().equalsIgnoreCase(primaryName); |
| | | && filter.getAttributeType().getNameOrOID().equalsIgnoreCase(primaryName); |
| | | } |
| | | |
| | | /** Search the changelog when a cookie control is provided. */ |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends; |
| | | |
| | |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.controls.SubtreeDeleteControl; |
| | | import org.opends.server.core.*; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.LDIFException; |
| | | import org.opends.server.util.LDIFReader; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends; |
| | | |
| | |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.BackupDirectory; |
| | | import org.opends.server.types.Control; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.backends; |
| | | |
| | |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.*; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.DynamicConstants; |
| | | import org.opends.server.util.LDIFWriter; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends; |
| | | |
| | |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.BackupDirectory; |
| | | import org.opends.server.types.DN; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends; |
| | | |
| | |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.LDIFWriter; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | 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.schema.DITContentRuleSyntax; |
| | | import org.opends.server.schema.DITStructureRuleSyntax; |
| | | import org.opends.server.schema.GeneralizedTimeSyntax; |
| | | import org.opends.server.schema.LDAPSyntaxDescriptionSyntax; |
| | | 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.schema.SomeSchemaElement; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.BackupManager; |
| | | import org.opends.server.util.DynamicConstants; |
| | |
| | | * Add the schema definition attributes. |
| | | */ |
| | | Schema schema = DirectoryServer.getSchema(); |
| | | buildSchemaAttribute(schema.getAttributeTypes().values(), userAttrs, |
| | | buildSchemaAttribute(schema.getAttributeTypes(), userAttrs, |
| | | operationalAttrs, attributeTypesType, includeSchemaFile, |
| | | AttributeTypeSyntax.isStripSyntaxMinimumUpperBound(), |
| | | ignoreShowAllOption); |
| | | buildSchemaAttribute(schema.getObjectClasses().values(), userAttrs, |
| | | operationalAttrs, objectClassesType, includeSchemaFile, false, |
| | | ignoreShowAllOption); |
| | | buildSchemaAttribute(schema.getMatchingRules().values(), userAttrs, |
| | | buildSchemaAttribute(schema.getMatchingRules(), userAttrs, |
| | | operationalAttrs, matchingRulesType, includeSchemaFile, false, |
| | | ignoreShowAllOption); |
| | | |
| | |
| | | * updates to fail. This means that you'll always have to explicitly request |
| | | * these attributes in order to be able to see them. |
| | | */ |
| | | buildSchemaAttribute(schema.getSyntaxes().values(), userAttrs, |
| | | buildSchemaAttribute(schema.getSyntaxes(), userAttrs, |
| | | operationalAttrs, ldapSyntaxesType, includeSchemaFile, false, true); |
| | | buildSchemaAttribute(schema.getNameFormsByNameOrOID().values(), userAttrs, |
| | | operationalAttrs, nameFormsType, includeSchemaFile, false, true); |
| | |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | AttributeType type; |
| | | try |
| | | { |
| | | type = AttributeTypeSyntax.decodeAttributeType(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_ATTRTYPE.get( |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | | |
| | | addAttributeType(type, newSchema, modifiedSchemaFiles); |
| | | AttributeType attributeType = newSchema.parseAttributeType(v.toString()); |
| | | addAttributeType(attributeType, newSchema, modifiedSchemaFiles); |
| | | } |
| | | } |
| | | else if (at.equals(objectClassesType)) |
| | |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | LDAPSyntaxDescription lsd; |
| | | try |
| | | { |
| | | lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, serverContext, newSchema, false, false); |
| | | addLdapSyntaxDescription(v.toString(), newSchema, modifiedSchemaFiles); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | | addLdapSyntaxDescription(lsd, newSchema, modifiedSchemaFiles); |
| | | } |
| | | } |
| | | else |
| | |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | AttributeType type; |
| | | try |
| | | { |
| | | type = AttributeTypeSyntax.decodeAttributeType(v, newSchema, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_ATTRTYPE.get( |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | | |
| | | removeAttributeType(type, newSchema, mods, pos, |
| | | modifiedSchemaFiles); |
| | | AttributeType type = newSchema.parseAttributeType(v.toString()); |
| | | removeAttributeType(type, newSchema, modifiedSchemaFiles); |
| | | } |
| | | } |
| | | else if (at.equals(objectClassesType)) |
| | |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | LDAPSyntaxDescription lsd; |
| | | try |
| | | { |
| | | lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, serverContext, newSchema, false, true); |
| | | removeLdapSyntaxDescription(v.toString(), newSchema, modifiedSchemaFiles); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | | removeLdapSyntaxDescription(lsd, newSchema, modifiedSchemaFiles); |
| | | } |
| | | } |
| | | else |
| | |
| | | * the provided attribute type to the server |
| | | * schema. |
| | | */ |
| | | private void addAttributeType(AttributeType attributeType, Schema schema, |
| | | Set<String> modifiedSchemaFiles) |
| | | private void addAttributeType(AttributeType attributeType, Schema schema, Set<String> modifiedSchemaFiles) |
| | | throws DirectoryException |
| | | { |
| | | // First, see if the specified attribute type already exists. We'll check |
| | | // the OID and all of the names, which means that it's possible there could |
| | | // be more than one match (although if there is, then we'll refuse the |
| | | // operation). |
| | | AttributeType existingType = |
| | | schema.getAttributeType(attributeType.getOID()); |
| | | for (String name : attributeType.getNormalizedNames()) |
| | | // Check if there is only a single attribute type for each name |
| | | // This is not checked by the SDK schema. |
| | | AttributeType existingType = schema.getAttributeType(attributeType.getOID()); |
| | | for (String name : attributeType.getNames()) |
| | | { |
| | | AttributeType t = schema.getAttributeType(name); |
| | | if (t == null) |
| | | if (t.isPlaceHolder()) |
| | | { |
| | | continue; |
| | | } |
| | | else if (existingType == null) |
| | | if (existingType.isPlaceHolder()) |
| | | { |
| | | existingType = t; |
| | | } |
| | |
| | | // NOTE: We really do want to use "!=" instead of "! t.equals()" |
| | | // because we want to check whether it's the same object instance, not |
| | | // just a logical equivalent. |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_MULTIPLE_CONFLICTS_FOR_ADD_ATTRTYPE. |
| | | get(attributeType.getNameOrOID(), existingType.getNameOrOID(), |
| | | t.getNameOrOID()); |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_MULTIPLE_CONFLICTS_FOR_ADD_ATTRTYPE.get( |
| | | attributeType.getNameOrOID(), existingType.getNameOrOID(), t.getNameOrOID()); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | } |
| | | |
| | | |
| | | // Make sure that the new attribute type doesn't reference an undefined |
| | | // or OBSOLETE superior attribute type. |
| | | // Make sure that the new attribute type doesn't reference an |
| | | // OBSOLETE superior attribute type. |
| | | AttributeType superiorType = attributeType.getSuperiorType(); |
| | | if (superiorType != null) |
| | | if (superiorType != null && superiorType.isObsolete()) |
| | | { |
| | | if (! schema.hasAttributeType(superiorType.getOID())) |
| | | { |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_UNDEFINED_SUPERIOR_ATTRIBUTE_TYPE. |
| | | get(attributeType.getNameOrOID(), superiorType.getNameOrOID()); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | else if (superiorType.isObsolete()) |
| | | { |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_OBSOLETE_SUPERIOR_ATTRIBUTE_TYPE. |
| | | get(attributeType.getNameOrOID(), superiorType.getNameOrOID()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_OBSOLETE_SUPERIOR_ATTRIBUTE_TYPE.get( |
| | | attributeType.getNameOrOID(), superiorType.getNameOrOID()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | |
| | | // Make sure that none of the associated matching rules are marked OBSOLETE. |
| | | MatchingRule mr = attributeType.getEqualityMatchingRule(); |
| | | if (mr != null && mr.isObsolete()) |
| | | { |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_ATTRTYPE_OBSOLETE_MR.get( |
| | | attributeType.getNameOrOID(), mr.getNameOrOID()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | mr = attributeType.getOrderingMatchingRule(); |
| | | if (mr != null && mr.isObsolete()) |
| | | { |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_ATTRTYPE_OBSOLETE_MR.get( |
| | | attributeType.getNameOrOID(), mr.getNameOrOID()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | mr = attributeType.getSubstringMatchingRule(); |
| | | if (mr != null && mr.isObsolete()) |
| | | { |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_ATTRTYPE_OBSOLETE_MR.get( |
| | | attributeType.getNameOrOID(), mr.getNameOrOID()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | mr = attributeType.getApproximateMatchingRule(); |
| | | if (mr != null && mr.isObsolete()) |
| | | { |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_ATTRTYPE_OBSOLETE_MR.get( |
| | | attributeType.getNameOrOID(), mr.getNameOrOID()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | throwIfObsoleteMatchingRule(attributeType, attributeType.getEqualityMatchingRule()); |
| | | throwIfObsoleteMatchingRule(attributeType, attributeType.getOrderingMatchingRule()); |
| | | throwIfObsoleteMatchingRule(attributeType, attributeType.getSubstringMatchingRule()); |
| | | throwIfObsoleteMatchingRule(attributeType, attributeType.getApproximateMatchingRule()); |
| | | |
| | | // If there is no existing type, then we're adding a new attribute. |
| | | // Otherwise, we're replacing an existing one. |
| | | if (existingType == null) |
| | | if (existingType.isPlaceHolder()) |
| | | { |
| | | schema.registerAttributeType(attributeType, false); |
| | | addNewSchemaElement(modifiedSchemaFiles, attributeType); |
| | | String schemaFile = addNewSchemaElement(modifiedSchemaFiles, new SomeSchemaElement(attributeType)); |
| | | schema.registerAttributeType(attributeType, schemaFile, false); |
| | | } |
| | | else |
| | | { |
| | | schema.deregisterAttributeType(existingType); |
| | | schema.registerAttributeType(attributeType, false); |
| | | schema.rebuildDependentElements(existingType); |
| | | replaceExistingSchemaElement(modifiedSchemaFiles, attributeType, |
| | | existingType); |
| | | |
| | | String schemaFile = replaceExistingSchemaElement( |
| | | modifiedSchemaFiles, new SomeSchemaElement(attributeType), new SomeSchemaElement(existingType)); |
| | | schema.registerAttributeType(attributeType, schemaFile, false); |
| | | schema.rebuildDependentElements(new SomeSchemaElement(existingType)); |
| | | } |
| | | } |
| | | |
| | | private void throwIfObsoleteMatchingRule(AttributeType attributeType, MatchingRule mr) throws DirectoryException |
| | | { |
| | | if (mr != null && mr.isObsolete()) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_SCHEMA_MODIFY_ATTRTYPE_OBSOLETE_MR.get(attributeType.getNameOrOID(), mr.getNameOrOID())); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void addNewSchemaElement(Set<String> modifiedSchemaFiles, |
| | | SchemaFileElement elem) |
| | | private void addNewSchemaElement(Set<String> modifiedSchemaFiles, SchemaFileElement elem) |
| | | { |
| | | String schemaFile = getSchemaFile(elem); |
| | | if (schemaFile == null || schemaFile.length() == 0) |
| | |
| | | schemaFile = FILE_USER_SCHEMA_ELEMENTS; |
| | | setSchemaFile(elem, schemaFile); |
| | | } |
| | | |
| | | modifiedSchemaFiles.add(schemaFile); |
| | | } |
| | | |
| | | |
| | | /** Update list of modified files and return the schema file to use for the added element (may be null). */ |
| | | private String addNewSchemaElement(Set<String> modifiedSchemaFiles, SomeSchemaElement elem) |
| | | { |
| | | String schemaFile = elem.getSchemaFile(); |
| | | String finalFile = schemaFile != null ? schemaFile : FILE_USER_SCHEMA_ELEMENTS; |
| | | modifiedSchemaFiles.add(finalFile); |
| | | return schemaFile == null ? finalFile : null; |
| | | } |
| | | |
| | | private <T extends SchemaFileElement> void replaceExistingSchemaElement( |
| | | Set<String> modifiedSchemaFiles, T newElem, T existingElem) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** Update list of modified files and return the schema file to use for the new element (may be null). */ |
| | | private String replaceExistingSchemaElement( |
| | | Set<String> modifiedSchemaFiles, SomeSchemaElement newElem, SomeSchemaElement existingElem) |
| | | { |
| | | String newSchemaFile = newElem.getSchemaFile(); |
| | | String oldSchemaFile = existingElem.getSchemaFile(); |
| | | if (newSchemaFile == null) |
| | | { |
| | | if (oldSchemaFile == null) |
| | | { |
| | | oldSchemaFile = FILE_USER_SCHEMA_ELEMENTS; |
| | | } |
| | | modifiedSchemaFiles.add(oldSchemaFile); |
| | | return oldSchemaFile; |
| | | } |
| | | else if (oldSchemaFile == null || oldSchemaFile.equals(newSchemaFile)) |
| | | { |
| | | modifiedSchemaFiles.add(newSchemaFile); |
| | | } |
| | | else |
| | | { |
| | | modifiedSchemaFiles.add(newSchemaFile); |
| | | modifiedSchemaFiles.add(oldSchemaFile); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Handles all processing required to remove the provided attribute type from |
| | |
| | | * the provided attribute type from the server |
| | | * schema. |
| | | */ |
| | | private void removeAttributeType(AttributeType attributeType, Schema schema, |
| | | ArrayList<Modification> modifications, |
| | | int currentPosition, |
| | | Set<String> modifiedSchemaFiles) |
| | | private void removeAttributeType(AttributeType attributeType, Schema schema, Set<String> modifiedSchemaFiles) |
| | | throws DirectoryException |
| | | { |
| | | // See if the specified attribute type is actually defined in the server |
| | | // schema. If not, then fail. |
| | | AttributeType removeType = schema.getAttributeType(attributeType.getOID()); |
| | | if (removeType == null || !removeType.equals(attributeType)) |
| | | if (removeType.isPlaceHolder() || !removeType.equals(attributeType)) |
| | | { |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_REMOVE_NO_SUCH_ATTRIBUTE_TYPE.get( |
| | | attributeType.getNameOrOID()); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | |
| | | |
| | | // See if there is another modification later to add the attribute type back |
| | | // into the schema. If so, then it's a replace and we should ignore the |
| | | // remove because adding it back will handle the replace. |
| | | for (int i=currentPosition+1; i < modifications.size(); i++) |
| | | { |
| | | Modification m = modifications.get(i); |
| | | Attribute a = m.getAttribute(); |
| | | |
| | | if (m.getModificationType() != ModificationType.ADD |
| | | || !a.getAttributeType().equals(attributeTypesType)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | for (ByteString v : a) |
| | | { |
| | | AttributeType at; |
| | | try |
| | | { |
| | | at = AttributeTypeSyntax.decodeAttributeType(v, schema, true); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_ATTRTYPE.get( |
| | | v, de.getMessageObject()); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | | |
| | | if (attributeType.getOID().equals(at.getOID())) |
| | | { |
| | | // We found a match where the attribute type is added back later, so |
| | | // we don't need to do anything else here. |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // Make sure that the attribute type isn't used as the superior type for |
| | | // any other attributes. |
| | | for (AttributeType at : schema.getAttributeTypes().values()) |
| | | for (AttributeType at : schema.getAttributeTypes()) |
| | | { |
| | | AttributeType superiorType = at.getSuperiorType(); |
| | | if (superiorType != null && superiorType.equals(removeType)) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // Make sure that the attribute type isn't used as a required or optional |
| | | // attribute type in any objectclass. |
| | | for (ObjectClass oc : schema.getObjectClasses().values()) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // Make sure that the attribute type isn't used as a required or optional |
| | | // attribute type in any name form. |
| | | for (List<NameForm> mappedForms : |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // Make sure that the attribute type isn't used as a required, optional, or |
| | | // prohibited attribute type in any DIT content rule. |
| | | for (DITContentRule dcr : schema.getDITContentRules().values()) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // Make sure that the attribute type isn't referenced by any matching rule |
| | | // use. |
| | | for (MatchingRuleUse mru : schema.getMatchingRuleUses().values()) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then it's OK to remove the attribute type from |
| | | // the schema. |
| | | schema.deregisterAttributeType(removeType); |
| | | String schemaFile = getSchemaFile(removeType); |
| | | String schemaFile = new SomeSchemaElement(removeType).getSchemaFile(); |
| | | if (schemaFile != null) |
| | | { |
| | | modifiedSchemaFiles.add(schemaFile); |
| | |
| | | schema.deregisterObjectClass(existingClass); |
| | | schema.registerObjectClass(objectClass, false); |
| | | schema.rebuildDependentElements(existingClass); |
| | | replaceExistingSchemaElement(modifiedSchemaFiles, objectClass, |
| | | existingClass); |
| | | replaceExistingSchemaElement(modifiedSchemaFiles, objectClass, existingClass); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Handles all processing required for adding the provided ldap syntax |
| | | * description to the given schema, replacing an existing ldap syntax |
| | | * description if necessary, and ensuring all other metadata is properly |
| | | * updated. |
| | | * Handles all processing required for adding the provided ldap syntax description to the given |
| | | * schema, replacing an existing ldap syntax description if necessary, and ensuring all other |
| | | * metadata is properly updated. |
| | | * |
| | | * @param ldapSyntaxDesc The ldap syntax description to add or replace in |
| | | * the server schema. |
| | | * @param schema The schema to which the name form should be |
| | | * added. |
| | | * @param modifiedSchemaFiles The names of the schema files containing |
| | | * schema elements that have been updated as part |
| | | * of the schema modification. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while attempting to add |
| | | * the provided ldap syntax description to the |
| | | * server schema. |
| | | * @param definition |
| | | * The definition of the ldap syntax description to add or replace in the server schema. |
| | | * @param schema |
| | | * The schema to which the LDAP syntax description should be added. |
| | | * @param modifiedSchemaFiles |
| | | * The names of the schema files containing schema elements that have been updated as |
| | | * part of the schema modification. |
| | | * @throws DirectoryException |
| | | * If a problem occurs while attempting to add the provided ldap syntax description to |
| | | * the server schema. |
| | | */ |
| | | private void addLdapSyntaxDescription(LDAPSyntaxDescription ldapSyntaxDesc, |
| | | Schema schema, |
| | | Set<String> modifiedSchemaFiles) |
| | | private void addLdapSyntaxDescription(final String definition, Schema schema, Set<String> modifiedSchemaFiles) |
| | | throws DirectoryException |
| | | { |
| | | //Check if there is an existing syntax with this oid. |
| | | String oid = ldapSyntaxDesc.getSyntax().getOID(); |
| | | // Check if there is an existing syntax with this oid. |
| | | String oid = |
| | | Schema.parseOID(definition, ResultCode.INVALID_ATTRIBUTE_SYNTAX, ERR_ATTR_SYNTAX_LDAPSYNTAX_EMPTY_VALUE); |
| | | |
| | | // We allow only unimplemented syntaxes to be substituted. |
| | | if(schema.getSyntax(oid) !=null) |
| | | if (schema.hasSyntax(oid)) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_INVALID_LDAP_SYNTAX.get(ldapSyntaxDesc, oid); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | message); |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_INVALID_LDAP_SYNTAX.get(definition, oid); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | 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. |
| | | if (existingLSD == null) |
| | | { |
| | | schema.registerLdapSyntaxDescription(ldapSyntaxDesc, false); |
| | | addNewSchemaElement(modifiedSchemaFiles, ldapSyntaxDesc); |
| | | String def = Schema.addSchemaFileToElementDefinitionIfAbsent(definition, FILE_USER_SCHEMA_ELEMENTS); |
| | | schema.registerLdapSyntaxDescription(def, false); |
| | | |
| | | // update schema NG |
| | | newSchema = schemaUpdater.getSchemaBuilder().buildSyntax(ldapSyntaxDesc.getSyntax()).addToSchema().toSchema(); |
| | | schemaUpdater.updateSchema(newSchema); |
| | | String schemaFile = getSchemaFile(schema.getLdapSyntaxDescription(oid)); |
| | | modifiedSchemaFiles.add(schemaFile); |
| | | } |
| | | 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); |
| | | |
| | | String oldSchemaFile = getSchemaFile(existingLSD); |
| | | String schemaFile = oldSchemaFile != null && oldSchemaFile.length() > 0 ? |
| | | oldSchemaFile : FILE_USER_SCHEMA_ELEMENTS; |
| | | String def = Schema.addSchemaFileToElementDefinitionIfAbsent(definition, schemaFile); |
| | | schema.registerLdapSyntaxDescription(def, false); |
| | | |
| | | schema.rebuildDependentElements(existingLSD); |
| | | replaceExistingSchemaElement(modifiedSchemaFiles, ldapSyntaxDesc, existingLSD); |
| | | String newSchemaFile = getSchemaFile(schema.getLdapSyntaxDescription(oid)); |
| | | |
| | | if (oldSchemaFile != null) |
| | | { |
| | | modifiedSchemaFiles.add(oldSchemaFile); |
| | | } |
| | | if (newSchemaFile != null) |
| | | { |
| | | modifiedSchemaFiles.add(newSchemaFile); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** Gets rid of the ldap syntax description. */ |
| | | private void removeLdapSyntaxDescription(LDAPSyntaxDescription ldapSyntaxDesc, |
| | | Schema schema, |
| | | Set<String> modifiedSchemaFiles) |
| | | throws DirectoryException |
| | | private void removeLdapSyntaxDescription(String definition, Schema schema, Set<String> modifiedSchemaFiles) |
| | | throws DirectoryException |
| | | { |
| | | /* |
| | | * See if the specified ldap syntax description is actually defined in the |
| | |
| | | * 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); |
| | | String oid = |
| | | Schema.parseOID(definition, ResultCode.INVALID_ATTRIBUTE_SYNTAX, ERR_ATTR_SYNTAX_LDAPSYNTAX_EMPTY_VALUE); |
| | | |
| | | if (removeLSD == null || !removeLSD.equals(ldapSyntaxDesc)) |
| | | LDAPSyntaxDescription removeLSD = schema.getLdapSyntaxDescription(oid); |
| | | if (removeLSD == null) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SCHEMA_MODIFY_REMOVE_NO_SUCH_LSD.get(oid); |
| | | 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) |
| | |
| | | // same file are written before the subordinate types. |
| | | Set<AttributeType> addedTypes = new HashSet<>(); |
| | | values = new LinkedHashSet<>(); |
| | | for (AttributeType at : schema.getAttributeTypes().values()) |
| | | for (AttributeType at : schema.getAttributeTypes()) |
| | | { |
| | | if (schemaFile.equals(getSchemaFile(at))) |
| | | String atSchemaFile = new SomeSchemaElement(at).getSchemaFile(); |
| | | if (schemaFile.equals(atSchemaFile)) |
| | | { |
| | | addAttrTypeToSchemaFile(schema, schemaFile, at, values, addedTypes, 0); |
| | | } |
| | |
| | | |
| | | AttributeType superiorType = attributeType.getSuperiorType(); |
| | | if (superiorType != null && |
| | | schemaFile.equals(getSchemaFile(superiorType)) && |
| | | schemaFile.equals(new SomeSchemaElement(attributeType).getSchemaFile()) && |
| | | !addedTypes.contains(superiorType)) |
| | | { |
| | | addAttrTypeToSchemaFile(schema, schemaFile, superiorType, values, |
| | |
| | | private void importEntry(Entry newSchemaEntry) |
| | | throws DirectoryException |
| | | { |
| | | Schema schema = DirectoryServer.getSchema(); |
| | | Schema newSchema = DirectoryServer.getSchema().duplicate(); |
| | | Schema schema = serverContext.getSchema(); |
| | | Schema newSchema = schema.duplicate(); |
| | | TreeSet<String> modifiedSchemaFiles = new TreeSet<>(); |
| | | |
| | | // Get the attributeTypes attribute from the entry. |
| | |
| | | { |
| | | attrTypeSyntax = CoreSchema.getAttributeTypeDescriptionSyntax(); |
| | | } |
| | | AttributeType attributeAttrType = DirectoryServer.getAttributeTypeOrDefault( |
| | | ATTR_ATTRIBUTE_TYPES_LC, ATTR_ATTRIBUTE_TYPES, attrTypeSyntax); |
| | | AttributeType attributeAttrType = CoreSchema.getAttributeTypesAttributeType(); |
| | | |
| | | // loop on the attribute types in the entry just received |
| | | // and add them in the existing schema. |
| | |
| | | for (ByteString v : a) |
| | | { |
| | | // Parse the attribute type. |
| | | AttributeType attrType = AttributeTypeSyntax.decodeAttributeType(v, schema, false); |
| | | String schemaFile = getSchemaFile(attrType); |
| | | AttributeType attrType = schema.parseAttributeType(v.toString()); |
| | | String schemaFile = new SomeSchemaElement(attrType).getSchemaFile(); |
| | | if (CONFIG_SCHEMA_ELEMENTS_FILE.equals(schemaFile)) |
| | | { |
| | | // Don't import the file containing the definitions of the |
| | |
| | | |
| | | // loop on all the attribute types in the current schema and delete |
| | | // them from the new schema if they are not in the imported schema entry. |
| | | ConcurrentHashMap<String, AttributeType> currentAttrTypes = |
| | | newSchema.getAttributeTypes(); |
| | | |
| | | for (AttributeType removeType : currentAttrTypes.values()) |
| | | for (AttributeType removeType : newSchema.getAttributeTypes()) |
| | | { |
| | | String schemaFile = getSchemaFile(removeType); |
| | | if (CONFIG_SCHEMA_ELEMENTS_FILE.equals(schemaFile) |
| | | || CORE_SCHEMA_ELEMENTS_FILE.equals(schemaFile)) |
| | | String schemaFile = new SomeSchemaElement(removeType).getSchemaFile(); |
| | | if (CONFIG_SCHEMA_ELEMENTS_FILE.equals(schemaFile) || CORE_SCHEMA_ELEMENTS_FILE.equals(schemaFile)) |
| | | { |
| | | // Don't import the file containing the definitions of the |
| | | // Schema elements used for configuration because these |
| | |
| | | newSchema.deregisterAttributeType(removeType); |
| | | if (schemaFile != null) |
| | | { |
| | | modifiedSchemaFiles.add(schemaFile); |
| | | modifiedSchemaFiles.add(schemaFile); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | ocSyntax = CoreSchema.getObjectClassDescriptionSyntax(); |
| | | } |
| | | AttributeType objectclassAttrType = DirectoryServer.getAttributeTypeOrDefault( |
| | | ATTR_OBJECTCLASSES_LC, ATTR_OBJECTCLASSES, ocSyntax); |
| | | AttributeType objectclassAttrType = CoreSchema.getObjectClassAttributeType(); |
| | | |
| | | oidList.clear(); |
| | | List<Attribute> ocList = newSchemaEntry.getAttribute(objectclassAttrType); |
| | |
| | | } |
| | | } |
| | | |
| | | // loop on all the attribute types in the current schema and delete |
| | | // loop on all the object classes in the current schema and delete |
| | | // them from the new schema if they are not in the imported schema entry. |
| | | ConcurrentHashMap<String, ObjectClass> currentObjectClasses = |
| | | newSchema.getObjectClasses(); |
| | | ConcurrentHashMap<String, ObjectClass> currentObjectClasses = newSchema.getObjectClasses(); |
| | | |
| | | for (ObjectClass removeClass : currentObjectClasses.values()) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends; |
| | | |
| | |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.CertificateManager; |
| | | import org.opends.server.util.Platform.KeyType; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | |
| | | import com.sleepycat.je.Environment; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | * Portions Copyright 2014 Manuel Gaupp |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | |
| | | import org.opends.server.backends.pluggable.spi.WriteOperation; |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.BackupDirectory; |
| | | import org.opends.server.types.CanceledOperationException; |
| | |
| | | OID_SERVER_SIDE_SORT_REQUEST_CONTROL, |
| | | OID_VLV_REQUEST_CONTROL); |
| | | |
| | | private ServerContext serverContext; |
| | | |
| | | /** |
| | | * Begin a Backend API method that accesses the {@link EntryContainer} for <code>entryDN</code> |
| | | * and returns it. |
| | |
| | | Reject.ifNull(cfg, "cfg must not be null"); |
| | | |
| | | this.cfg = cfg; |
| | | this.serverContext = serverContext; |
| | | baseDNs = this.cfg.getBaseDN().toArray(new DN[0]); |
| | | storage = new TracedStorage(configureStorage(cfg, serverContext), cfg.getBackendId()); |
| | | } |
| | |
| | | throws ConfigException, InitializationException { |
| | | // Open the storage |
| | | try { |
| | | final RootContainer rc = new RootContainer(getBackendID(), storage, cfg); |
| | | final RootContainer rc = new RootContainer(getBackendID(), serverContext, storage, cfg); |
| | | rc.open(accessMode); |
| | | return rc; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.CanceledOperationException; |
| | | import org.opends.server.types.Control; |
| | |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * Copyright 2015 ForgeRock AS |
| | | * Copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2015 ForgeRock AS |
| | | * Portions copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | |
| | | import org.opends.server.backends.pluggable.AttributeIndex.IndexFilterType; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.FilterType; |
| | | import org.opends.server.types.SearchFilter; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.spi.IndexQueryFactory; |
| | | import org.forgerock.opendj.ldap.spi.IndexingOptions; |
| | | import org.forgerock.util.Utils; |
| | |
| | | import org.opends.server.backends.pluggable.spi.Cursor; |
| | | import org.opends.server.backends.pluggable.spi.ReadableTransaction; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.types.AttributeType; |
| | | |
| | | /** |
| | | * This class is an implementation of IndexQueryFactory which creates |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | |
| | | import org.opends.server.backends.pluggable.spi.WriteOperation; |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | |
| | | /** |
| | | * Creates a new instance of this compressed schema manager. |
| | | * |
| | | * @param serverContext |
| | | * The server context. |
| | | * @param storage |
| | | * A reference to the storage in which the trees will be held. |
| | | * @param txn a non null transaction |
| | |
| | | * If an error occurs while loading and processing the compressed |
| | | * schema definitions. |
| | | */ |
| | | PersistentCompressedSchema(final Storage storage, WriteableTransaction txn, AccessMode accessMode) |
| | | throws StorageRuntimeException, InitializationException |
| | | PersistentCompressedSchema(ServerContext serverContext, final Storage storage, WriteableTransaction txn, |
| | | AccessMode accessMode) throws StorageRuntimeException, InitializationException |
| | | { |
| | | super(serverContext); |
| | | this.storage = storage; |
| | | load(txn, accessMode.isWriteable()); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | |
| | | import org.opends.server.backends.pluggable.spi.WriteOperation; |
| | | import org.opends.server.backends.pluggable.spi.WriteableTransaction; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | |
| | | /** The compressed schema manager for this backend. */ |
| | | private PersistentCompressedSchema compressedSchema; |
| | | |
| | | private final ServerContext serverContext; |
| | | |
| | | /** |
| | | * Creates a new RootContainer object representing a storage. |
| | | * |
| | | * @param config |
| | | * The configuration of the backend. |
| | | * @param backendID |
| | | * A reference to the backend that is creating this root |
| | | * container. |
| | | * @param serverContext |
| | | * The server context. |
| | | * @param config |
| | | * The configuration of the backend. |
| | | */ |
| | | RootContainer(String backendID, Storage storage, PluggableBackendCfg config) |
| | | RootContainer(String backendID, ServerContext serverContext, Storage storage, PluggableBackendCfg config) |
| | | { |
| | | this.backendId = backendID; |
| | | this.serverContext = serverContext; |
| | | this.storage = storage; |
| | | this.config = config; |
| | | |
| | |
| | | @Override |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | compressedSchema = new PersistentCompressedSchema(storage, txn, accessMode); |
| | | compressedSchema = new PersistentCompressedSchema(serverContext, storage, txn, accessMode); |
| | | openAndRegisterEntryContainers(txn, config.getBaseDN(), accessMode); |
| | | } |
| | | }); |
| | |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | |
| | | import org.opends.server.backends.pluggable.spi.SequentialCursor; |
| | | import org.opends.server.backends.pluggable.spi.StorageRuntimeException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.task; |
| | | |
| | |
| | | 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.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.task; |
| | | |
| | |
| | | import org.opends.messages.Severity; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.LockManager.DNLock; |
| | | import org.opends.server.util.EMailMessage; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.task; |
| | | |
| | |
| | | import org.opends.server.api.Backupable; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.*; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.LockManager.DNLock; |
| | | import org.opends.server.util.BackupManager; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.task; |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.api.AlertGenerator; |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.config; |
| | | |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.api.ConfigAddListener; |
| | | import org.opends.server.api.ConfigChangeListener; |
| | | import org.opends.server.api.ConfigDeleteListener; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.config; |
| | | |
| | |
| | | * |
| | | * @return The name of the data type for this configuration attribute. |
| | | */ |
| | | @Override |
| | | public String getDataType() |
| | | { |
| | | return "DN"; |
| | |
| | | * |
| | | * @return The attribute syntax for this configuration attribute. |
| | | */ |
| | | @Override |
| | | public Syntax getSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultStringSyntax(); |
| | |
| | | * configuration attribute. This will not take any action if there are no |
| | | * pending values. |
| | | */ |
| | | @Override |
| | | public void applyPendingValues() |
| | | { |
| | | if (! hasPendingValues()) |
| | |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use in |
| | | * this attribute, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteString value, StringBuilder rejectReason) |
| | | { |
| | | // Make sure that the value is not null. |
| | |
| | | * @throws ConfigException If an unrecoverable problem occurs while |
| | | * performing the conversion. |
| | | */ |
| | | @Override |
| | | public LinkedHashSet<ByteString> stringsToValues(List<String> valueStrings, boolean allowFailures) |
| | | throws ConfigException |
| | | { |
| | |
| | | * @return The string representations of the set of active values for this |
| | | * configuration attribute. |
| | | */ |
| | | @Override |
| | | public List<String> activeValuesToStrings() |
| | | { |
| | | ArrayList<String> valueStrings = new ArrayList<>(activeValues.size()); |
| | |
| | | * configuration attribute, or <CODE>null</CODE> if there are no |
| | | * pending values. |
| | | */ |
| | | @Override |
| | | public List<String> pendingValuesToStrings() |
| | | { |
| | | if (hasPendingValues()) |
| | |
| | | * single-valued and the provided attribute has |
| | | * multiple values). |
| | | */ |
| | | @Override |
| | | public ConfigAttribute getConfigAttribute(List<Attribute> attributeList) |
| | | throws ConfigException |
| | | { |
| | |
| | | * configuration attribute, or <CODE>null</CODE> if it does not have |
| | | * any active values. |
| | | */ |
| | | @Override |
| | | public javax.management.Attribute toJMXAttribute() |
| | | { |
| | | return _toJMXAttribute(false) ; |
| | |
| | | * @return A JMX attribute containing the pending value set for this |
| | | * configuration attribute. |
| | | */ |
| | | @Override |
| | | public javax.management.Attribute toJMXAttributePending() |
| | | { |
| | | return _toJMXAttribute(true) ; |
| | |
| | | * @param attributeList The attribute list to which the JMX attribute(s) |
| | | * should be added. |
| | | */ |
| | | @Override |
| | | public void toJMXAttribute(AttributeList attributeList) |
| | | { |
| | | if (!activeValues.isEmpty()) |
| | |
| | | * @param attributeInfoList The list to which the attribute information |
| | | * should be added. |
| | | */ |
| | | @Override |
| | | public void toJMXAttributeInfo(List<MBeanAttributeInfo> attributeInfoList) |
| | | { |
| | | attributeInfoList.add(new MBeanAttributeInfo(getName(), getType(), |
| | |
| | | * @return A JMX <CODE>MBeanParameterInfo</CODE> object that describes this |
| | | * configuration attribute. |
| | | */ |
| | | @Override |
| | | public MBeanParameterInfo toJMXParameterInfo() |
| | | { |
| | | return new MBeanParameterInfo(getName(), getType(), String.valueOf(getDescription())); |
| | |
| | | * acceptable value for this configuration |
| | | * attribute. |
| | | */ |
| | | @Override |
| | | public void setValue(javax.management.Attribute jmxAttribute) |
| | | throws ConfigException |
| | | { |
| | |
| | | * |
| | | * @return A duplicate of this configuration attribute. |
| | | */ |
| | | @Override |
| | | public ConfigAttribute duplicate() |
| | | { |
| | | return new DNConfigAttribute(getName(), getDescription(), isRequired(), |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.config; |
| | | |
| | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.util.CollectionUtils; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | |
| | | /** |
| | | * This class defines an integer configuration attribute, which can hold zero or |
| | |
| | | * |
| | | * @return The name of the data type for this configuration attribute. |
| | | */ |
| | | @Override |
| | | public String getDataType() |
| | | { |
| | | return "Integer"; |
| | |
| | | * |
| | | * @return The attribute syntax for this configuration attribute. |
| | | */ |
| | | @Override |
| | | public Syntax getSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultIntegerSyntax(); |
| | |
| | | * configuration attribute. This will not take any action if there are no |
| | | * pending values. |
| | | */ |
| | | @Override |
| | | public void applyPendingValues() |
| | | { |
| | | if (! hasPendingValues()) |
| | |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use in |
| | | * this attribute, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteString value, StringBuilder rejectReason) |
| | | { |
| | | // First, make sure we can represent it as a long. |
| | |
| | | * @throws ConfigException If an unrecoverable problem occurs while |
| | | * performing the conversion. |
| | | */ |
| | | @Override |
| | | public LinkedHashSet<ByteString> |
| | | stringsToValues(List<String> valueStrings, boolean allowFailures) |
| | | throws ConfigException |
| | |
| | | * @return The string representations of the set of active values for this |
| | | * configuration attribute. |
| | | */ |
| | | @Override |
| | | public List<String> activeValuesToStrings() |
| | | { |
| | | return toListOfString(activeValues); |
| | |
| | | * configuration attribute, or <CODE>null</CODE> if there are no |
| | | * pending values. |
| | | */ |
| | | @Override |
| | | public List<String> pendingValuesToStrings() |
| | | { |
| | | if (hasPendingValues()) |
| | |
| | | * single-valued and the provided attribute has |
| | | * multiple values). |
| | | */ |
| | | @Override |
| | | public ConfigAttribute getConfigAttribute(List<Attribute> attributeList) |
| | | throws ConfigException |
| | | { |
| | |
| | | * configuration attribute, or <CODE>null</CODE> if it does not have |
| | | * any active values. |
| | | */ |
| | | @Override |
| | | public javax.management.Attribute toJMXAttribute() |
| | | { |
| | | return _toJMXAttribute(false); |
| | |
| | | * @return A JMX attribute containing the pending value set for this |
| | | * configuration attribute. |
| | | */ |
| | | @Override |
| | | public javax.management.Attribute toJMXAttributePending() |
| | | { |
| | | return _toJMXAttribute(true); |
| | |
| | | * @param attributeList The attribute list to which the JMX attribute(s) |
| | | * should be added. |
| | | */ |
| | | @Override |
| | | public void toJMXAttribute(AttributeList attributeList) |
| | | { |
| | | if (!activeValues.isEmpty()) |
| | |
| | | * @param attributeInfoList The list to which the attribute information |
| | | * should be added. |
| | | */ |
| | | @Override |
| | | public void toJMXAttributeInfo(List<MBeanAttributeInfo> attributeInfoList) |
| | | { |
| | | if (isMultiValued()) |
| | |
| | | * @return A JMX <CODE>MBeanParameterInfo</CODE> object that describes this |
| | | * configuration attribute. |
| | | */ |
| | | @Override |
| | | public MBeanParameterInfo toJMXParameterInfo() |
| | | { |
| | | if (isMultiValued()) |
| | |
| | | * acceptable value for this configuration |
| | | * attribute. |
| | | */ |
| | | @Override |
| | | public void setValue(javax.management.Attribute jmxAttribute) |
| | | throws ConfigException |
| | | { |
| | |
| | | * |
| | | * @return A duplicate of this configuration attribute. |
| | | */ |
| | | @Override |
| | | public ConfigAttribute duplicate() |
| | | { |
| | | return new IntegerConfigAttribute(getName(), getDescription(), isRequired(), |
| | |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.config; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.jmx.Credential; |
| | | import org.opends.server.protocols.jmx.JmxClientConnection; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InvokableMethod; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.config; |
| | | |
| | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.util.CollectionUtils; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | |
| | | /** |
| | | * This class defines a multi-choice configuration attribute, which can hold |
| | |
| | | * |
| | | * @return The name of the data type for this configuration attribute. |
| | | */ |
| | | @Override |
| | | public String getDataType() |
| | | { |
| | | return "MultiChoice"; |
| | |
| | | * |
| | | * @return The attribute syntax for this configuration attribute. |
| | | */ |
| | | @Override |
| | | public Syntax getSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultStringSyntax(); |
| | |
| | | * configuration attribute. This will not take any action if there are no |
| | | * pending values. |
| | | */ |
| | | @Override |
| | | public void applyPendingValues() |
| | | { |
| | | if (! hasPendingValues()) |
| | |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use in |
| | | * this attribute, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteString value, |
| | | StringBuilder rejectReason) |
| | | { |
| | |
| | | * @throws ConfigException If an unrecoverable problem occurs while |
| | | * performing the conversion. |
| | | */ |
| | | @Override |
| | | public LinkedHashSet<ByteString> |
| | | stringsToValues(List<String> valueStrings, boolean allowFailures) |
| | | throws ConfigException |
| | |
| | | * |
| | | * @return The string representations of the set of active values for this configuration attribute. |
| | | */ |
| | | @Override |
| | | public List<String> activeValuesToStrings() |
| | | { |
| | | return activeValues; |
| | |
| | | * configuration attribute, or <CODE>null</CODE> if there are no |
| | | * pending values. |
| | | */ |
| | | @Override |
| | | public List<String> pendingValuesToStrings() |
| | | { |
| | | if (hasPendingValues()) |
| | |
| | | * single-valued and the provided attribute has |
| | | * multiple values). |
| | | */ |
| | | @Override |
| | | public ConfigAttribute getConfigAttribute(List<Attribute> attributeList) |
| | | throws ConfigException |
| | | { |
| | |
| | | * configuration attribute, or <CODE>null</CODE> if it does not have |
| | | * any active values. |
| | | */ |
| | | @Override |
| | | public javax.management.Attribute toJMXAttribute() |
| | | { |
| | | return _toJMXAttribute(false) ; |
| | |
| | | * configuration attribute, or <CODE>null</CODE> if it does not have |
| | | * any active values. |
| | | */ |
| | | @Override |
| | | public javax.management.Attribute toJMXAttributePending() |
| | | { |
| | | return _toJMXAttribute(true) ; |
| | |
| | | * @param attributeList The attribute list to which the JMX attribute(s) |
| | | * should be added. |
| | | */ |
| | | @Override |
| | | public void toJMXAttribute(AttributeList attributeList) |
| | | { |
| | | if (!activeValues.isEmpty()) |
| | |
| | | * @param attributeInfoList The list to which the attribute information |
| | | * should be added. |
| | | */ |
| | | @Override |
| | | public void toJMXAttributeInfo(List<MBeanAttributeInfo> attributeInfoList) |
| | | { |
| | | attributeInfoList.add(new MBeanAttributeInfo(getName(), getType(), |
| | |
| | | * @return A JMX <CODE>MBeanParameterInfo</CODE> object that describes this |
| | | * configuration attribute. |
| | | */ |
| | | @Override |
| | | public MBeanParameterInfo toJMXParameterInfo() |
| | | { |
| | | return new MBeanParameterInfo(getName(), getType(), String.valueOf(getDescription())); |
| | |
| | | * acceptable value for this configuration |
| | | * attribute. |
| | | */ |
| | | @Override |
| | | public void setValue(javax.management.Attribute jmxAttribute) |
| | | throws ConfigException |
| | | { |
| | |
| | | * |
| | | * @return A duplicate of this configuration attribute. |
| | | */ |
| | | @Override |
| | | public ConfigAttribute duplicate() |
| | | { |
| | | return new MultiChoiceConfigAttribute(getName(), getDescription(), |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.config; |
| | | |
| | |
| | | * |
| | | * @return The name of the data type for this configuration attribute. |
| | | */ |
| | | @Override |
| | | public String getDataType() |
| | | { |
| | | return "String"; |
| | |
| | | * |
| | | * @return The attribute syntax for this configuration attribute. |
| | | */ |
| | | @Override |
| | | public Syntax getSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultStringSyntax(); |
| | |
| | | * configuration attribute. This will not take any action if there are no |
| | | * pending values. |
| | | */ |
| | | @Override |
| | | public void applyPendingValues() |
| | | { |
| | | if (! hasPendingValues()) |
| | |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use in |
| | | * this attribute, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteString value, |
| | | StringBuilder rejectReason) |
| | | { |
| | |
| | | * @throws ConfigException If an unrecoverable problem occurs while |
| | | * performing the conversion. |
| | | */ |
| | | @Override |
| | | public LinkedHashSet<ByteString> stringsToValues(List<String> valueStrings, boolean allowFailures) |
| | | throws ConfigException |
| | | { |
| | |
| | | * @return The string representations of the set of active values for this |
| | | * configuration attribute. |
| | | */ |
| | | @Override |
| | | public List<String> activeValuesToStrings() |
| | | { |
| | | return activeValues; |
| | |
| | | * configuration attribute, or <CODE>null</CODE> if there are no |
| | | * pending values. |
| | | */ |
| | | @Override |
| | | public List<String> pendingValuesToStrings() |
| | | { |
| | | if (hasPendingValues()) |
| | |
| | | * single-valued and the provided attribute has |
| | | * multiple values). |
| | | */ |
| | | @Override |
| | | public ConfigAttribute getConfigAttribute(List<Attribute> attributeList) |
| | | throws ConfigException |
| | | { |
| | |
| | | * configuration attribute, or <CODE>null</CODE> if it does not have |
| | | * any active values. |
| | | */ |
| | | @Override |
| | | public javax.management.Attribute toJMXAttribute() |
| | | { |
| | | return _toJMXAttribute(false) ; |
| | |
| | | * configuration attribute, or <CODE>null</CODE> if it does not have |
| | | * any active values. |
| | | */ |
| | | @Override |
| | | public javax.management.Attribute toJMXAttributePending() |
| | | { |
| | | return _toJMXAttribute(true) ; |
| | |
| | | * @param attributeList The attribute list to which the JMX attribute(s) |
| | | * should be added. |
| | | */ |
| | | @Override |
| | | public void toJMXAttribute(AttributeList attributeList) |
| | | { |
| | | if (!activeValues.isEmpty()) |
| | |
| | | * @param attributeInfoList The list to which the attribute information |
| | | * should be added. |
| | | */ |
| | | @Override |
| | | public void toJMXAttributeInfo(List<MBeanAttributeInfo> attributeInfoList) |
| | | { |
| | | attributeInfoList.add(new MBeanAttributeInfo(getName(), getType(), |
| | |
| | | * @return A JMX <CODE>MBeanParameterInfo</CODE> object that describes this |
| | | * configuration attribute. |
| | | */ |
| | | @Override |
| | | public MBeanParameterInfo toJMXParameterInfo() |
| | | { |
| | | return new MBeanParameterInfo(getName(), getType(), String.valueOf(getDescription())); |
| | |
| | | * acceptable value for this configuration |
| | | * attribute. |
| | | */ |
| | | @Override |
| | | public void setValue(javax.management.Attribute jmxAttribute) |
| | | throws ConfigException |
| | | { |
| | |
| | | * |
| | | * @return A duplicate of this configuration attribute. |
| | | */ |
| | | @Override |
| | | public ConfigAttribute duplicate() |
| | | { |
| | | return new StringConfigAttribute(getName(), getDescription(), isRequired(), |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.controls; |
| | | |
| | |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | private static final class Decoder |
| | | implements ControlDecoder<GetEffectiveRightsRequestControl> |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public GetEffectiveRightsRequestControl decode(boolean isCritical, |
| | | ByteString value) throws DirectoryException |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return OID_GET_EFFECTIVE_RIGHTS; |
| | |
| | | this.rawAttrs=attrs; |
| | | } |
| | | |
| | | /** |
| | | * Writes this control's value to an ASN.1 writer. The value (if any) must be |
| | | * written as an ASN1OctetString. |
| | | * |
| | | * @param writer The ASN.1 output stream to write to. |
| | | * @throws IOException If a problem occurs while writing to the stream. |
| | | */ |
| | | @Override |
| | | public void writeValue(ASN1Writer writer) throws IOException { |
| | | writer.writeStartSequence(ASN1.UNIVERSAL_OCTET_STRING_TYPE); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.controls; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | import java.io.IOException; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 Manuel Gaupp |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.controls; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.Assertion; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RawFilter; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.controls; |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.io.*; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | implements ControlDecoder<ServerSideSortRequestControl> |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ServerSideSortRequestControl decode(boolean isCritical, |
| | | ByteString value) |
| | | throws DirectoryException |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return OID_SERVER_SIDE_SORT_REQUEST_CONTROL; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.PostResponseAddOperation; |
| | | import org.opends.server.types.operation.PreParseAddOperation; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | 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.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | 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; |
| | |
| | | AttributeSyntax<?> syntax = loadSyntax(className, syntaxConfiguration, true); |
| | | try |
| | | { |
| | | Syntax sdkSyntax = syntax.getSDKSyntax(serverContext.getSchemaNG()); |
| | | serverContext.getSchema().registerSyntax(sdkSyntax, false); |
| | | Schema schemaNG = serverContext.getSchemaNG(); |
| | | Syntax sdkSyntax = syntax.getSDKSyntax(schemaNG); |
| | | // skip the syntax registration if already defined in the (core) schema |
| | | if (!schemaNG.hasSyntax(sdkSyntax.getOID())) |
| | | { |
| | | // The syntaxes configuration options (e.g. strictness, support for zero length values, etc) |
| | | // are set by the call to loadSyntax() which calls initializeSyntax() |
| | | // which updates the SDK schema options. |
| | | serverContext.getSchema().registerSyntax(sdkSyntax, false); |
| | | } |
| | | syntaxes.put(syntaxConfiguration.dn(), syntax); |
| | | } |
| | | catch (DirectoryException de) |
| | |
| | | if (syntax != null) |
| | | { |
| | | String oid = syntax.getOID(); |
| | | for (AttributeType at : DirectoryServer.getAttributeTypes().values()) |
| | | for (AttributeType at : DirectoryServer.getAttributeTypes()) |
| | | { |
| | | if (oid.equals(at.getSyntax().getOID())) |
| | | { |
| | |
| | | if (syntax != null) |
| | | { |
| | | String oid = syntax.getOID(); |
| | | for (AttributeType at : DirectoryServer.getAttributeTypes().values()) |
| | | for (AttributeType at : DirectoryServer.getAttributeTypes()) |
| | | { |
| | | if (oid.equals(at.getSyntax().getOID())) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.PostResponseCompareOperation; |
| | | import org.opends.server.types.operation.PreParseCompareOperation; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import java.util.Set; |
| | | |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | 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.RootCfg; |
| | | import org.opends.server.api.AuthenticationPolicy; |
| | | import org.opends.server.loggers.CommonAudit; |
| | | import org.opends.server.schema.SchemaUpdater; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.forgerock.opendj.ldap.schema.SchemaOptions.*; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // Apply the configuration to the server. |
| | | applyGlobalConfiguration(globalConfig, serverContext); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Applies the settings in the provided configuration to the Directory Server. |
| | | * |
| | | * @param globalConfig The configuration settings to be applied. |
| | | */ |
| | | private static void applyGlobalConfiguration(GlobalCfg globalConfig, ServerContext serverContext) |
| | | private static void applyGlobalConfiguration(final GlobalCfg globalConfig, final ServerContext serverContext) |
| | | throws ConfigException |
| | | { |
| | | setCheckSchema(globalConfig.isCheckSchema()); |
| | | setDefaultPasswordPolicyDN(globalConfig.getDefaultPasswordPolicyDN()); |
| | |
| | | commonAudit.setTrustTransactionIds(globalConfig.isTrustTransactionIds()); |
| | | } |
| | | |
| | | // 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()) |
| | | // Update the "new" schema with configuration changes if necessary |
| | | try |
| | | { |
| | | schema = schema.asNonStrictSchema(); |
| | | final boolean allowMalformedNames = globalConfig.isAllowAttributeNameExceptions(); |
| | | serverContext.getSchema().updateSchemaOption(ALLOW_MALFORMED_NAMES_AND_OPTIONS, allowMalformedNames); |
| | | } |
| | | schemaUpdater.updateSchema(schema); |
| | | catch (DirectoryException e) |
| | | { |
| | | throw new ConfigException(e.getMessageObject(), e); |
| | | } |
| | | } |
| | | |
| | | private static AcceptRejectWarn convert(InvalidAttributeSyntaxBehavior invalidAttributeSyntaxBehavior) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(GlobalCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | } |
| | | catch (RuntimeException e) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_CORE_INVALID_SMTP_SERVER.get(server); |
| | | unacceptableReasons.add(message); |
| | | unacceptableReasons.add(ERR_CONFIG_CORE_INVALID_SMTP_SERVER.get(server)); |
| | | configAcceptable = false; |
| | | } |
| | | } |
| | |
| | | return configAcceptable; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange(GlobalCfg configuration) |
| | | { |
| | | final ConfigChangeResult ccr = new ConfigChangeResult(); |
| | | |
| | | applyGlobalConfiguration(configuration, serverContext); |
| | | |
| | | try |
| | | { |
| | | applyGlobalConfiguration(configuration, serverContext); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | | ccr.setResultCode(DirectoryServer.getServerErrorResultCode()); |
| | | ccr.addMessage(e.getMessageObject()); |
| | | } |
| | | return ccr; |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | |
| | | /** |
| | | * Creates a new instance of this compressed schema manager. |
| | | * |
| | | * @param serverContext |
| | | * The server context. |
| | | */ |
| | | public DefaultCompressedSchema() |
| | | public DefaultCompressedSchema(ServerContext serverContext) |
| | | { |
| | | super(serverContext); |
| | | load(); |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2010-2015 ForgeRock AS. |
| | | * Portions Copyright 2010-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | 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.AttributeType; |
| | | 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.forgerock.util.Reject; |
| | | import org.opends.server.admin.AdministrationConnector; |
| | |
| | | import org.opends.server.api.InitializationCompletedListener; |
| | | import org.opends.server.api.InvokableComponent; |
| | | import org.opends.server.api.KeyManagerProvider; |
| | | import org.opends.server.api.MatchingRuleFactory; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.api.PasswordGenerator; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | |
| | | 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.BooleanEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.CaseExactEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.CaseExactIA5EqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.CaseExactIA5SubstringMatchingRuleFactory; |
| | | import org.opends.server.schema.CaseExactOrderingMatchingRuleFactory; |
| | | import org.opends.server.schema.CaseExactSubstringMatchingRuleFactory; |
| | | import org.opends.server.schema.CaseIgnoreEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.CaseIgnoreIA5EqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.CaseIgnoreIA5SubstringMatchingRuleFactory; |
| | | import org.opends.server.schema.CaseIgnoreOrderingMatchingRuleFactory; |
| | | import org.opends.server.schema.CaseIgnoreSubstringMatchingRuleFactory; |
| | | import org.opends.server.schema.DistinguishedNameEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.DoubleMetaphoneApproximateMatchingRuleFactory; |
| | | import org.opends.server.schema.GeneralizedTimeEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.GeneralizedTimeOrderingMatchingRuleFactory; |
| | | import org.opends.server.schema.IntegerEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.IntegerOrderingMatchingRuleFactory; |
| | | import org.opends.server.schema.ObjectIdentifierEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.OctetStringEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.OctetStringOrderingMatchingRuleFactory; |
| | | import org.opends.server.schema.OctetStringSubstringMatchingRuleFactory; |
| | | import org.opends.server.schema.SchemaUpdater; |
| | | import org.opends.server.schema.TelephoneNumberEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.TelephoneNumberSubstringMatchingRuleFactory; |
| | | import org.opends.server.types.AcceptRejectWarn; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DITContentRule; |
| | |
| | | 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; |
| | |
| | | /** The account status notification handler config manager for the server. */ |
| | | private AccountStatusNotificationHandlerConfigManager accountStatusNotificationHandlerConfigManager; |
| | | |
| | | /** The attribute type used to reference the "objectclass" attribute. */ |
| | | private AttributeType objectClassAttributeType; |
| | | /** The authenticated users manager for the server. */ |
| | | private AuthenticatedUsers authenticatedUsers; |
| | | /** The configuration manager that will handle the server backends. */ |
| | |
| | | /** The schema for the Directory Server. */ |
| | | private Schema schema; |
| | | |
| | | /** |
| | | * 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. */ |
| | | private SchemaConfigManager schemaConfigManager; |
| | | |
| | |
| | | */ |
| | | private class DirectoryServerContext implements ServerContext |
| | | { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getInstanceRoot() |
| | | { |
| | | return DirectoryServer.getInstanceRoot(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getServerRoot() |
| | | { |
| | | return DirectoryServer.getServerRoot(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Schema getSchema() |
| | | { |
| | | return directoryServer.schema; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public org.forgerock.opendj.ldap.schema.Schema getSchemaNG() |
| | | { |
| | | return directoryServer.schemaNG; |
| | | return directoryServer.schema.getSchemaNG(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DirectoryEnvironmentConfig getEnvironment() |
| | | { |
| | | return directoryServer.environmentConfig; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SchemaUpdater getSchemaUpdater() |
| | | { |
| | | return new SchemaUpdater() |
| | | { |
| | | @Override |
| | | public boolean updateSchema(org.forgerock.opendj.ldap.schema.Schema schema) |
| | | { |
| | | schemaNG = schema; |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public SchemaBuilder getSchemaBuilder() |
| | | { |
| | | return new SchemaBuilder(schemaNG); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public org.forgerock.opendj.config.server.ServerManagementContext getServerManagementContext() |
| | | { |
| | |
| | | { |
| | | synchronized (directoryServer) |
| | | { |
| | | // Set default values for variables that may be needed during schema |
| | | // processing. |
| | | // Set default values for variables that may be needed during schema processing. |
| | | directoryServer.syntaxEnforcementPolicy = AcceptRejectWarn.REJECT; |
| | | |
| | | // 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(); |
| | | org.forgerock.opendj.ldap.schema.Schema coreSchema = org.forgerock.opendj.ldap.schema.Schema.getCoreSchema(); |
| | | directoryServer.schema = new Schema(coreSchema); |
| | | directoryServer.bootstrapAttributeSyntaxes(); |
| | | |
| | | // Perform any additional initialization that might be necessary before |
| | |
| | | } |
| | | |
| | | /** |
| | | * Registers a basic set of matching rules with the server that should always |
| | | * be available regardless of the server configuration and may be needed for |
| | | * configuration processing. |
| | | */ |
| | | private void bootstrapMatchingRules() |
| | | { |
| | | MatchingRuleFactory<?>[] factories = |
| | | new MatchingRuleFactory<?>[] { |
| | | new DoubleMetaphoneApproximateMatchingRuleFactory(), |
| | | new BooleanEqualityMatchingRuleFactory(), |
| | | new CaseExactEqualityMatchingRuleFactory(), |
| | | new CaseExactIA5EqualityMatchingRuleFactory(), |
| | | new CaseIgnoreEqualityMatchingRuleFactory(), |
| | | new CaseIgnoreIA5EqualityMatchingRuleFactory(), |
| | | new DistinguishedNameEqualityMatchingRuleFactory(), |
| | | new GeneralizedTimeEqualityMatchingRuleFactory(), |
| | | new IntegerEqualityMatchingRuleFactory(), |
| | | new OctetStringEqualityMatchingRuleFactory(), |
| | | new ObjectIdentifierEqualityMatchingRuleFactory(), |
| | | new TelephoneNumberEqualityMatchingRuleFactory(), |
| | | new CaseExactOrderingMatchingRuleFactory(), |
| | | new CaseIgnoreOrderingMatchingRuleFactory(), |
| | | new GeneralizedTimeOrderingMatchingRuleFactory(), |
| | | new IntegerOrderingMatchingRuleFactory(), |
| | | new OctetStringOrderingMatchingRuleFactory(), |
| | | new CaseExactSubstringMatchingRuleFactory(), |
| | | new CaseExactIA5SubstringMatchingRuleFactory(), |
| | | new CaseIgnoreSubstringMatchingRuleFactory(), |
| | | new CaseIgnoreIA5SubstringMatchingRuleFactory(), |
| | | new OctetStringSubstringMatchingRuleFactory(), |
| | | new TelephoneNumberSubstringMatchingRuleFactory()}; |
| | | |
| | | MatchingRuleFactory<?> currentFactory = null; |
| | | try |
| | | { |
| | | for(MatchingRuleFactory<?> factory: factories) |
| | | { |
| | | currentFactory = factory; |
| | | currentFactory.initializeMatchingRule(null); |
| | | for(MatchingRule matchingRule: currentFactory.getMatchingRules()) |
| | | { |
| | | registerMatchingRule(matchingRule, true); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | logger.error(ERR_CANNOT_BOOTSTRAP_MATCHING_RULE, currentFactory.getClass().getName(), |
| | | stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Registers a basic set of attribute syntaxes with the server that should |
| | | * always be available regardless of the server configuration and may be |
| | | * needed for configuration processing. |
| | |
| | | schemaConfigManager.initializeSchemaFromFiles(); |
| | | |
| | | // With server schema in place set compressed schema. |
| | | compressedSchema = new DefaultCompressedSchema(); |
| | | compressedSchema = new DefaultCompressedSchema(serverContext); |
| | | |
| | | // At this point we have a problem, because none of the configuration is |
| | | // usable because it was all read before we had a schema (and therefore all |
| | |
| | | |
| | | /** |
| | | * Retrieves the set of matching rules registered with the Directory Server. |
| | | * The mapping will be between the lowercase name or OID for each matching |
| | | * rule and the matching rule implementation. The same matching rule instance |
| | | * may be included multiple times with different keys. |
| | | * |
| | | * @return The set of matching rules registered with the Directory Server. |
| | | */ |
| | | public static ConcurrentMap<String, MatchingRule> getMatchingRules() |
| | | public static Collection<MatchingRule> getMatchingRules() |
| | | { |
| | | return directoryServer.schema.getMatchingRules(); |
| | | } |
| | |
| | | * @return The set of attribute type definitions that have been |
| | | * defined in the Directory Server. |
| | | */ |
| | | public static ConcurrentMap<String, AttributeType> getAttributeTypes() |
| | | public static Collection<AttributeType> getAttributeTypes() |
| | | { |
| | | return directoryServer.schema.getAttributeTypes(); |
| | | } |
| | |
| | | */ |
| | | public static AttributeType getAttributeTypeOrNull(String lowerName) |
| | | { |
| | | return directoryServer.schema.getAttributeType(lowerName); |
| | | AttributeType attrType = directoryServer.schema.getAttributeType(lowerName); |
| | | return attrType.isPlaceHolder() ? null : attrType; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static AttributeType getAttributeTypeOrDefault(String lowerName, String upperName, Syntax syntax) |
| | | { |
| | | AttributeType attrType = getAttributeTypeOrNull(lowerName); |
| | | if (attrType == null) |
| | | { |
| | | attrType = getDefaultAttributeType(upperName, syntax); |
| | | } |
| | | return attrType; |
| | | return directoryServer.schema.getAttributeType(upperName, syntax); |
| | | } |
| | | |
| | | /** |
| | |
| | | boolean overwriteExisting) |
| | | throws DirectoryException |
| | | { |
| | | directoryServer.schema.registerAttributeType(attributeType, |
| | | overwriteExisting); |
| | | directoryServer.schema.registerAttributeType(attributeType, overwriteExisting); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static AttributeType getObjectClassAttributeType() |
| | | { |
| | | if (directoryServer.objectClassAttributeType == null) |
| | | { |
| | | directoryServer.objectClassAttributeType = |
| | | directoryServer.schema.getAttributeType( |
| | | OBJECTCLASS_ATTRIBUTE_TYPE_NAME); |
| | | |
| | | if (directoryServer.objectClassAttributeType == null) |
| | | { |
| | | Syntax oidSyntax = directoryServer.schema.getSyntax(SYNTAX_OID_NAME); |
| | | if (oidSyntax == null) |
| | | { |
| | | try |
| | | { |
| | | oidSyntax = CoreSchema.getOIDSyntax(); |
| | | directoryServer.schema.registerSyntax(oidSyntax, true); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | |
| | | String definition = |
| | | "( 2.5.4.0 NAME 'objectClass' EQUALITY objectIdentifierMatch " + |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 X-ORIGIN 'RFC 2256' )"; |
| | | |
| | | directoryServer.objectClassAttributeType = |
| | | newAttributeType(definition, "objectClass", OBJECTCLASS_ATTRIBUTE_TYPE_OID, oidSyntax); |
| | | try |
| | | { |
| | | directoryServer.schema.registerAttributeType( |
| | | directoryServer.objectClassAttributeType, true); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // This should never happen. |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return directoryServer.objectClassAttributeType; |
| | | } |
| | | |
| | | /** |
| | | * Causes the Directory Server to construct a new attribute type definition |
| | | * with the provided name and syntax. This should only be used if there is no |
| | | * real attribute type for the specified name. |
| | | * <p> |
| | | * TODO remove once we switch to the SDK Schema |
| | | * <p> |
| | | * FIXME move to {@link org.opends.server.types.Schema}? |
| | | * |
| | | * @param name The name to use for the attribute type, as provided by the user. |
| | | * @param syntax The syntax to use for the attribute type. |
| | | * |
| | | * @return The constructed attribute type definition. |
| | | */ |
| | | public static AttributeType getDefaultAttributeType(String name, Syntax syntax) |
| | | { |
| | | String oid = toLowerCase(name) + "-oid"; |
| | | String definition = "( " + oid + " NAME '" + name + "' SYNTAX " + |
| | | syntax.getOID() + " )"; |
| | | |
| | | // Temporary attribute types are immediately dirty. |
| | | return newAttributeType(definition, name, oid, syntax).setDirty(); |
| | | } |
| | | |
| | | private static AttributeType newAttributeType(String definition, String name, String oid, Syntax syntax) |
| | | { |
| | | return new AttributeType(definition, name, Collections.singleton(name), oid, null, null, syntax, |
| | | AttributeUsage.USER_APPLICATIONS, false, false, false, false); |
| | | return directoryServer.schema.getAttributeType(OBJECTCLASS_ATTRIBUTE_TYPE_NAME); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The set of attribute syntaxes defined in the Directory Server. |
| | | */ |
| | | public static ConcurrentMap<String, Syntax> getAttributeSyntaxes() |
| | | public static Collection<Syntax> getAttributeSyntaxes() |
| | | { |
| | | return directoryServer.schema.getSyntaxes(); |
| | | } |
| | |
| | | cryptoManager = null; |
| | | entryCache = null; |
| | | environmentConfig = null; |
| | | objectClassAttributeType = null; |
| | | schemaDN = null; |
| | | shutdownHook = null; |
| | | workQueue = null; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | 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.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | |
| | | import org.opends.server.admin.std.server.MatchingRuleCfg; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.api.MatchingRuleFactory; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.opends.server.schema.CollationMatchingRuleFactory; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.MatchingRuleUse; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | /** |
| | | * This class defines a utility that will be used to manage the set of matching |
| | |
| | | */ |
| | | private ConcurrentHashMap<DN,MatchingRuleFactory> matchingRuleFactories; |
| | | |
| | | /** Creates a new instance of this matching rule config manager. */ |
| | | public MatchingRuleConfigManager() |
| | | private final ServerContext serverContext; |
| | | |
| | | /** |
| | | * Creates a new instance of this matching rule config manager. |
| | | * |
| | | * @param serverContext |
| | | * The server context. |
| | | */ |
| | | public MatchingRuleConfigManager(ServerContext serverContext) |
| | | { |
| | | this.serverContext = serverContext; |
| | | matchingRuleFactories = new ConcurrentHashMap<>(); |
| | | } |
| | | |
| | |
| | | throws ConfigException, InitializationException |
| | | { |
| | | // Get the root configuration object. |
| | | ServerManagementContext managementContext = |
| | | ServerManagementContext.getInstance(); |
| | | ServerManagementContext managementContext = ServerManagementContext.getInstance(); |
| | | RootCfg rootConfiguration = |
| | | managementContext.getRootConfiguration(); |
| | | |
| | |
| | | rootConfiguration.addMatchingRuleAddListener(this); |
| | | rootConfiguration.addMatchingRuleDeleteListener(this); |
| | | |
| | | |
| | | //Initialize the existing matching rules. |
| | | for (String name : rootConfiguration.listMatchingRules()) |
| | | { |
| | |
| | | String className = mrConfiguration.getJavaClass(); |
| | | try |
| | | { |
| | | MatchingRuleFactory<?> factory = |
| | | loadMatchingRuleFactory(className, mrConfiguration, true); |
| | | MatchingRuleFactory<?> factory = loadMatchingRuleFactory(className, mrConfiguration, true); |
| | | |
| | | try |
| | | { |
| | | for(MatchingRule matchingRule: factory.getMatchingRules()) |
| | | { |
| | | DirectoryServer.registerMatchingRule(matchingRule, false); |
| | | Schema schema = serverContext.getSchema(); |
| | | // skip the matching rule registration if already defined in the (core) schema |
| | | if (!schema.hasMatchingRule(matchingRule.getNameOrOID())) |
| | | { |
| | | DirectoryServer.registerMatchingRule(matchingRule, false); |
| | | } |
| | | } |
| | | matchingRuleFactories.put(mrConfiguration.dn(), factory); |
| | | } |
| | |
| | | { |
| | | if (matchingRule != null) |
| | | { |
| | | for (AttributeType at : DirectoryServer.getAttributeTypes().values()) |
| | | for (AttributeType at : DirectoryServer.getAttributeTypes()) |
| | | { |
| | | final String attr = at.getNameOrOID(); |
| | | if (!isDeleteAcceptable(at.getApproximateMatchingRule(), matchingRule, attr, unacceptableReasons) |
| | |
| | | { |
| | | if (matchingRule != null) |
| | | { |
| | | for (AttributeType at : DirectoryServer.getAttributeTypes().values()) |
| | | for (AttributeType at : DirectoryServer.getAttributeTypes()) |
| | | { |
| | | final String attr = at.getNameOrOID(); |
| | | if (!isDisableAcceptable(at.getApproximateMatchingRule(), matchingRule, attr, unacceptableReasons) |
| | |
| | | propertyDefinition.loadClass(className, |
| | | MatchingRuleFactory.class); |
| | | factory = matchingRuleFactoryClass.newInstance(); |
| | | // specific behavior for collation |
| | | // in order to avoid useless injection of context server for all factories |
| | | if (factory instanceof CollationMatchingRuleFactory) |
| | | { |
| | | CollationMatchingRuleFactory collationFactory = (CollationMatchingRuleFactory) factory; |
| | | collationFactory.setServerContext(serverContext); |
| | | } |
| | | |
| | | if (initialize) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.PostResponseModifyOperation; |
| | | import org.opends.server.types.operation.PreParseModifyOperation; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2015 ForgeRock AS. |
| | | * Portions copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | |
| | | import org.opends.server.admin.std.meta.PasswordPolicyCfgDefn.*; |
| | | import org.opends.server.api.*; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | import org.opends.server.admin.std.meta.PasswordPolicyCfgDefn.StateUpdateFailurePolicy; |
| | | import org.opends.server.admin.std.server.PasswordPolicyCfg; |
| | | import org.opends.server.api.*; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | import org.opends.server.types.AccountStatusNotificationType; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | 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.*; |
| | |
| | | public SchemaConfigManager(ServerContext serverContext) |
| | | { |
| | | this.serverContext = serverContext; |
| | | schema = new Schema(); |
| | | // the manager will build the schema from scratch, but we need to start from |
| | | // core schema for SDK schema |
| | | schema = new Schema(org.forgerock.opendj.ldap.schema.Schema.getCoreSchema()); |
| | | } |
| | | |
| | | |
| | |
| | | public void initializeMatchingRules() |
| | | throws ConfigException, InitializationException |
| | | { |
| | | MatchingRuleConfigManager matchingRuleConfigManager = |
| | | new MatchingRuleConfigManager(); |
| | | MatchingRuleConfigManager matchingRuleConfigManager = new MatchingRuleConfigManager(serverContext); |
| | | matchingRuleConfigManager.initializeMatchingRules(); |
| | | } |
| | | |
| | |
| | | // from that entry and parse them to initialize the server schema. |
| | | for (String schemaFile : fileNames) |
| | | { |
| | | loadSchemaFile(serverContext, schema, schemaFile, false); |
| | | loadSchemaFile(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(ServerContext serverContext, Schema schema, String schemaFile) |
| | | public static List<Modification> loadSchemaFile(Schema schema, String schemaFile) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | return loadSchemaFile(serverContext, schema, schemaFile, true); |
| | | return loadSchemaFile(schema, schemaFile, true); |
| | | } |
| | | |
| | | |
| | |
| | | * the schema elements that is not related |
| | | * to the server configuration. |
| | | */ |
| | | private static List<Modification> loadSchemaFile(ServerContext serverContext, Schema schema, String schemaFile, |
| | | private static List<Modification> loadSchemaFile(Schema schema, String schemaFile, |
| | | boolean failOnError) throws ConfigException, InitializationException |
| | | { |
| | | // Create an LDIF reader to use when reading the files. |
| | |
| | | } |
| | | } |
| | | |
| | | parseLdapSyntaxesDefinitions(serverContext, schema, schemaFile, failOnError, |
| | | ldapSyntaxList); |
| | | parseLdapSyntaxesDefinitions(schema, schemaFile, failOnError, ldapSyntaxList); |
| | | parseAttributeTypeDefinitions(schema, schemaFile, failOnError, attrList); |
| | | parseObjectclassDefinitions(schema, schemaFile, failOnError, ocList); |
| | | parseNameFormDefinitions(schema, schemaFile, failOnError, nfList); |
| | |
| | | syntax = CoreSchema.getLDAPSyntaxDescriptionSyntax(); |
| | | } |
| | | |
| | | AttributeType ldapSyntaxAttrType = getAttributeType(schema, ATTR_LDAP_SYNTAXES, ATTR_LDAP_SYNTAXES_LC, syntax); |
| | | AttributeType ldapSyntaxAttrType = schema.getAttributeType(ATTR_LDAP_SYNTAXES, syntax); |
| | | return createAddModifications(entry, mods, ldapSyntaxAttrType); |
| | | } |
| | | |
| | |
| | | { |
| | | syntax = CoreSchema.getAttributeTypeDescriptionSyntax(); |
| | | } |
| | | AttributeType attributeAttrType = getAttributeType( |
| | | schema, ATTR_ATTRIBUTE_TYPES, ATTR_ATTRIBUTE_TYPES_LC, syntax); |
| | | AttributeType attributeAttrType = schema.getAttributeType(ATTR_ATTRIBUTE_TYPES, syntax); |
| | | return createAddModifications(entry, mods, attributeAttrType); |
| | | } |
| | | |
| | |
| | | { |
| | | syntax = CoreSchema.getObjectClassDescriptionSyntax(); |
| | | } |
| | | AttributeType objectclassAttrType = getAttributeType(schema, ATTR_OBJECTCLASSES, ATTR_OBJECTCLASSES_LC, syntax); |
| | | AttributeType objectclassAttrType = schema.getAttributeType(ATTR_OBJECTCLASSES, syntax); |
| | | return createAddModifications(entry, mods, objectclassAttrType); |
| | | } |
| | | |
| | |
| | | { |
| | | syntax = CoreSchema.getNameFormDescriptionSyntax(); |
| | | } |
| | | AttributeType nameFormAttrType = getAttributeType( |
| | | schema, ATTR_NAME_FORMS, ATTR_NAME_FORMS_LC, syntax); |
| | | AttributeType nameFormAttrType = schema.getAttributeType(ATTR_NAME_FORMS, syntax); |
| | | return createAddModifications(entry, mods, nameFormAttrType); |
| | | } |
| | | |
| | |
| | | { |
| | | syntax = CoreSchema.getDITContentRuleDescriptionSyntax(); |
| | | } |
| | | AttributeType dcrAttrType = getAttributeType( |
| | | schema, ATTR_DIT_CONTENT_RULES, ATTR_DIT_CONTENT_RULES_LC, syntax); |
| | | AttributeType dcrAttrType = schema.getAttributeType(ATTR_DIT_CONTENT_RULES, syntax); |
| | | return createAddModifications(entry, mods, dcrAttrType); |
| | | } |
| | | |
| | |
| | | { |
| | | syntax = CoreSchema.getDITStructureRuleDescriptionSyntax(); |
| | | } |
| | | AttributeType dsrAttrType = getAttributeType(schema, ATTR_DIT_STRUCTURE_RULES, ATTR_DIT_STRUCTURE_RULES_LC, syntax); |
| | | AttributeType dsrAttrType = schema.getAttributeType(ATTR_DIT_STRUCTURE_RULES, syntax); |
| | | return createAddModifications(entry, mods, dsrAttrType); |
| | | } |
| | | |
| | |
| | | { |
| | | syntax = CoreSchema.getMatchingRuleUseDescriptionSyntax(); |
| | | } |
| | | AttributeType mruAttrType = getAttributeType(schema, ATTR_MATCHING_RULE_USE, ATTR_MATCHING_RULE_USE_LC, syntax); |
| | | AttributeType mruAttrType = schema.getAttributeType(ATTR_MATCHING_RULE_USE, syntax); |
| | | return createAddModifications(entry, mods, mruAttrType); |
| | | } |
| | | |
| | | private static AttributeType getAttributeType(Schema schema, String attrName, |
| | | String attrLowerName, Syntax syntax) |
| | | { |
| | | final AttributeType attrType = schema.getAttributeType(attrLowerName); |
| | | if (attrType != null) |
| | | { |
| | | return attrType; |
| | | } |
| | | return DirectoryServer.getDefaultAttributeType(attrName, syntax); |
| | | } |
| | | |
| | | private static List<Attribute> createAddModifications(Entry entry, |
| | | List<Modification> mods, AttributeType attrType) |
| | | { |
| | |
| | | } |
| | | |
| | | /** Parse the ldapsyntaxes definitions if there are any. */ |
| | | private static void parseLdapSyntaxesDefinitions(ServerContext serverContext, Schema schema, |
| | | private static void parseLdapSyntaxesDefinitions(Schema schema, |
| | | String schemaFile, boolean failOnError, List<Attribute> ldapSyntaxList) |
| | | throws ConfigException |
| | | { |
| | |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | LDAPSyntaxDescription syntaxDescription; |
| | | final String definition = Schema.addSchemaFileToElementDefinitionIfAbsent(v.toString(), schemaFile); |
| | | try |
| | | { |
| | | syntaxDescription = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, serverContext, schema, false, false); |
| | | setExtraProperty(syntaxDescription, SCHEMA_PROPERTY_FILENAME, null); |
| | | setSchemaFile(syntaxDescription, schemaFile); |
| | | schema.registerLdapSyntaxDescription(definition, failOnError); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_LDAP_SYNTAX.get( |
| | | schemaFile, |
| | | de.getMessageObject()); |
| | | reportError(failOnError, de, message); |
| | | continue; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_LDAP_SYNTAX.get( |
| | | schemaFile, v + ": " + getExceptionMessage(e)); |
| | | reportError(failOnError, e, message); |
| | | continue; |
| | | } |
| | | |
| | | // Register it with the schema. We will allow duplicates, with the |
| | | // later definition overriding any earlier definition, but we want |
| | | // to trap them and log a warning. |
| | | try |
| | | { |
| | | schema.registerLdapSyntaxDescription(syntaxDescription, failOnError); |
| | | registerLdapSyntaxInSchemaNG(serverContext, syntaxDescription, failOnError); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | logger.warn(WARN_CONFIG_SCHEMA_CONFLICTING_LDAP_SYNTAX, schemaFile, de.getMessageObject()); |
| | | |
| | | try |
| | | if (de.getResultCode().equals(ResultCode.CONSTRAINT_VIOLATION)) |
| | | { |
| | | schema.registerLdapSyntaxDescription(syntaxDescription, true); |
| | | registerLdapSyntaxInSchemaNG(serverContext, syntaxDescription, true); |
| | | // Register it with the schema. We will allow duplicates, with the |
| | | // later definition overriding any earlier definition, but we want |
| | | // to trap them and log a warning. |
| | | logger.warn(WARN_CONFIG_SCHEMA_CONFLICTING_LDAP_SYNTAX, schemaFile, de.getMessageObject()); |
| | | try |
| | | { |
| | | schema.registerLdapSyntaxDescription(definition, true); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // This should never happen. |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | else |
| | | { |
| | | // This should never happen. |
| | | logger.traceException(e); |
| | | LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_LDAP_SYNTAX.get( |
| | | schemaFile, de.getMessageObject()); |
| | | reportError(failOnError, de, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private static void registerLdapSyntaxInSchemaNG(ServerContext serverContext, LDAPSyntaxDescription syntaxDescription, |
| | | boolean overwrite) |
| | | { |
| | | // The server context may be null when this code is reached through non-server code (e.g. gui tools) |
| | | if (serverContext != null) |
| | | { |
| | | 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) |
| | | throws ConfigException |
| | | private static void parseAttributeTypeDefinitions( |
| | | Schema schema, String schemaFile, boolean failOnError, List<Attribute> attrList) |
| | | throws ConfigException |
| | | { |
| | | if (attrList != null) |
| | | { |
| | | List<String> definitions = new ArrayList<>(); |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | // Parse the attribute type. |
| | | AttributeType attrType; |
| | | try |
| | | { |
| | | attrType = AttributeTypeSyntax.decodeAttributeType(v, schema, false); |
| | | setExtraProperty(attrType, SCHEMA_PROPERTY_FILENAME, null); |
| | | setSchemaFile(attrType, schemaFile); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | definitions.add(v.toString()); |
| | | } |
| | | } |
| | | try |
| | | { |
| | | schema.registerAttributeTypes(definitions, schemaFile, !failOnError); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_ATTR_TYPE.get( |
| | | schemaFile, de.getMessageObject()); |
| | | reportError(failOnError, de, message); |
| | | continue; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_ATTR_TYPE.get( |
| | | schemaFile, v + ": " + getExceptionMessage(e)); |
| | | reportError(failOnError, e, message); |
| | | continue; |
| | | } |
| | | |
| | | // Register it with the schema. We will allow duplicates, with the |
| | | if (de.getResultCode().equals(ResultCode.CONSTRAINT_VIOLATION)) |
| | | { |
| | | // Register it with the schema. We will allow duplicates, with the |
| | | // later definition overriding any earlier definition, but we want |
| | | // to trap them and log a warning. |
| | | logger.warn(WARN_CONFIG_SCHEMA_CONFLICTING_ATTR_TYPE, schemaFile, de.getMessageObject()); |
| | | try |
| | | { |
| | | schema.registerAttributeType(attrType, failOnError); |
| | | schema.registerAttributeTypes(definitions, schemaFile, true); |
| | | } |
| | | catch (DirectoryException de) |
| | | catch (DirectoryException e) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | logger.warn(WARN_CONFIG_SCHEMA_CONFLICTING_ATTR_TYPE, schemaFile, de.getMessageObject()); |
| | | |
| | | try |
| | | { |
| | | schema.registerAttributeType(attrType, true); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // This should never happen. |
| | | logger.traceException(e); |
| | | } |
| | | // This should never happen |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_ATTR_TYPE.get(schemaFile, de.getMessageObject()); |
| | | reportError(failOnError, de, message); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS |
| | | * Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.replication.plugin.HistoricalCsnOrderingMatchingRuleImpl.*; |
| | | import static org.opends.server.schema.AciSyntax.*; |
| | | import static org.opends.server.schema.SubtreeSpecificationSyntax.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.io.File; |
| | |
| | | import org.forgerock.opendj.server.config.server.SchemaProviderCfg; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.schema.SchemaProvider; |
| | | import org.opends.server.schema.SchemaUpdater; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Schema.SchemaUpdater; |
| | | import org.opends.server.util.ActivateOnceSDKSchemaIsUsed; |
| | | |
| | | /** |
| | | * Responsible for loading the server schema. |
| | |
| | | * <li>Load all schema files located in the schema directory.</li> |
| | | * </ul> |
| | | */ |
| | | @ActivateOnceSDKSchemaIsUsed |
| | | public final class SchemaHandler |
| | | { |
| | | private static final String CORE_SCHEMA_PROVIDER_NAME = "Core Schema"; |
| | |
| | | this.serverContext = serverContext; |
| | | |
| | | final RootCfg rootConfiguration = serverContext.getServerManagementContext().getRootConfiguration(); |
| | | final SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater(); |
| | | final org.opends.server.types.Schema schema = serverContext.getSchema(); |
| | | |
| | | // Start from the core schema (TODO: or start with empty schema and add core schema in core schema provider ?) |
| | | final SchemaBuilder schemaBuilder = new SchemaBuilder(Schema.getCoreSchema()); |
| | | schema.exclusiveLock(); |
| | | try |
| | | { |
| | | // Start from the core schema (TODO: or start with empty schema and add core schema in core schema provider ?) |
| | | final SchemaBuilder schemaBuilder = new SchemaBuilder(Schema.getCoreSchema()); |
| | | |
| | | // Take providers into account. |
| | | loadSchemaFromProviders(rootConfiguration, schemaBuilder, schemaUpdater); |
| | | // Take providers into account. |
| | | loadSchemaFromProviders(rootConfiguration, schemaBuilder); |
| | | |
| | | // Take schema files into account (TODO : or load files using provider mechanism ?) |
| | | completeSchemaFromFiles(schemaBuilder); |
| | | // Take schema files into account (TODO : or load files using provider mechanism ?) |
| | | completeSchemaFromFiles(schemaBuilder); |
| | | |
| | | schemaUpdater.updateSchema(schemaBuilder.toSchema()); |
| | | try |
| | | { |
| | | schema.updateSchema(new SchemaUpdater() |
| | | { |
| | | @Override |
| | | public Schema update(SchemaBuilder ignored) |
| | | { |
| | | // see RemoteSchemaLoader.readSchema() |
| | | addAciSyntax(schemaBuilder); |
| | | addSubtreeSpecificationSyntax(schemaBuilder); |
| | | addHistoricalCsnOrderingMatchingRule(schemaBuilder); |
| | | |
| | | // Uses the builder incrementally updated instead of the default provided by the method. |
| | | // This is why it is necessary to explicitly lock/unlock the schema updater. |
| | | return schemaBuilder.toSchema(); |
| | | } |
| | | }); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | throw new ConfigException(e.getMessageObject(), e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | | schema.exclusiveUnlock(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param schemaBuilder |
| | | * The schema builder that providers should update. |
| | | * @param schemaUpdater |
| | | * The updater that providers should use when applying a |
| | | * configuration change. |
| | | * The updater that providers should use when applying a configuration change. |
| | | */ |
| | | private void loadSchemaFromProviders(final RootCfg rootConfiguration, final SchemaBuilder schemaBuilder, |
| | | final SchemaUpdater schemaUpdater) throws ConfigException, InitializationException { |
| | | private void loadSchemaFromProviders(final RootCfg rootConfiguration, final SchemaBuilder schemaBuilder) |
| | | throws ConfigException, InitializationException { |
| | | for (final String name : rootConfiguration.listSchemaProviders()) |
| | | { |
| | | final SchemaProviderCfg config = rootConfiguration.getSchemaProvider(name); |
| | | if (config.isEnabled()) |
| | | { |
| | | loadSchemaProvider(config.getJavaClass(), config, schemaBuilder, schemaUpdater, true); |
| | | loadSchemaProvider(config.getJavaClass(), config, schemaBuilder, true); |
| | | } |
| | | else if (name.equals(CORE_SCHEMA_PROVIDER_NAME)) { |
| | | else if (name.equals(CORE_SCHEMA_PROVIDER_NAME)) |
| | | { |
| | | // TODO : use correct message ERR_CORE_SCHEMA_NOT_ENABLED |
| | | LocalizableMessage message = LocalizableMessage.raw("Core Schema can't be disabled"); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(LocalizableMessage.raw("Core Schema can't be disabled")); |
| | | } |
| | | } |
| | | } |
| | |
| | | * Load the schema provider from the provided class name. |
| | | * <p> |
| | | * If {@code} initialize} is {@code true}, then the provider is initialized, |
| | | * and the provided schema builder is updated with schema elements fropm the |
| | | * provider. |
| | | * and the provided schema builder is updated with schema elements from the provider. |
| | | */ |
| | | private <T extends SchemaProviderCfg> SchemaProvider<T> loadSchemaProvider(final String className, |
| | | final T config, final SchemaBuilder schemaBuilder, final SchemaUpdater schemaUpdater, final boolean initialize) |
| | | final T config, final SchemaBuilder schemaBuilder, final boolean initialize) |
| | | throws InitializationException |
| | | { |
| | | try |
| | |
| | | final Class<? extends SchemaProvider> providerClass = propertyDef.loadClass(className, SchemaProvider.class); |
| | | final SchemaProvider<T> provider = providerClass.newInstance(); |
| | | |
| | | if (initialize) { |
| | | provider.initialize(config, schemaBuilder, schemaUpdater); |
| | | if (initialize) |
| | | { |
| | | provider.initialize(serverContext, config, schemaBuilder); |
| | | } |
| | | else { |
| | | else |
| | | { |
| | | final List<LocalizableMessage> unacceptableReasons = new ArrayList<>(); |
| | | final boolean isAcceptable = provider.isConfigurationAcceptable(config, unacceptableReasons); |
| | | if (!isAcceptable) |
| | | if (!provider.isConfigurationAcceptable(config, unacceptableReasons)) |
| | | { |
| | | final String reasons = Utils.joinAsString(". ", unacceptableReasons); |
| | | // TODO : fix message, eg CONFIG SCHEMA PROVIDER CONFIG NOT ACCEPTABLE |
| | |
| | | return provider; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // TODO : fix message |
| | | throw new InitializationException(ERR_CONFIG_SCHEMA_SYNTAX_CANNOT_INITIALIZE. |
| | | get(className, config.dn(), stackTraceToSingleLineString(e)), e); |
| | | } |
| | | { |
| | | // TODO : fix message |
| | | throw new InitializationException(ERR_CONFIG_SCHEMA_SYNTAX_CANNOT_INITIALIZE.get( |
| | | className, config.dn(), stackTraceToSingleLineString(e)), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | import org.opends.server.types.AbstractOperation; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.CancelRequest; |
| | | import org.opends.server.types.CancelResult; |
| | | import org.opends.server.types.CanceledOperationException; |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import org.forgerock.opendj.config.server.ServerManagementContext; |
| | | import org.opends.server.extensions.DiskSpaceMonitor; |
| | | import org.opends.server.loggers.CommonAudit; |
| | | import org.opends.server.schema.SchemaUpdater; |
| | | import org.opends.server.types.DirectoryEnvironmentConfig; |
| | | import org.opends.server.types.Schema; |
| | | |
| | |
| | | org.forgerock.opendj.ldap.schema.Schema getSchemaNG(); |
| | | |
| | | /** |
| | | * Returns the schema updater, which provides |
| | | * a mean to update the server's current schema. |
| | | * |
| | | * @return the schema updater |
| | | */ |
| | | SchemaUpdater getSchemaUpdater(); |
| | | |
| | | /** |
| | | * Returns the environment of the server. |
| | | * |
| | | * @return the environment |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.admin.std.meta.PasswordPolicyCfgDefn.StateUpdateFailurePolicy; |
| | | import org.opends.server.admin.std.server.PasswordValidatorCfg; |
| | | import org.opends.server.api.AccountStatusNotificationHandler; |
| | |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2009 Parametric Technology Corporation (PTC) |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.crypto; |
| | | |
| | |
| | | import org.opends.server.tools.LDAPConnectionOptions; |
| | | import org.opends.server.tools.LDAPReader; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.SelectableCertificateKeyManager; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.crypto; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.CryptoManagerException; |
| | | import org.opends.server.types.DN; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.admin.std.server.AttributeValuePasswordValidatorCfg; |
| | | import org.opends.server.admin.std.server.PasswordValidatorCfg; |
| | | import org.opends.server.api.PasswordValidator; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.schema.GeneralizedTimeSyntax; |
| | | import org.opends.server.tools.LDIFModify; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.BackupManager; |
| | | import org.opends.server.util.LDIFException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.api.ServerShutdownListener; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.admin.std.server.DynamicGroupImplementationCfg; |
| | | import org.opends.server.api.Group; |
| | | 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.DN; |
| | | import org.opends.server.types.DirectoryConfig; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.core.BindOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.ldap.LDAPClientConnection; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.meta.LDAPPassThroughAuthenticationPolicyCfgDefn.MappingPolicy; |
| | | import org.opends.server.admin.std.server.LDAPPassThroughAuthenticationPolicyCfg; |
| | |
| | | import org.opends.server.tools.LDAPReader; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.ExtendedOperationHandlerCfg; |
| | | import org.opends.server.admin.std.server.PasswordModifyExtendedOperationHandlerCfg; |
| | |
| | | import org.opends.server.types.AccountStatusNotificationProperty; |
| | | import org.opends.server.types.AdditionalLogItem; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | * Portions copyright 2015 Edan Idzerda |
| | | */ |
| | | package org.opends.server.extensions; |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.AccountStatusNotificationHandlerCfg; |
| | |
| | | import org.opends.server.types.AccountStatusNotificationProperty; |
| | | import org.opends.server.types.AccountStatusNotificationType; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.EMailMessage; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | * Portions Copyright 2013 Manuel Gaupp |
| | | */ |
| | | package org.opends.server.extensions; |
| | |
| | | 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.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | |
| | | |
| | | /** |
| | | * Tries to normalize the given attribute name; if normalization is not |
| | | * Normalizes the given attribute name; if normalization is not |
| | | * possible the original String value is returned. |
| | | * |
| | | * @param attrName The attribute name which should be normalized. |
| | |
| | | private static String normalizeAttributeName(String attrName) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(attrName); |
| | | if (attrType != null) |
| | | { |
| | | String attrNameNormalized = attrType.getNormalizedPrimaryNameOrOID(); |
| | | if (attrNameNormalized != null) |
| | | { |
| | | return attrNameNormalized; |
| | | } |
| | | } |
| | | return attrName; |
| | | return attrType != null ? attrType.getNormalizedNameOrOID() : attrName; |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.CertificateMapperCfg; |
| | | import org.opends.server.admin.std.server.SubjectDNToUserAttributeCertificateMapperCfg; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.AccountStatusNotification; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Entry; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.admin.std.server.VirtualStaticGroupImplementationCfg; |
| | | import org.opends.server.api.Group; |
| | | 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.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.monitors; |
| | | |
| | |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.schema.BooleanSyntax; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.monitors; |
| | | |
| | |
| | | import org.opends.server.api.ConnectionHandler; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.monitors; |
| | | |
| | |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.extensions.ParallelWorkQueue; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.monitors; |
| | | |
| | |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.extensions.TraditionalWorkQueue; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | | import static org.opends.messages.PluginMessages.*; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.schema.AttributeUsage; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.meta.PluginCfgDefn; |
| | | import org.opends.server.admin.std.server.EntryUUIDPluginCfg; |
| | |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.PreOperationAddOperation; |
| | | |
| | |
| | | extends DirectoryServerPlugin<EntryUUIDPluginCfg> |
| | | implements ConfigurationChangeListener<EntryUUIDPluginCfg> |
| | | { |
| | | /** |
| | | * The name of the entryUUID attribute type. |
| | | */ |
| | | /** The name of the entryUUID attribute type. */ |
| | | private static final String ENTRYUUID = "entryuuid"; |
| | | |
| | | |
| | | |
| | | /** The attribute type for the "entryUUID" attribute. */ |
| | | private final AttributeType entryUUIDType; |
| | | |
| | | /** The current configuration for this plugin. */ |
| | | private EntryUUIDPluginCfg currentConfig; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new instance of this Directory Server plugin. Every plugin must |
| | | * implement a default constructor (it is the only one that will be used to |
| | | * create plugins defined in the configuration), and every plugin constructor |
| | | * must call <CODE>super()</CODE> as its first element. |
| | | */ |
| | | /** Mandatory default constructor of this Directory Server plugin. */ |
| | | public EntryUUIDPlugin() |
| | | { |
| | | super(); |
| | | |
| | | |
| | | // Get the entryUUID attribute type. This needs to be done in the |
| | | // constructor in order to make the associated variables "final". |
| | | AttributeType at = DirectoryServer.getAttributeTypeOrNull(ENTRYUUID); |
| | | if (at == null) |
| | | { |
| | | String definition = |
| | | "( 1.3.6.1.1.16.4 NAME 'entryUUID' DESC 'UUID of the entry' " + |
| | | "EQUALITY uuidMatch ORDERING uuidOrderingMatch " + |
| | | "SYNTAX 1.3.6.1.1.16.1 SINGLE-VALUE NO-USER-MODIFICATION " + |
| | | "USAGE directoryOperation X-ORIGIN 'RFC 4530' )"; |
| | | |
| | | at = new AttributeType(definition, ENTRYUUID, |
| | | Collections.singleton(ENTRYUUID), ENTRYUUID, null, |
| | | null, DirectoryConfig.getDefaultAttributeSyntax(), |
| | | AttributeUsage.DIRECTORY_OPERATION, false, true, |
| | | false, true); |
| | | } |
| | | |
| | | entryUUIDType = at; |
| | | entryUUIDType = DirectoryServer.getAttributeTypeOrDefault(ENTRYUUID); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void initializePlugin(Set<PluginType> pluginTypes, |
| | | EntryUUIDPluginCfg configuration) |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.opends.server.types.DirectoryConfig; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.meta.PluginCfgDefn; |
| | | import org.opends.server.admin.std.server.LastModPluginCfg; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | |
| | | import org.opends.server.core.SubentryPasswordPolicy; |
| | | import org.opends.server.schema.AuthPasswordSyntax; |
| | | import org.opends.server.schema.UserPasswordSyntax; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | |
| | | super(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void initializePlugin(Set<PluginType> pluginTypes, |
| | | PasswordPolicyImportPluginCfg configuration) |
| | |
| | | processImportBegin(null, null); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void processImportBegin(Backend backend, LDIFImportConfig config) |
| | | { |
| | | // Find the set of attribute types with the auth password and user password |
| | | // syntax defined in the schema. |
| | | HashSet<AttributeType> authPWTypes = new HashSet<>(); |
| | | HashSet<AttributeType> userPWTypes = new HashSet<>(); |
| | | for (AttributeType t : DirectoryServer.getAttributeTypes().values()) |
| | | for (AttributeType t : DirectoryServer.getAttributeTypes()) |
| | | { |
| | | if (t.getSyntax().getOID().equals(SYNTAX_AUTH_PASSWORD_OID)) |
| | | { |
| | |
| | | userPasswordTypes = userTypesArray; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void processImportEnd(Backend backend, LDIFImportConfig config, |
| | | boolean successful) |
| | | { |
| | | // No implementation is required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final PluginResult.ImportLDIF |
| | | doLDIFImport(LDIFImportConfig importConfig, Entry entry) |
| | |
| | | return PluginResult.ImportLDIF.continueEntryProcessing(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationAcceptable(PluginCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | return isConfigurationChangeAcceptable(config, unacceptableReasons); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | PasswordPolicyImportPluginCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | return configAcceptable; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | PasswordPolicyImportPluginCfg configuration) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | * Portions copyright 2011 profiq s.r.o. |
| | | */ |
| | | package org.opends.server.plugins; |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.PostOperationDeleteOperation; |
| | | import org.opends.server.types.operation.PostOperationModifyDNOperation; |
| | |
| | | if (attrType == null || !theAttributeTypes.contains(attrType)) |
| | | { |
| | | isAcceptable = false; |
| | | unacceptableReasons.add( |
| | | ERR_PLUGIN_REFERENT_ATTR_NOT_LISTED.get(attr)); |
| | | unacceptableReasons.add(ERR_PLUGIN_REFERENT_ATTR_NOT_LISTED.get(attr)); |
| | | } |
| | | |
| | | /* Verify the filter. |
| | | */ |
| | | |
| | | try |
| | | { |
| | | SearchFilter.createFilterFromString(filtStr); |
| | |
| | | unacceptableReasons.add( |
| | | ERR_PLUGIN_REFERENT_BAD_FILTER.get(filtStr, de.getMessage())); |
| | | } |
| | | |
| | | } |
| | | |
| | | return isAcceptable; |
| | |
| | | * |
| | | * |
| | | * Copyright 2011-2012 profiq s.r.o. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | |
| | | import org.opends.server.extensions.PasswordModifyExtendedOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.operation.PostOperationExtendedOperation; |
| | |
| | | this.timeStampProvider = (timeStampProvider == null) |
| | | ? DEFAULT_TIMESTAMP_PROVIDER : timeStampProvider; |
| | | } |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.*; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.internal; |
| | | |
| | |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.ConnectionHandler; |
| | | import org.opends.server.core.*; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.AddChangeRecordEntry; |
| | | import org.opends.server.util.DeleteChangeRecordEntry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.FilterType; |
| | | import org.opends.server.types.LDAPException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DirectoryConfig; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | */ |
| | | protected Attribute createAttribute(String name, Object value) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(name.toLowerCase()); |
| | | return Attributes.create(attrType, String.valueOf(value)); |
| | | return Attributes.create(name, String.valueOf(value)); |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDAPException; |
| | |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock, AS. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | /** |
| | | * This class is used to store historical information for multiple valued attributes. |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.replication.protocol.OperationContext; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.PreOperationAddOperation; |
| | | import org.opends.server.types.operation.PreOperationModifyDNOperation; |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeDescription; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Modification; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRuleImpl; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.ldap.spi.IndexQueryFactory; |
| | | import org.forgerock.opendj.ldap.spi.Indexer; |
| | | import org.forgerock.opendj.ldap.spi.IndexingOptions; |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<? extends Indexer> createIndexers(IndexingOptions options) |
| | | { |
| | | return indexers; |
| | | } |
| | | |
| | | /** |
| | | * Adds the historical csn ordering matching rule to the provided schema builder. |
| | | * |
| | | * @param builder |
| | | * where to add the historical csn ordering matching rule |
| | | * @return the provided builder |
| | | */ |
| | | public static SchemaBuilder addHistoricalCsnOrderingMatchingRule(SchemaBuilder builder) |
| | | { |
| | | return builder |
| | | .buildMatchingRule("1.3.6.1.4.1.26027.1.4.4") |
| | | .names("historicalCsnOrderingMatch") |
| | | .syntaxOID("1.3.6.1.4.1.1466.115.121.1.40") |
| | | .implementation(new HistoricalCsnOrderingMatchingRuleImpl()) |
| | | .addToSchema(); |
| | | } |
| | | } |
| | |
| | | import org.opends.server.replication.service.ReplicationDomain; |
| | | import org.opends.server.tasks.PurgeConflictsHistoricalTask; |
| | | import org.opends.server.tasks.TaskUtils; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.*; |
| | | import org.opends.server.util.LDIFReader; |
| | |
| | | { |
| | | // Get attribute from attributes1 |
| | | AttributeType attributeType1 = schema.getAttributeType(attrName1); |
| | | if (attributeType1 == null) |
| | | if (attributeType1.isPlaceHolder()) |
| | | { |
| | | throw new ConfigException( |
| | | NOTE_ERR_FRACTIONAL_CONFIG_UNKNOWN_ATTRIBUTE_TYPE.get(attrName1)); |
| | |
| | | for (String attrName2 : attributes2) |
| | | { |
| | | AttributeType attributeType2 = schema.getAttributeType(attrName2); |
| | | if (attributeType2 == null) |
| | | if (attributeType2.isPlaceHolder()) |
| | | { |
| | | throw new ConfigException( |
| | | NOTE_ERR_FRACTIONAL_CONFIG_UNKNOWN_ATTRIBUTE_TYPE.get(attrName2)); |
| | |
| | | |
| | | // Does the attribute exist ? |
| | | AttributeType attributeType = schema.getAttributeType(attrName); |
| | | if (attributeType != null) |
| | | if (!attributeType.isPlaceHolder()) |
| | | { |
| | | // No more checking for the extensibleObject class |
| | | if (!isExtensibleObjectClass |
| | |
| | | |
| | | private static boolean isFractionalProhibited(AttributeType attrType) |
| | | { |
| | | String attributeName = attrType.getPrimaryName(); |
| | | String attributeName = attrType.getNameOrOID(); |
| | | return (attributeName != null && isFractionalProhibitedAttr(attributeName)) |
| | | || isFractionalProhibitedAttr(attrType.getOID()); |
| | | } |
| | |
| | | private static boolean canRemoveAttribute(AttributeType attributeType, |
| | | boolean fractionalExclusive, Set<String> fractionalConcernedAttributes) |
| | | { |
| | | String attributeName = attributeType.getPrimaryName(); |
| | | String attributeName = attributeType.getNameOrOID(); |
| | | String attributeOid = attributeType.getOID(); |
| | | |
| | | // Is the current attribute part of the established list ? |
| | | boolean foundAttribute = |
| | | contains(fractionalConcernedAttributes, attributeName, attributeOid); |
| | | boolean foundAttribute = contains(fractionalConcernedAttributes, attributeName, attributeOid); |
| | | // Now remove the attribute or modification if: |
| | | // - exclusive mode and attribute is in configuration |
| | | // - inclusive mode and attribute is not in configuration |
| | |
| | | || (!foundAttribute && !fractionalExclusive); |
| | | } |
| | | |
| | | private static boolean contains(Set<String> attrNames, String attrName, |
| | | String attrOID) |
| | | private static boolean contains(Set<String> attrNames, String attrName, String attrOID) |
| | | { |
| | | return attrNames.contains(attrOID) |
| | | || (attrName != null && attrNames.contains(attrName.toLowerCase())); |
| | | return attrNames.contains(attrOID) || attrNames.contains(attrName.toLowerCase()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.replication.common.ServerState; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.RawModification; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.replication.plugin.EntryHistorical; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.PostOperationAddOperation; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.replication.plugin.EntryHistorical; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | |
| | | import org.opends.server.replication.server.changelog.file.ECLEnabledDomainPredicate; |
| | | import org.opends.server.replication.server.changelog.file.FileChangelogDB; |
| | | import org.opends.server.replication.service.DSRSShutdownSync; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.HostPort; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | 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.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Schema.SchemaUpdater; |
| | | |
| | | /** |
| | | * This class implements the access control information (aci) attribute syntax. |
| | |
| | | super(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration, ServerContext serverContext) throws ConfigException |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration, ServerContext serverContext) |
| | | throws ConfigException, DirectoryException |
| | | { |
| | | // 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()); |
| | | serverContext.getSchema().updateSchema(new SchemaUpdater() |
| | | { |
| | | @Override |
| | | public Schema update(SchemaBuilder builder) |
| | | { |
| | | return addAciSyntax(builder).toSchema(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | /** |
| | | * Adds the ACI syntax to the provided schema builder. |
| | | * |
| | | * @param builder |
| | | * where to add the ACI syntax |
| | | * @return the provided builder |
| | | */ |
| | | public static SchemaBuilder addAciSyntax(SchemaBuilder builder) |
| | | { |
| | | return builder |
| | | .buildSyntax(SYNTAX_ACI_OID) |
| | | .description(SYNTAX_ACI_DESCRIPTION) |
| | | .implementation(new AciSyntaxImpl()) |
| | | .addToSchema(); |
| | | } |
| | | |
| | | @Override |
| | | public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema) |
| | | { |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_ACI_OID); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the common name for this attribute syntax. |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_ACI_NAME; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the OID for this attribute syntax. |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_ACI_OID; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves a description for this attribute syntax. |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.forgerock.opendj.ldap.schema.SchemaOptions.*; |
| | | 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.LinkedList; |
| | | 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.ByteSequence; |
| | | 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.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.util.Option; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.AttributeTypeDescriptionAttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | 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; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | |
| | | /** |
| | | * This class defines the attribute type description syntax, which is used to |
| | | * hold attribute type definitions in the server schema. The format of this |
| | | * syntax is defined in RFC 2252. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public class AttributeTypeSyntax |
| | | extends AttributeSyntax<AttributeTypeDescriptionAttributeSyntaxCfg> |
| | | implements |
| | |
| | | super(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void |
| | | initializeSyntax(AttributeTypeDescriptionAttributeSyntaxCfg configuration, ServerContext serverContext) |
| | | throws ConfigException, InitializationException |
| | | throws ConfigException, InitializationException, DirectoryException |
| | | { |
| | | this.serverContext = serverContext; |
| | | |
| | |
| | | |
| | | currentConfig = configuration; |
| | | currentConfig.addAttributeTypeDescriptionChangeListener(this); |
| | | stripMinimumUpperBound=configuration.isStripSyntaxMinUpperBound(); |
| | | updateNewSchema(); |
| | | stripMinimumUpperBound = configuration.isStripSyntaxMinUpperBound(); |
| | | serverContext.getSchema().updateSchemaOption(STRIP_UPPER_BOUND_FOR_ATTRIBUTE_TYPE, stripMinimumUpperBound); |
| | | } |
| | | |
| | | /** 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) |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_ATTRIBUTE_TYPE_OID); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_ATTRIBUTE_TYPE_NAME; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_ATTRIBUTE_TYPE_OID; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_ATTRIBUTE_TYPE_DESCRIPTION; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 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 |
| | | * provided octet string value does not need to be normalized (and in fact, it |
| | | * should not be in order to allow the desired capitalization to be |
| | | * preserved). |
| | | * |
| | | * @param value The ASN.1 octet string containing the value |
| | | * to decode (it does not need to be |
| | | * normalized). |
| | | * @param schema The schema to use to resolve references to |
| | | * other schema elements. |
| | | * @param allowUnknownElements Indicates whether to allow values that |
| | | * reference a superior attribute type which are |
| | | * not defined in the server schema. This should |
| | | * only be true when called by |
| | | * {@code valueIsAcceptable}. |
| | | * |
| | | * @return The decoded attribute type definition. |
| | | * |
| | | * @throws DirectoryException If the provided value cannot be decoded as an |
| | | * attribute type definition. |
| | | */ |
| | | public static AttributeType decodeAttributeType(ByteSequence value, |
| | | Schema schema, |
| | | boolean allowUnknownElements) |
| | | throws DirectoryException |
| | | { |
| | | // 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. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_EMPTY_VALUE.get(); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // The next character must be an open parenthesis. If it is not, then that |
| | | // is an error. |
| | | char c = valueStr.charAt(pos++); |
| | | if (c != '(') |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_EXPECTED_OPEN_PARENTHESIS.get(valueStr, pos - 1, c); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // 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. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // The next set of characters must be the OID. Strictly speaking, this |
| | | // should only be a numeric OID, but we'll also allow for the |
| | | // "attrname-oid" case as well. Look at the first character to figure out |
| | | // which we will be using. |
| | | int oidStartPos = pos; |
| | | 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)) != ' ') |
| | | && ((c = valueStr.charAt(pos)) != ')')) |
| | | { |
| | | if (c == '.') |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRTYPE_DOUBLE_PERIOD_IN_NUMERIC_OID. |
| | | get(valueStr, pos - 1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | else |
| | | { |
| | | lastWasPeriod = true; |
| | | } |
| | | } |
| | | else if (! isDigit(c)) |
| | | { |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos - 1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | | lastWasPeriod = false; |
| | | } |
| | | pos++; |
| | | } |
| | | } |
| | | 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)) != ' ') |
| | | && ((c = valueStr.charAt(pos)) != ')')) |
| | | { |
| | | if (isAlpha(c) |
| | | || isDigit(c) |
| | | || c == '-' |
| | | || (c == '_' && DirectoryServer.allowAttributeNameExceptions())) |
| | | { |
| | | // This is fine. It is an acceptable character. |
| | | pos++; |
| | | } |
| | | else |
| | | { |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR_IN_STRING_OID.get(valueStr, c, pos - 1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // If we're at the end of the value, then it isn't a valid attribute type |
| | | // description. Otherwise, parse out the OID. |
| | | String oid; |
| | | if (pos >= length) |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | | oid = lowerStr.substring(oidStartPos, pos); |
| | | } |
| | | |
| | | |
| | | // 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. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // 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. |
| | | String primaryName = oid; |
| | | List<String> typeNames = new LinkedList<>(); |
| | | String description = null; |
| | | AttributeType superiorType = null; |
| | | Syntax syntax = DirectoryServer.getDefaultAttributeSyntax(); |
| | | MatchingRule approximateMatchingRule = null; |
| | | MatchingRule equalityMatchingRule = null; |
| | | MatchingRule orderingMatchingRule = null; |
| | | MatchingRule substringMatchingRule = null; |
| | | AttributeUsage attributeUsage = AttributeUsage.USER_APPLICATIONS; |
| | | boolean isCollective = false; |
| | | boolean isNoUserModification = false; |
| | | boolean isObsolete = false; |
| | | boolean isSingleValue = false; |
| | | HashMap<String,List<String>> extraProperties = new LinkedHashMap<>(); |
| | | |
| | | |
| | | while (true) |
| | | { |
| | | StringBuilder tokenNameBuffer = new StringBuilder(); |
| | | pos = readTokenName(valueStr, tokenNameBuffer, pos); |
| | | String tokenName = tokenNameBuffer.toString(); |
| | | String lowerTokenName = toLowerCase(tokenName); |
| | | if (")".equals(tokenName)) |
| | | { |
| | | // We must be at the end of the value. If not, then that's a problem. |
| | | if (pos < length) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRTYPE_UNEXPECTED_CLOSE_PARENTHESIS. |
| | | get(valueStr, pos - 1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | else if ("name".equals(lowerTokenName)) |
| | | { |
| | | // This specifies the set of names for the attribute type. 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(); |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, pos - 1); |
| | | primaryName = userBuffer.toString(); |
| | | typeNames.add(primaryName); |
| | | } |
| | | else if (c == '(') |
| | | { |
| | | StringBuilder userBuffer = new StringBuilder(); |
| | | StringBuilder lowerBuffer = new StringBuilder(); |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, |
| | | pos); |
| | | primaryName = userBuffer.toString(); |
| | | typeNames.add(primaryName); |
| | | |
| | | |
| | | while (true) |
| | | { |
| | | if (valueStr.charAt(pos) == ')') |
| | | { |
| | | // Skip over any spaces after the parenthesis. |
| | | pos++; |
| | | while (pos < length && ((c = valueStr.charAt(pos)) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | | |
| | | break; |
| | | } |
| | | userBuffer = new StringBuilder(); |
| | | lowerBuffer = new StringBuilder(); |
| | | |
| | | pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, pos); |
| | | typeNames.add(userBuffer.toString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // This is an illegal character. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR.get(valueStr, c, pos - 1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | //RFC 2251: A specification may also assign one or more textual names |
| | | //for an attribute type. These names MUST begin with a letter, and |
| | | //only contain ASCII letters, digit characters and hyphens. |
| | | |
| | | //The global config hasn't been read so far. Allow the name exceptions |
| | | //during startup. |
| | | boolean allowExceptions = DirectoryServer.isRunning()? |
| | | DirectoryServer.allowAttributeNameExceptions():true; |
| | | //Iterate over all the names and throw an exception if it is invalid. |
| | | for(String name : typeNames) |
| | | { |
| | | for(int index=0; index < name.length(); index++) |
| | | { |
| | | char ch = name.charAt(index); |
| | | switch(ch) |
| | | { |
| | | case '-': |
| | | //hyphen is allowed but not as the first byte. |
| | | if (index==0) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_ATTR_SYNTAX_ATTR_ILLEGAL_INITIAL_DASH.get(value)); |
| | | } |
| | | break; |
| | | case '_': |
| | | // This will never be allowed as the first character. It |
| | | // may be allowed for subsequent characters if the attribute |
| | | // name exceptions option is enabled. |
| | | if (index==0) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_ATTR_SYNTAX_ATTR_ILLEGAL_INITIAL_UNDERSCORE.get( |
| | | value, ATTR_ALLOW_ATTRIBUTE_NAME_EXCEPTIONS)); |
| | | } |
| | | else if (!allowExceptions) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_ATTR_SYNTAX_ATTR_ILLEGAL_UNDERSCORE_CHAR.get( |
| | | value, ATTR_ALLOW_ATTRIBUTE_NAME_EXCEPTIONS)); |
| | | } |
| | | break; |
| | | |
| | | default: |
| | | //Only digits and ascii letters are allowed but the first byte |
| | | //can not be a digit. |
| | | if(index ==0 && isDigit(ch) && !allowExceptions) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_ATTR_SYNTAX_ATTR_ILLEGAL_INITIAL_DIGIT.get( |
| | | value, ch, ATTR_ALLOW_ATTRIBUTE_NAME_EXCEPTIONS)); |
| | | } |
| | | else if (!(('0'<=ch && ch<='9') |
| | | || ('A'<=ch && ch<='Z') |
| | | || ('a'<=ch && ch<='z'))) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_ATTR_SYNTAX_ATTR_ILLEGAL_CHAR.get(value, ch, index)); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | else if ("desc".equals(lowerTokenName)) |
| | | { |
| | | // This specifies the description for the attribute type. It is an |
| | | // arbitrary string of characters enclosed in single quotes. |
| | | StringBuilder descriptionBuffer = new StringBuilder(); |
| | | pos = readQuotedString(valueStr, descriptionBuffer, pos); |
| | | description = descriptionBuffer.toString(); |
| | | } |
| | | else if ("obsolete".equals(lowerTokenName)) |
| | | { |
| | | // This indicates whether the attribute type should be considered |
| | | // obsolete. We do not need to do any more parsing for this token. |
| | | isObsolete = true; |
| | | } |
| | | else if ("sup".equals(lowerTokenName)) |
| | | { |
| | | // This specifies the name or OID of the superior attribute type from |
| | | // which this attribute type should inherit its properties. |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, pos); |
| | | String woidString = woidBuffer.toString(); |
| | | superiorType = schema.getAttributeType(woidString); |
| | | if (superiorType == null) |
| | | { |
| | | if (allowUnknownElements) |
| | | { |
| | | superiorType = DirectoryServer.getAttributeTypeOrDefault(woidString); |
| | | } |
| | | else |
| | | { |
| | | // This is bad because we don't know what the superior attribute |
| | | // type is so we can't base this attribute type on it. |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_SUPERIOR_TYPE.get(oid, woidString); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | } |
| | | |
| | | |
| | | // Use the information in the superior type to provide defaults for the |
| | | // rest of the components in this attribute type description. |
| | | // Technically, the definition of the superior type should be provided |
| | | // before the matching rule, syntax, single-value, collective, |
| | | // no-user-modification, and usage components, and in that case we won't |
| | | // undo something else that has already been set by an earlier |
| | | // definition. However, if the information is provided out-of-order, |
| | | // then it is possible that this could overwrite some desired setting |
| | | // that is different from that of the supertype. |
| | | approximateMatchingRule = superiorType.getApproximateMatchingRule(); |
| | | equalityMatchingRule = superiorType.getEqualityMatchingRule(); |
| | | orderingMatchingRule = superiorType.getOrderingMatchingRule(); |
| | | substringMatchingRule = superiorType.getSubstringMatchingRule(); |
| | | syntax = superiorType.getSyntax(); |
| | | isSingleValue = superiorType.isSingleValue(); |
| | | isCollective = superiorType.isCollective(); |
| | | isNoUserModification = superiorType.isNoUserModification(); |
| | | attributeUsage = superiorType.getUsage(); |
| | | } |
| | | else if ("equality".equals(lowerTokenName)) |
| | | { |
| | | // This specifies the name or OID of the equality matching rule to use |
| | | // for this attribute type. |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, pos); |
| | | MatchingRule emr = |
| | | schema.getMatchingRule(woidBuffer.toString()); |
| | | if (emr == null) |
| | | { |
| | | // This is bad because we have no idea what the equality matching |
| | | // rule should be. |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_EQUALITY_MR.get(oid, woidBuffer); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | else |
| | | { |
| | | equalityMatchingRule = emr; |
| | | } |
| | | } |
| | | else if ("ordering".equals(lowerTokenName)) |
| | | { |
| | | // This specifies the name or OID of the ordering matching rule to use |
| | | // for this attribute type. |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, pos); |
| | | MatchingRule omr = schema.getMatchingRule(woidBuffer.toString()); |
| | | if (omr == null) |
| | | { |
| | | // This is bad because we have no idea what the ordering matching |
| | | // rule should be. |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_ORDERING_MR.get(oid, woidBuffer); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | else |
| | | { |
| | | orderingMatchingRule = omr; |
| | | } |
| | | } |
| | | else if ("substr".equals(lowerTokenName)) |
| | | { |
| | | // This specifies the name or OID of the substring matching rule to use |
| | | // for this attribute type. |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, pos); |
| | | MatchingRule smr = schema.getMatchingRule(woidBuffer.toString()); |
| | | if (smr == null) |
| | | { |
| | | // This is bad because we have no idea what the substring matching |
| | | // rule should be. |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_SUBSTRING_MR.get(oid, woidBuffer); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | else |
| | | { |
| | | substringMatchingRule = smr; |
| | | } |
| | | } |
| | | else if ("syntax".equals(lowerTokenName)) |
| | | { |
| | | // This specifies the numeric OID of the syntax for this matching rule. |
| | | // It may optionally be immediately followed by an open curly brace, an |
| | | // integer value, and a close curly brace to suggest the minimum number |
| | | // of characters that should be allowed in values of that type. This |
| | | // implementation will ignore any such length because it does not |
| | | // impose any practical limit on the length of attribute values. |
| | | boolean inBrace = false; |
| | | boolean lastWasPeriod = false; |
| | | StringBuilder oidBuffer = new StringBuilder(); |
| | | while (pos < length) |
| | | { |
| | | c = lowerStr.charAt(pos++); |
| | | if (inBrace) |
| | | { |
| | | // The only thing we'll allow here will be numeric digits and the |
| | | // closing curly brace. |
| | | if (c == '}') |
| | | { |
| | | // The next character must be a space or a closing parenthesis. |
| | | c = lowerStr.charAt(pos); |
| | | if (c != ' ' && c != ')') |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos - 1); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | else if (! isDigit(c)) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos - 1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (isDigit(c)) |
| | | { |
| | | oidBuffer.append(c); |
| | | lastWasPeriod = false; |
| | | } |
| | | else if (c == '.') |
| | | { |
| | | if (lastWasPeriod) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRTYPE_DOUBLE_PERIOD_IN_NUMERIC_OID. |
| | | get(valueStr, pos - 1); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | | oidBuffer.append(c); |
| | | lastWasPeriod = true; |
| | | } |
| | | } |
| | | else if (c == '{') |
| | | { |
| | | // It's the start of the length specification. |
| | | inBrace = true; |
| | | } |
| | | else if (c == ' ') |
| | | { |
| | | // It's the end of the value. |
| | | break; |
| | | } |
| | | else if(c == ')') |
| | | { |
| | | // As per RFC 4512 (4.1.2) it is end of the value. |
| | | --pos; |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos - 1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | } |
| | | } |
| | | } |
| | | |
| | | syntax = schema.getSyntax(oidBuffer.toString()); |
| | | if (syntax == null) |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_SYNTAX.get(oid, oidBuffer); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | message); |
| | | } |
| | | |
| | | if (approximateMatchingRule == null) |
| | | { |
| | | approximateMatchingRule = syntax.getApproximateMatchingRule(); |
| | | } |
| | | |
| | | if (equalityMatchingRule == null) |
| | | { |
| | | equalityMatchingRule = syntax.getEqualityMatchingRule(); |
| | | } |
| | | |
| | | if (orderingMatchingRule == null) |
| | | { |
| | | orderingMatchingRule = syntax.getOrderingMatchingRule(); |
| | | } |
| | | |
| | | if (substringMatchingRule == null) |
| | | { |
| | | substringMatchingRule = syntax.getSubstringMatchingRule(); |
| | | } |
| | | } |
| | | else if ("single-value".equals(lowerTokenName)) |
| | | { |
| | | // This indicates that attributes of this type are allowed to have at |
| | | // most one value. We do not need any more parsing for this token. |
| | | isSingleValue = true; |
| | | } |
| | | else if ("collective".equals(lowerTokenName)) |
| | | { |
| | | // This indicates that attributes of this type are collective (i.e., |
| | | // have their values generated dynamically in some way). We do not need |
| | | // any more parsing for this token. |
| | | isCollective = true; |
| | | } |
| | | else if ("no-user-modification".equals(lowerTokenName)) |
| | | { |
| | | // This indicates that the values of attributes of this type are not to |
| | | // be modified by end users. We do not need any more parsing for this |
| | | // token. |
| | | isNoUserModification = true; |
| | | } |
| | | else if ("usage".equals(lowerTokenName)) |
| | | { |
| | | // This specifies the usage string for this attribute type. It should |
| | | // be followed by one of the strings "userApplications", |
| | | // "directoryOperation", "distributedOperation", or "dSAOperation". |
| | | StringBuilder usageBuffer = new StringBuilder(); |
| | | while (pos < length) |
| | | { |
| | | c = lowerStr.charAt(pos++); |
| | | if (c == ' ') |
| | | { |
| | | break; |
| | | } |
| | | else if(c == ')') |
| | | { |
| | | pos--; |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | usageBuffer.append(c); |
| | | } |
| | | } |
| | | |
| | | String usageStr = usageBuffer.toString(); |
| | | if ("userapplications".equals(usageStr)) |
| | | { |
| | | attributeUsage = AttributeUsage.USER_APPLICATIONS; |
| | | } |
| | | else if ("directoryoperation".equals(usageStr)) |
| | | { |
| | | attributeUsage = AttributeUsage.DIRECTORY_OPERATION; |
| | | } |
| | | else if ("distributedoperation".equals(usageStr)) |
| | | { |
| | | attributeUsage = AttributeUsage.DISTRIBUTED_OPERATION; |
| | | } |
| | | else if ("dsaoperation".equals(usageStr)) |
| | | { |
| | | attributeUsage = AttributeUsage.DSA_OPERATION; |
| | | } |
| | | else |
| | | { |
| | | // This must be an illegal usage. |
| | | attributeUsage = AttributeUsage.USER_APPLICATIONS; |
| | | |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_INVALID_ATTRIBUTE_USAGE.get(oid, usageStr); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | | 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. |
| | | List<String> valueList = new ArrayList<>(); |
| | | pos = readExtraParameterValues(valueStr, valueList, pos); |
| | | extraProperties.put(tokenName, valueList); |
| | | } |
| | | } |
| | | |
| | | List<String> approxRules = extraProperties.get(SCHEMA_PROPERTY_APPROX_RULE); |
| | | if (approxRules != null && !approxRules.isEmpty()) |
| | | { |
| | | String ruleName = approxRules.get(0); |
| | | String lowerName = toLowerCase(ruleName); |
| | | MatchingRule amr = schema.getMatchingRule(lowerName); |
| | | if (amr == null) |
| | | { |
| | | // This is bad because we have no idea what the approximate matching |
| | | // rule should be. |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_APPROXIMATE_MR.get(oid, ruleName); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | else |
| | | { |
| | | approximateMatchingRule = amr; |
| | | } |
| | | } |
| | | |
| | | |
| | | // If there is a superior type, then it must have the same usage as the |
| | | // subordinate type. Also, if the superior type is collective, then so must |
| | | // the subordinate type be collective. |
| | | if (superiorType != null) |
| | | { |
| | | if (superiorType.getUsage() != attributeUsage) |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_INVALID_SUPERIOR_USAGE.get( |
| | | oid, attributeUsage, superiorType.getNameOrOID()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | if (superiorType.isCollective() && !isCollective) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | WARN_ATTR_SYNTAX_ATTRTYPE_NONCOLLECTIVE_FROM_COLLECTIVE |
| | | .get(oid, superiorType.getNameOrOID())); |
| | | } |
| | | } |
| | | |
| | | |
| | | // If the attribute type is NO-USER-MODIFICATION, then it must not have a |
| | | // usage of userApplications. |
| | | if (isNoUserModification |
| | | && attributeUsage == AttributeUsage.USER_APPLICATIONS) |
| | | { |
| | | LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_ATTRTYPE_NO_USER_MOD_NOT_OPERATIONAL.get(oid); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | CommonSchemaElements.checkSafeProperties(extraProperties); |
| | | |
| | | return new AttributeType(value.toString(), primaryName, typeNames, oid, |
| | | description, superiorType, syntax, |
| | | approximateMatchingRule, equalityMatchingRule, |
| | | orderingMatchingRule, substringMatchingRule, |
| | | attributeUsage, isCollective, isNoUserModification, |
| | | isObsolete, isSingleValue, extraProperties); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Reads the next token name from the attribute type definition, skipping over |
| | | * any leading or trailing spaces, and appends it to the provided buffer. |
| | | * |
| | | * @param valueStr The string representation of the attribute type |
| | | * 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_ATTRTYPE_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)) != ' ') |
| | | && ((c = valueStr.charAt(startPos)) != ')')) |
| | | { |
| | | tokenName.append(c); |
| | | startPos++; |
| | | } |
| | | |
| | | //We may be left with only ')' which is not part of the token yet. |
| | | //Let us see if it is the case. |
| | | if(tokenName.length()==0 && c == ')') |
| | | { |
| | | tokenName.append(c); |
| | | startPos++; |
| | | } |
| | | |
| | | // 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 attribute type |
| | | * 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_ATTRTYPE_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // The next character must be a single quote. |
| | | if (c != '\'') |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_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_ATTRTYPE_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 attribute type |
| | | * definition. |
| | | * @param lowerStr The all-lowercase representation of the attribute type |
| | | * 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_ATTRTYPE_TRUNCATED_VALUE.get(lowerStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // The next character must be a single quote. |
| | | if (c != '\'') |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_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_ATTRTYPE_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 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_ATTRTYPE_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 attribute 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) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_ATTR_SYNTAX_ATTRTYPE_DOUBLE_PERIOD_IN_NUMERIC_OID |
| | | .get(lowerStr, startPos - 1)); |
| | | } |
| | | 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_ATTRTYPE_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 attribute 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_ATTRTYPE_ILLEGAL_CHAR_IN_STRING_OID.get( |
| | | lowerStr, c, startPos - 1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_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_ATTRTYPE_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, |
| | | List<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_ATTRTYPE_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_ATTRTYPE_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_ATTRSYNTAX_EXTENSION_INVALID_CHARACTER.get( |
| | | valueStr, 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_ATTRTYPE_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_ATTRTYPE_TRUNCATED_VALUE.get(valueStr); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | return startPos; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | AttributeTypeDescriptionAttributeSyntaxCfg configuration) |
| | | { |
| | | ConfigChangeResult ccr = new ConfigChangeResult(); |
| | | currentConfig = configuration; |
| | | stripMinimumUpperBound = configuration.isStripSyntaxMinUpperBound(); |
| | | updateNewSchema(); |
| | | return new ConfigChangeResult(); |
| | | try |
| | | { |
| | | serverContext.getSchema().updateSchemaOption(STRIP_UPPER_BOUND_FOR_ATTRIBUTE_TYPE, stripMinimumUpperBound); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | ccr.setResultCode(e.getResultCode()); |
| | | ccr.addMessage(e.getMessageObject()); |
| | | } |
| | | return ccr; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | AttributeTypeDescriptionAttributeSyntaxCfg configuration, |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | * Portions Copyright 2013-2014 Manuel Gaupp |
| | | */ |
| | | package org.opends.server.schema; |
| | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaOptions; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.util.Option; |
| | | 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; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | |
| | | /** |
| | |
| | | super(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(CertificateAttributeSyntaxCfg configuration, ServerContext serverContext) |
| | | throws ConfigException |
| | | throws ConfigException, DirectoryException |
| | | { |
| | | this.config = configuration; |
| | | this.serverContext = serverContext; |
| | | updateNewSchema(); |
| | | serverContext.getSchema().updateSchemaOption(SchemaOptions.ALLOW_MALFORMED_CERTIFICATES, !config.isStrictFormat()); |
| | | 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, |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | CertificateAttributeSyntaxCfg configuration) |
| | | { |
| | | this.config = configuration; |
| | | updateNewSchema(); |
| | | return new ConfigChangeResult(); |
| | | final ConfigChangeResult ccr = new ConfigChangeResult(); |
| | | try |
| | | { |
| | | serverContext.getSchema() |
| | | .updateSchemaOption(SchemaOptions.ALLOW_MALFORMED_CERTIFICATES, !config.isStrictFormat()); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | ccr.setResultCode(e.getResultCode()); |
| | | ccr.addMessage(e.getMessageObject()); |
| | | } |
| | | return ccr; |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | import org.opends.server.admin.std.server.CollationMatchingRuleCfg; |
| | | import org.opends.server.api.MatchingRuleFactory; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.CollectionUtils; |
| | |
| | | /** Map of OID and the Matching Rule. */ |
| | | private final Map<String, MatchingRule> matchingRules = new HashMap<>(); |
| | | |
| | | private ServerContext serverContext; |
| | | |
| | | |
| | | /** Creates a new instance of CollationMatchingRuleFactory. */ |
| | | public CollationMatchingRuleFactory() |
| | |
| | | super(); |
| | | } |
| | | |
| | | /** |
| | | * Sets the server context. |
| | | * |
| | | * @param serverContext |
| | | * The server context. |
| | | */ |
| | | public void setServerContext(ServerContext serverContext) |
| | | { |
| | | this.serverContext = serverContext; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules() |
| | |
| | | // Clear the associated matching rules. |
| | | resetRules(); |
| | | |
| | | final Schema coreSchema = CoreSchema.getInstance(); |
| | | final Schema schema = serverContext.getSchemaNG(); |
| | | for (String collation : configuration.getCollation()) |
| | | { |
| | | // validation has already been performed in isConfigurationChangeAcceptable() |
| | | CollationMapper mapper = new CollationMapper(collation); |
| | | String nOID = mapper.getNumericOID(); |
| | | addMatchingRule(nOID, coreSchema.getMatchingRule(nOID)); |
| | | addMatchingRule(nOID, schema.getMatchingRule(nOID)); |
| | | } |
| | | |
| | | try |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.config.server.ConfigurationChangeListener; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.server.config.server.CoreSchemaCfg; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Schema.SchemaUpdater; |
| | | |
| | | /** |
| | | * Provides the core schema, which includes core matching rules and syntaxes. |
| | |
| | | /** The current configuration of core schema. */ |
| | | private CoreSchemaCfg currentConfig; |
| | | |
| | | /** The current schema builder. */ |
| | | private SchemaBuilder currentSchemaBuilder; |
| | | private ServerContext serverContext; |
| | | |
| | | /** Updater to notify schema update when configuration changes. */ |
| | | private SchemaUpdater schemaUpdater; |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initialize(final CoreSchemaCfg configuration, final SchemaBuilder initialSchemaBuilder, |
| | | final SchemaUpdater schemaUpdater) throws ConfigException, InitializationException |
| | | public void initialize(final ServerContext serverContext, final CoreSchemaCfg configuration, |
| | | final SchemaBuilder initialSchemaBuilder) throws ConfigException, InitializationException |
| | | { |
| | | this.serverContext = serverContext; |
| | | this.currentConfig = configuration; |
| | | this.currentSchemaBuilder = initialSchemaBuilder; |
| | | this.schemaUpdater = schemaUpdater; |
| | | |
| | | updateSchemaFromConfiguration(initialSchemaBuilder, configuration); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void finalizeProvider() |
| | | { |
| | | currentConfig.removeCoreSchemaChangeListener(this); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationAcceptable(final CoreSchemaCfg configuration, |
| | | final List<LocalizableMessage> unacceptableReasons) |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SchemaBuilder getSchema() |
| | | { |
| | | return currentSchemaBuilder; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(final CoreSchemaCfg configuration, |
| | | final List<LocalizableMessage> unacceptableReasons) |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange(final CoreSchemaCfg configuration) |
| | | { |
| | | currentSchemaBuilder = schemaUpdater.getSchemaBuilder(); |
| | | |
| | | updateSchemaFromConfiguration(currentSchemaBuilder, configuration); |
| | | |
| | | final boolean isUpdated = schemaUpdater.updateSchema(currentSchemaBuilder.toSchema()); |
| | | |
| | | // TODO : fix result code + log an error in case of failure |
| | | final ConfigChangeResult result = new ConfigChangeResult(); |
| | | result.setResultCode(isUpdated ? ResultCode.SUCCESS : ResultCode.OTHER); |
| | | return result; |
| | | final ConfigChangeResult ccr = new ConfigChangeResult(); |
| | | // TODO : the server schema should probably be renamed to something like ServerSchema |
| | | // Even after migration to SDK schema, it will be probably be kept |
| | | try |
| | | { |
| | | serverContext.getSchema().updateSchema(new SchemaUpdater() |
| | | { |
| | | @Override |
| | | public Schema update(SchemaBuilder builder) |
| | | { |
| | | updateSchemaFromConfiguration(builder, configuration); |
| | | return builder.toSchema(); |
| | | } |
| | | }); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | ccr.setResultCode(DirectoryServer.getServerErrorResultCode()); |
| | | ccr.addMessage(e.getMessageObject()); |
| | | } |
| | | return ccr; |
| | | } |
| | | |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | * Portions Copyright 2012 Manuel Gaupp |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | |
| | | import static org.forgerock.opendj.ldap.schema.SchemaOptions.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import java.util.List; |
| | |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaOptions; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.util.Option; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.CountryStringAttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | /** |
| | | * This class defines the country string attribute syntax, which should be a |
| | |
| | | super(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(CountryStringAttributeSyntaxCfg configuration, ServerContext serverContext) |
| | | throws ConfigException |
| | | throws ConfigException, DirectoryException |
| | | { |
| | | this.config = configuration; |
| | | this.serverContext = serverContext; |
| | | updateNewSchema(); |
| | | serverContext.getSchema().updateSchemaOption(STRICT_FORMAT_FOR_COUNTRY_STRINGS, config.isStrictFormat()); |
| | | 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, |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | CountryStringAttributeSyntaxCfg configuration) |
| | | public ConfigChangeResult applyConfigurationChange(CountryStringAttributeSyntaxCfg configuration) |
| | | { |
| | | this.config = configuration; |
| | | updateNewSchema(); |
| | | return new ConfigChangeResult(); |
| | | |
| | | final ConfigChangeResult ccr = new ConfigChangeResult(); |
| | | try |
| | | { |
| | | serverContext.getSchema().updateSchemaOption(STRICT_FORMAT_FOR_COUNTRY_STRINGS, config.isStrictFormat()); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | ccr.setResultCode(e.getResultCode()); |
| | | ccr.addMessage(e.getMessageObject()); |
| | | } |
| | | return ccr; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the common name for this attribute syntax. |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_COUNTRY_STRING_NAME; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the OID for this attribute syntax. |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_COUNTRY_STRING_OID; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves a description for this attribute syntax. |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg2; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | 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; |
| | |
| | | { |
| | | String woidString = woidBuffer.toString(); |
| | | AttributeType attr = schema.getAttributeType(woidString); |
| | | if (attr == null) |
| | | if (attr.isPlaceHolder() && !allowUnknownElements) |
| | | { |
| | | // This isn't good because it means that the DIT content rule |
| | | // refers to an attribute type that we don't know anything about. |
| | | if (!allowUnknownElements) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | msg.get(valueStr, woidString)); |
| | | } |
| | | attr = DirectoryServer.getAttributeTypeOrDefault(woidString); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, msg.get(valueStr, woidString)); |
| | | } |
| | | return attr; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.forgerock.opendj.ldap.schema.SchemaOptions.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import java.util.List; |
| | |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaOptions; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.util.Option; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.DirectoryStringAttributeSyntaxCfg; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | |
| | | /** |
| | |
| | | super(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(DirectoryStringAttributeSyntaxCfg configuration, ServerContext serverContext) |
| | | throws ConfigException |
| | | throws ConfigException, DirectoryException |
| | | { |
| | | this.serverContext = serverContext; |
| | | |
| | |
| | | currentConfig = configuration; |
| | | currentConfig.addDirectoryStringChangeListener(this); |
| | | allowZeroLengthValues = currentConfig.isAllowZeroLengthValues(); |
| | | updateNewSchema(); |
| | | serverContext.getSchema().updateSchemaOption(ALLOW_ZERO_LENGTH_DIRECTORY_STRINGS, allowZeroLengthValues); |
| | | } |
| | | |
| | | /** 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); |
| | | } |
| | | |
| | | /** |
| | | * Performs any finalization that may be necessary for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public void finalizeSyntax() |
| | | { |
| | | currentConfig.removeDirectoryStringChangeListener(this); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the common name for this attribute syntax. |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_DIRECTORY_STRING_NAME; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the OID for this attribute syntax. |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_DIRECTORY_STRING_OID; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves a description for this attribute syntax. |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | |
| | | return allowZeroLengthValues; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | DirectoryStringAttributeSyntaxCfg configuration, |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | DirectoryStringAttributeSyntaxCfg configuration) |
| | | { |
| | | currentConfig = configuration; |
| | | allowZeroLengthValues = configuration.isAllowZeroLengthValues(); |
| | | updateNewSchema(); |
| | | |
| | | return new ConfigChangeResult(); |
| | | final ConfigChangeResult ccr = new ConfigChangeResult(); |
| | | try |
| | | { |
| | | serverContext.getSchema().updateSchemaOption(ALLOW_ZERO_LENGTH_DIRECTORY_STRINGS, allowZeroLengthValues); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | ccr.setResultCode(e.getResultCode()); |
| | | ccr.addMessage(e.getMessageObject()); |
| | | } |
| | | return ccr; |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | * |
| | | */ |
| | | package org.opends.server.schema; |
| | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaOptions; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.util.Option; |
| | | 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; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | /** |
| | | * This class implements the JPEG attribute syntax. This is actually |
| | |
| | | super(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(JPEGAttributeSyntaxCfg configuration, ServerContext serverContext) |
| | | throws ConfigException |
| | | throws ConfigException, DirectoryException |
| | | { |
| | | this.config = configuration; |
| | | this.serverContext = serverContext; |
| | | updateNewSchema(); |
| | | serverContext.getSchema().updateSchemaOption(SchemaOptions.ALLOW_MALFORMED_JPEG_PHOTOS, !config.isStrictFormat()); |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the OID for this attribute syntax. |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_JPEG_OID; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves a description for this attribute syntax. |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_JPEG_DESCRIPTION; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | JPEGAttributeSyntaxCfg configuration, |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | JPEGAttributeSyntaxCfg configuration) |
| | | { |
| | | this.config = configuration; |
| | | updateNewSchema(); |
| | | return new ConfigChangeResult(); |
| | | final ConfigChangeResult ccr = new ConfigChangeResult(); |
| | | try |
| | | { |
| | | serverContext.getSchema().updateSchemaOption(SchemaOptions.ALLOW_MALFORMED_JPEG_PHOTOS, !config.isStrictFormat()); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | ccr.setResultCode(e.getResultCode()); |
| | | ccr.addMessage(e.getMessageObject()); |
| | | } |
| | | return ccr; |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | 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; |
| | |
| | | * @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 |
| | |
| | | * @throws DirectoryException If the provided value cannot be decoded as an |
| | | * ldapsyntax definition. |
| | | */ |
| | | public static LDAPSyntaxDescription decodeLDAPSyntax(ByteSequence value, ServerContext serverContext, |
| | | Schema schema, boolean allowUnknownElements, boolean forDelete) throws DirectoryException |
| | | public static LDAPSyntaxDescription decodeLDAPSyntax( |
| | | ByteSequence value, Schema schema, boolean allowUnknownElements, boolean forDelete) |
| | | throws DirectoryException |
| | | { |
| | | // Get string representations of the provided value using the provided form. |
| | | String valueStr = value.toString(); |
| | |
| | | if (lastWasPeriod) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_DOUBLE_PERIOD_IN_NUMERIC_OID. |
| | | get(valueStr, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_DOUBLE_PERIOD_IN_NUMERIC_OID.get(valueStr, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | | lastWasPeriod = true; |
| | | } |
| | | lastWasPeriod = true; |
| | | } |
| | | else if (! isDigit(c)) |
| | | { |
| | | // This must have been an illegal character. |
| | | LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_ILLEGAL_CHAR_IN_NUMERIC_OID. |
| | | get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | ERR_ATTR_SYNTAX_LDAPSYNTAX_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos-1); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | SchemaBuilder schemaBuilder = serverContext != null ? |
| | | serverContext.getSchemaUpdater().getSchemaBuilder() : new SchemaBuilder(CoreSchema.getInstance()); |
| | | SchemaBuilder schemaBuilder = new SchemaBuilder(schema.getSchemaNG()); |
| | | |
| | | if (lowerTokenName.equals("x-subst")) |
| | | { |
| | |
| | | CommonSchemaElements.checkSafeProperties(extraProperties); |
| | | |
| | | //Since we reached here it means everything is OK. |
| | | return new LDAPSyntaxDescription(valueStr, syntax, extraProperties); |
| | | return new LDAPSyntaxDescription(valueStr, syntax.getOID(), extraProperties); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | 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.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.MatchingRuleUse; |
| | | import org.opends.server.types.Schema; |
| | |
| | | { |
| | | String woidString = woidBuffer.toString(); |
| | | AttributeType attr = schema.getAttributeType(woidString); |
| | | if (attr == null) |
| | | if (attr.isPlaceHolder() && !allowUnknownElements) |
| | | { |
| | | // This isn't good because it means that the matching rule use |
| | | // refers to an attribute type that we don't know anything about. |
| | | if (!allowUnknownElements) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_ATTR.get(oid, woidString)); |
| | | } |
| | | attr = DirectoryServer.getAttributeTypeOrDefault(woidString); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_ATTR.get(oid, woidString)); |
| | | } |
| | | return attr; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg2; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | 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; |
| | |
| | | { |
| | | String woidString = woidBuffer.toString(); |
| | | AttributeType attr = schema.getAttributeType(woidString); |
| | | if (attr == null) |
| | | if (attr.isPlaceHolder() && !allowUnknownElements) |
| | | { |
| | | // This isn't good because it means that the name form |
| | | // refers to an attribute type that we don't know anything about. |
| | | if (!allowUnknownElements) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | msg.get(oid, woidString)); |
| | | } |
| | | attr = DirectoryServer.getAttributeTypeOrDefault(woidString); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, msg.get(oid, woidString)); |
| | | } |
| | | return attr; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg2; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | 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; |
| | |
| | | { |
| | | String woidString = woidBuffer.toString(); |
| | | AttributeType attr = schema.getAttributeType(woidString); |
| | | if (attr == null) |
| | | if (attr.isPlaceHolder() && !allowUnknownElements) |
| | | { |
| | | // This isn't good because it means that the objectclass |
| | | // refers to an attribute type that we don't know anything about. |
| | | if (!allowUnknownElements) |
| | | { |
| | | LocalizableMessage message = msg.get(oid, woidString); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | attr = DirectoryServer.getAttributeTypeOrDefault(woidString); |
| | | LocalizableMessage message = msg.get(oid, woidString); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | return attr; |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.server.config.server.SchemaProviderCfg; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | /** |
| | |
| | | * Initialize the schema provider from provided configuration and schema |
| | | * builder. |
| | | * |
| | | * @param serverContext |
| | | * The server context. |
| | | * @param configuration |
| | | * Configuration of the provider. |
| | | * @param initialSchemaBuilder |
| | | * Schema builder to update during initialization phase. |
| | | * @param schemaUpdater |
| | | * The updater to call when applying a configuration change. |
| | | * @throws ConfigException |
| | | * If a configuration problem arises in the process of performing |
| | | * the initialization. |
| | |
| | | * If a problem that is not configuration-related occurs during |
| | | * initialization. |
| | | */ |
| | | void initialize(T configuration, SchemaBuilder initialSchemaBuilder, SchemaUpdater schemaUpdater) |
| | | void initialize(ServerContext serverContext, T configuration, SchemaBuilder initialSchemaBuilder) |
| | | throws ConfigException, InitializationException; |
| | | |
| | | /** |
| | |
| | | */ |
| | | boolean isConfigurationAcceptable(T configuration, List<LocalizableMessage> unacceptableReasons); |
| | | |
| | | /** |
| | | * Returns the schema builder, as updated by this provider. |
| | | * |
| | | * @return the schema builder resulting from this provider. |
| | | */ |
| | | SchemaBuilder getSchema(); |
| | | } |
| 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 2015-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.CommonSchemaElements; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.SchemaFileElement; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | /** |
| | | * Represents a schema element which is either a SDK attribute type or an objectclass from the server. |
| | | * <p> |
| | | * In absence of a common interface, this class allows to process all elements in the same way, |
| | | * and to provide useful server-oriented methods like {@code getSchemaFile()} or |
| | | * {@code getOrigin()}. |
| | | */ |
| | | @RemoveOnceSDKSchemaIsUsed("This class is a temporary mechanism" |
| | | + " to manage in the same way SDK and server schema element classes") |
| | | public class SomeSchemaElement implements SchemaFileElement |
| | | { |
| | | private final ObjectClass objectClass; |
| | | private AttributeType attributeType; |
| | | |
| | | /** |
| | | * Builds SomeSchemaElement. |
| | | * |
| | | * @param objectClass |
| | | * the common schema element to wrap |
| | | */ |
| | | public SomeSchemaElement(ObjectClass objectClass) |
| | | { |
| | | this.objectClass = objectClass; |
| | | this.attributeType = null; |
| | | } |
| | | |
| | | /** |
| | | * Builds SomeSchemaElement. |
| | | * |
| | | * @param attributeType |
| | | * the attribute type element to wrap |
| | | */ |
| | | public SomeSchemaElement(AttributeType attributeType) |
| | | { |
| | | this.objectClass = null; |
| | | this.attributeType = attributeType; |
| | | } |
| | | |
| | | /** |
| | | * Returns the wrapped schema element as an object class. |
| | | * |
| | | * @return the wrapped object class |
| | | */ |
| | | public ObjectClass getObjectClass() |
| | | { |
| | | return objectClass; |
| | | } |
| | | |
| | | /** |
| | | * Returns the wrapped schema element as an attribute type. |
| | | * |
| | | * @return the wrapped attribute type |
| | | */ |
| | | public AttributeType getAttributeType() |
| | | { |
| | | return attributeType; |
| | | } |
| | | |
| | | /** |
| | | * Returns whether the wrapped element is an attribute type. |
| | | * |
| | | * @return {@code true} when the wrapped element is an attribute type, {@code false} otherwise |
| | | */ |
| | | public boolean isAttributeType() |
| | | { |
| | | return attributeType != null; |
| | | } |
| | | |
| | | /** |
| | | * Returns whether the wrapped element is an object class. |
| | | * |
| | | * @return {@code true} when the wrapped element is an object class, {@code false} otherwise |
| | | */ |
| | | public boolean isObjectClass() |
| | | { |
| | | return objectClass != null; |
| | | } |
| | | |
| | | /** |
| | | * Returns the OID of the wrapped element. |
| | | * |
| | | * @return the OID of the wrapped element. |
| | | */ |
| | | public String getOID() |
| | | { |
| | | return attributeType != null ? attributeType.getOID() : objectClass.getOID(); |
| | | } |
| | | |
| | | /** |
| | | * Returns the name or OID of the wrapped element. |
| | | * |
| | | * @return the name or OID of the wrapped element. |
| | | */ |
| | | public String getNameOrOID() |
| | | { |
| | | return attributeType != null ? attributeType.getNameOrOID() : objectClass.getNameOrOID(); |
| | | } |
| | | |
| | | /** |
| | | * Returns the names of the wrapped element. |
| | | * |
| | | * @return the names of the wrapped element. |
| | | */ |
| | | public Iterable<String> getNames() |
| | | { |
| | | return attributeType != null ? attributeType.getNames() : objectClass.getNormalizedNames(); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, List<String>> getExtraProperties() |
| | | { |
| | | return attributeType != null ? attributeType.getExtraProperties() : objectClass.getExtraProperties(); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return attributeType != null ? attributeType.toString() : objectClass.toString(); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the definition string used to create this attribute |
| | | * type and including the X-SCHEMA-FILE extension. |
| | | * |
| | | * @return The definition string used to create this attribute |
| | | * type including the X-SCHEMA-FILE extension. |
| | | */ |
| | | public String getDefinitionWithFileName() |
| | | { |
| | | final String schemaFile = getSchemaFile(); |
| | | final String definition = toString(); |
| | | if (schemaFile != null) |
| | | { |
| | | int pos = definition.lastIndexOf(')'); |
| | | return definition.substring(0, pos).trim() + " " + SCHEMA_PROPERTY_FILENAME + " '" + schemaFile + "' )"; |
| | | } |
| | | return definition; |
| | | } |
| | | |
| | | /** |
| | | * Returns the name of the schema file that contains the definition of the wrapped element. |
| | | * |
| | | * @return the name of the schema file that contains the definition of the wrapped element. |
| | | */ |
| | | public String getSchemaFile() |
| | | { |
| | | return getExtraPropertySingleValue(ServerConstants.SCHEMA_PROPERTY_FILENAME); |
| | | } |
| | | |
| | | /** |
| | | * Sets the name of the schema file that contains the definition of the wrapped element. |
| | | * |
| | | * @param serverContext |
| | | * the server context |
| | | * @param schemaFile |
| | | * the name of the schema file that contains the definition of the wrapped element. |
| | | */ |
| | | public void setSchemaFile(ServerContext serverContext, String schemaFile) |
| | | { |
| | | setExtraPropertySingleValue(serverContext, SCHEMA_PROPERTY_FILENAME, schemaFile); |
| | | } |
| | | |
| | | /** |
| | | * Returns the origin of the provided schema element. |
| | | * @return the origin of the provided schema element. |
| | | */ |
| | | public String getOrigin() |
| | | { |
| | | return getExtraPropertySingleValue(ServerConstants.SCHEMA_PROPERTY_ORIGIN); |
| | | } |
| | | |
| | | private String getExtraPropertySingleValue(String schemaPropertyOrigin) |
| | | { |
| | | if (objectClass != null) |
| | | { |
| | | return CommonSchemaElements.getSingleValueProperty(objectClass, schemaPropertyOrigin); |
| | | } |
| | | List<String> values = attributeType.getExtraProperties().get(schemaPropertyOrigin); |
| | | return values != null && !values.isEmpty() ? values.get(0) : null; |
| | | } |
| | | |
| | | /** |
| | | * Returns the attribute name of the wrapped element. |
| | | * @return the attribute name of the wrapped element. |
| | | */ |
| | | public String getAttributeName() |
| | | { |
| | | return attributeType!= null ? ConfigConstants.ATTR_ATTRIBUTE_TYPES : ConfigConstants.ATTR_OBJECTCLASSES; |
| | | } |
| | | |
| | | /** |
| | | * Sets a single-valued extra property on the wrapped element. |
| | | * |
| | | * @param serverContext |
| | | * the server context |
| | | * @param property |
| | | * the property to set |
| | | * @param value |
| | | * the value to set |
| | | */ |
| | | public void setExtraPropertySingleValue(ServerContext serverContext, String property, String value) |
| | | { |
| | | if (attributeType != null) |
| | | { |
| | | List<String> values = value != null ? Arrays.asList(value) : null; |
| | | setExtraPropertyMultipleValues(serverContext, property, values); |
| | | } |
| | | else |
| | | { |
| | | CommonSchemaElements.setExtraProperty(objectClass, property, value); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Sets a multi-valued extra property on the wrapped element. |
| | | * |
| | | * @param serverContext |
| | | * the server context |
| | | * @param property |
| | | * the property to set |
| | | * @param values |
| | | * the values to set |
| | | */ |
| | | public void setExtraPropertyMultipleValues(ServerContext serverContext, String property, List<String> values) |
| | | { |
| | | if (attributeType != null) |
| | | { |
| | | SchemaBuilder schemaBuilder = serverContext != null ? |
| | | new SchemaBuilder(serverContext.getSchemaNG()) : new SchemaBuilder(Schema.getDefaultSchema()); |
| | | AttributeType.Builder builder = |
| | | schemaBuilder.buildAttributeType(attributeType).removeExtraProperty(property, (String) null); |
| | | if (values != null && !values.isEmpty()) |
| | | { |
| | | builder.extraProperties(property, values); |
| | | } |
| | | attributeType = builder.addToSchemaOverwrite().toSchema().getAttributeType(attributeType.getNameOrOID()); |
| | | } |
| | | else |
| | | { |
| | | objectClass.setExtraProperty(property, values); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns a copy of the provided attribute type, changing the superior attribute type. |
| | | * |
| | | * @param attributeType |
| | | * the attribute type for which a modified copy must be built |
| | | * @param newSuperiorType |
| | | * the new superior attribute type to set, {@code null} means remove the superior type |
| | | * @return an attribute type builder to build an updated copy of the provided attribute type |
| | | */ |
| | | public static AttributeType changeSuperiorType(AttributeType attributeType, AttributeType newSuperiorType) |
| | | { |
| | | String superiorTypeOID = newSuperiorType != null ? newSuperiorType.getNameOrOID() : null; |
| | | Schema schema = new SchemaBuilder() |
| | | .buildAttributeType(attributeType) |
| | | .superiorType(superiorTypeOID) |
| | | .addToSchemaOverwrite() |
| | | .toSchema(); |
| | | return schema.getAttributeType(attributeType.getNameOrOID()); |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | 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.Schema; |
| | | 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.ServerContext; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Schema.SchemaUpdater; |
| | | import org.opends.server.types.SubtreeSpecification; |
| | | |
| | | |
| | | /** |
| | | * This class defines the subtree specification attribute syntax, |
| | | * which is used to specify the scope of sub-entries (RFC 3672). |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(AttributeSyntaxCfg configuration, ServerContext serverContext) |
| | | throws ConfigException |
| | | throws ConfigException, DirectoryException |
| | | { |
| | | // 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()); |
| | | serverContext.getSchema().updateSchema(new SchemaUpdater() |
| | | { |
| | | @Override |
| | | public Schema update(SchemaBuilder builder) |
| | | { |
| | | return addSubtreeSpecificationSyntax(builder).toSchema(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | /** |
| | | * Adds the subtree specification syntax to the provided schema builder. |
| | | * |
| | | * @param builder |
| | | * where to add the subtree specification syntax |
| | | * @return the provided builder |
| | | */ |
| | | public static SchemaBuilder addSubtreeSpecificationSyntax(SchemaBuilder builder) |
| | | { |
| | | return builder |
| | | .buildSyntax(SYNTAX_SUBTREE_SPECIFICATION_OID) |
| | | .description(SYNTAX_SUBTREE_SPECIFICATION_DESCRIPTION) |
| | | .implementation(new SubtreeSpecificationSyntaxImpl()) |
| | | .addToSchema(); |
| | | } |
| | | |
| | | @Override |
| | | public Syntax getSDKSyntax(Schema schema) |
| | | { |
| | | return schema.getSyntax(SchemaConstants.SYNTAX_SUBTREE_SPECIFICATION_OID); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the common name for this attribute syntax. |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() { |
| | | |
| | | return SYNTAX_SUBTREE_SPECIFICATION_NAME; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the OID for this attribute syntax. |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() { |
| | | |
| | | return SYNTAX_SUBTREE_SPECIFICATION_OID; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves a description for this attribute syntax. |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() { |
| | | |
| | | return SYNTAX_SUBTREE_SPECIFICATION_DESCRIPTION; |
| | | } |
| | | |
| | | /** |
| | | * 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 subtree specification code to make this determination. |
| | | try { |
| | | SubtreeSpecification.valueOf(DN.rootDN(), value.toString()); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isHumanReadable() |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaOptions; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.util.Option; |
| | | 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.ServerContext; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | /** |
| | | * This class implements the telephone number attribute syntax, which is defined |
| | |
| | | super(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeSyntax(TelephoneNumberAttributeSyntaxCfg configuration, ServerContext serverContext) |
| | | throws ConfigException |
| | | throws ConfigException, DirectoryException |
| | | { |
| | | 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 |
| | | // won't. |
| | | // we should use the strict compliance mode. If not, just assume that we won't. |
| | | strictMode = false; |
| | | if (configuration != null) |
| | | { |
| | | currentConfig = configuration; |
| | | currentConfig.addTelephoneNumberChangeListener(this); |
| | | strictMode = currentConfig.isStrictFormat(); |
| | | updateNewSchema(); |
| | | serverContext.getSchema().updateSchemaOption(SchemaOptions.ALLOW_NON_STANDARD_TELEPHONE_NUMBERS, !strictMode); |
| | | } |
| | | } |
| | | |
| | | /** 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); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the common name for this attribute syntax. |
| | | * |
| | | * @return The common name for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return SYNTAX_TELEPHONE_NAME; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the OID for this attribute syntax. |
| | | * |
| | | * @return The OID for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getOID() |
| | | { |
| | | return SYNTAX_TELEPHONE_OID; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves a description for this attribute syntax. |
| | | * |
| | | * @return A description for this attribute syntax. |
| | | */ |
| | | @Override |
| | | public String getDescription() |
| | | { |
| | | return SYNTAX_TELEPHONE_DESCRIPTION; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | TelephoneNumberAttributeSyntaxCfg configuration, |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | TelephoneNumberAttributeSyntaxCfg configuration) |
| | | { |
| | | currentConfig = configuration; |
| | | strictMode = configuration.isStrictFormat(); |
| | | updateNewSchema(); |
| | | |
| | | return new ConfigChangeResult(); |
| | | final ConfigChangeResult ccr = new ConfigChangeResult(); |
| | | try |
| | | { |
| | | serverContext.getSchema().updateSchemaOption(SchemaOptions.ALLOW_NON_STANDARD_TELEPHONE_NUMBERS, !strictMode); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | ccr.setResultCode(e.getResultCode()); |
| | | ccr.addMessage(e.getMessageObject()); |
| | | } |
| | | return ccr; |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.admin.std.server.SynchronizationProviderCfg; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.SynchronizationProvider; |
| | |
| | | { |
| | | try |
| | | { |
| | | SchemaConfigManager.loadSchemaFile(getServerContext(), schema, schemaFile); |
| | | SchemaConfigManager.loadSchemaFile(schema, schemaFile); |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | List<Modification> modList = |
| | | SchemaConfigManager.loadSchemaFile(getServerContext(), schema, schemaFile); |
| | | List<Modification> modList = SchemaConfigManager.loadSchemaFile(schema, schemaFile); |
| | | for (Modification m : modList) |
| | | { |
| | | Attribute a = m.getAttribute(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.messages.Severity; |
| | | import org.opends.messages.TaskMessages; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.BackupDirectory; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DisconnectReason; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.tools.makeldif.TemplateFile; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.replication.plugin.LDAPReplicationDomain; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.replication.plugin.LDAPReplicationDomain; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.replication.plugin.LDAPReplicationDomain; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.TimeThread; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2015 ForgeRock AS |
| | | * Copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.backends.task.Task; |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.opends.server.replication.server.changelog.api.ChangelogException; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.BackupDirectory; |
| | | import org.opends.server.types.BackupInfo; |
| | | import org.opends.server.types.DN; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | |
| | | import org.opends.server.replication.plugin.LDAPReplicationDomain; |
| | | import org.opends.server.replication.service.ReplicationDomain; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Operation; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.tasks.ExportTask; |
| | | import org.opends.server.tools.tasks.TaskTool; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.ExistingFileBehavior; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | |
| | | import org.opends.server.tasks.ImportTask; |
| | | import org.opends.server.tools.makeldif.TemplateFile; |
| | | import org.opends.server.tools.tasks.TaskTool; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.ExistingFileBehavior; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | |
| | | import org.opends.server.loggers.JDKLogging; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.JDKLogging; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.JDKLogging; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.LDIFException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler; |
| | | import org.opends.server.loggers.JDKLogging; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.ExistingFileBehavior; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | |
| | |
| | | import java.util.HashSet; |
| | | import java.util.Map; |
| | | |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.LDIFException; |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | names[i] = t.getPrimaryName(); |
| | | names[i] = t.getNameOrOID(); |
| | | values[i] = ByteString.valueOfUtf8(v.getValue().toString()); |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | |
| | |
| | | import java.util.StringTokenizer; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS |
| | | * Portions Copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | /** |
| | | * This class defines a line that may appear in a template or branch. It may |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | |
| | | |
| | | |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools.tasks; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.backends.task.FailedDependencyAction; |
| | | import org.opends.server.backends.task.Task; |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | |
| | |
| | | // Build a map of non-superior attribute value pairs for display |
| | | Map<AttributeType, List<Attribute>> attrMap = entry.getUserAttributes(); |
| | | for (AttributeType type : attrMap.keySet()) { |
| | | String typeName = type.getNameOrOID(); |
| | | String typeName = type.getNormalizedNameOrOID(); |
| | | |
| | | // See if we've handled it already above |
| | | if (!supAttrNames.contains(typeName)) { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.util.AbstractSet; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * Copyright 2015 ForgeRock AS |
| | | * Copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** Temporary class until we move to {@link org.forgerock.opendj.ldap.AttributeDescription}. */ |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class contains various methods for manipulating |
| | | * {@link Attribute}s as well as static factory methods for |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedHashSet; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | |
| | | // Create the new RDN with the provided information. |
| | | RDN rdn = newRDN(attributeName, parsedValue); |
| | | |
| | | |
| | | // Skip over any spaces that might be after the attribute value. |
| | | b = ' '; |
| | | while (dnReader.remaining() > 0 && (b = dnReader.readByte()) == ' ') |
| | |
| | | |
| | | // Parse the value for this RDN component. |
| | | parsedValue = parseAttributeValue(dnReader); |
| | | |
| | | |
| | | addValue(attributeName, rdn, parsedValue); |
| | | |
| | | |
| | | // Skip over any spaces that might be after the attribute value. |
| | | // Skip over any spaces that might be after the attribute value. |
| | | b = ' '; |
| | |
| | | // Parse the value for this RDN component. |
| | | parsedValue.clear(); |
| | | pos = parseAttributeValue(dnString, pos, parsedValue); |
| | | |
| | | |
| | | // Create the new RDN with the provided information. |
| | | addValue(attributeName, rdn, parsedValue.toByteString()); |
| | | |
| | | |
| | |
| | | { |
| | | return toNormalizedByteString().compareTo(other.toNormalizedByteString()); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | |
| | | |
| | | /** |
| | | * Retrieves the set of matching rules registered with the Directory |
| | | * Server. The mapping will be between the lowercase name or OID |
| | | * for each matching rule and the matching rule implementation. The |
| | | * same matching rule instance may be included multiple times with |
| | | * different keys. The returned map must not be altered by the |
| | | * caller. |
| | | * Server. |
| | | * |
| | | * @return The set of matching rules registered with the Directory |
| | | * Server. |
| | | */ |
| | | public static Map<String,MatchingRule> getMatchingRules() |
| | | public static Collection<MatchingRule> getMatchingRules() |
| | | { |
| | | return DirectoryServer.getMatchingRules(); |
| | | } |
| | |
| | | * @return The set of attribute type definitions that have been |
| | | * defined in the Directory Server. |
| | | */ |
| | | public static Map<String,AttributeType> getAttributeTypes() |
| | | public static Collection<AttributeType> getAttributeTypes() |
| | | { |
| | | return DirectoryServer.getAttributeTypes(); |
| | | } |
| | |
| | | |
| | | /** |
| | | * Retrieves the set of attribute syntaxes defined in the Directory |
| | | * Server. The mapping will be between the OID and the |
| | | * corresponding syntax implementation. The returned map must not |
| | | * be altered by the caller. |
| | | * Server. |
| | | * |
| | | * @return The set of attribute syntaxes defined in the Directory |
| | | * Server. |
| | | */ |
| | | public static Map<String,Syntax> |
| | | getAttributeSyntaxes() |
| | | public static Collection<Syntax> getAttributeSyntaxes() |
| | | { |
| | | return DirectoryServer.getAttributeSyntaxes(); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the default attribute syntax that should be used for |
| | | * attributes that are not defined in the server schema. |
| | | * |
| | | * @return The default attribute syntax that should be used for |
| | | * attributes that are not defined in the server schema. |
| | | */ |
| | | public static Syntax getDefaultAttributeSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultAttributeSyntax(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the default attribute syntax that should be used for |
| | | * attributes that are not defined in the server schema and are |
| | | * meant to store binary values. |
| | | * |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.io.BufferedWriter; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | |
| | | } |
| | | |
| | | // Check sub-types. |
| | | if (attributeType.mayHaveSubordinateTypes()) |
| | | for (AttributeType subType : schema.getSubTypes(attributeType)) |
| | | { |
| | | for (AttributeType subType : schema.getSubTypes(attributeType)) |
| | | attributes = getAttributes(subType); |
| | | if (attributes != null) |
| | | { |
| | | attributes = getAttributes(subType); |
| | | if (attributes != null) |
| | | for (Attribute attribute : attributes) |
| | | { |
| | | for (Attribute attribute : attributes) |
| | | // It's possible that there could be an attribute without any values, |
| | | // which we should treat as not having the requested attribute. |
| | | if (!attribute.isEmpty() && attribute.hasAllOptions(options)) |
| | | { |
| | | // It's possible that there could be an attribute without any values, |
| | | // which we should treat as not having the requested attribute. |
| | | if (!attribute.isEmpty() && attribute.hasAllOptions(options)) |
| | | { |
| | | return true; |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | |
| | | public List<Attribute> getAttribute(AttributeType attributeType, |
| | | boolean includeSubordinates) |
| | | { |
| | | if (includeSubordinates && attributeType.mayHaveSubordinateTypes()) |
| | | if (includeSubordinates && !attributeType.isObjectClass()) |
| | | { |
| | | List<Attribute> attributes = new LinkedList<>(); |
| | | addAllIfNotNull(attributes, userAttributes.get(attributeType)); |
| | |
| | | Set<String> options) |
| | | { |
| | | List<Attribute> attributes = new LinkedList<>(); |
| | | if (attributeType.mayHaveSubordinateTypes()) |
| | | if (!attributeType.isObjectClass()) |
| | | { |
| | | addAllIfNotNull(attributes, userAttributes.get(attributeType)); |
| | | addAllIfNotNull(attributes, operationalAttributes.get(attributeType)); |
| | |
| | | private List<Attribute> getAttribute(AttributeType attributeType, |
| | | Map<AttributeType, List<Attribute>> attrs) |
| | | { |
| | | if (attributeType.mayHaveSubordinateTypes()) |
| | | List<Attribute> attributes = new LinkedList<>(); |
| | | addAllIfNotNull(attributes, attrs.get(attributeType)); |
| | | for (AttributeType at : schema.getSubTypes(attributeType)) |
| | | { |
| | | List<Attribute> attributes = new LinkedList<>(); |
| | | addAllIfNotNull(attributes, attrs.get(attributeType)); |
| | | for (AttributeType at : schema.getSubTypes(attributeType)) |
| | | { |
| | | addAllIfNotNull(attributes, attrs.get(at)); |
| | | } |
| | | return attributes; |
| | | addAllIfNotNull(attributes, attrs.get(at)); |
| | | } |
| | | List<Attribute> results = attrs.get(attributeType); |
| | | return results != null ? results : Collections.<Attribute> emptyList(); |
| | | return attributes; |
| | | } |
| | | |
| | | |
| | |
| | | List<Attribute> attributes = new LinkedList<>(); |
| | | addAllIfNotNull(attributes, attrs.get(attributeType)); |
| | | |
| | | if (attributeType.mayHaveSubordinateTypes()) |
| | | for (AttributeType at : schema.getSubTypes(attributeType)) |
| | | { |
| | | for (AttributeType at : schema.getSubTypes(attributeType)) |
| | | { |
| | | addAllIfNotNull(attributes, attrs.get(at)); |
| | | } |
| | | addAllIfNotNull(attributes, attrs.get(at)); |
| | | } |
| | | |
| | | onlyKeepAttributesWithAllOptions(attributes, options); |
| | |
| | | return true; |
| | | } |
| | | |
| | | if (attributeType.mayHaveSubordinateTypes()) |
| | | for (AttributeType at : schema.getSubTypes(attributeType)) |
| | | { |
| | | for (AttributeType at : schema.getSubTypes(attributeType)) |
| | | if (attributes.containsKey(at)) |
| | | { |
| | | if (attributes.containsKey(at)) |
| | | { |
| | | return true; |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the requested operational attribute element(s) for the |
| | | * specified attribute type. The list returned may include multiple |
| | |
| | | for (Attribute collectiveAttr : collectiveAttrList) |
| | | { |
| | | AttributeType attributeType = collectiveAttr.getAttributeType(); |
| | | if (exclusionsNameSet.contains( |
| | | attributeType.getNormalizedPrimaryNameOrOID())) |
| | | if (exclusionsNameSet.contains(attributeType.getNormalizedNameOrOID())) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | |
| | | /** |
| | | * This class defines a data structure for storing and interacting |
| | | * with an ldap syntax, which defines the custom ldap syntaxes. |
| | |
| | | /** The definition string used to create this ldap syntax description. */ |
| | | private final String definition; |
| | | |
| | | /** The description for this ldap syntax description. */ |
| | | private final String description; |
| | | |
| | | /** The OID of the enclosed ldap syntax description. */ |
| | | private final String oid; |
| | | |
| | | /** The LDAPSyntaxDescritpionSyntax associated with this ldap syntax. */ |
| | | private Syntax syntax; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new ldap syntax definition with the provided |
| | | * information. |
| | | * Creates a new ldap syntax definition with the provided information. |
| | | * |
| | | * @param definition The definition string used to create |
| | | * this ldap syntax. It must not be |
| | | * {@code null}. |
| | | * @param syntax The ldap syntax description syntax |
| | | * associated with this ldap syntax. |
| | | * @param extraProperties A set of extra properties for this |
| | | * ldap syntax description. |
| | | * @param definition |
| | | * The definition string used to create this ldap syntax. It must not be {@code null}. |
| | | * @param oid |
| | | * oid of the syntax |
| | | * @param extraProperties |
| | | * A set of extra properties for this ldap syntax description. |
| | | */ |
| | | public LDAPSyntaxDescription(String definition, Syntax syntax, Map<String,List<String>> extraProperties) |
| | | public LDAPSyntaxDescription(String definition, String oid, Map<String,List<String>> extraProperties) |
| | | { |
| | | ifNull(definition, syntax); |
| | | ifNull(definition, oid); |
| | | |
| | | this.syntax = syntax; |
| | | this.oid = syntax.getOID(); |
| | | this.description = syntax.getDescription(); |
| | | this.oid = oid; |
| | | |
| | | int schemaFilePos = definition.indexOf(SCHEMA_PROPERTY_FILENAME); |
| | | if (schemaFilePos > 0) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the ldap syntax description syntax associated with |
| | | * this ldap syntax. |
| | | * |
| | | * @return The description syntax for this definition. |
| | | */ |
| | | public Syntax getSyntax() |
| | | { |
| | | return syntax; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the description for this ldap syntax description. |
| | | * |
| | | * @return The description for this ldap syntax description, or |
| | | * {@code true} if there is none. |
| | | */ |
| | | public String getDescription() |
| | | { |
| | | return description; |
| | | } |
| | | |
| | | /** |
| | | * Returns the oid. |
| | | * |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.io.*; |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import static org.opends.messages.UtilityMessages.*; |
| | | |
| | | import java.io.*; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.HashSet; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.nio.CharBuffer; |
| | |
| | | { |
| | | Reject.ifNull(attributeType, attributeValue); |
| | | attributeTypes = new AttributeType[] { attributeType }; |
| | | attributeNames = new String[] { attributeType.getPrimaryName() }; |
| | | attributeNames = new String[] { attributeType.getNameOrOID() }; |
| | | attributeValues = new ByteString[] { attributeValue }; |
| | | } |
| | | |
| | |
| | | // don't return it yet because this could be a multi-valued RDN. |
| | | String name = attributeName.toString(); |
| | | String lowerName = toLowerCase(name); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(lowerName); |
| | | if (attrType == null) |
| | | { |
| | | // This must be an attribute type that we don't know about. |
| | | // In that case, we'll create a new attribute using the default |
| | | // syntax. If this is a problem, it will be caught later either |
| | | // by not finding the target entry or by not allowing the entry |
| | | // to be added. |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(name); |
| | | } |
| | | |
| | | // If using default is a problem, it will be caught later either |
| | | // by not finding the target entry or by not allowing the entry |
| | | // to be added. |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(lowerName, name); |
| | | |
| | | RDN rdn = new RDN(attrType, name, parsedValue.toByteString()); |
| | | |
| | |
| | | { |
| | | name = attributeName.toString(); |
| | | lowerName = toLowerCase(name); |
| | | attrType = DirectoryServer.getAttributeTypeOrNull(lowerName); |
| | | |
| | | if (attrType == null) |
| | | { |
| | | // This must be an attribute type that we don't know about. |
| | | // In that case, we'll create a new attribute using the |
| | | // default syntax. If this is a problem, it will be caught |
| | | // later either by not finding the target entry or by not |
| | | // allowing the entry to be added. |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(name); |
| | | } |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(lowerName.toString(), name); |
| | | |
| | | rdn.addValue(attrType, name, ByteString.empty()); |
| | | return rdn; |
| | |
| | | // Update the RDN to include the new attribute/value. |
| | | name = attributeName.toString(); |
| | | lowerName = toLowerCase(name); |
| | | attrType = DirectoryServer.getAttributeTypeOrNull(lowerName); |
| | | if (attrType == null) |
| | | { |
| | | // This must be an attribute type that we don't know about. |
| | | // In that case, we'll create a new attribute using the |
| | | // default syntax. If this is a problem, it will be caught |
| | | // later either by not finding the target entry or by not |
| | | // allowing the entry to be added. |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(name); |
| | | } |
| | | // If using default is a problem, it will be caught later either |
| | | // by not finding the target entry or by not allowing the entry |
| | | // to be added. |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(lowerName, name); |
| | | |
| | | rdn.addValue(attrType, name, parsedValue.toByteString()); |
| | | |
| | |
| | | */ |
| | | private ByteStringBuilder normalizeAVAToByteString(int position, final ByteStringBuilder builder) |
| | | { |
| | | builder.appendUtf8(attributeTypes[position].getNormalizedPrimaryNameOrOID()); |
| | | builder.appendUtf8(attributeTypes[position].getNormalizedNameOrOID()); |
| | | builder.appendUtf8("="); |
| | | final ByteString value = getEqualityNormalizedValue(position); |
| | | if (value.length() > 0) |
| | |
| | | */ |
| | | private StringBuilder normalizeAVAToUrlSafeString(int position, StringBuilder builder) |
| | | { |
| | | builder.append(attributeTypes[position].getNormalizedPrimaryNameOrOID()); |
| | | builder.append(attributeTypes[position].getNormalizedNameOrOID()); |
| | | builder.append('='); |
| | | |
| | | ByteString value = getEqualityNormalizedValue(position); |
| | |
| | | { |
| | | return builder; |
| | | } |
| | | final boolean hasAttributeName = attributeTypes[position].getPrimaryName() != null; |
| | | final boolean hasAttributeName = !attributeTypes[position].getNames().isEmpty(); |
| | | final boolean isHumanReadable = attributeTypes[position].getSyntax().isHumanReadable(); |
| | | if (!hasAttributeName || !isHumanReadable) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import java.io.*; |
| | | import java.io.BufferedReader; |
| | | import java.io.BufferedWriter; |
| | | import java.io.File; |
| | | import java.io.FileReader; |
| | | import java.io.FileWriter; |
| | | import java.io.FilenameFilter; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashSet; |
| | |
| | | import java.util.Set; |
| | | import java.util.TreeSet; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.locks.Lock; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg0; |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.ConflictingSchemaElementException; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException; |
| | | import org.forgerock.util.Option; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SchemaConfigManager; |
| | | import org.opends.server.schema.AttributeTypeSyntax; |
| | | import org.opends.server.schema.DITContentRuleSyntax; |
| | | import org.opends.server.schema.DITStructureRuleSyntax; |
| | | import org.opends.server.schema.MatchingRuleUseSyntax; |
| | | import org.opends.server.schema.NameFormSyntax; |
| | | import org.opends.server.schema.ObjectClassSyntax; |
| | | import org.opends.server.schema.SomeSchemaElement; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import static org.opends.messages.BackendMessages.*; |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.types.CommonSchemaElements.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | |
| | | * <LI>DIT structure rule definitions</LI> |
| | | * <LI>Name form definitions</LI> |
| | | * </UL> |
| | | * It always uses non-strict {@link org.forgerock.opendj.ldap.schema.Schema} under the hood. |
| | | */ |
| | | @org.opends.server.types.PublicAPI( |
| | | stability=org.opends.server.types.StabilityLevel.UNCOMMITTED, |
| | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * The set of subordinate attribute types registered within the server schema. |
| | | * Provides for each attribute type having at least one subordinate type the complete list of |
| | | * its descendants. |
| | | */ |
| | | private ConcurrentHashMap<AttributeType,List<AttributeType>> |
| | | subordinateTypes; |
| | | |
| | | /** |
| | | * The set of attribute type definitions for this schema, mapped between the |
| | | * lowercase names and OID for the definition and the attribute type itself. |
| | | */ |
| | | private ConcurrentHashMap<String,AttributeType> attributeTypes; |
| | | private Map<AttributeType, List<AttributeType>> subordinateTypes; |
| | | |
| | | /** |
| | | * The set of objectclass definitions for this schema, mapped between the |
| | |
| | | private ConcurrentHashMap<String,ObjectClass> objectClasses; |
| | | |
| | | /** |
| | | * The set of attribute syntaxes for this schema, mapped between the OID for |
| | | * the syntax and the syntax itself. |
| | | */ |
| | | private ConcurrentHashMap<String,Syntax> syntaxes; |
| | | |
| | | /** |
| | | * The default attribute syntax to use for attributes with no defined syntax. |
| | | */ |
| | | private Syntax defaultSyntax; |
| | | |
| | | /** |
| | | * The entire set of matching rules for this schema, mapped between the |
| | | * lowercase names and OID for the definition and the matching rule itself. |
| | | */ |
| | | private ConcurrentHashMap<String,MatchingRule> matchingRules; |
| | | |
| | | |
| | | private String defaultSyntaxOID; |
| | | |
| | | /** |
| | | * The set of matching rule uses for this schema, mapped between the matching |
| | |
| | | */ |
| | | private Map<String, Attribute> extraAttributes = new HashMap<>(); |
| | | |
| | | /** |
| | | * The SDK schema. |
| | | * <p> |
| | | * It will progressively take over server implementation of the schema. |
| | | * <p> |
| | | * @GuardedBy("exclusiveLock") |
| | | */ |
| | | private volatile org.forgerock.opendj.ldap.schema.Schema schemaNG; |
| | | |
| | | /** Creates a new schema structure with all elements initialized but empty. */ |
| | | public Schema() |
| | | /** Guards updates to the schema. */ |
| | | private final Lock exclusiveLock = new ReentrantLock(); |
| | | |
| | | /** |
| | | * Creates a new schema structure with all elements initialized but empty. |
| | | * |
| | | * @param schemaNG |
| | | * The SDK schema |
| | | */ |
| | | public Schema(org.forgerock.opendj.ldap.schema.Schema schemaNG) |
| | | { |
| | | attributeTypes = new ConcurrentHashMap<>(); |
| | | objectClasses = new ConcurrentHashMap<>(); |
| | | syntaxes = new ConcurrentHashMap<>(); |
| | | matchingRules = new ConcurrentHashMap<>(); |
| | | matchingRuleUses = new ConcurrentHashMap<>(); |
| | | ditContentRules = new ConcurrentHashMap<>(); |
| | | ditStructureRulesByID = new ConcurrentHashMap<>(); |
| | | ditStructureRulesByNameForm = new ConcurrentHashMap<>(); |
| | | nameFormsByOC = new ConcurrentHashMap<>(); |
| | | nameFormsByName = new ConcurrentHashMap<>(); |
| | | ldapSyntaxDescriptions = new ConcurrentHashMap<>(); |
| | | subordinateTypes = new ConcurrentHashMap<>(); |
| | | setSchemaNG(schemaNG); |
| | | |
| | | objectClasses = new ConcurrentHashMap<String,ObjectClass>(); |
| | | matchingRuleUses = new ConcurrentHashMap<MatchingRule,MatchingRuleUse>(); |
| | | ditContentRules = new ConcurrentHashMap<ObjectClass,DITContentRule>(); |
| | | ditStructureRulesByID = new ConcurrentHashMap<Integer,DITStructureRule>(); |
| | | ditStructureRulesByNameForm = new ConcurrentHashMap<NameForm,DITStructureRule>(); |
| | | nameFormsByOC = new ConcurrentHashMap<ObjectClass,List<NameForm>>(); |
| | | nameFormsByName = new ConcurrentHashMap<String,NameForm>(); |
| | | ldapSyntaxDescriptions = new ConcurrentHashMap<String,LDAPSyntaxDescription>(); |
| | | subordinateTypes = new ConcurrentHashMap<AttributeType,List<AttributeType>>(); |
| | | |
| | | oldestModificationTime = System.currentTimeMillis(); |
| | | youngestModificationTime = oldestModificationTime; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns the SDK schema. |
| | | * |
| | | * @return the SDK schema |
| | | */ |
| | | public org.forgerock.opendj.ldap.schema.Schema getSchemaNG() |
| | | { |
| | | return schemaNG; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the attribute type definitions for this schema, as a |
| | | * mapping between the lowercase names and OIDs for the attribute |
| | | * type and the attribute type itself. Each attribute type may be |
| | | * associated with multiple keys (once for the OID and again for |
| | | * each name). The contents of the returned mapping must not be |
| | | * altered. |
| | | * Retrieves the attribute type definitions for this schema. |
| | | * |
| | | * @return The attribute type definitions for this schema. |
| | | */ |
| | | public ConcurrentHashMap<String,AttributeType> getAttributeTypes() |
| | | public Collection<AttributeType> getAttributeTypes() |
| | | { |
| | | return attributeTypes; |
| | | return schemaNG.getAttributeTypes(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this schema definition includes an attribute |
| | | * type with the provided name or OID. |
| | | * |
| | | * @param lowerName The name or OID for which to make the |
| | | * determination, formatted in all lowercase |
| | | * characters. |
| | | * |
| | | * @param nameOrOid The name or OID for which to make the determination, ignoring case considerations |
| | | * @return {@code true} if this schema contains an attribute type |
| | | * with the provided name or OID, or {@code false} if not. |
| | | */ |
| | | public boolean hasAttributeType(String lowerName) |
| | | public boolean hasAttributeType(String nameOrOid) |
| | | { |
| | | return attributeTypes.containsKey(lowerName); |
| | | return schemaNG.hasAttributeType(nameOrOid); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the attribute type definition with the specified name |
| | | * or OID. |
| | | * Retrieves the attribute type definition with the specified name or OID. |
| | | * |
| | | * @param lowerName The name or OID of the attribute type to |
| | | * retrieve, formatted in all lowercase |
| | | * characters. |
| | | * |
| | | * @return The requested attribute type, or <CODE>null</CODE> if no |
| | | * type is registered with the provided name or OID. |
| | | * @param nameOrOid |
| | | * The name or OID of the attribute type to retrieve, ignoring case considerations |
| | | * @return The requested attribute type |
| | | */ |
| | | public AttributeType getAttributeType(String lowerName) |
| | | public AttributeType getAttributeType(String nameOrOid) |
| | | { |
| | | return attributeTypes.get(lowerName); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Registers the provided attribute type definition with this |
| | | * schema. |
| | | * |
| | | * @param attributeType The attribute type to register with |
| | | * this schema. |
| | | * @param overwriteExisting Indicates whether to overwrite an |
| | | * existing mapping if there are any |
| | | * conflicts (i.e., another attribute |
| | | * type with the same OID or name). |
| | | * |
| | | * @throws DirectoryException If a conflict is encountered and the |
| | | * <CODE>overwriteExisting</CODE> flag |
| | | * is set to <CODE>false</CODE> |
| | | */ |
| | | public void registerAttributeType(AttributeType attributeType, |
| | | boolean overwriteExisting) |
| | | throws DirectoryException |
| | | { |
| | | synchronized (attributeTypes) |
| | | try |
| | | { |
| | | if (! overwriteExisting) |
| | | { |
| | | String oid = toLowerCase(attributeType.getOID()); |
| | | if (attributeTypes.containsKey(oid)) |
| | | { |
| | | AttributeType conflictingType = attributeTypes.get(oid); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_CONFLICTING_ATTRIBUTE_OID. |
| | | get(attributeType.getNameOrOID(), oid, |
| | | conflictingType.getNameOrOID()); |
| | | throw new DirectoryException( |
| | | ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | for (String name : attributeType.getNormalizedNames()) |
| | | { |
| | | if (attributeTypes.containsKey(name)) |
| | | { |
| | | AttributeType conflictingType = attributeTypes.get(name); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_CONFLICTING_ATTRIBUTE_NAME. |
| | | get(attributeType.getNameOrOID(), name, |
| | | conflictingType.getNameOrOID()); |
| | | throw new DirectoryException( |
| | | ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | } |
| | | } |
| | | |
| | | AttributeType old = attributeTypes.put( |
| | | toLowerCase(attributeType.getOID()), attributeType); |
| | | if (old != null && old != attributeType) |
| | | { |
| | | // Mark the old attribute type as stale so that caches (such as |
| | | // compressed schema) can detect changes. |
| | | old.setDirty(); |
| | | } |
| | | |
| | | for (String name : attributeType.getNormalizedNames()) |
| | | { |
| | | attributeTypes.put(name, attributeType); |
| | | } |
| | | |
| | | AttributeType superiorType = attributeType.getSuperiorType(); |
| | | if (superiorType != null) |
| | | { |
| | | registerSubordinateType(attributeType, superiorType); |
| | | } |
| | | return schemaNG.getAttributeType(nameOrOid); |
| | | } |
| | | catch (UnknownSchemaElementException e) |
| | | { |
| | | // It should never happen because we only use non-strict schemas |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Deregisters the provided attribute type definition with this |
| | | * schema. |
| | | * Retrieves the attribute type definition with the specified name or OID. |
| | | * |
| | | * @param attributeType The attribute type to deregister with this |
| | | * schema. |
| | | * @param nameOrOid |
| | | * The name or OID of the attribute type to retrieve, ignoring case considerations |
| | | * @param syntax |
| | | * The syntax to use when creating the temporary "place-holder" attribute type. |
| | | * @return The requested attribute type |
| | | */ |
| | | public void deregisterAttributeType(AttributeType attributeType) |
| | | public AttributeType getAttributeType(String nameOrOid, Syntax syntax) |
| | | { |
| | | synchronized (attributeTypes) |
| | | try |
| | | { |
| | | if (attributeTypes.remove(toLowerCase(attributeType.getOID()), |
| | | attributeType)) |
| | | { |
| | | // Mark the old attribute type as stale so that caches (such as |
| | | // compressed schema) can detect changes. |
| | | attributeType.setDirty(); |
| | | } |
| | | |
| | | for (String name : attributeType.getNormalizedNames()) |
| | | { |
| | | attributeTypes.remove(name, attributeType); |
| | | } |
| | | |
| | | AttributeType superiorType = attributeType.getSuperiorType(); |
| | | if (superiorType != null) |
| | | { |
| | | deregisterSubordinateType(attributeType, superiorType); |
| | | } |
| | | return schemaNG.getAttributeType(nameOrOid, syntax); |
| | | } |
| | | catch (UnknownSchemaElementException e) |
| | | { |
| | | // It should never happen because we only use non-strict schemas |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Parses an attribute type from its provided definition. |
| | | * |
| | | * @param definition |
| | | * The definition of the attribute type |
| | | * @return the attribute type |
| | | * @throws DirectoryException |
| | | * If an error occurs |
| | | */ |
| | | public AttributeType parseAttributeType(final String definition) throws DirectoryException |
| | | { |
| | | try |
| | | { |
| | | SchemaBuilder builder = new SchemaBuilder(schemaNG); |
| | | builder.addAttributeType(definition, true); |
| | | org.forgerock.opendj.ldap.schema.Schema newSchema = builder.toSchema(); |
| | | rejectSchemaWithWarnings(newSchema); |
| | | return newSchema.getAttributeType(parseAttributeTypeOID(definition)); |
| | | } |
| | | catch (UnknownSchemaElementException e) |
| | | { |
| | | // this should never happen |
| | | LocalizableMessage msg = ERR_ATTR_TYPE_CANNOT_REGISTER.get(definition); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, msg, e); |
| | | } |
| | | catch (LocalizedIllegalArgumentException e) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, e.getMessageObject(), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Registers a list of attribute types from their provided definitions. |
| | | * <p> |
| | | * This method allows to do only one schema change for multiple definitions, |
| | | * thus avoiding the cost (and the issue of stale schema references) of rebuilding a new schema for each definition. |
| | | * |
| | | * @param definitions |
| | | * The definitions of the attribute types |
| | | * @param schemaFile |
| | | * The schema file where these definitions belong, can be {@code null} |
| | | * @param overwrite |
| | | * Indicates whether to overwrite the attribute |
| | | * type if it already exists based on OID or name |
| | | * @throws DirectoryException |
| | | * If an error occurs |
| | | */ |
| | | public void registerAttributeTypes(final List<String> definitions, final String schemaFile, final boolean overwrite) |
| | | throws DirectoryException |
| | | { |
| | | exclusiveLock.lock(); |
| | | try |
| | | { |
| | | SchemaBuilder builder = new SchemaBuilder(schemaNG); |
| | | for (String definition : definitions) |
| | | { |
| | | String defWithFile = schemaFile != null ? |
| | | addSchemaFileToElementDefinitionIfAbsent(definition, schemaFile) : definition; |
| | | builder.addAttributeType(defWithFile, overwrite); |
| | | } |
| | | switchSchema(builder.toSchema()); |
| | | |
| | | for (String definition : definitions) |
| | | { |
| | | updateSubordinateTypes(schemaNG.getAttributeType(parseAttributeTypeOID(definition))); |
| | | } |
| | | } |
| | | catch (ConflictingSchemaElementException | UnknownSchemaElementException e) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, e.getMessageObject(), e); |
| | | } |
| | | catch (LocalizedIllegalArgumentException e) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, e.getMessageObject(), e); |
| | | } |
| | | finally |
| | | { |
| | | exclusiveLock.unlock(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Registers an attribute type from its provided definition. |
| | | * |
| | | * @param definition |
| | | * The definition of the attribute type |
| | | * @param schemaFile |
| | | * The schema file where this definition belongs, |
| | | * maybe {@code null} |
| | | * @param overwrite |
| | | * Indicates whether to overwrite the attribute |
| | | * type if it already exists based on OID or name |
| | | * @throws DirectoryException |
| | | * If an error occurs |
| | | */ |
| | | public void registerAttributeType(final String definition, final String schemaFile, final boolean overwrite) |
| | | throws DirectoryException |
| | | { |
| | | registerAttributeTypes(Arrays.asList(definition), schemaFile, overwrite); |
| | | } |
| | | |
| | | /** |
| | | * Registers the provided attribute type definition with this schema. |
| | | * |
| | | * @param attributeType |
| | | * The attribute type to register with this schema. |
| | | * @param overwriteExisting |
| | | * Indicates whether to overwrite an existing mapping if there are |
| | | * any conflicts (i.e., another attribute type with the same OID or |
| | | * name). |
| | | * @throws DirectoryException |
| | | * If a conflict is encountered and the |
| | | * <CODE>overwriteExisting</CODE> flag is set to <CODE>false</CODE> |
| | | */ |
| | | public void registerAttributeType(final AttributeType attributeType, final boolean overwriteExisting) |
| | | throws DirectoryException |
| | | { |
| | | registerAttributeType(attributeType, null, overwriteExisting); |
| | | } |
| | | |
| | | /** |
| | | * Registers the provided attribute type definition with this schema. |
| | | * |
| | | * @param attributeType |
| | | * The attribute type to register with this schema. |
| | | * @param schemaFile |
| | | * The schema file where this definition belongs, maybe {@code null} |
| | | * @param overwriteExisting |
| | | * Indicates whether to overwrite an existing mapping if there are |
| | | * any conflicts (i.e., another attribute type with the same OID or |
| | | * name). |
| | | * @throws DirectoryException |
| | | * If a conflict is encountered and the |
| | | * <CODE>overwriteExisting</CODE> flag is set to <CODE>false</CODE> |
| | | */ |
| | | public void registerAttributeType(final AttributeType attributeType, final String schemaFile, |
| | | final boolean overwriteExisting) throws DirectoryException |
| | | { |
| | | exclusiveLock.lock(); |
| | | try |
| | | { |
| | | SchemaBuilder builder = new SchemaBuilder(schemaNG); |
| | | AttributeType.Builder b = builder.buildAttributeType(attributeType); |
| | | if (schemaFile != null) |
| | | { |
| | | b.removeExtraProperty(SCHEMA_PROPERTY_FILENAME).extraProperties(SCHEMA_PROPERTY_FILENAME, schemaFile); |
| | | } |
| | | if (overwriteExisting) |
| | | { |
| | | b.addToSchemaOverwrite(); |
| | | } |
| | | else |
| | | { |
| | | b.addToSchema(); |
| | | } |
| | | switchSchema(builder.toSchema()); |
| | | |
| | | updateSubordinateTypes(attributeType); |
| | | } |
| | | catch (LocalizedIllegalArgumentException e) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, e.getMessageObject(), e); |
| | | } |
| | | finally |
| | | { |
| | | exclusiveLock.unlock(); |
| | | } |
| | | } |
| | | |
| | | private String parseAttributeTypeOID(String definition) throws DirectoryException |
| | | { |
| | | return parseOID(definition, ResultCode.INVALID_ATTRIBUTE_SYNTAX, ERR_ATTR_SYNTAX_ATTRTYPE_EMPTY_VALUE); |
| | | } |
| | | |
| | | /** |
| | | * Returns the OID from the provided attribute type definition, assuming the |
| | | * definition is valid. |
| | | * <p> |
| | | * This method does not perform any check. |
| | | * |
| | | * @param definition |
| | | * The definition, assumed to be valid |
| | | * @param parsingErrorResultCode the result code to use if a problem occurs while parsing the definition |
| | | * @param parsingErrorMsg the message to use if a problem occurs while parsing the definition |
| | | * @return the OID, which is never {@code null} |
| | | * @throws DirectoryException |
| | | * If a problem occurs while parsing the definition |
| | | */ |
| | | public static String parseOID(String definition, ResultCode parsingErrorResultCode, Arg0 parsingErrorMsg) |
| | | throws DirectoryException |
| | | { |
| | | try |
| | | { |
| | | int pos = 0; |
| | | int length = definition.length(); |
| | | // Skip over any leading whitespace. |
| | | while (pos < length && (definition.charAt(pos) == ' ')) |
| | | { |
| | | pos++; |
| | | } |
| | | // Skip the open parenthesis. |
| | | pos++; |
| | | // Skip over any spaces immediately following the opening parenthesis. |
| | | while (pos < length && definition.charAt(pos) == ' ') |
| | | { |
| | | pos++; |
| | | } |
| | | // The next set of characters must be the OID. |
| | | int oidStartPos = pos; |
| | | while (pos < length && definition.charAt(pos) != ' ' && definition.charAt(pos) != ')') |
| | | { |
| | | pos++; |
| | | } |
| | | return definition.substring(oidStartPos, pos); |
| | | } |
| | | catch (IndexOutOfBoundsException e) |
| | | { |
| | | throw new DirectoryException(parsingErrorResultCode, parsingErrorMsg.get(), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Deregisters the provided attribute type definition with this schema. |
| | | * |
| | | * @param attributeType The attribute type to deregister with this schema. |
| | | */ |
| | | public void deregisterAttributeType(final AttributeType attributeType) |
| | | { |
| | | exclusiveLock.lock(); |
| | | try |
| | | { |
| | | SchemaBuilder builder = new SchemaBuilder(schemaNG); |
| | | if (builder.removeAttributeType(attributeType.getNameOrOID())) |
| | | { |
| | | AttributeType superiorType = attributeType.getSuperiorType(); |
| | | if (superiorType != null) |
| | | { |
| | | deregisterSubordinateType(attributeType, superiorType); |
| | | } |
| | | setSchemaNG(builder.toSchema()); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | | exclusiveLock.unlock(); |
| | | } |
| | | } |
| | | |
| | | private void setSchemaNG(org.forgerock.opendj.ldap.schema.Schema newSchemaNG) |
| | | { |
| | | schemaNG = newSchemaNG.asNonStrictSchema(); |
| | | } |
| | | |
| | | private void updateSubordinateTypes(AttributeType attributeType) |
| | | { |
| | | AttributeType superiorType = attributeType.getSuperiorType(); |
| | | if (superiorType != null) |
| | | { |
| | | registerSubordinateType(attributeType, superiorType); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Registers the provided attribute type as a subtype of the given |
| | |
| | | * @param superiorType The superior type for which to register |
| | | * the given attribute type as a subtype. |
| | | */ |
| | | private void registerSubordinateType(AttributeType attributeType, |
| | | AttributeType superiorType) |
| | | private void registerSubordinateType(AttributeType attributeType, AttributeType superiorType) |
| | | { |
| | | List<AttributeType> subTypes = subordinateTypes.get(superiorType); |
| | | if (subTypes == null) |
| | | { |
| | | superiorType.setMayHaveSubordinateTypes(); |
| | | subordinateTypes.put(superiorType, newLinkedList(attributeType)); |
| | | } |
| | | else if (! subTypes.contains(attributeType)) |
| | | else if (!subTypes.contains(attributeType)) |
| | | { |
| | | superiorType.setMayHaveSubordinateTypes(); |
| | | subTypes.add(attributeType); |
| | | |
| | | AttributeType higherSuperior = superiorType.getSuperiorType(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Deregisters the provided attribute type as a subtype of the given |
| | | * superior attribute type, recursively following any additional |
| | |
| | | * @param superiorType The superior type for which to deregister |
| | | * the given attribute type as a subtype. |
| | | */ |
| | | private void deregisterSubordinateType(AttributeType attributeType, |
| | | AttributeType superiorType) |
| | | private void deregisterSubordinateType(AttributeType attributeType, AttributeType superiorType) |
| | | { |
| | | List<AttributeType> subTypes = subordinateTypes.get(superiorType); |
| | | if (subTypes != null && subTypes.remove(attributeType)) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the set of subtypes registered for the given attribute |
| | | * type. |
| | |
| | | public List<AttributeType> getSubTypes(AttributeType attributeType) |
| | | { |
| | | List<AttributeType> subTypes = subordinateTypes.get(attributeType); |
| | | if (subTypes == null) |
| | | { |
| | | return Collections.emptyList(); |
| | | } |
| | | else |
| | | { |
| | | return subTypes; |
| | | } |
| | | return subTypes != null ? subTypes : Collections.<AttributeType> emptyList(); |
| | | } |
| | | |
| | | |
| | |
| | | boolean overwriteExisting) |
| | | throws DirectoryException |
| | | { |
| | | synchronized (objectClasses) |
| | | exclusiveLock.lock(); |
| | | try |
| | | { |
| | | if (! overwriteExisting) |
| | | { |
| | |
| | | objectClasses.put(name, objectClass); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | | exclusiveLock.unlock(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the attribute syntax definitions for this schema, as a |
| | | * mapping between the OID for the syntax and the syntax itself. |
| | | * Each syntax should only be present once, since its only key is |
| | | * its OID. The contents of the returned mapping must not be |
| | | * altered. |
| | | * Retrieves the attribute syntax definitions for this schema. |
| | | * |
| | | * @return The attribute syntax definitions for this schema. |
| | | */ |
| | | public ConcurrentHashMap<String,Syntax> getSyntaxes() |
| | | public Collection<Syntax> getSyntaxes() |
| | | { |
| | | return syntaxes; |
| | | return schemaNG.getSyntaxes(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this schema definition includes an attribute |
| | | * syntax with the provided name or OID. |
| | | * syntax with the provided OID. |
| | | * |
| | | * @param lowerName The name or OID for which to make the |
| | | * determination, formatted in all lowercase |
| | | * characters. |
| | | * |
| | | * @param oid The OID for which to make the determination |
| | | * @return {@code true} if this schema contains an attribute syntax |
| | | * with the provided name or OID, or {@code false} if not. |
| | | * with the provided OID, or {@code false} if not. |
| | | */ |
| | | public boolean hasSyntax(String lowerName) |
| | | public boolean hasSyntax(String oid) |
| | | { |
| | | return syntaxes.containsKey(lowerName); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the requested attribute syntax. |
| | | * |
| | | * @param oid |
| | | * The OID of the syntax to retrieve. |
| | | * @param allowDefault |
| | | * Indicates whether to return the default attribute syntax if the |
| | | * requested syntax is unknown. |
| | | * @return The requested attribute syntax, the default syntax if the requested |
| | | * syntax is unknown and the caller has indicated that the default is |
| | | * acceptable, or <CODE>null</CODE> otherwise. |
| | | */ |
| | | public Syntax getSyntax(String oid, boolean allowDefault) |
| | | { |
| | | Syntax syntax = getSyntax(oid); |
| | | if (syntax == null && allowDefault) |
| | | { |
| | | return getDefaultSyntax(); |
| | | } |
| | | |
| | | return syntax; |
| | | return schemaNG.hasSyntax(oid); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the attribute syntax definition with the OID. |
| | | * |
| | | * @param lowerName The OID of the attribute syntax to retrieve, |
| | | * formatted in all lowercase characters. |
| | | * |
| | | * @return The requested attribute syntax, or <CODE>null</CODE> if |
| | | * no syntax is registered with the provided OID. |
| | | * @param oid The OID of the attribute syntax to retrieve. |
| | | * @return The requested attribute syntax, |
| | | * or {@code null} if no syntax is registered with the provided OID. |
| | | */ |
| | | public Syntax getSyntax(String lowerName) |
| | | public Syntax getSyntax(String oid) |
| | | { |
| | | return syntaxes.get(lowerName); |
| | | return schemaNG.getSyntax(oid); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public Syntax getDefaultSyntax() |
| | | { |
| | | return defaultSyntax; |
| | | return schemaNG.getSyntax(defaultSyntaxOID); |
| | | } |
| | | |
| | | |
| | |
| | | * @param defaultSyntax |
| | | * The defautl syntax to use. |
| | | */ |
| | | public void registerDefaultSyntax( |
| | | Syntax defaultSyntax) |
| | | public void registerDefaultSyntax(Syntax defaultSyntax) |
| | | { |
| | | this.defaultSyntax = defaultSyntax; |
| | | this.defaultSyntaxOID = defaultSyntax.getOID(); |
| | | } |
| | | |
| | | |
| | |
| | | * <CODE>overwriteExisting</CODE> flag |
| | | * is set to <CODE>false</CODE> |
| | | */ |
| | | public void registerSyntax(Syntax syntax, |
| | | boolean overwriteExisting) |
| | | throws DirectoryException |
| | | public void registerSyntax(final Syntax syntax, final boolean overwriteExisting) throws DirectoryException |
| | | { |
| | | synchronized (syntaxes) |
| | | exclusiveLock.lock(); |
| | | try |
| | | { |
| | | if (! overwriteExisting) |
| | | SchemaBuilder builder = new SchemaBuilder(schemaNG); |
| | | Syntax.Builder b = builder.buildSyntax(syntax); |
| | | if (overwriteExisting) |
| | | { |
| | | String oid = toLowerCase(syntax.getOID()); |
| | | if (syntaxes.containsKey(oid)) |
| | | { |
| | | Syntax conflictingSyntax = syntaxes.get(oid); |
| | | |
| | | LocalizableMessage message = ERR_SCHEMA_CONFLICTING_SYNTAX_OID. |
| | | get(syntax.getName(), oid, |
| | | conflictingSyntax.getName()); |
| | | throw new DirectoryException( |
| | | ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | b.addToSchemaOverwrite(); |
| | | } |
| | | |
| | | syntaxes.put(toLowerCase(syntax.getOID()), syntax); |
| | | else |
| | | { |
| | | b.addToSchema(); |
| | | } |
| | | switchSchema(builder.toSchema()); |
| | | } |
| | | catch (LocalizedIllegalArgumentException e) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, e.getMessageObject(), e); |
| | | } |
| | | finally |
| | | { |
| | | exclusiveLock.unlock(); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void registerSyntax(final String definition, final boolean overwriteExisting) throws DirectoryException |
| | | { |
| | | exclusiveLock.lock(); |
| | | try |
| | | { |
| | | org.forgerock.opendj.ldap.schema.Schema newSchema = |
| | | new SchemaBuilder(schemaNG) |
| | | .addSyntax(definition, overwriteExisting) |
| | | .toSchema(); |
| | | switchSchema(newSchema); |
| | | } |
| | | catch (ConflictingSchemaElementException | UnknownSchemaElementException e) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, e.getMessageObject(), e); |
| | | } |
| | | catch (LocalizedIllegalArgumentException e) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, e.getMessageObject(), e); |
| | | } |
| | | finally |
| | | { |
| | | exclusiveLock.unlock(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Deregisters the provided attribute syntax definition with this |
| | | * schema. |
| | | * Deregisters the provided attribute syntax definition with this schema. |
| | | * |
| | | * @param syntax The attribute syntax to deregister with this |
| | | * schema. |
| | | * @param syntax The attribute syntax to deregister with this schema. |
| | | */ |
| | | public void deregisterSyntax(Syntax syntax) |
| | | public void deregisterSyntax(final Syntax syntax) |
| | | { |
| | | synchronized (syntaxes) |
| | | exclusiveLock.lock(); |
| | | try |
| | | { |
| | | syntaxes.remove(toLowerCase(syntax.getOID()), syntax); |
| | | SchemaBuilder builder = new SchemaBuilder(schemaNG); |
| | | builder.removeSyntax(syntax.getOID()); |
| | | setSchemaNG(builder.toSchema()); |
| | | } |
| | | finally |
| | | { |
| | | exclusiveLock.unlock(); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * @return The ldap syntax definitions for this schema. |
| | | */ |
| | | public ConcurrentHashMap<String,LDAPSyntaxDescription> |
| | | getLdapSyntaxDescriptions() |
| | | public ConcurrentHashMap<String,LDAPSyntaxDescription> getLdapSyntaxDescriptions() |
| | | { |
| | | return ldapSyntaxDescriptions; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this schema definition includes an ldap |
| | | * syntax description with the provided name or OID. |
| | | * |
| | | * @param lowerName The OID for which to make the |
| | | * determination, formatted in all lowercase |
| | | * characters. |
| | | * |
| | | * @return {@code true} if this schema contains an ldap syntax |
| | | * with the provided name or OID, or {@code false} if not. |
| | | */ |
| | | public boolean hasLdapSyntaxDescription(String lowerName) |
| | | { |
| | | return ldapSyntaxDescriptions.containsKey(lowerName); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the ldap syntax definition with the OID. |
| | | * |
| | |
| | | * @return The requested ldap syntax, or <CODE>null</CODE> if |
| | | * no syntax is registered with the provided OID. |
| | | */ |
| | | public LDAPSyntaxDescription getLdapSyntaxDescription( |
| | | String lowerName) |
| | | public LDAPSyntaxDescription getLdapSyntaxDescription(String lowerName) |
| | | { |
| | | return ldapSyntaxDescriptions.get(lowerName); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Registers the provided ldap syntax description with this |
| | | * schema. |
| | | * Registers the provided ldap syntax description with this schema. |
| | | * |
| | | * @param syntax The ldap syntax description to register |
| | | * with this schema. |
| | | * @param overwriteExisting Indicates whether to overwrite an |
| | | * existing mapping if there are any |
| | | * conflicts (i.e., another ldap |
| | | * syntax with the same OID). |
| | | * |
| | | * @throws DirectoryException If a conflict is encountered and |
| | | * <CODE>overwriteExisting</CODE> flag |
| | | * is set to <CODE>false</CODE> |
| | | * @param definition |
| | | * The ldap syntax definition to register with this schema. |
| | | * @param overwriteExisting |
| | | * Indicates whether to overwrite an existing mapping if there are |
| | | * any conflicts (i.e., another ldap syntax with the same OID). |
| | | * @throws DirectoryException |
| | | * If a conflict is encountered and <CODE>overwriteExisting</CODE> |
| | | * flag is set to <CODE>false</CODE> |
| | | */ |
| | | public void registerLdapSyntaxDescription( |
| | | LDAPSyntaxDescription syntax, |
| | | boolean overwriteExisting) |
| | | throws DirectoryException |
| | | public void registerLdapSyntaxDescription(String definition, boolean overwriteExisting) |
| | | throws DirectoryException |
| | | { |
| | | /** |
| | | * ldapsyntaxes is part real and part virtual. For any |
| | |
| | | * virtual syntax set to make this available through virtual |
| | | * ldapsyntaxes attribute. |
| | | */ |
| | | synchronized (ldapSyntaxDescriptions) |
| | | exclusiveLock.lock(); |
| | | try |
| | | { |
| | | String oid = toLowerCase(syntax.getSyntax().getOID()); |
| | | String oid = parseAttributeTypeOID(definition); |
| | | if (! overwriteExisting && ldapSyntaxDescriptions.containsKey(oid)) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_SCHEMA_MODIFY_MULTIPLE_CONFLICTS_FOR_ADD_LDAP_SYNTAX.get(oid)); |
| | | } |
| | | |
| | | ldapSyntaxDescriptions.put(oid, syntax); |
| | | // Register the attribute syntax with the schema. |
| | | // It will ensure syntax is available along with the other virtual values for ldapsyntaxes. |
| | | registerSyntax(definition, overwriteExisting); |
| | | |
| | | //Register the attribute syntax with the schema. It will ensure |
| | | // syntax is available along with the other virtual values for |
| | | // ldapsyntaxes. |
| | | registerSyntax(syntax.getSyntax(), overwriteExisting); |
| | | Syntax syntax = schemaNG.getSyntax(oid); |
| | | LDAPSyntaxDescription syntaxDesc = new LDAPSyntaxDescription(definition, oid, syntax.getExtraProperties()); |
| | | ldapSyntaxDescriptions.put(oid, syntaxDesc); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Deregisters the provided ldap syntax description with this |
| | | * schema. |
| | | * |
| | | * @param syntax The ldap syntax to deregister with this |
| | | * schema. |
| | | */ |
| | | public void deregisterLdapSyntaxDescription( |
| | | LDAPSyntaxDescription syntax) |
| | | { |
| | | synchronized (ldapSyntaxDescriptions) |
| | | finally |
| | | { |
| | | //Remove the real value. |
| | | ldapSyntaxDescriptions.remove( |
| | | toLowerCase(syntax.getSyntax().getOID()), |
| | | syntax); |
| | | |
| | | try |
| | | { |
| | | //Get rid of this from the virtual ldapsyntaxes. |
| | | deregisterSyntax(syntax.getSyntax()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | deregisterSyntax(syntax.getSyntax()); |
| | | } |
| | | exclusiveLock.unlock(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the entire set of matching rule definitions for this |
| | | * schema, as a mapping between the lowercase names and OIDs for the |
| | | * matching rule and the matching rule itself. Each matching rule |
| | | * may be associated with multiple keys (once for the OID and again |
| | | * for each name). This should be a superset of the sets of |
| | | * approximate, equality, ordering, and substring matching rules. |
| | | * The contents of the returned mapping must not be altered. |
| | | * Deregisters the provided ldap syntax description with this schema. |
| | | * |
| | | * @return The matching rule definitions for this schema. |
| | | * @param syntaxDesc |
| | | * The ldap syntax to deregister with this schema. |
| | | */ |
| | | public ConcurrentHashMap<String,MatchingRule> getMatchingRules() |
| | | public void deregisterLdapSyntaxDescription(LDAPSyntaxDescription syntaxDesc) |
| | | { |
| | | return matchingRules; |
| | | exclusiveLock.lock(); |
| | | try |
| | | { |
| | | // Remove the real value. |
| | | ldapSyntaxDescriptions.remove(toLowerCase(syntaxDesc.getOID()), syntaxDesc); |
| | | |
| | | // Get rid of this from the virtual ldapsyntaxes. |
| | | deregisterSyntax(getSyntax(syntaxDesc.getOID())); |
| | | } |
| | | finally |
| | | { |
| | | exclusiveLock.unlock(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves all matching rule definitions for this schema. |
| | | * |
| | | * @return The matching rule definitions for this schema |
| | | */ |
| | | public Collection<MatchingRule> getMatchingRules() |
| | | { |
| | | return schemaNG.getMatchingRules(); |
| | | } |
| | | |
| | | |
| | |
| | | * Indicates whether this schema definition includes a matching rule |
| | | * with the provided name or OID. |
| | | * |
| | | * @param lowerName The name or OID for which to make the |
| | | * determination, formatted in all lowercase |
| | | * characters. |
| | | * |
| | | * @param nameOrOid The name or OID for which to make the determination, ignoring case considerations |
| | | * @return {@code true} if this schema contains a matching rule |
| | | * with the provided name or OID, or {@code false} if not. |
| | | */ |
| | | public boolean hasMatchingRule(String lowerName) |
| | | public boolean hasMatchingRule(String nameOrOid) |
| | | { |
| | | return matchingRules.containsKey(lowerName); |
| | | return schemaNG.hasMatchingRule(nameOrOid); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the matching rule definition with the specified name or |
| | | * OID. |
| | | * Retrieves the matching rule definition with the specified name or OID. |
| | | * |
| | | * @param lowerName The name or OID of the matching rule to |
| | | * retrieve, formatted in all lowercase |
| | | * characters. |
| | | * |
| | | * @return The requested matching rule, or <CODE>null</CODE> if no |
| | | * rule is registered with the provided name or OID. |
| | | * @param nameOrOid The name or OID of the matching rule to retrieve, ignoring case considerations |
| | | * @return The requested matching rule, or {@code null} if no rule is registered with the provided name or OID. |
| | | */ |
| | | public MatchingRule getMatchingRule(String lowerName) |
| | | public MatchingRule getMatchingRule(String nameOrOid) |
| | | { |
| | | return matchingRules.get(lowerName); |
| | | return schemaNG.getMatchingRule(nameOrOid); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * Registers the provided matching rule definition with this schema. |
| | | * |
| | | * @param matchingRule The matching rule to register with |
| | | * this schema. |
| | | * @param overwriteExisting Indicates whether to overwrite an |
| | | * existing mapping if there are any |
| | | * conflicts (i.e., |
| | | * another matching rule with the same |
| | | * OID or name). |
| | | * |
| | | * @throws DirectoryException If a conflict is encountered and the |
| | | * <CODE>overwriteExisting</CODE> flag |
| | | * is set to <CODE>false</CODE> |
| | | * @param matchingRule |
| | | * The matching rule to register with this schema. |
| | | * @param overwriteExisting |
| | | * Indicates whether to overwrite an existing mapping if there are |
| | | * any conflicts (i.e., another matching rule with the same OID or |
| | | * name). |
| | | * @throws DirectoryException |
| | | * If a conflict is encountered and the |
| | | * {@code overwriteExisting} flag is set to {@code false} |
| | | */ |
| | | public void registerMatchingRule(MatchingRule matchingRule, boolean overwriteExisting) |
| | | public void registerMatchingRule(final MatchingRule matchingRule, final boolean overwriteExisting) |
| | | throws DirectoryException |
| | | { |
| | | synchronized (matchingRules) |
| | | exclusiveLock.lock(); |
| | | try |
| | | { |
| | | if (!overwriteExisting) |
| | | { |
| | | String oid = toLowerCase(matchingRule.getOID()); |
| | | if (matchingRules.containsKey(oid)) |
| | | { |
| | | MatchingRule conflictingRule = matchingRules.get(oid); |
| | | |
| | | LocalizableMessage message = |
| | | ERR_SCHEMA_CONFLICTING_MR_OID.get(matchingRule.getNameOrOID(), |
| | | oid, conflictingRule.getNameOrOID()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | // check all names of the matching rules because it is not checked by SDK schema |
| | | for (String name : matchingRule.getNames()) |
| | | { |
| | | if (name != null) |
| | | if (schemaNG.hasMatchingRule(name)) |
| | | { |
| | | name = toLowerCase(name); |
| | | if (matchingRules.containsKey(name)) |
| | | { |
| | | MatchingRule conflictingRule = matchingRules.get(name); |
| | | Collection<MatchingRule> conflictingRules = schemaNG.getMatchingRulesWithName(name); |
| | | // there should be only one |
| | | MatchingRule conflictingRule = conflictingRules.iterator().next(); |
| | | |
| | | LocalizableMessage message = |
| | | ERR_SCHEMA_CONFLICTING_MR_NAME.get(matchingRule.getOID(), |
| | | name, conflictingRule.getOID()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | message); |
| | | } |
| | | LocalizableMessage message = |
| | | ERR_SCHEMA_CONFLICTING_MR_NAME.get(matchingRule.getOID(), name, conflictingRule.getOID()); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | } |
| | | } |
| | | matchingRules.put(toLowerCase(matchingRule.getOID()), matchingRule); |
| | | |
| | | for (String name : matchingRule.getNames()) |
| | | // now register the matching rule |
| | | SchemaBuilder builder = new SchemaBuilder(schemaNG); |
| | | MatchingRule.Builder b = builder.buildMatchingRule(matchingRule); |
| | | if (overwriteExisting) |
| | | { |
| | | if (name != null) |
| | | { |
| | | matchingRules.put(toLowerCase(name), matchingRule); |
| | | } |
| | | b.addToSchemaOverwrite(); |
| | | } |
| | | else |
| | | { |
| | | b.addToSchema(); |
| | | } |
| | | switchSchema(builder.toSchema()); |
| | | } |
| | | catch (LocalizedIllegalArgumentException e) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, e.getMessageObject(), e); |
| | | } |
| | | finally |
| | | { |
| | | exclusiveLock.unlock(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Deregisters the provided matching rule definition with this |
| | | * schema. |
| | | * Deregisters the provided matching rule definition with this schema. |
| | | * |
| | | * @param matchingRule The matching rule to deregister with this |
| | | * schema. |
| | | * @param matchingRule |
| | | * The matching rule to deregister with this schema. |
| | | */ |
| | | public void deregisterMatchingRule(MatchingRule matchingRule) |
| | | public void deregisterMatchingRule(final MatchingRule matchingRule) |
| | | { |
| | | synchronized (matchingRules) |
| | | exclusiveLock.lock(); |
| | | try |
| | | { |
| | | matchingRules.remove(toLowerCase(matchingRule.getOID()), matchingRule); |
| | | |
| | | for (String name : matchingRule.getNames()) |
| | | { |
| | | if (name != null) |
| | | { |
| | | matchingRules.remove(toLowerCase(name), matchingRule); |
| | | } |
| | | } |
| | | SchemaBuilder builder = new SchemaBuilder(schemaNG); |
| | | builder.removeMatchingRule(matchingRule.getNameOrOID()); |
| | | setSchemaNG(builder.toSchema()); |
| | | } |
| | | finally |
| | | { |
| | | exclusiveLock.unlock(); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this schema definition includes a matching rule |
| | | * use for the provided matching rule. |
| | | * |
| | | * @param matchingRule The matching rule for which to make the |
| | | * determination. |
| | | * |
| | | * @return {@code true} if this schema contains a matching rule use |
| | | * for the provided matching rule, or {@code false} if not. |
| | | */ |
| | | public boolean hasMatchingRuleUse(MatchingRule matchingRule) |
| | | { |
| | | return matchingRuleUses.containsKey(matchingRule); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the matching rule use definition for the specified |
| | | * matching rule. |
| | | * |
| | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this schema definition includes a DIT content |
| | | * rule for the provided objectclass. |
| | | * |
| | | * @param objectClass The objectclass for which to make the |
| | | * determination. |
| | | * |
| | | * @return {@code true} if this schema contains a DIT content rule |
| | | * for the provided objectclass, or {@code false} if not. |
| | | */ |
| | | public boolean hasDITContentRule(ObjectClass objectClass) |
| | | { |
| | | return ditContentRules.containsKey(objectClass); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the DIT content rule definition for the specified |
| | | * objectclass. |
| | | * |
| | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this schema definition includes a DIT structure |
| | | * rule with the provided rule ID. |
| | | * |
| | | * @param ruleID The rule ID for which to make the determination. |
| | | * |
| | | * @return {@code true} if this schema contains a DIT structure |
| | | * rule with the provided rule ID, or {@code false} if not. |
| | | */ |
| | | public boolean hasDITStructureRule(int ruleID) |
| | | { |
| | | return ditStructureRulesByID.containsKey(ruleID); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this schema definition includes a DIT structure |
| | | * rule for the provided name form. |
| | | * |
| | | * @param nameForm The name form for which to make the |
| | | * determination. |
| | | * |
| | | * @return {@code true} if this schema contains a DIT structure |
| | | * rule for the provided name form, or {@code false} if |
| | | * not. |
| | | */ |
| | | public boolean hasDITStructureRule(NameForm nameForm) |
| | | { |
| | | return ditStructureRulesByNameForm.containsKey(nameForm); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the DIT structure rule definition with the provided |
| | | * rule ID. |
| | | * |
| | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this schema definition includes a name form for |
| | | * the specified objectclass. |
| | | * |
| | | * @param objectClass The objectclass for which to make the |
| | | * determination. |
| | | * |
| | | * @return {@code true} if this schema contains a name form for the |
| | | * provided objectclass, or {@code false} if not. |
| | | */ |
| | | public boolean hasNameForm(ObjectClass objectClass) |
| | | { |
| | | return nameFormsByOC.containsKey(objectClass); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this schema definition includes a name form |
| | | * with the specified name or OID. |
| | | * |
| | |
| | | this.youngestModificationTime = youngestModificationTime; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Recursively rebuilds all schema elements that are dependent upon |
| | | * the provided element. This must be invoked whenever an existing |
| | |
| | | * @throws DirectoryException If a problem occurs while rebuilding |
| | | * any of the schema elements. |
| | | */ |
| | | public void rebuildDependentElements(SchemaFileElement element) |
| | | throws DirectoryException |
| | | public void rebuildDependentElements(SchemaFileElement element) throws DirectoryException |
| | | { |
| | | try |
| | | { |
| | | rebuildDependentElements(element, 0); |
| | | // increase the depth for each level of recursion to protect against errors due to circular references. |
| | | final int depth = 0; |
| | | |
| | | if (element instanceof SomeSchemaElement) |
| | | { |
| | | SomeSchemaElement elt = (SomeSchemaElement) element; |
| | | if (elt.isAttributeType()) |
| | | { |
| | | rebuildDependentElements(elt.getAttributeType(), depth); |
| | | } |
| | | } |
| | | else if (element instanceof ObjectClass) |
| | | { |
| | | rebuildDependentElements((ObjectClass) element, depth); |
| | | } |
| | | else if (element instanceof NameForm) |
| | | { |
| | | rebuildDependentElements((NameForm) element, depth); |
| | | } |
| | | else if (element instanceof DITStructureRule) |
| | | { |
| | | rebuildDependentElements((DITStructureRule) element, depth); |
| | | } |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SCHEMA_CIRCULAR_DEPENDENCY_REFERENCE.get(element); |
| | | throw new DirectoryException(de.getResultCode(), message, |
| | | de); |
| | | throw new DirectoryException(de.getResultCode(), message, de); |
| | | } |
| | | |
| | | |
| | | // It wasn't a circular reference error, so just re-throw the |
| | | // exception. |
| | | // It wasn't a circular reference error, so just re-throw the exception. |
| | | throw de; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Recursively rebuilds all schema elements that are dependent upon |
| | | * the provided element, increasing the depth for each level of |
| | | * recursion to protect against errors due to circular references. |
| | | * |
| | | * @param element The element for which to recursively rebuild all |
| | | * dependent elements. |
| | | * @param depth The current recursion depth. |
| | | * |
| | | * @throws DirectoryException If a problem occurs while rebuilding |
| | | * any of the schema elements. |
| | | */ |
| | | private void rebuildDependentElements(SchemaFileElement element, |
| | | int depth) |
| | | throws DirectoryException |
| | | private void circularityCheck(int depth, SchemaFileElement element) throws DirectoryException |
| | | { |
| | | if (depth > 20) |
| | | { |
| | | // FIXME -- Is this an appropriate maximum depth for detecting |
| | | // circular references? |
| | | // FIXME use a stack of already traversed elements and verify we're updating them only once instead of depth only |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | | ERR_SCHEMA_CIRCULAR_DEPENDENCY_REFERENCE.get(element)); |
| | | } |
| | | } |
| | | |
| | | private void rebuildDependentElements(AttributeType type, int depth) throws DirectoryException |
| | | { |
| | | circularityCheck(depth, null); |
| | | |
| | | // Figure out what type of element we're dealing with and make the |
| | | // appropriate determinations for that element. |
| | | if (element instanceof AttributeType) |
| | | for (AttributeType at : schemaNG.getAttributeTypes()) |
| | | { |
| | | AttributeType t = (AttributeType) element; |
| | | |
| | | for (AttributeType at : attributeTypes.values()) |
| | | if ((at.getSuperiorType() != null) && at.getSuperiorType().equals(type)) |
| | | { |
| | | if (at.getSuperiorType() != null && at.getSuperiorType().equals(t)) |
| | | { |
| | | AttributeType newAT = recreateFromDefinition(at); |
| | | deregisterAttributeType(at); |
| | | registerAttributeType(newAT, true); |
| | | rebuildDependentElements(at, depth+1); |
| | | } |
| | | deregisterAttributeType(at); |
| | | registerAttributeType(at.toString(), getSchemaFileName(at), true); |
| | | rebuildDependentElements(at, depth + 1); |
| | | } |
| | | } |
| | | |
| | | for (ObjectClass oc : objectClasses.values()) |
| | | for (ObjectClass oc : objectClasses.values()) |
| | | { |
| | | if (oc.getRequiredAttributes().contains(type) || oc.getOptionalAttributes().contains(type)) |
| | | { |
| | | if (oc.getRequiredAttributes().contains(t) || |
| | | oc.getOptionalAttributes().contains(t)) |
| | | { |
| | | ObjectClass newOC = recreateFromDefinition(oc); |
| | | deregisterObjectClass(oc); |
| | | registerObjectClass(newOC, true); |
| | | rebuildDependentElements(oc, depth+1); |
| | | } |
| | | ObjectClass newOC = recreateFromDefinition(oc); |
| | | deregisterObjectClass(oc); |
| | | registerObjectClass(newOC, true); |
| | | rebuildDependentElements(oc, depth + 1); |
| | | } |
| | | } |
| | | |
| | | for (List<NameForm> mappedForms : nameFormsByOC.values()) |
| | | for (List<NameForm> mappedForms : nameFormsByOC.values()) |
| | | { |
| | | for (NameForm nf : mappedForms) |
| | | { |
| | | for(NameForm nf : mappedForms) |
| | | if (nf.getRequiredAttributes().contains(type) || nf.getOptionalAttributes().contains(type)) |
| | | { |
| | | if (nf.getRequiredAttributes().contains(t) || |
| | | nf.getOptionalAttributes().contains(t)) |
| | | { |
| | | NameForm newNF = recreateFromDefinition(nf); |
| | | deregisterNameForm(nf); |
| | | registerNameForm(newNF, true); |
| | | rebuildDependentElements(nf, depth+1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (DITContentRule dcr : ditContentRules.values()) |
| | | { |
| | | if (dcr.getRequiredAttributes().contains(t) || |
| | | dcr.getOptionalAttributes().contains(t) || |
| | | dcr.getProhibitedAttributes().contains(t)) |
| | | { |
| | | DITContentRule newDCR = recreateFromDefinition(dcr); |
| | | deregisterDITContentRule(dcr); |
| | | registerDITContentRule(newDCR, true); |
| | | rebuildDependentElements(dcr, depth+1); |
| | | } |
| | | } |
| | | |
| | | for (MatchingRuleUse mru : matchingRuleUses.values()) |
| | | { |
| | | if (mru.getAttributes().contains(t)) |
| | | { |
| | | MatchingRuleUse newMRU = recreateFromDefinition(mru); |
| | | deregisterMatchingRuleUse(mru); |
| | | registerMatchingRuleUse(newMRU, true); |
| | | rebuildDependentElements(mru, depth+1); |
| | | NameForm newNF = recreateFromDefinition(nf); |
| | | deregisterNameForm(nf); |
| | | registerNameForm(newNF, true); |
| | | rebuildDependentElements(nf, depth + 1); |
| | | } |
| | | } |
| | | } |
| | | else if (element instanceof ObjectClass) |
| | | |
| | | for (DITContentRule dcr : ditContentRules.values()) |
| | | { |
| | | ObjectClass c = (ObjectClass) element; |
| | | |
| | | for (ObjectClass oc : objectClasses.values()) |
| | | if (dcr.getRequiredAttributes().contains(type) || dcr.getOptionalAttributes().contains(type) |
| | | || dcr.getProhibitedAttributes().contains(type)) |
| | | { |
| | | if (oc.getSuperiorClasses().contains(c)) |
| | | { |
| | | ObjectClass newOC = recreateFromDefinition(oc); |
| | | deregisterObjectClass(oc); |
| | | registerObjectClass(newOC, true); |
| | | rebuildDependentElements(oc, depth+1); |
| | | } |
| | | } |
| | | |
| | | List<NameForm> mappedForms = nameFormsByOC.get(c); |
| | | if(mappedForms != null) |
| | | { |
| | | for(NameForm nf : mappedForms) |
| | | { |
| | | if (nf != null) |
| | | { |
| | | NameForm newNF = recreateFromDefinition(nf); |
| | | deregisterNameForm(nf); |
| | | registerNameForm(newNF, true); |
| | | rebuildDependentElements(nf, depth+1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (DITContentRule dcr : ditContentRules.values()) |
| | | { |
| | | if (dcr.getStructuralClass().equals(c) || |
| | | dcr.getAuxiliaryClasses().contains(c)) |
| | | { |
| | | DITContentRule newDCR = recreateFromDefinition(dcr); |
| | | deregisterDITContentRule(dcr); |
| | | registerDITContentRule(newDCR, true); |
| | | rebuildDependentElements(dcr, depth+1); |
| | | } |
| | | DITContentRule newDCR = recreateFromDefinition(dcr); |
| | | deregisterDITContentRule(dcr); |
| | | registerDITContentRule(newDCR, true); |
| | | } |
| | | } |
| | | else if (element instanceof NameForm) |
| | | |
| | | for (MatchingRuleUse mru : matchingRuleUses.values()) |
| | | { |
| | | NameForm n = (NameForm) element; |
| | | DITStructureRule dsr = ditStructureRulesByNameForm.get(n); |
| | | if (dsr != null) |
| | | if (mru.getAttributes().contains(type)) |
| | | { |
| | | DITStructureRule newDSR = recreateFromDefinition(dsr); |
| | | deregisterDITStructureRule(dsr); |
| | | registerDITStructureRule(newDSR, true); |
| | | rebuildDependentElements(dsr, depth+1); |
| | | } |
| | | } |
| | | else if (element instanceof DITStructureRule) |
| | | { |
| | | DITStructureRule d = (DITStructureRule) element; |
| | | for (DITStructureRule dsr : ditStructureRulesByID.values()) |
| | | { |
| | | if (dsr.getSuperiorRules().contains(d)) |
| | | { |
| | | DITStructureRule newDSR = recreateFromDefinition(dsr); |
| | | deregisterDITStructureRule(dsr); |
| | | registerDITStructureRule(newDSR, true); |
| | | rebuildDependentElements(dsr, depth+1); |
| | | } |
| | | MatchingRuleUse newMRU = recreateFromDefinition(mru); |
| | | deregisterMatchingRuleUse(mru); |
| | | registerMatchingRuleUse(newMRU, true); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private AttributeType recreateFromDefinition(AttributeType attrType) |
| | | throws DirectoryException |
| | | private void rebuildDependentElements(ObjectClass c, int depth) throws DirectoryException |
| | | { |
| | | ByteString value = ByteString.valueOfUtf8(attrType.toString()); |
| | | AttributeType copy = |
| | | AttributeTypeSyntax.decodeAttributeType(value, this, false); |
| | | setSchemaFile(copy, getSchemaFile(attrType)); |
| | | if (attrType.mayHaveSubordinateTypes()) |
| | | circularityCheck(depth, c); |
| | | for (ObjectClass oc : objectClasses.values()) |
| | | { |
| | | copy.setMayHaveSubordinateTypes(); |
| | | if (oc.getSuperiorClasses().contains(c)) |
| | | { |
| | | ObjectClass newOC = recreateFromDefinition(oc); |
| | | deregisterObjectClass(oc); |
| | | registerObjectClass(newOC, true); |
| | | rebuildDependentElements(oc, depth + 1); |
| | | } |
| | | } |
| | | return copy; |
| | | |
| | | List<NameForm> mappedForms = nameFormsByOC.get(c); |
| | | if (mappedForms != null) |
| | | { |
| | | for (NameForm nf : mappedForms) |
| | | { |
| | | if (nf != null) |
| | | { |
| | | NameForm newNF = recreateFromDefinition(nf); |
| | | deregisterNameForm(nf); |
| | | registerNameForm(newNF, true); |
| | | rebuildDependentElements(nf, depth + 1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (DITContentRule dcr : ditContentRules.values()) |
| | | { |
| | | if (dcr.getStructuralClass().equals(c) || dcr.getAuxiliaryClasses().contains(c)) |
| | | { |
| | | DITContentRule newDCR = recreateFromDefinition(dcr); |
| | | deregisterDITContentRule(dcr); |
| | | registerDITContentRule(newDCR, true); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void rebuildDependentElements(NameForm n, int depth) throws DirectoryException |
| | | { |
| | | circularityCheck(depth, n); |
| | | DITStructureRule dsr = ditStructureRulesByNameForm.get(n); |
| | | if (dsr != null) |
| | | { |
| | | DITStructureRule newDSR = recreateFromDefinition(dsr); |
| | | deregisterDITStructureRule(dsr); |
| | | registerDITStructureRule(newDSR, true); |
| | | rebuildDependentElements(dsr, depth + 1); |
| | | } |
| | | } |
| | | |
| | | private void rebuildDependentElements(DITStructureRule d, int depth) throws DirectoryException |
| | | { |
| | | circularityCheck(depth, d); |
| | | for (DITStructureRule dsr : ditStructureRulesByID.values()) |
| | | { |
| | | if (dsr.getSuperiorRules().contains(d)) |
| | | { |
| | | DITStructureRule newDSR = recreateFromDefinition(dsr); |
| | | deregisterDITStructureRule(dsr); |
| | | registerDITStructureRule(newDSR, true); |
| | | rebuildDependentElements(dsr, depth + 1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private String getSchemaFileName(AttributeType attributeType) |
| | | { |
| | | List<String> values = attributeType.getExtraProperties().get(ServerConstants.SCHEMA_PROPERTY_FILENAME); |
| | | return values != null && ! values.isEmpty() ? values.get(0) : null; |
| | | } |
| | | |
| | | private DITContentRule recreateFromDefinition(DITContentRule dcr) |
| | |
| | | */ |
| | | public Schema duplicate() |
| | | { |
| | | Schema dupSchema = new Schema(); |
| | | Schema dupSchema = new Schema(schemaNG); |
| | | |
| | | dupSchema.attributeTypes.putAll(attributeTypes); |
| | | dupSchema.subordinateTypes.putAll(subordinateTypes); |
| | | dupSchema.objectClasses.putAll(objectClasses); |
| | | dupSchema.syntaxes.putAll(syntaxes); |
| | | dupSchema.matchingRules.putAll(matchingRules); |
| | | dupSchema.matchingRuleUses.putAll(matchingRuleUses); |
| | | dupSchema.ditContentRules.putAll(ditContentRules); |
| | | dupSchema.ditStructureRulesByID.putAll(ditStructureRulesByID); |
| | |
| | | concatFilePath = concatFile.getAbsolutePath(); |
| | | |
| | | File tempFile = new File(concatFilePath + ".tmp"); |
| | | BufferedWriter writer = |
| | | new BufferedWriter(new FileWriter(tempFile, false)); |
| | | writer.write("dn: " + DirectoryServer.getSchemaDN()); |
| | | writer.newLine(); |
| | | writer.write("objectClass: top"); |
| | | writer.newLine(); |
| | | writer.write("objectClass: ldapSubentry"); |
| | | writer.newLine(); |
| | | writer.write("objectClass: subschema"); |
| | | writer.newLine(); |
| | | |
| | | for (String line : attributeTypes) |
| | | try (BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile, false))) |
| | | { |
| | | writer.write(ATTR_ATTRIBUTE_TYPES); |
| | | writer.write(": "); |
| | | writer.write(line); |
| | | writer.write("dn: " + DirectoryServer.getSchemaDN()); |
| | | writer.newLine(); |
| | | } |
| | | |
| | | for (String line : objectClasses) |
| | | { |
| | | writer.write(ATTR_OBJECTCLASSES); |
| | | writer.write(": "); |
| | | writer.write(line); |
| | | writer.write("objectClass: top"); |
| | | writer.newLine(); |
| | | } |
| | | |
| | | for (String line : nameForms) |
| | | { |
| | | writer.write(ATTR_NAME_FORMS); |
| | | writer.write(": "); |
| | | writer.write(line); |
| | | writer.write("objectClass: ldapSubentry"); |
| | | writer.newLine(); |
| | | } |
| | | |
| | | for (String line : ditContentRules) |
| | | { |
| | | writer.write(ATTR_DIT_CONTENT_RULES); |
| | | writer.write(": "); |
| | | writer.write(line); |
| | | writer.write("objectClass: subschema"); |
| | | writer.newLine(); |
| | | |
| | | writeLines(writer, ATTR_ATTRIBUTE_TYPES, attributeTypes); |
| | | writeLines(writer, ATTR_OBJECTCLASSES, objectClasses); |
| | | writeLines(writer, ATTR_NAME_FORMS, nameForms); |
| | | writeLines(writer, ATTR_DIT_CONTENT_RULES, ditContentRules); |
| | | writeLines(writer, ATTR_DIT_STRUCTURE_RULES, ditStructureRules); |
| | | writeLines(writer, ATTR_MATCHING_RULE_USE, matchingRuleUses); |
| | | writeLines(writer, ATTR_LDAP_SYNTAXES, ldapSyntaxes); |
| | | } |
| | | |
| | | for (String line : ditStructureRules) |
| | | { |
| | | writer.write(ATTR_DIT_STRUCTURE_RULES); |
| | | writer.write(": "); |
| | | writer.write(line); |
| | | writer.newLine(); |
| | | } |
| | | |
| | | for (String line : matchingRuleUses) |
| | | { |
| | | writer.write(ATTR_MATCHING_RULE_USE); |
| | | writer.write(": "); |
| | | writer.write(line); |
| | | writer.newLine(); |
| | | } |
| | | |
| | | |
| | | for (String line : ldapSyntaxes) |
| | | { |
| | | writer.write(ATTR_LDAP_SYNTAXES); |
| | | writer.write(": "); |
| | | writer.write(line); |
| | | writer.newLine(); |
| | | } |
| | | |
| | | writer.close(); |
| | | |
| | | if (concatFile.exists()) |
| | | { |
| | | concatFile.delete(); |
| | |
| | | } |
| | | } |
| | | |
| | | private static void writeLines(BufferedWriter writer, String beforeColumn, Set<String> lines) throws IOException |
| | | { |
| | | for (String line : lines) |
| | | { |
| | | writer.write(beforeColumn); |
| | | writer.write(": "); |
| | | writer.write(line); |
| | | writer.newLine(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | mayInvoke=true) |
| | | public synchronized void destroy() |
| | | { |
| | | if (attributeTypes != null) |
| | | if (schemaNG != null) |
| | | { |
| | | attributeTypes.clear(); |
| | | attributeTypes = null; |
| | | schemaNG = null; |
| | | } |
| | | |
| | | if (ditContentRules != null) |
| | |
| | | ditStructureRulesByNameForm = null; |
| | | } |
| | | |
| | | if (matchingRules != null) |
| | | { |
| | | matchingRules.clear(); |
| | | matchingRules = null; |
| | | } |
| | | |
| | | if (matchingRuleUses != null) |
| | | { |
| | | matchingRuleUses.clear(); |
| | |
| | | extraAttributes = null; |
| | | } |
| | | |
| | | if (syntaxes != null) |
| | | { |
| | | syntaxes.clear(); |
| | | syntaxes = null; |
| | | } |
| | | |
| | | if(ldapSyntaxDescriptions != null) |
| | | { |
| | | ldapSyntaxDescriptions.clear(); |
| | | ldapSyntaxDescriptions = null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Update the schema using the provided schema updater. |
| | | * <p> |
| | | * An implicit lock is performed, so it is in general not necessary |
| | | * to call the {code lock()} and {code unlock() methods. |
| | | * However, these method should be used if/when the SchemaBuilder passed |
| | | * as an argument to the updater is not used to return the schema |
| | | * (see for example usage in {@code CoreSchemaProvider} class). This |
| | | * case should remain exceptional. |
| | | * |
| | | * @param updater |
| | | * the updater that returns a new schema |
| | | * @throws DirectoryException if there is any problem updating the schema |
| | | */ |
| | | public void updateSchema(SchemaUpdater updater) throws DirectoryException |
| | | { |
| | | exclusiveLock.lock(); |
| | | try |
| | | { |
| | | switchSchema(updater.update(new SchemaBuilder(schemaNG))); |
| | | } |
| | | finally |
| | | { |
| | | exclusiveLock.unlock(); |
| | | } |
| | | } |
| | | |
| | | /** Interface to update a schema provided a schema builder. */ |
| | | public interface SchemaUpdater |
| | | { |
| | | /** |
| | | * Returns an updated schema. |
| | | * |
| | | * @param builder |
| | | * The builder on the current schema |
| | | * @return the new schema |
| | | */ |
| | | org.forgerock.opendj.ldap.schema.Schema update(SchemaBuilder builder); |
| | | } |
| | | |
| | | /** |
| | | * Updates the schema option if the new value differs from the old value. |
| | | * |
| | | * @param <T> the schema option's type |
| | | * @param option the schema option to update |
| | | * @param newValue the new value for the schema option |
| | | * @throws DirectoryException if there is any problem updating the schema |
| | | */ |
| | | public <T> void updateSchemaOption(final Option<T> option, final T newValue) throws DirectoryException |
| | | { |
| | | final T oldValue = schemaNG.getOption(option); |
| | | if (!oldValue.equals(newValue)) |
| | | { |
| | | updateSchema(new SchemaUpdater() |
| | | { |
| | | @Override |
| | | public org.forgerock.opendj.ldap.schema.Schema update(SchemaBuilder builder) |
| | | { |
| | | return builder.setOption(option, newValue).toSchema(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /** Takes an exclusive lock on the schema. */ |
| | | public void exclusiveLock() |
| | | { |
| | | exclusiveLock.lock(); |
| | | } |
| | | |
| | | /** Releases an exclusive lock on the schema. */ |
| | | public void exclusiveUnlock() |
| | | { |
| | | exclusiveLock.unlock(); |
| | | } |
| | | |
| | | /** |
| | | * Adds the provided schema file to the provided schema element definition. |
| | | * |
| | | * @param definition |
| | | * The schema element definition |
| | | * @param schemaFile |
| | | * The name of the schema file to include in the definition |
| | | * @return The definition string of the element |
| | | * including the X-SCHEMA-FILE extension. |
| | | */ |
| | | public static String addSchemaFileToElementDefinitionIfAbsent(String definition, String schemaFile) |
| | | { |
| | | if (schemaFile != null && !definition.contains(SCHEMA_PROPERTY_FILENAME)) |
| | | { |
| | | int pos = definition.lastIndexOf(')'); |
| | | return definition.substring(0, pos).trim() + " " + SCHEMA_PROPERTY_FILENAME + " '" + schemaFile + "' )"; |
| | | } |
| | | return definition; |
| | | } |
| | | |
| | | private void switchSchema(org.forgerock.opendj.ldap.schema.Schema newSchema) throws DirectoryException |
| | | { |
| | | rejectSchemaWithWarnings(newSchema); |
| | | setSchemaNG(newSchema); |
| | | } |
| | | |
| | | private void rejectSchemaWithWarnings(org.forgerock.opendj.ldap.schema.Schema newSchema) throws DirectoryException |
| | | { |
| | | Collection<LocalizableMessage> warnings = newSchema.getWarnings(); |
| | | if (!warnings.isEmpty()) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_SCHEMA_HAS_WARNINGS.get(warnings.size(), Utils.joinAsString("; ", warnings))); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | * Portions Copyright 2013-2014 Manuel Gaupp |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.Iterator; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn; |
| | | import org.opends.server.admin.std.server.VirtualAttributeCfg; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types.operation; |
| | | |
| | |
| | | import java.util.Map; |
| | | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types.operation; |
| | | |
| | | |
| | | |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types.operation; |
| | | |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types.operation; |
| | | |
| | | |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types.operation; |
| | | |
| | |
| | | import java.util.Map; |
| | | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types.operation; |
| | | |
| | |
| | | import java.util.Map; |
| | | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types.operation; |
| | | |
| | | |
| | | |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.util; |
| | | |
| | |
| | | import java.util.Map; |
| | | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.util; |
| | | |
| | |
| | | import org.opends.server.types.AcceptRejectWarn; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.util; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.tools.makeldif.TemplateEntry; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.forgerock.util.Reject.*; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.util; |
| | | |
| | |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.workflowelement.localbackend; |
| | | |
| | |
| | | import org.opends.server.schema.UserPasswordSyntax; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.CanceledOperationException; |
| | | import org.opends.server.types.Control; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.workflowelement.localbackend; |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.admin.std.meta.PasswordPolicyCfgDefn; |
| | | import org.opends.server.api.AuthenticationPolicyState; |
| | | import org.opends.server.api.Backend; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.workflowelement.localbackend; |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.api.AccessControlHandler; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.ClientConnection; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.workflowelement.localbackend; |
| | | |
| | |
| | | import org.opends.server.core.ModifyDNOperationWrapper; |
| | | import org.opends.server.core.PersistentSearch; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.CanceledOperationException; |
| | | import org.opends.server.types.Control; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2011 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.workflowelement.localbackend; |
| | | |
| | |
| | | import org.opends.server.types.AccountStatusNotificationType; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.CanceledOperationException; |
| | | import org.opends.server.types.Control; |
| | |
| | | # CDDL HEADER END |
| | | # |
| | | # Copyright 2006-2010 Sun Microsystems, Inc. |
| | | # Portions Copyright 2011-2015 ForgeRock AS |
| | | # Portions Copyright 2011-2016 ForgeRock AS |
| | | # Portions Copyright 2012-2014 Manuel Gaupp |
| | | |
| | | |
| | |
| | | characters at the end of the assertion |
| | | ERR_CERTIFICATE_MATCH_GSER_INVALID_339=An error occurred while parsing the \ |
| | | GSER String: "%s" |
| | | ERR_ATTR_TYPE_CANNOT_REGISTER_340=Attribute type could not be registered from definition: %s |
| | | ERR_SCHEMA_HAS_WARNINGS_341=There should be no warnings on the schema, \ |
| | | but instead got %d warnings: %s |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | * Copyright 2014-2016 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; |
| | | import org.opends.server.types.DirectoryEnvironmentConfig; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | |
| | | return this; |
| | | } |
| | | |
| | | public ServerContextBuilder schemaNG(Schema schema) |
| | | public ServerContextBuilder schema(org.opends.server.types.Schema schema) |
| | | { |
| | | when(serverContext.getSchemaNG()).thenReturn(schema); |
| | | when(serverContext.getSchema()).thenReturn(schema); |
| | | when(serverContext.getSchemaNG()).thenReturn(schema.getSchemaNG()); |
| | | return this; |
| | | } |
| | | |
| | |
| | | return this; |
| | | } |
| | | |
| | | public ServerContextBuilder schemaUpdater(SchemaUpdater updater) |
| | | { |
| | | when(serverContext.getSchemaUpdater()).thenReturn(updater); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * Ensure that configuration is fully bootstrapped. Only use when necessary as |
| | | * it will impact test performance. |
| | |
| | | public ServerContextBuilder withConfigurationBootstrapped() |
| | | throws InitializationException |
| | | { |
| | | if (serverContext.getSchemaUpdater() == null) { |
| | | throw new RuntimeException("You must set a non-null schema updater to bootstrap configuration."); |
| | | } |
| | | final ServerManagementContext serverManagementContext = |
| | | ConfigurationBootstrapper.bootstrap(serverContext); |
| | | when(serverContext.getServerManagementContext()).thenReturn( |
| | | serverManagementContext); |
| | | final ServerManagementContext serverManagementContext = ConfigurationBootstrapper.bootstrap(serverContext); |
| | | when(serverContext.getServerManagementContext()).thenReturn(serverManagementContext); |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | * Portions Copyright 2013 Manuel Gaupp |
| | | */ |
| | | package org.opends.server; |
| | |
| | | public static void startFakeServer() throws Exception |
| | | { |
| | | schemaBeforeStartingFakeServer = DirectoryServer.getSchema(); |
| | | DirectoryServer.setSchema(initializeInMemory(new Schema())); |
| | | } |
| | | |
| | | private static Schema initializeInMemory(final Schema schema) throws Exception |
| | | { |
| | | for (AttributeType attributeType : AttributeTypeConstants.ALL) |
| | | { |
| | | schema.registerAttributeType(attributeType, true); |
| | | } |
| | | return schema; |
| | | DirectoryServer.setSchema(new Schema(org.forgerock.opendj.ldap.schema.Schema.getDefaultSchema())); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.admin.std.meta.RootCfgDefn; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import java.util.SortedSet; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A server-side interface for querying Test Child settings. |
| | | * <p> |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import java.util.Collection; |
| | | import java.util.SortedSet; |
| | | import org.opends.server.admin.ConfigurationClient; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.TestChildCfg; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A client-side interface for reading and modifying Test Child |
| | | * settings. |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | |
| | | import org.opends.server.admin.std.server.ConnectionHandlerCfg; |
| | | import org.opends.server.admin.server.ServerManagedObject; |
| | | import org.opends.server.admin.TestChildCfg; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import java.util.SortedSet; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A server-side interface for querying Test Parent settings. |
| | | * <p> |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import java.util.Collection; |
| | | import java.util.SortedSet; |
| | | import org.opends.server.admin.client.AuthorizationException; |
| | |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A client-side interface for reading and modifying Test Parent |
| | | * settings. |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | |
| | | import org.opends.server.admin.server.ServerManagedObject; |
| | | import org.opends.server.admin.UndefinedDefaultBehaviorProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | import org.testng.Assert; |
| | |
| | | |
| | | |
| | | Schema schema = DirectoryServer.getSchema(); |
| | | AttributeType attrType = schema.getAttributeType(ldapAttrName.toLowerCase()); |
| | | |
| | | // LDAP attribute exists |
| | | if (attrType == null) { |
| | | if (!schema.hasAttributeType(ldapAttrName.toLowerCase())) |
| | | { |
| | | errors.append(propName + " property on config object " + objName + " is declared" + |
| | | " to use ldap attribute " + ldapAttrName + ", but this attribute is not in the schema ").append(EOL + EOL); |
| | | } else { |
| | | AttributeType attrType = schema.getAttributeType(ldapAttrName.toLowerCase()); |
| | | |
| | | // LDAP attribute is multivalued if the property is multivalued |
| | | if (propDef.hasOption(PropertyOption.MULTI_VALUED) && attrType.isSingleValue()) { |
old mode 100755
new mode 100644
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.admin.client.spi; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | import java.util.Map; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.backends; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.DITContentRule; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ExistingFileBehavior; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.MatchingRuleUse; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.util.CollectionUtils; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | int ruleID = 999001; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, false); |
| | | |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, true); |
| | | } |
| | | |
| | | private void assertSchemaHasDITStructureRule(int ruleID, boolean expected) |
| | | { |
| | | assertEquals(DirectoryServer.getSchema().getDITStructureRulesByID().containsKey(ruleID), expected); |
| | | } |
| | | |
| | | /** |
| | |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | int ruleID = 999002; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, false); |
| | | |
| | | assertEquals(runModify(argsPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, true); |
| | | } |
| | | |
| | | /** |
| | |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | int ruleID = 999010; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, false); |
| | | |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(), |
| | | "98-schema-test-dsr.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, true); |
| | | |
| | | assertTrue(schemaFile.exists()); |
| | | } |
| | |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | int ruleID = 999003; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, false); |
| | | |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, true); |
| | | } |
| | | |
| | | /** |
| | |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | int ruleID = 999004; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, false); |
| | | |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, false); |
| | | } |
| | | |
| | | /** |
| | |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | int ruleID = 999005; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, false); |
| | | |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, false); |
| | | } |
| | | |
| | | /** |
| | |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | int ruleID = 999006; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, false); |
| | | |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, false); |
| | | } |
| | | |
| | | /** |
| | |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | int ruleID = 999007; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, false); |
| | | |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, true); |
| | | |
| | | ldif = toLdif( |
| | | "dn: cn=schema", |
| | |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | assertSchemaHasDITStructureRule(ruleID, false); |
| | | } |
| | | |
| | | private MatchingRule getMatchingRule(String name, String oid, boolean isObsolete) |
| | |
| | | "NAME 'testAddMRUSuccessful' APPLIES cn " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | assertSchemaDoesNotHaveMatchingRuleUse(matchingRule); |
| | | |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | |
| | |
| | | "X-SCHEMA-FILE '98-schema-test-mru.ldif' " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | assertSchemaDoesNotHaveMatchingRuleUse(matchingRule); |
| | | |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(), |
| | | "98-schema-test-mru.ldif"); |
| | |
| | | "NAME 'testReplaceMRUSuccessful' APPLIES ( cn $ sn ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | assertSchemaDoesNotHaveMatchingRuleUse(matchingRule); |
| | | |
| | | assertEquals(runModify(argsPermissive(), ldif, System.err), 0); |
| | | |
| | |
| | | "NAME 'testRemoveAndAddMRU' APPLIES ( cn $ sn ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | assertSchemaDoesNotHaveMatchingRuleUse(matchingRule); |
| | | |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | |
| | |
| | | "NAME 'testAddMRUMRConflict2' APPLIES sn " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | assertSchemaDoesNotHaveMatchingRuleUse(matchingRule); |
| | | |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | |
| | |
| | | "APPLIES xxxundefinedxxx " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | assertSchemaDoesNotHaveMatchingRuleUse(matchingRule); |
| | | |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | |
| | | "APPLIES ( cn $ xxxundefinedxxx ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | assertSchemaDoesNotHaveMatchingRuleUse(matchingRule); |
| | | |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | private void assertSchemaDoesNotHaveMatchingRuleUse(MatchingRule matchingRule) |
| | | { |
| | | assertFalse(DirectoryServer.getSchema().getMatchingRuleUses().containsKey(matchingRule)); |
| | | } |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * matching rule whose matching rule is OBSOLETE. |
| | |
| | | "NAME 'testAddMatchingRuleUseObsoleteMatchingRule' " + |
| | | "APPLIES cn X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | assertSchemaDoesNotHaveMatchingRuleUse(matchingRule); |
| | | |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | |
| | | "APPLIES testAddMRUObsoleteAT " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | assertSchemaDoesNotHaveMatchingRuleUse(matchingRule); |
| | | |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | |
| | | "NAME 'testRemoveMRUSuccessful' APPLIES cn " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | assertSchemaDoesNotHaveMatchingRuleUse(matchingRule); |
| | | |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | |
| | |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String attrName = "testmatchingruleusematchingruleat1"; |
| | | assertNull(DirectoryServer.getSchema().getAttributeType(attrName)); |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 20); |
| | | } |
| | |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | | "objectClasses: ( testissue1318oc1-oid NAME 'testIssue1381OC1' )", |
| | | "objectClasses: ( testissue1318oc1-oid NAME 'testIssue1381OC1')", |
| | | "", |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | |
| | | "objectClasses: ( testissue1318oc1-oid NAME 'testIssue1381OC1' )", |
| | | "-", |
| | | "add: attributeTypes", |
| | | "attributeTypes: ( testissue1318at-oid NAME 'testIssue1381AT' )", |
| | | "attributeTypes: ( testissue1318at-oid NAME 'testIssue1381AT' SUP name)", |
| | | "-", |
| | | "add: objectClasses", |
| | | "objectClasses: ( testissue1318oc2-oid NAME 'testIssue1381OC2' " + |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2015 ForgeRock AS |
| | | * Copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | 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.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.BackupDirectory; |
| | | import org.opends.server.types.DN; |
| | |
| | | when(backendCfg.listBackendIndexes()).thenReturn(new String[0]); |
| | | when(backendCfg.listBackendVLVIndexes()).thenReturn(new String[0]); |
| | | |
| | | final Storage storage = backend.configureStorage(backendCfg, DirectoryServer.getInstance().getServerContext()); |
| | | final RootContainer readOnlyContainer = new RootContainer(backend.getBackendID(), storage, backendCfg); |
| | | ServerContext serverContext = DirectoryServer.getInstance().getServerContext(); |
| | | final Storage storage = backend.configureStorage(backendCfg, serverContext); |
| | | final RootContainer readOnlyContainer = |
| | | new RootContainer(backend.getBackendID(), serverContext, storage, backendCfg); |
| | | |
| | | // Put backend offline so that export LDIF open read-only container |
| | | backend.finalizeBackend(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.opends.server.util.StaticUtils; |
| | |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 Manuel Gaupp |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.controls; |
| | | |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.api.MatchingRuleFactory; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.schema.BooleanEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.DistinguishedNameEqualityMatchingRuleFactory; |
| | | import org.opends.server.schema.IntegerEqualityMatchingRuleFactory; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Test MatchedValuesControl. |
| | | */ |
| | | public class MatchedValuesControlTest |
| | | extends ControlsTestCase |
| | | /** Test MatchedValuesControl. */ |
| | | @SuppressWarnings("javadoc") |
| | | public class MatchedValuesControlTest extends ControlsTestCase |
| | | { |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | @DataProvider(name = "extensibleMatchFilterData") |
| | | public Object[][] createExtensibleMatchFilterData() throws Exception |
| | | @DataProvider |
| | | public Object[][] extensibleMatchFilterData() throws Exception |
| | | { |
| | | MatchingRuleFactory<?> factory = new BooleanEqualityMatchingRuleFactory(); |
| | | factory.initializeMatchingRule(null); |
| | | MatchingRule booleanEquality = factory.getMatchingRules().iterator().next(); |
| | | factory = new IntegerEqualityMatchingRuleFactory(); |
| | | factory.initializeMatchingRule(null); |
| | | MatchingRule integerEquality = factory.getMatchingRules().iterator().next(); |
| | | factory = new DistinguishedNameEqualityMatchingRuleFactory(); |
| | | factory.initializeMatchingRule(null); |
| | | MatchingRule distinguishedEquality = factory.getMatchingRules().iterator().next(); |
| | | |
| | | return new Object[][] |
| | | { |
| | | { "description", booleanEquality, "description" }, |
| | | { "objectclass", integerEquality ,"top" }, |
| | | { "fakeobjecttype", distinguishedEquality, "fakevalue" }, }; |
| | | { "description", CoreSchema.getBooleanMatchingRule(), "description" }, |
| | | { "objectclass", CoreSchema.getIntegerMatchingRule(), "top" }, |
| | | { "fakeobjecttype", CoreSchema.getDistinguishedNameMatchingRule(), "fakevalue" }, |
| | | }; |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.controls; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.controls; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | import org.opends.server.tools.LDAPReader; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.CancelRequest; |
| | | import org.opends.server.types.CancelResult; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.schema.UserPasswordSyntax; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | |
| | | import java.io.File; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.opends.server.ServerContextBuilder.MockSchemaUpdater; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.schema.SchemaUpdater; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.testng.annotations.Test; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | |
| | | @Test |
| | | public void testSchemaInitialization() throws Exception |
| | | { |
| | | MockSchemaUpdater schemaUpdater = new MockSchemaUpdater(Schema.getEmptySchema()); |
| | | initializeSchemaHandler(schemaUpdater); |
| | | |
| | | assertThat(schemaUpdater.getSchemaBuilder()).isNotNull(); |
| | | |
| | | Schema schema = schemaUpdater.getSchemaBuilder().toSchema(); |
| | | org.opends.server.types.Schema schema = new org.opends.server.types.Schema(Schema.getCoreSchema()); |
| | | initializeSchemaHandler(schema); |
| | | |
| | | assertThat(schema.getMatchingRules()).isNotEmpty(); // some matching rules defined |
| | | schema.getSyntax(DIRECTORY_STRING_SYNTAX_OID); |
| | |
| | | schema.getObjectClass("changeLogEntry"); // from file 03-changelog.ldif |
| | | } |
| | | |
| | | |
| | | private void initializeSchemaHandler(SchemaUpdater updater) throws InitializationException, ConfigException |
| | | private void initializeSchemaHandler(org.opends.server.types.Schema schema) throws Exception |
| | | { |
| | | final ServerContext serverContext = aServerContext(). |
| | | schemaDirectory(new File(TestCaseUtils.getBuildRoot(), "resource/schema")). |
| | | configFile(TestCaseUtils.getTestResource("config-small.ldif")). |
| | | schemaUpdater(updater). |
| | | withConfigurationBootstrapped(). |
| | | build(); |
| | | final ServerContext serverContext = aServerContext() |
| | | .schemaDirectory(new File(TestCaseUtils.getBuildRoot(), "resource/schema")) |
| | | .configFile(TestCaseUtils.getTestResource("config-small.ldif")) |
| | | .withConfigurationBootstrapped() |
| | | .schema(schema) |
| | | .build(); |
| | | |
| | | SchemaHandler schemaHandler = new SchemaHandler(); |
| | | schemaHandler.initialize(serverContext); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.core; |
| | |
| | | import org.opends.server.tools.LDAPDelete; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.AuthenticationPolicy; |
| | | import org.opends.server.api.PasswordValidator; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.util.StaticUtils; |
| | |
| | | assertEquals(policy.getLockoutDuration(), 300); |
| | | assertEquals(policy.getLockoutFailureCount(), 3); |
| | | assertEquals(policy.isForceChangeOnReset(), true); |
| | | assertTrue(policy.getPasswordAttribute( |
| | | ).getPrimaryName().equalsIgnoreCase( |
| | | "authPassword")); |
| | | assertTrue(policy.getPasswordAttribute().getNameOrOID().equalsIgnoreCase("authPassword")); |
| | | assertEquals(policy.getMinPasswordAge(), 600); |
| | | assertEquals(policy.getMaxPasswordAge(), 2147483647); |
| | | assertEquals(policy.getPasswordHistoryCount(), 5); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | * Portions copyright 2013 Manuel Gaupp |
| | | */ |
| | | package org.opends.server.core; |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.controls.ProxiedAuthV1Control; |
| | | import org.opends.server.controls.ProxiedAuthV2Control; |
| | |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.CancelRequest; |
| | | import org.opends.server.types.CancelResult; |
| | | import org.opends.server.types.Control; |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013-2014 ForgeRock AS |
| | | * Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | |
| | |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Utility class providing common code for extensions tests. |
| | | */ |
| | | /** Utility class providing common code for extensions tests. */ |
| | | @SuppressWarnings("javadoc") |
| | | class ExtensionTestUtils |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.schema.UserPasswordSyntax; |
| | | import org.opends.server.tools.LDAPReader; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.util.TimeThread; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.tools.LDAPPasswordModify; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | * Portions Copyright 2013 Manuel Gaupp |
| | | */ |
| | | package org.opends.server.extensions; |
| | |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.admin.std.server.PluginCfg; |
| | | import org.opends.server.api.plugin.DirectoryServerPlugin; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | |
| | | import org.opends.server.admin.std.server.EntryUUIDPluginCfg; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryConfig; |
| | |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 profiq s.r.o. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.ReferentialIntegrityPluginCfgDefn; |
| | |
| | | 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.Attributes; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.*; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RDN; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RDN; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RDN; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RDN; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RDN; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication; |
| | | |
| | |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.opends.server.tasks.LdifFileWriter; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication; |
| | | |
| | |
| | | { |
| | | // Modify the schema |
| | | Attribute attr = Attributes.create("attributetypes", |
| | | "( 2.5.44.77.33 NAME 'dummy' )"); |
| | | "( 2.5.44.77.33 NAME 'dummy' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )"); |
| | | Modification mod = new Modification(ADD, attr); |
| | | processModify(baseDN, mod); |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication; |
| | | |
| | |
| | | import org.opends.server.replication.common.CSNGenerator; |
| | | import org.opends.server.replication.protocol.*; |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.TestTimer; |
| | | import org.opends.server.util.TimeThread; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.replication.common.CSNGenerator; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.opends.server.replication.service.FakeReplicationDomain; |
| | | import org.opends.server.replication.service.ReplicationDomain; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | import org.opends.server.replication.server.ReplServerFakeConfiguration; |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.TimeThread; |
| | | import org.testng.annotations.Test; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | |
| | | import org.assertj.core.api.Assertions; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | |
| | | private static void publishModify(ReplicationBroker broker, CSN changeNum, |
| | | DN dn, String entryuuid, AttributeType attrType, String newValue) |
| | | { |
| | | Attribute attr = Attributes.create(attrType.getNameOrOID(), newValue); |
| | | Attribute attr = Attributes.create(attrType.getNormalizedNameOrOID(), newValue); |
| | | List<Modification> mods = newArrayList(new Modification(ModificationType.ADD, attr)); |
| | | broker.publish(new ModifyMsg(changeNum, dn, mods, entryuuid)); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | import org.opends.server.replication.protocol.LDAPUpdateMsg; |
| | | import org.opends.server.replication.protocol.ModifyContext; |
| | | import org.opends.server.replication.protocol.ReplicationMsg; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.workflowelement.localbackend.LocalBackendModifyOperation; |
| | | import org.testng.annotations.Test; |
| | |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * Copyright 2015 ForgeRock AS |
| | | * Copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.replication.protocol.ModifyContext; |
| | | import org.opends.server.replication.protocol.OperationContext; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.*; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.TimeThread; |
| | | import org.testng.annotations.AfterClass; |
| | |
| | | assertEquals(msg.getDetails().toString(), errorDetails); |
| | | } |
| | | |
| | | @DataProvider(name = "initializeTargetMsgV3") |
| | | @DataProvider |
| | | public Object[][] createInitializeTargetMsgV3() |
| | | { |
| | | return new Object[][] { |
| | |
| | | assertEquals(msg.getEntryCount(), entryCount); |
| | | } |
| | | |
| | | @DataProvider(name = "initializeRequestMsgV3") |
| | | @DataProvider |
| | | public Object[][] createInitializeRequestMsgV3() |
| | | { |
| | | return new Object[][] { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.*; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.TimeThread; |
| | | import org.opends.server.workflowelement.localbackend.LocalBackendAddOperation; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public abstract class AttributeSyntaxTest extends SchemaTestCase |
| | | { |
| | |
| | | * Get an instance of the attribute syntax that must be tested. |
| | | * |
| | | * @return An instance of the attribute syntax that must be tested. |
| | | * @throws Exception |
| | | * if a problem occurs |
| | | */ |
| | | protected abstract AttributeSyntax<?> getRule(); |
| | | protected abstract AttributeSyntax<?> getRule() throws Exception; |
| | | |
| | | /** |
| | | * Test the normalization and the approximate comparison. |
| | | */ |
| | | /** Test the normalization and the approximate comparison. */ |
| | | @Test(dataProvider= "acceptableValues") |
| | | public void testAcceptableValues(String value, Boolean result) throws Exception |
| | | { |
| | |
| | | |
| | | LocalizableMessageBuilder reason = new LocalizableMessageBuilder(); |
| | | // test the valueIsAcceptable method |
| | | Boolean liveResult = |
| | | boolean liveResult = |
| | | syntax.valueIsAcceptable(ByteString.valueOfUtf8(value), reason); |
| | | |
| | | assertSame(liveResult, result, syntax + ".valueIsAcceptable gave bad result for " + value + " reason : " + reason); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | 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.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; |
| | |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Test the AttributeTypeSyntax. |
| | | */ |
| | | /** Test the AttributeTypeSyntax. */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public class AttributeTypeSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected AttributeSyntax getRule() |
| | | { |
| | | return new AttributeTypeSyntax(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name="acceptableValues") |
| | | public Object[][] createAcceptableValues() |
| | |
| | | @Test |
| | | public void testXAPPROXExtension() throws Exception |
| | | { |
| | | MatchingRule mrule = Schema.getCoreSchema().getMatchingRule("ds-mr-double-metaphone-approx"); |
| | | |
| | | // Get a reference to the attribute type syntax implementation in the |
| | | // server. |
| | | Syntax attrTypeSyntax = DirectoryServer.getSchema().getSyntax("1.3.6.1.4.1.1466.115.121.1.3", false); |
| | | org.opends.server.types.Schema schema = DirectoryServer.getSchema(); |
| | | Syntax attrTypeSyntax = schema.getSyntax("1.3.6.1.4.1.1466.115.121.1.3"); |
| | | assertNotNull(attrTypeSyntax); |
| | | |
| | | |
| | | // Create an attribute type definition and verify that it is acceptable. |
| | | ByteString definition = ByteString.valueOfUtf8( |
| | | "( testxapproxtype-oid NAME 'testXApproxType' " + |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " + |
| | | "X-APPROX 'ds-mr-double-metaphone-approx' )"); |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertTrue(attrTypeSyntax.valueIsAcceptable(definition, invalidReason), |
| | | invalidReason.toString()); |
| | | |
| | | assertTrue(attrTypeSyntax.valueIsAcceptable(definition, invalidReason), invalidReason.toString()); |
| | | |
| | | // Verify that we can decode the attribute type and that it has the |
| | | // correct approximate matching rule. |
| | | AttributeType attrType = |
| | | AttributeTypeSyntax.decodeAttributeType(definition, |
| | | DirectoryServer.getSchema(), |
| | | false); |
| | | assertNotNull(attrType); |
| | | Schema newSchema = new SchemaBuilder(schema.getSchemaNG()) |
| | | .addAttributeType(definition.toString(), false) |
| | | .toSchema(); |
| | | |
| | | AttributeType attrType = newSchema.getAttributeType("testXApproxType"); |
| | | assertNotNull(attrType.getApproximateMatchingRule()); |
| | | assertEquals(attrType.getApproximateMatchingRule(), mrule); |
| | | assertEquals(attrType.getApproximateMatchingRule(), schema.getMatchingRule("ds-mr-double-metaphone-approx")); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests a situation when two radically different equality and substring |
| | | * matching rules (such as Case Ignore and Case Exact) are used to define an |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | 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.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | public abstract class BinaryAttributeSyntaxTest extends SchemaTestCase |
| | | { |
| | |
| | | * Get an instance of the attribute syntax that must be tested. |
| | | * |
| | | * @return An instance of the attribute syntax that must be tested. |
| | | * @throws Exception if a problem occurs |
| | | */ |
| | | protected abstract AttributeSyntax getRule(); |
| | | protected abstract AttributeSyntax<?> getRule() throws Exception; |
| | | |
| | | /** |
| | | * Test the normalization and the approximate comparison. |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.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; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the CertificateSyntax. |
| | | */ |
| | | /** Test the CertificateSyntax. */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | @Test |
| | | public class CertificateSyntaxTest extends BinaryAttributeSyntaxTest |
| | | { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected AttributeSyntax<?> getRule() |
| | | protected AttributeSyntax<?> getRule() throws Exception |
| | | { |
| | | CertificateSyntax syntax = new CertificateSyntax(); |
| | | CertificateAttributeSyntaxCfg cfg = new CertificateAttributeSyntaxCfg() |
| | |
| | | } |
| | | }; |
| | | |
| | | try |
| | | { |
| | | Schema schema = Schema.getCoreSchema(); |
| | | ServerContext serverContext = ServerContextBuilder.aServerContext() |
| | | .schemaNG(schema) |
| | | .schemaUpdater(new ServerContextBuilder.MockSchemaUpdater(schema)).build(); |
| | | syntax.initializeSyntax(cfg, serverContext); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | | // Should never happen. |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | ServerContext serverContext = ServerContextBuilder.aServerContext() |
| | | .schema(new org.opends.server.types.Schema(Schema.getCoreSchema())) |
| | | .build(); |
| | | syntax.initializeSyntax(cfg, serverContext); |
| | | return syntax; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name="acceptableValues") |
| | | public Object[][] createAcceptableValues() |
| | |
| | | return new Object[][] {}; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.server.config.server.CoreSchemaCfg; |
| | | import org.opends.server.ConfigurationMock; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.CoreTestCase; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.schema.SchemaOptions.*; |
| | | import static org.mockito.Mockito.*; |
| | | import static org.opends.server.ServerContextBuilder.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.io.File; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | public class CoreSchemaProviderTestCase extends CoreTestCase |
| | | { |
| | |
| | | CoreSchemaCfg coreSchemaCfg = ConfigurationMock.mockCfg(CoreSchemaCfg.class); |
| | | |
| | | CoreSchemaProvider provider = new CoreSchemaProvider(); |
| | | provider.initialize(coreSchemaCfg, new SchemaBuilder(), mock(SchemaUpdater.class)); |
| | | |
| | | org.opends.server.types.Schema schema = new org.opends.server.types.Schema( Schema.getCoreSchema()); |
| | | provider.initialize(getServerContext(schema), coreSchemaCfg, new SchemaBuilder()); |
| | | |
| | | verify(coreSchemaCfg).addCoreSchemaChangeListener(provider); |
| | | } |
| | | |
| | | private ServerContext getServerContext(org.opends.server.types.Schema schema) throws Exception |
| | | { |
| | | return aServerContext() |
| | | .schemaDirectory(new File(TestCaseUtils.getBuildRoot(), "resource/schema")) |
| | | .configFile(TestCaseUtils.getTestResource("config-small.ldif")) |
| | | .withConfigurationBootstrapped() |
| | | .schema(schema) |
| | | .build(); |
| | | } |
| | | |
| | | @Test |
| | | public void testEnableZeroLengthDirectoryStrings() throws Exception |
| | | { |
| | |
| | | SchemaBuilder schemaBuilder = new SchemaBuilder(); |
| | | |
| | | CoreSchemaProvider provider = new CoreSchemaProvider(); |
| | | provider.initialize(coreSchemaCfg, schemaBuilder, mock(SchemaUpdater.class)); |
| | | org.opends.server.types.Schema schema = new org.opends.server.types.Schema( Schema.getCoreSchema()); |
| | | provider.initialize(getServerContext(schema), coreSchemaCfg, schemaBuilder); |
| | | |
| | | assertThat(schemaBuilder.toSchema().getOption(ALLOW_ZERO_LENGTH_DIRECTORY_STRINGS)).isTrue(); |
| | | } |
| | |
| | | SchemaBuilder schemaBuilder = new SchemaBuilder(Schema.getCoreSchema()); |
| | | |
| | | CoreSchemaProvider provider = new CoreSchemaProvider(); |
| | | provider.initialize(coreSchemaCfg, schemaBuilder, mock(SchemaUpdater.class)); |
| | | org.opends.server.types.Schema schema = new org.opends.server.types.Schema( Schema.getCoreSchema()); |
| | | provider.initialize(getServerContext(schema), coreSchemaCfg, schemaBuilder); |
| | | |
| | | assertThat(schemaBuilder.toSchema().hasSyntax(DIRECTORY_STRING_SYNTAX_OID)).isFalse(); |
| | | } |
| | |
| | | SchemaBuilder schemaBuilder = new SchemaBuilder(Schema.getCoreSchema()); |
| | | |
| | | CoreSchemaProvider provider = new CoreSchemaProvider(); |
| | | provider.initialize(coreSchemaCfg, schemaBuilder, mock(SchemaUpdater.class)); |
| | | org.opends.server.types.Schema schema = new org.opends.server.types.Schema( Schema.getCoreSchema()); |
| | | provider.initialize(getServerContext(schema), coreSchemaCfg, schemaBuilder); |
| | | |
| | | assertThat(schemaBuilder.toSchema().hasMatchingRule(DIRECTORY_STRING_SYNTAX_OID)).isFalse(); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | * Portions Copyright 2012 Manuel Gaupp |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.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.api.AttributeSyntax; |
| | | 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. |
| | | */ |
| | | /** Test the CountryStringSyntax. */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | @Test |
| | | public class CountryStringSyntaxTest extends AttributeSyntaxTest |
| | | { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected AttributeSyntax getRule() |
| | | protected AttributeSyntax<?> getRule() throws Exception |
| | | { |
| | | CountryStringSyntax syntax = new CountryStringSyntax(); |
| | | CountryStringAttributeSyntaxCfg cfg = new CountryStringAttributeSyntaxCfg() |
| | |
| | | } |
| | | }; |
| | | |
| | | try |
| | | { |
| | | Schema schema = Schema.getCoreSchema(); |
| | | ServerContext serverContext = ServerContextBuilder.aServerContext() |
| | | .schemaNG(schema) |
| | | .schemaUpdater(new ServerContextBuilder.MockSchemaUpdater(schema)).build(); |
| | | syntax.initializeSyntax(cfg, serverContext); |
| | | } |
| | | catch (ConfigException e) |
| | | { |
| | | // Should never happen. |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | ServerContext serverContext = ServerContextBuilder.aServerContext() |
| | | .schema(new org.opends.server.types.Schema(Schema.getCoreSchema())) |
| | | .build(); |
| | | syntax.initializeSyntax(cfg, serverContext); |
| | | return syntax; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name="acceptableValues") |
| | | public Object[][] createAcceptableValues() |
| | |
| | | {"\u00D6\u00C4", false}, |
| | | }; |
| | | } |
| | | |
| | | } |
| | |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * Copyright 2015 ForgeRock AS |
| | | * Copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.Assertion; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.spi.Indexer; |
| | | import org.forgerock.opendj.ldap.spi.IndexingOptions; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | * |
| | | */ |
| | | package org.opends.server.schema; |
| | |
| | | import java.util.TreeSet; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.NameForm; |
| | |
| | | TreeSet<String> invalidOIDs = new TreeSet<>(); |
| | | |
| | | Schema schema = DirectoryServer.getSchema(); |
| | | for (Syntax as : schema.getSyntaxes().values()) |
| | | for (Syntax as : schema.getSyntaxes()) |
| | | { |
| | | if (! isNumericOID(as.getOID())) |
| | | { |
| | |
| | | TreeSet<String> invalidOIDs = new TreeSet<>(); |
| | | |
| | | Schema schema = DirectoryServer.getSchema(); |
| | | for (MatchingRule mr : schema.getMatchingRules().values()) |
| | | for (MatchingRule mr : schema.getMatchingRules()) |
| | | { |
| | | if (! isNumericOID(mr.getOID())) |
| | | { |
| | |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | AttributeType at = AttributeTypeSyntax.decodeAttributeType( |
| | | v, DirectoryServer.getSchema(),true); |
| | | AttributeType at = DirectoryServer.getSchema().parseAttributeType(v.toString()); |
| | | if (! isNumericOID(at.getOID())) |
| | | { |
| | | invalidOIDs.add(at.getNameOrOID()); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2010-2015 ForgeRock AS. |
| | | * Portions Copyright 2010-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.FilterType; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tasks; |
| | | |
| | |
| | | "objectClass: ldapSubentry", |
| | | "objectClass: subschema", |
| | | "attributeTypes: ( testaddvalidschemafileat-oid " + |
| | | "NAME 'testAddValidSchemaFileAT' )", |
| | | "NAME 'testAddValidSchemaFileAT' SUP name)", |
| | | "objectClasses: ( testaddvalidschemafileoc-oid " + |
| | | "NAME 'testAddValidSchemaFileOC' STRUCTURAL " + |
| | | "MUST testAddValidSchemaFileAT )", |
| | |
| | | "objectClass: ldapSubentry", |
| | | "objectClass: subschema", |
| | | "attributeTypes: ( testaddmultiplevalidschemafiles1at-oid " + |
| | | "NAME 'testAddMultipleValidSchemaFiles1AT' )", |
| | | "NAME 'testAddMultipleValidSchemaFiles1AT' SUP name)", |
| | | "objectClasses: ( testaddmultiplevalidschemafiles1oc-oid " + |
| | | "NAME 'testAddMultipleValidSchemaFiles1OC' STRUCTURAL " + |
| | | "MUST testAddMultipleValidSchemaFiles1AT )", |
| | |
| | | "objectClass: ldapSubentry", |
| | | "objectClass: subschema", |
| | | "attributeTypes: ( testaddmultiplevalidschemafiles2at-oid " + |
| | | "NAME 'testAddMultipleValidSchemaFiles2AT' )", |
| | | "NAME 'testAddMultipleValidSchemaFiles2AT' SUP name)", |
| | | "objectClasses: ( testaddmultiplevalidschemafiles2oc-oid " + |
| | | "NAME 'testAddMultipleValidSchemaFiles2OC' STRUCTURAL " + |
| | | "MUST testAddMultipleValidSchemaFiles2AT )", |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.*; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.HashSet; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.NoSuchElementException; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.testng.Assert; |
| | |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * Copyright 2015 ForgeRock AS |
| | | * Copyright 2015-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.testng.Assert; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import static org.opends.server.types.AcceptRejectWarn.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.GlobalCfgDefn.DisabledPrivilege; |
| | | import org.opends.server.admin.std.meta.RootDNCfgDefn; |
| | |
| | | "objectClass: top", |
| | | "objectClass: ldapSubentry", |
| | | "objectClass: subschema", |
| | | "attributeTypes: ( " + identifier.toLowerCase() + "-oid " + |
| | | "NAME '" + identifier + "' )" |
| | | "attributeTypes: ( " + identifier.toLowerCase() + "-oid" |
| | | + " NAME '" + identifier + "'" |
| | | + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )" |
| | | }; |
| | | |
| | | File validFile = new File(schemaDirectory, "05-" + identifier + ".ldif"); |
| | | BufferedWriter writer = new BufferedWriter(new FileWriter(validFile)); |
| | | for (String line : fileLines) |
| | | try (BufferedWriter writer = new BufferedWriter(new FileWriter(validFile))) |
| | | { |
| | | writer.write(line); |
| | | writer.newLine(); |
| | | for (String line : fileLines) |
| | | { |
| | | writer.write(line); |
| | | writer.newLine(); |
| | | } |
| | | } |
| | | writer.close(); |
| | | |
| | | assertPrivilege(conn, hasPrivilege, |
| | | "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | |
| | | |
| | | // We won't use an internal connection here because these are not notified |
| | | // of dynamic changes to authentication info. |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | try |
| | | try (Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort())) |
| | | { |
| | | TestCaseUtils.configureSocket(s); |
| | | LDAPReader r = new LDAPReader(s); |
| | |
| | | DeleteOperation deleteOperation = rootConnection.processDelete("cn=Test User,o=test"); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | finally |
| | | { |
| | | s.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 Manuel Gaupp |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.text.ParseException; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | * Portions Copyright 2012-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | |
| | | DN dn1 = DN.valueOf(first); |
| | | DN dn2 = DN.valueOf(second); |
| | | |
| | | String msg = "DN equality for <" + first + "> and <" + second + ">"; |
| | | if (result == 0) { |
| | | assertEquals (dn1, dn2, "DN equality for <" + first + "> and <" + second + ">"); |
| | | assertEquals (dn1, dn2, msg); |
| | | } else { |
| | | assertNotEquals(dn1, dn2, "DN equality for <" + first + "> and <" + second + ">"); |
| | | assertNotEquals(dn1, dn2, msg); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.schema.AttributeTypeSyntax; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | String string = "( 2.5.18.6 NAME 'subtreeSpecification' " |
| | | + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.45 )"; |
| | | |
| | | AttributeType type = AttributeTypeSyntax.decodeAttributeType( |
| | | ByteString.valueOfUtf8(string), |
| | | DirectoryServer.getSchema(), false); |
| | | AttributeType type = DirectoryServer.getSchema().parseAttributeType(string); |
| | | |
| | | // Test values. |
| | | String[] values = new String[] { "{ }", |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | import java.util.ArrayList; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashSet; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashSet; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.util; |
| | | |
| | |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.testng.Assert; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.util; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.AfterClass; |