Code cleanup
DirectoryServer.java:
Added getAttributeType(String lowerName, String upperName).
*.java:
Used the newly added DirectoryServer.getAttributeType(String lowerName, String upperName).
Used more DirectoryServer.getAttributeType(String, boolean).
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | } |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName, attrName); |
| | | AttributeBuilder builder = new AttributeBuilder(attribute, true); |
| | | for (Object value : getAttributeValues(attrName)) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | } |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName, attrName); |
| | | AttributeBuilder builder = new AttributeBuilder(attribute, true); |
| | | for (Object value : csr.getAttributeValues(attrName)) |
| | | { |
| | |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | */ |
| | | public final class AdministrationDataSync |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * The root connection. |
| | | */ |
| | | /** The root connection. */ |
| | | private InternalClientConnection internalConnection; |
| | | |
| | | /** |
| | | * The attribute name used to store the port. TODO Use the default |
| | | * one. |
| | | */ |
| | | /** The attribute name used to store the port. TODO Use the default one. */ |
| | | private static final String LDAP_PORT = "ds-cfg-listen-port"; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create an object that will syncrhonize configuration and the |
| | | * admin data. |
| | | * Create an object that will synchronize configuration and the admin data. |
| | | * |
| | | * @param internalConnection |
| | | * The root connection. |
| | |
| | | this.internalConnection = internalConnection; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Check if information found in "cn=admin data" is coherent with |
| | | * cn=config. If and inconsistancy is detected, we log a warning |
| | | * cn=config. If and inconsistency is detected, we log a warning |
| | | * message and update "cn=admin data" |
| | | */ |
| | | public void synchronize() |
| | |
| | | checkAdminConnector(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Check if the admin connector is in sync. The desynchronization |
| | | * could occurs after the upgrade from 1.0. |
| | |
| | | } |
| | | |
| | | // Get the admin port |
| | | String adminPort = getAttr("cn=Administration Connector,cn=config", |
| | | LDAP_PORT); |
| | | String adminPort = getAttr("cn=Administration Connector,cn=config", LDAP_PORT); |
| | | if (adminPort == null) |
| | | { |
| | | // best effort. |
| | | return; |
| | | } |
| | | |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | // adminport |
| | | String attName = "adminport"; |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attName |
| | | .toLowerCase()); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attName.toLowerCase()); |
| | | } |
| | | mods.add(new Modification(ModificationType.REPLACE, Attributes.create( |
| | | attrType, adminPort))); |
| | | AttributeType attrType1 = DirectoryServer.getAttributeType("adminport".toLowerCase(), true); |
| | | AttributeType attrType2 = DirectoryServer.getAttributeType("adminEnabled".toLowerCase(), true); |
| | | |
| | | // adminEnabled |
| | | attName = "adminEnabled"; |
| | | attrType = DirectoryServer.getAttributeType(attName.toLowerCase()); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attName.toLowerCase()); |
| | | } |
| | | mods.add(new Modification(ModificationType.REPLACE, Attributes.create( |
| | | attrType, "true"))); |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, Attributes.create(attrType1, adminPort))); |
| | | mods.add(new Modification(ModificationType.REPLACE, Attributes.create(attrType2, "true"))); |
| | | |
| | | // Process modification |
| | | internalConnection.processModify(serverEntryDN, mods); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Look for the DN of the local register server. Assumption: default |
| | | * Connection Handler naming is used. |
| | |
| | | DN returnDN = null; |
| | | |
| | | // Get the LDAP and LDAPS port |
| | | String ldapPort = getAttr( |
| | | "cn=LDAP Connection Handler,cn=Connection Handlers,cn=config", |
| | | LDAP_PORT); |
| | | String ldapsPort = getAttr( |
| | | "cn=LDAPS Connection Handler,cn=Connection Handlers,cn=config", |
| | | LDAP_PORT); |
| | | String ldapPort = getAttr("cn=LDAP Connection Handler,cn=Connection Handlers,cn=config", LDAP_PORT); |
| | | String ldapsPort = getAttr("cn=LDAPS Connection Handler,cn=Connection Handlers,cn=config", LDAP_PORT); |
| | | boolean ldapsPortEnable = false; |
| | | String val = getAttr( |
| | | "cn=LDAPS Connection Handler,cn=Connection Handlers,cn=config", |
| | | "ds-cfg-enabled"); |
| | | String val = getAttr("cn=LDAPS Connection Handler,cn=Connection Handlers,cn=config", "ds-cfg-enabled"); |
| | | if (val != null) |
| | | { |
| | | ldapsPortEnable = val.toLowerCase().equals("true"); |
| | | ldapsPortEnable = "true".equals(val.toLowerCase()); |
| | | } |
| | | if ((ldapPort == null) && (ldapsPort == null)) |
| | | if (ldapPort == null && ldapsPort == null) |
| | | { |
| | | // best effort (see assumption) |
| | | return null; |
| | |
| | | String hostName; |
| | | try |
| | | { |
| | | hostName = java.net.InetAddress.getLocalHost().getCanonicalHostName(); |
| | | hostName = InetAddress.getLocalHost().getCanonicalHostName(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | |
| | | InternalSearchOperation op = internalConnection.processSearch(request); |
| | | if (op.getResultCode() == ResultCode.SUCCESS) |
| | | { |
| | | Entry entry = null; |
| | | for (Entry currentEntry : op.getSearchEntries()) |
| | | Entry entry = findSameHostAndPort(op.getSearchEntries(), hostName, ldapPort, ldapsPortEnable, ldapsPort); |
| | | if (entry != null) |
| | | { |
| | | String currentHostname = |
| | | currentEntry.parseAttribute("hostname").asString(); |
| | | returnDN = entry.getName(); |
| | | } |
| | | } |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | // never happens because the filter is always valid. |
| | | return null; |
| | | } |
| | | return returnDN; |
| | | } |
| | | |
| | | private Entry findSameHostAndPort(LinkedList<SearchResultEntry> searchResultEntries, |
| | | String hostName, String ldapPort, boolean ldapsPortEnable, String ldapsPort) |
| | | { |
| | | for (Entry currentEntry : searchResultEntries) |
| | | { |
| | | String currentHostname = currentEntry.parseAttribute("hostname").asString(); |
| | | try |
| | | { |
| | | String currentIPAddress = java.net.InetAddress.getByName( |
| | | currentHostname).getCanonicalHostName(); |
| | | String currentIPAddress = InetAddress.getByName(currentHostname).getCanonicalHostName(); |
| | | if (currentIPAddress.equals(hostName)) |
| | | { |
| | | // Check if one of the port match |
| | | String currentport = |
| | | currentEntry.parseAttribute("ldapport").asString(); |
| | | String currentport = currentEntry.parseAttribute("ldapport").asString(); |
| | | if (currentport.equals(ldapPort)) |
| | | { |
| | | entry = currentEntry; |
| | | break; |
| | | return currentEntry; |
| | | } |
| | | if (ldapsPortEnable) |
| | | { |
| | | currentport = |
| | | currentEntry.parseAttribute("ldapsport").asString(); |
| | | currentport = currentEntry.parseAttribute("ldapsport").asString(); |
| | | if (currentport.equals(ldapsPort)) |
| | | { |
| | | entry = currentEntry; |
| | | break; |
| | | return currentEntry; |
| | | } |
| | | } |
| | | } |
| | |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if (entry != null) |
| | | { |
| | | returnDN = entry.getName(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | // never happens because the filter is always valid. |
| | | return null; |
| | | } |
| | | return returnDN; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets an attribute value from an entry. |
| | |
| | | { |
| | | // can not happen |
| | | // best effort. |
| | | // TODO Log an Error. |
| | | logger.traceException(e); |
| | | return null; |
| | | } |
| | | |
| | |
| | | adminConnectorEntry = result.getFirst(); |
| | | } |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrName); |
| | | if (attrType == null) |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrName, true); |
| | | List<Attribute> attrs = adminConnectorEntry.getAttribute(attrType); |
| | | if (attrs != null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | // Get the attribute value |
| | | return attrs.get(0).iterator().next().toString(); |
| | | } |
| | | |
| | | List<Attribute> attrs = adminConnectorEntry.getAttribute(attrType); |
| | | if (attrs == null) |
| | | { |
| | | // can not happen |
| | | // best effort. |
| | | // TODO Log an Error. |
| | | return null; |
| | | } |
| | | |
| | | // Get the attribute value |
| | | return attrs.get(0).iterator().next().toString(); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import static org.opends.server.authorization.dseecompat.Aci.*; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | 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.opends.server.types.Attributes; |
| | | import org.opends.server.types.Entry; |
| | | |
| | | /** |
| | | * This class implements the dseecompat geteffectiverights evaluation. |
| | | */ |
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(a |
| | | .toLowerCase()); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(a.toLowerCase()); |
| | | } |
| | | nonRightsAttrs.add(attrType); |
| | | nonRightsAttrs.add(DirectoryServer.getAttributeType(a.toLowerCase(), true)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // If the special geteffectiverights attributes were not found or |
| | | // the user does not have both bypass-acl privs and is not allowed to |
| | | // perform rights evalation -- return the entry unchanged. |
| | | // perform rights evaluation -- return the entry unchanged. |
| | | if (attrMask == ACI_NULL |
| | | || (!skipCheck && !rightsAccessAllowed(container, handler, attrMask))) |
| | | { |
| | |
| | | |
| | | private static AttributeType getAttributeType(String name) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(name); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | } |
| | | return attrType; |
| | | return DirectoryServer.getAttributeType(name, true); |
| | | } |
| | | |
| | | |
| | |
| | | * @return The attribute type. |
| | | */ |
| | | public AttributeType getAttributeType() { |
| | | final String attrName = attrTypeStr.toLowerCase(); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrName); |
| | | if(attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | } |
| | | return attrType; |
| | | return DirectoryServer.getAttributeType(attrTypeStr.toLowerCase(), true); |
| | | } |
| | | |
| | | /** |
| | |
| | | attributeName=attributeName.substring(0, semicolon); |
| | | } |
| | | String filterString=matcher.group(filterPos); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attributeName); |
| | | if (attrType == null) { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attributeName); |
| | | } |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attributeName, true); |
| | | SearchFilter filter; |
| | | //Check if it is a valid filter and add it to the list map if ok. |
| | | try { |
| | |
| | | /** |
| | | * A class representing an ACI's targetattr keyword. |
| | | */ |
| | | public class TargetAttr { |
| | | class TargetAttr { |
| | | /** Enumeration representing the targetattr operator. */ |
| | | private EnumTargetOperator operator = EnumTargetOperator.EQUALITY; |
| | | private final EnumTargetOperator operator; |
| | | |
| | | /** Flags that is set if all user attributes pattern seen "*". */ |
| | | private boolean allUserAttributes; |
| | | /** Flags that is set if all operational attributes pattern seen "+". */ |
| | | private boolean allOpAttributes; |
| | | /** Set of the attribute types parsed by the constructor. */ |
| | | private HashSet<AttributeType> attributes = new HashSet<>(); |
| | | private final HashSet<AttributeType> attributes = new HashSet<>(); |
| | | /** Set of the operational attribute types parsed by the constructor. */ |
| | | private HashSet<AttributeType> opAttributes = new HashSet<>(); |
| | | private final HashSet<AttributeType> opAttributes = new HashSet<>(); |
| | | |
| | | /** |
| | | * Regular expression that matches one or more ATTR_NAME's separated by |
| | |
| | | throw new AciException(message); |
| | | } |
| | | } else { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attribute); |
| | | if (attrType == null) { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attribute); |
| | | } |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attribute, true); |
| | | if(attrType.isOperational()) |
| | | { |
| | | opAttributes.add(attrType); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Return array holding each attribute type to be evaluated |
| | | * in the expression. |
| | | * @return Array holding each attribute types. |
| | | */ |
| | | public HashSet<AttributeType> getAttributes() { |
| | | return attributes; |
| | | } |
| | | |
| | | /** |
| | | * Return array holding operational attribute types to be evaluated |
| | | * in the expression. |
| | | * @return Array holding attribute types. |
| | | */ |
| | | public HashSet<AttributeType> getOpAttributes() { |
| | | return opAttributes; |
| | | } |
| | | |
| | | /** |
| | | * Decodes an targetattr expression string into a targetattr class suitable |
| | | * for evaluation. |
| | | * @param operator The operator enumeration of the expression. |
| | |
| | | * @return A TargetAttr suitable to evaluate this ACI's targetattrs. |
| | | * @throws AciException If the expression string is invalid. |
| | | */ |
| | | public static TargetAttr decode(EnumTargetOperator operator, String expr) |
| | | throws AciException { |
| | | static TargetAttr decode(EnumTargetOperator operator, String expr) throws AciException { |
| | | return new TargetAttr(operator, expr); |
| | | } |
| | | |
| | |
| | | * @return The boolean result of the above tests and application |
| | | * TargetAttr's operator value applied to the test result. |
| | | */ |
| | | |
| | | public static boolean isApplicable(AttributeType a, TargetAttr targetAttr) { |
| | | static boolean isApplicable(AttributeType a, TargetAttr targetAttr) { |
| | | if(targetAttr.isAllUserAttributes() && targetAttr.isAllOpAttributes()) { |
| | | return !targetAttr.getOperator().equals(EnumTargetOperator.NOT_EQUALITY); |
| | | } else { |
| | |
| | | private EnumEvalResult evalVAL(AciEvalContext evalCtx) { |
| | | EnumEvalResult matched= EnumEvalResult.FALSE; |
| | | boolean undefined=false; |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrStr); |
| | | if (attrType == null) { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrStr); |
| | | } |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrStr, true); |
| | | final SearchRequest request = newSearchRequest(evalCtx.getClientDN(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation op = getRootConnection().processSearch(request); |
| | | LinkedList<SearchResultEntry> result = op.getSearchEntries(); |
| | |
| | | private EnumEvalResult evalURL(AciEvalContext evalCtx) { |
| | | EnumEvalResult matched= EnumEvalResult.FALSE; |
| | | boolean undefined=false; |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrStr); |
| | | if (attrType == null) { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrStr); |
| | | } |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrStr, true); |
| | | List<Attribute> attrs=evalCtx.getResourceEntry().getAttribute(attrType); |
| | | if(!attrs.isEmpty()) { |
| | | for(Attribute a : attrs) { |
| | |
| | | private SearchFilter buildSearchFilterFrom(final DN baseDN, final String lowerCaseAttr, final String upperCaseAttr) |
| | | { |
| | | final RDN rdn = baseDN.rdn(); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerCaseAttr); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(upperCaseAttr); |
| | | } |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerCaseAttr, upperCaseAttr); |
| | | final ByteString attrValue = rdn.getAttributeValue(attrType); |
| | | if (attrValue != null) |
| | | { |
| | |
| | | final Map<AttributeType, List<Attribute>> userAttrs, |
| | | final Map<AttributeType, List<Attribute>> operationalAttrs, final boolean addByType) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrNameLowercase); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrNameUppercase); |
| | | } |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrNameLowercase, attrNameUppercase); |
| | | final Attribute a = addByType |
| | | ? Attributes.create(attrType, attrValue) |
| | | : Attributes.create(attrNameUppercase, attrValue); |
| | |
| | | private Attribute createAttribute(String name, String lowerName, |
| | | Collection<? extends Object> values) |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeType(lowerName); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(name); |
| | | } |
| | | AttributeType type = DirectoryServer.getAttributeType(lowerName, name); |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(type, name); |
| | | builder.addAllStrings(values); |
| | |
| | | private static final int MINIMUM_AVAILABLE_MEMORY = 32 * MB; |
| | | |
| | | /** The DN attribute type. */ |
| | | private static final AttributeType dnType; |
| | | private static final AttributeType dnType = DirectoryServer.getAttributeType("dn", true); |
| | | static final IndexOutputBuffer.IndexComparator indexComparator = |
| | | new IndexOutputBuffer.IndexComparator(); |
| | | |
| | |
| | | |
| | | private final DiskSpaceMonitor diskSpaceMonitor; |
| | | |
| | | static |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType("dn"); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType("dn"); |
| | | } |
| | | dnType = attrType; |
| | | } |
| | | |
| | | /** |
| | | * Create a new import job with the specified rebuild index config. |
| | | * |
| | |
| | | private static final int SMALL_HEAP_SIZE = 256 * MB; |
| | | |
| | | /** The DN attribute type. */ |
| | | private static final AttributeType DN_TYPE; |
| | | static |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType("dn"); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType("dn"); |
| | | } |
| | | DN_TYPE = attrType; |
| | | } |
| | | private static final AttributeType DN_TYPE = DirectoryServer.getAttributeType("dn", true); |
| | | |
| | | /** Root container. */ |
| | | private final RootContainer rootContainer; |
| | |
| | | |
| | | // Get the recurring task ID from the entry. If there isn't one, then fail. |
| | | AttributeType attrType = DirectoryServer.getAttributeType( |
| | | ATTR_RECURRING_TASK_ID.toLowerCase()); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(ATTR_RECURRING_TASK_ID); |
| | | } |
| | | |
| | | ATTR_RECURRING_TASK_ID.toLowerCase(), ATTR_RECURRING_TASK_ID); |
| | | List<Attribute> attrList = recurringTaskEntry.getAttribute(attrType); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | |
| | | String messageString = buffer.toString(); |
| | | logMessages.add(messageString); |
| | | |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | ATTR_TASK_LOG_MESSAGES.toLowerCase()); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(ATTR_TASK_LOG_MESSAGES); |
| | | } |
| | | ATTR_TASK_LOG_MESSAGES.toLowerCase(), ATTR_TASK_LOG_MESSAGES); |
| | | |
| | | List<Attribute> attrList = taskEntry.getAttribute(type); |
| | | ByteString value = ByteString.valueOf(messageString); |
| | |
| | | throws DirectoryException |
| | | { |
| | | // Get the name of the class that implements the task logic. |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(ATTR_TASK_CLASS.toLowerCase()); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(ATTR_TASK_CLASS); |
| | | } |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeType(ATTR_TASK_CLASS.toLowerCase(), ATTR_TASK_CLASS); |
| | | List<Attribute> attrList = entry.getAttribute(attrType); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | { |
| | |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | 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.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | throws ConfigException |
| | | { |
| | | String attrName = stub.getName(); |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(attrName.toLowerCase()); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | } |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrName.toLowerCase(), attrName); |
| | | List<Attribute> attrList = entry.getAttribute(attrType); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | |
| | | { |
| | | // It's possible that this is a monitor attribute rather than a configurable |
| | | // one. Check all of those. |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(name.toLowerCase()); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | } |
| | | for (MonitorProvider<? extends MonitorProviderCfg> monitor : |
| | | monitorProviders) |
| | | AttributeType attrType = DirectoryServer.getAttributeType(name.toLowerCase(), name); |
| | | for (MonitorProvider<? extends MonitorProviderCfg> monitor : monitorProviders) |
| | | { |
| | | for (org.opends.server.types.Attribute a : monitor.getMonitorData()) |
| | | { |
| | |
| | | |
| | | // It's possible that this is a monitor attribute rather than a |
| | | // configurable one. Check all of those. |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(name.toLowerCase()); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(name); |
| | | } |
| | | AttributeType attrType = DirectoryServer.getAttributeType(name.toLowerCase(), name); |
| | | |
| | | monitorLoop: |
| | | for (MonitorProvider<? extends MonitorProviderCfg> monitor : |
| | |
| | | */ |
| | | package org.opends.server.controls; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | 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.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | 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; |
| | | |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * This class partially implements the geteffectiverights control as defined |
| | | * in draft-ietf-ldapext-acl-model-08.txt. The main differences are: |
| | |
| | | attrs = new LinkedList<>(); |
| | | reader.readStartSequence(); |
| | | while(reader.hasNextElement()) { |
| | | //Decode as an octet string. |
| | | String attrStr = reader.readOctetStringAsString(); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrStr); |
| | | //Get an attribute type for it and add to the list. |
| | | if (attrType == null) { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrStr); |
| | | } |
| | | attrs.add(attrType); |
| | | attrs.add(DirectoryServer.getAttributeType(attrStr, true)); |
| | | } |
| | | reader.readEndSequence(); |
| | | } |
| | |
| | | { |
| | | return OID_GET_EFFECTIVE_RIGHTS; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | import org.forgerock.opendj.ldap.Assertion; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.util.Reject; |
| | | 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.*; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RawFilter; |
| | | |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | |
| | | { |
| | | if (attributeType == null && rawAttributeType != null) |
| | | { |
| | | attributeType = DirectoryServer.getAttributeType(toLowerCase(rawAttributeType)); |
| | | if (attributeType == null) |
| | | { |
| | | attributeType = DirectoryServer.getDefaultAttributeType(rawAttributeType); |
| | | } |
| | | String lowerName = toLowerCase(rawAttributeType); |
| | | attributeType = DirectoryServer.getAttributeType(lowerName, rawAttributeType); |
| | | } |
| | | return attributeType; |
| | | } |
| | |
| | | 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.forgerock.util.Utils; |
| | | import org.opends.server.admin.AdministrationConnector; |
| | |
| | | import org.opends.server.api.AccountStatusNotificationHandler; |
| | | import org.opends.server.api.AlertGenerator; |
| | | import org.opends.server.api.AlertHandler; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.api.AuthenticationPolicy; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.BackendInitializationListener; |
| | |
| | | { |
| | | type = getDefaultAttributeType(lowerName); |
| | | } |
| | | |
| | | return type; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Retrieves the attribute type for the provided lowercase name or OID. It will return a generated |
| | | * "default" version with the uppercase name or OID if the requested attribute type is not defined |
| | | * in the schema. |
| | | * |
| | | * @param lowerName |
| | | * The lowercase name or OID for the attribute type to retrieve. |
| | | * @param upperName |
| | | * The uppercase name or OID for the attribute type to generate. |
| | | * @return The requested attribute type, or a generated "default" version if there is no attribute |
| | | * with the specified type defined in the server schema |
| | | */ |
| | | public static AttributeType getAttributeType(String lowerName, String upperName) |
| | | { |
| | | AttributeType type = directoryServer.schema.getAttributeType(lowerName); |
| | | if (type == null) |
| | | { |
| | | type = getDefaultAttributeType(upperName); |
| | | } |
| | | return type; |
| | | } |
| | | |
| | | /** |
| | | * Registers the provided attribute type with the Directory Server. |
| | |
| | | { |
| | | // Get the password changed time for the user. |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_CHANGED_TIME_LC, true); |
| | | |
| | | try |
| | | { |
| | | passwordChangedTime = getGeneralizedTime(userEntry, type); |
| | |
| | | return authFailureTimes; |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_FAILURE_TIME_LC); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(OP_ATTR_PWPOLICY_FAILURE_TIME); |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | OP_ATTR_PWPOLICY_FAILURE_TIME_LC, OP_ATTR_PWPOLICY_FAILURE_TIME); |
| | | try |
| | | { |
| | | authFailureTimes = getGeneralizedTimes(type); |
| | |
| | | failureTimes.add(highestFailureTime); |
| | | |
| | | // And the attribute in the user entry |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_FAILURE_TIME_LC); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(OP_ATTR_PWPOLICY_FAILURE_TIME); |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | OP_ATTR_PWPOLICY_FAILURE_TIME_LC, OP_ATTR_PWPOLICY_FAILURE_TIME); |
| | | Attribute addAttr = Attributes.create(type, GeneralizedTimeSyntax.format(highestFailureTime)); |
| | | modifications.add(new Modification(ModificationType.ADD, addAttr, true)); |
| | | |
| | |
| | | |
| | | failureTimes.clear(); // Note: failureTimes != this.authFailureTimes |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_FAILURE_TIME_LC); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(OP_ATTR_PWPOLICY_FAILURE_TIME); |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | OP_ATTR_PWPOLICY_FAILURE_TIME_LC, OP_ATTR_PWPOLICY_FAILURE_TIME); |
| | | modifications.add(new Modification(ModificationType.REPLACE, Attributes.empty(type), true)); |
| | | } |
| | | |
| | |
| | | return failureLockedTime; |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_LOCKED_TIME_LC); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(OP_ATTR_PWPOLICY_LOCKED_TIME); |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | OP_ATTR_PWPOLICY_LOCKED_TIME_LC, OP_ATTR_PWPOLICY_LOCKED_TIME); |
| | | try |
| | | { |
| | | failureLockedTime = getGeneralizedTime(userEntry, type); |
| | |
| | | |
| | | failureLockedTime = time; |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_LOCKED_TIME_LC); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(OP_ATTR_PWPOLICY_LOCKED_TIME); |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | OP_ATTR_PWPOLICY_LOCKED_TIME_LC, OP_ATTR_PWPOLICY_LOCKED_TIME); |
| | | Attribute a = Attributes.create(type, GeneralizedTimeSyntax.format(failureLockedTime)); |
| | | modifications.add(new Modification(ModificationType.REPLACE, a, true)); |
| | | } |
| | |
| | | |
| | | failureLockedTime = -1L; |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_LOCKED_TIME_LC); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(OP_ATTR_PWPOLICY_LOCKED_TIME); |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | OP_ATTR_PWPOLICY_LOCKED_TIME_LC, OP_ATTR_PWPOLICY_LOCKED_TIME); |
| | | modifications.add(new Modification(ModificationType.REPLACE, Attributes.empty(type), true)); |
| | | } |
| | | |
| | |
| | | return false; |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_RESET_REQUIRED_LC); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(OP_ATTR_PWPOLICY_RESET_REQUIRED); |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | OP_ATTR_PWPOLICY_RESET_REQUIRED_LC, OP_ATTR_PWPOLICY_RESET_REQUIRED); |
| | | try |
| | | { |
| | | mustChangePassword = getBoolean(userEntry, type); |
| | |
| | | return; // requested state matches current state |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | OP_ATTR_PWPOLICY_RESET_REQUIRED_LC, OP_ATTR_PWPOLICY_RESET_REQUIRED); |
| | | this.mustChangePassword = ConditionResult.not(this.mustChangePassword); |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_RESET_REQUIRED_LC); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(OP_ATTR_PWPOLICY_RESET_REQUIRED); |
| | | } |
| | | |
| | | if (mustChangePassword) |
| | | { |
| | | Attribute a = Attributes.create(type, String.valueOf(true)); |
| | |
| | | { |
| | | if (graceLoginTimes == null) |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME_LC); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME_LC, OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); |
| | | try |
| | | { |
| | | graceLoginTimes = getGeneralizedTimes(type); |
| | |
| | | } |
| | | graceTimes.add(highestGraceTime); // graceTimes == this.graceLoginTimes |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME_LC); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME_LC, OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); |
| | | Attribute addAttr = Attributes.create(type, GeneralizedTimeSyntax.format(highestGraceTime)); |
| | | modifications.add(new Modification(ModificationType.ADD, addAttr, true)); |
| | | } |
| | |
| | | } |
| | | graceTimes.clear(); // graceTimes == this.graceLoginTimes |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME_LC); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME_LC, OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); |
| | | modifications.add(new Modification(ModificationType.REPLACE, Attributes.empty(type), true)); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.monitors; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | |
| | |
| | | if (handler == null) |
| | | { |
| | | // Get information about all the available connections. |
| | | for (ConnectionHandler<?> hdl : DirectoryServer |
| | | .getConnectionHandlers()) |
| | | for (ConnectionHandler<?> hdl : DirectoryServer.getConnectionHandlers()) |
| | | { |
| | | // FIXME: connections from different handlers could have the |
| | | // same ID. |
| | | // FIXME: connections from different handlers could have the same ID. |
| | | for (ClientConnection conn : hdl.getClientConnections()) |
| | | { |
| | | connMap.put(conn.getConnectionID(), conn); |
| | |
| | | } |
| | | else |
| | | { |
| | | Collection<ClientConnection> collection = |
| | | handler.getClientConnections(); |
| | | for (ClientConnection conn : collection) |
| | | for (ClientConnection conn : handler.getClientConnections()) |
| | | { |
| | | connMap.put(conn.getConnectionID(), conn); |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.FilterType; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RawFilter; |
| | | import org.opends.server.types.SearchFilter; |
| | | |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines the data structures and methods to use when interacting |
| | | * with an LDAP search filter, which defines a set of criteria for locating |
| | |
| | | if (semicolonPos > 0) |
| | | { |
| | | String baseName = attributeType.substring(0, semicolonPos); |
| | | attrType = DirectoryServer.getAttributeType(toLowerCase(baseName)); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(baseName); |
| | | } |
| | | |
| | | attrType = DirectoryServer.getAttributeType(toLowerCase(baseName), baseName); |
| | | options = new HashSet<>(); |
| | | StringTokenizer tokenizer = |
| | | new StringTokenizer(attributeType.substring(semicolonPos+1), ";"); |
| | |
| | | else |
| | | { |
| | | options = null; |
| | | attrType = |
| | | DirectoryServer.getAttributeType(toLowerCase(attributeType)); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attributeType); |
| | | } |
| | | attrType = DirectoryServer.getAttributeType(toLowerCase(attributeType), attributeType); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Modification; |
| | | |
| | | /** |
| | | * This class stores an internal usable representation of the value of |
| | |
| | | { |
| | | // This HistVal was used to store the date when some |
| | | // modifications were done to the entries. |
| | | attrType = DirectoryServer.getSchema().getAttributeType(attrString); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrString); |
| | | } |
| | | attrType = DirectoryServer.getAttributeType(attrString, true); |
| | | } |
| | | else |
| | | { |
| | |
| | | // For the checksum computing mode, only consider the 'stable' attributes |
| | | if (checksumOutput) |
| | | { |
| | | String includeAttributeStrings[] = |
| | | {"objectclass", "sn", "cn", "entryuuid"}; |
| | | String includeAttributeStrings[] = { "objectclass", "sn", "cn", "entryuuid" }; |
| | | Set<AttributeType> includeAttributes = new HashSet<>(); |
| | | for (String attrName : includeAttributeStrings) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrName); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | } |
| | | includeAttributes.add(attrType); |
| | | includeAttributes.add(DirectoryServer.getAttributeType(attrName, true)); |
| | | } |
| | | exportConfig.setIncludeAttributes(includeAttributes); |
| | | } |
| | |
| | | // which this attribute type should inherit its properties. |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, pos); |
| | | superiorType = schema.getAttributeType(woidBuffer.toString()); |
| | | String woidString = woidBuffer.toString(); |
| | | superiorType = schema.getAttributeType(woidString); |
| | | if (superiorType == null) |
| | | { |
| | | if (allowUnknownElements) |
| | | { |
| | | superiorType = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | superiorType = DirectoryServer.getDefaultAttributeType(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, woidBuffer); |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_SUPERIOR_TYPE.get(oid, woidString); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | } |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg2; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_REQUIRED_ATTR)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the DIT content rule |
| | | // requires an attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType(woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_REQUIRED_ATTR.get(valueStr, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | |
| | | |
| | | // The next character must be either a dollar sign or a closing |
| | | // parenthesis. |
| | | // The next character must be either a dollar sign or a closing parenthesis. |
| | | c = valueStr.charAt(pos++); |
| | | if (c == ')') |
| | | { |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the DIT content rule |
| | | // requires an attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_REQUIRED_ATTR.get(valueStr, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_REQUIRED_ATTR)); |
| | | } |
| | | |
| | | requiredAttributes.addAll(attrs); |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_OPTIONAL_ATTR)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the DIT content rule |
| | | // allows an attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_OPTIONAL_ATTR.get(valueStr, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | |
| | | |
| | | // The next character must be either a dollar sign or a closing |
| | | // parenthesis. |
| | | // The next character must be either a dollar sign or a closing parenthesis. |
| | | c = valueStr.charAt(pos++); |
| | | if (c == ')') |
| | | { |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the DIT content rule allows |
| | | // an attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_OPTIONAL_ATTR.get(valueStr, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_OPTIONAL_ATTR)); |
| | | } |
| | | |
| | | optionalAttributes.addAll(attrs); |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_PROHIBITED_ATTR)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the DIT content rule |
| | | // prohibits an attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_PROHIBITED_ATTR.get( |
| | | valueStr, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | |
| | | |
| | | // The next character must be either a dollar sign or a closing |
| | | // parenthesis. |
| | | // The next character must be either a dollar sign or a closing parenthesis. |
| | | c = valueStr.charAt(pos++); |
| | | if (c == ')') |
| | | { |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the DIT content rule |
| | | // prohibits an attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_PROHIBITED_ATTR.get(valueStr, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer, |
| | | ERR_ATTR_SYNTAX_DCR_UNKNOWN_PROHIBITED_ATTR)); |
| | | } |
| | | |
| | | prohibitedAttributes.addAll(attrs); |
| | |
| | | isObsolete, extraProperties); |
| | | } |
| | | |
| | | private static AttributeType getAttribute(Schema schema, boolean allowUnknownElements, String valueStr, |
| | | StringBuilder woidBuffer, Arg2<Object, Object> msg) throws DirectoryException |
| | | { |
| | | String woidString = woidBuffer.toString(); |
| | | AttributeType attr = schema.getAttributeType(woidString); |
| | | if (attr == null) |
| | | { |
| | | // 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.getDefaultAttributeType(woidString); |
| | | } |
| | | return attr; |
| | | } |
| | | |
| | | /** |
| | | * Reads the next token name from the DIT content rule definition, skipping |
| | | * over any leading or trailing spaces, and appends it to the provided buffer. |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the matching rule use |
| | | // specifies an attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_ATTR.get(oid, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | |
| | | |
| | | // The next character must be either a dollar sign or a closing |
| | | // parenthesis. |
| | | // The next character must be either a dollar sign or a closing parenthesis. |
| | | c = valueStr.charAt(pos++); |
| | | if (c == ')') |
| | | { |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the matching rule use |
| | | // specifies an attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_ATTR.get(oid, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer)); |
| | | } |
| | | |
| | | attributes = new LinkedHashSet<>(attrs); |
| | |
| | | extraProperties); |
| | | } |
| | | |
| | | private static AttributeType getAttributeType( |
| | | Schema schema, boolean allowUnknownElements, String oid, StringBuilder woidBuffer) throws DirectoryException |
| | | { |
| | | String woidString = woidBuffer.toString(); |
| | | AttributeType attr = schema.getAttributeType(woidString); |
| | | if (attr == null) |
| | | { |
| | | // 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.getDefaultAttributeType(woidString); |
| | | } |
| | | return attr; |
| | | } |
| | | |
| | | /** |
| | | * Reads the next token name from the matching rule use definition, skipping |
| | | * over any leading or trailing spaces, and appends it to the provided buffer. |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg2; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_REQUIRED_ATTR)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the name form requires |
| | | // an attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_REQUIRED_ATTR.get(oid, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | |
| | | |
| | | // The next character must be either a dollar sign or a closing |
| | | // parenthesis. |
| | | // The next character must be either a dollar sign or a closing parenthesis. |
| | | c = valueStr.charAt(pos++); |
| | | if (c == ')') |
| | | { |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the name form requires an |
| | | // attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_REQUIRED_ATTR.get(oid, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_REQUIRED_ATTR)); |
| | | } |
| | | |
| | | requiredAttributes.addAll(attrs); |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_OPTIONAL_ATTR)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the name form allows an |
| | | // attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_OPTIONAL_ATTR.get(oid, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | |
| | | |
| | | // The next character must be either a dollar sign or a closing |
| | | // parenthesis. |
| | | // The next character must be either a dollar sign or a closing parenthesis. |
| | | c = valueStr.charAt(pos++); |
| | | if (c == ')') |
| | | { |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the name form allows an |
| | | // attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_OPTIONAL_ATTR.get(oid, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_OPTIONAL_ATTR)); |
| | | } |
| | | |
| | | optionalAttributes.addAll(attrs); |
| | |
| | | optionalAttributes, extraProperties); |
| | | } |
| | | |
| | | private static AttributeType getAttributeType(Schema schema, boolean allowUnknownElements, String oid, |
| | | StringBuilder woidBuffer, Arg2<Object, Object> msg) throws DirectoryException |
| | | { |
| | | String woidString = woidBuffer.toString(); |
| | | AttributeType attr = schema.getAttributeType(woidString); |
| | | if (attr == null) |
| | | { |
| | | // 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.getDefaultAttributeType(woidString); |
| | | } |
| | | return attr; |
| | | } |
| | | |
| | | /** |
| | | * Reads the next token name from the name form definition, skipping over any |
| | | * leading or trailing spaces, and appends it to the provided buffer. |
| | |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg2; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_UNKNOWN_REQUIRED_ATTR)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | // This isn't good because it means that the objectclass |
| | | // requires an attribute type that we don't know anything about. |
| | | LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_UNKNOWN_REQUIRED_ATTR. |
| | | get(oid, woidBuffer); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | message); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | |
| | | |
| | | // The next character must be either a dollar sign or a closing |
| | | // parenthesis. |
| | | // The next character must be either a dollar sign or a closing parenthesis. |
| | | c = valueStr.charAt(pos++); |
| | | if (c == ')') |
| | | { |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | // This isn't good because it means that the objectclass requires |
| | | // an attribute type that we don't know anything about. |
| | | LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_UNKNOWN_REQUIRED_ATTR. |
| | | get(oid, woidBuffer); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | message); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_UNKNOWN_REQUIRED_ATTR)); |
| | | } |
| | | |
| | | requiredAttributes.addAll(attrs); |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_UNKNOWN_OPTIONAL_ATTR)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | // This isn't good because it means that the objectclass allows |
| | | // an attribute type that we don't know anything about. |
| | | LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_UNKNOWN_OPTIONAL_ATTR. |
| | | get(oid, woidBuffer); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | message); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | |
| | | |
| | | // The next character must be either a dollar sign or a closing |
| | | // parenthesis. |
| | | // The next character must be either a dollar sign or a closing parenthesis. |
| | | c = valueStr.charAt(pos++); |
| | | if (c == ')') |
| | | { |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | // This isn't good because it means that the objectclass allows an |
| | | // attribute type that we don't know anything about. |
| | | LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_UNKNOWN_OPTIONAL_ATTR. |
| | | get(oid, woidBuffer); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | message); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | WARN_ATTR_SYNTAX_OBJECTCLASS_UNKNOWN_OPTIONAL_ATTR)); |
| | | } |
| | | |
| | | optionalAttributes.addAll(attrs); |
| | |
| | | extraProperties); |
| | | } |
| | | |
| | | private static AttributeType getAttributeType(Schema schema, boolean allowUnknownElements, String oid, |
| | | StringBuilder woidBuffer, Arg2<Object, Object> msg) throws DirectoryException |
| | | { |
| | | String woidString = woidBuffer.toString(); |
| | | AttributeType attr = schema.getAttributeType(woidString); |
| | | if (attr == null) |
| | | { |
| | | // 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.getDefaultAttributeType(woidString); |
| | | } |
| | | return attr; |
| | | } |
| | | |
| | | /** |
| | | * Reads the next token name from the objectclass definition, skipping over |
| | | * any leading or trailing spaces, and appends it to the provided buffer. |
| | |
| | | } |
| | | } |
| | | |
| | | // If we got here the task either completed successfully or |
| | | // was interrupted |
| | | // If we got here the task either completed successfully or was interrupted |
| | | return getFinalTaskState(); |
| | | } |
| | | |
| | |
| | | HashSet<AttributeType> attributes = new HashSet<>(); |
| | | for (String attrName : attributeStrings) |
| | | { |
| | | String lowerName = attrName.toLowerCase(); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | } |
| | | |
| | | attributes.add(attrType); |
| | | attributes.add(DirectoryServer.getAttributeType(attrName.toLowerCase(), attrName)); |
| | | } |
| | | return attributes; |
| | | } |
| | |
| | | final HashSet<AttributeType> attrTypes = new HashSet<>(attrNames.size()); |
| | | for (String attrName : attrNames) |
| | | { |
| | | String lowerName = attrName.toLowerCase(); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | } |
| | | |
| | | attrTypes.add(attrType); |
| | | attrTypes.add(DirectoryServer.getAttributeType(attrName.toLowerCase(), attrName)); |
| | | } |
| | | return attrTypes; |
| | | } |
| | |
| | | excludeAttributes = new HashSet<>(); |
| | | for (String attrName : excludeAttributeStrings.getValues()) |
| | | { |
| | | String lowerName = attrName.toLowerCase(); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | } |
| | | |
| | | excludeAttributes.add(attrType); |
| | | excludeAttributes.add( |
| | | DirectoryServer.getAttributeType(attrName.toLowerCase(), attrName)); |
| | | } |
| | | } |
| | | |
| | |
| | | includeAttributes = new HashSet<>(); |
| | | for (String attrName : includeAttributeStrings.getValues()) |
| | | { |
| | | String lowerName = attrName.toLowerCase(); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | } |
| | | |
| | | includeAttributes.add(attrType); |
| | | includeAttributes.add( |
| | | DirectoryServer.getAttributeType(attrName.toLowerCase(), attrName)); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | } |
| | | |
| | | excludeAttributes.add(attrType); |
| | | excludeAttributes.add(DirectoryServer.getAttributeType(lowerName, attrName)); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | } |
| | | |
| | | includeAttributes.add(attrType); |
| | | includeAttributes.add(DirectoryServer.getAttributeType(lowerName, attrName)); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | private static AttributeType getAttributeType(String attributeName) |
| | | { |
| | | String lc = toLowerCase(attributeName); |
| | | AttributeType type = DirectoryServer.getAttributeType(lc); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(attributeName); |
| | | } |
| | | return type; |
| | | return DirectoryServer.getAttributeType(toLowerCase(attributeName), attributeName); |
| | | } |
| | | |
| | | /** The attribute type for this attribute. */ |
| | |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the named attribute type, creating a default attribute if |
| | | * necessary. |
| | |
| | | */ |
| | | private static AttributeType getAttributeType(String attributeName) |
| | | { |
| | | String lc = toLowerCase(attributeName); |
| | | AttributeType type = DirectoryServer.getAttributeType(lc); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(attributeName); |
| | | return DirectoryServer.getAttributeType(toLowerCase(attributeName), attributeName); |
| | | } |
| | | return type; |
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | StringBuilder lowerName = new StringBuilder(); |
| | | toLowerCase(attributeName, lowerName, true); |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(lowerName.toString()); |
| | | String attributeNameString = attributeName.toString(); |
| | | |
| | | 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.getDefaultAttributeType( |
| | | attributeNameString); |
| | | } |
| | | |
| | | AttributeType attrType = getAttributeType(lowerName.toString(), attributeNameString); |
| | | rdnComponents.add( |
| | | new RDN(attrType, attributeNameString, ByteString.empty())); |
| | | return new DN(rdnComponents); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Decodes the provided string as a DN. |
| | | * |
| | |
| | | { |
| | | String name = attributeName.toString(); |
| | | String lowerName = toLowerCase(name); |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(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.getDefaultAttributeType(name); |
| | | } |
| | | |
| | | AttributeType attrType = getAttributeType(lowerName, name); |
| | | rdnComponents.add(new RDN(attrType, name, ByteString.empty())); |
| | | return new DN(rdnComponents); |
| | | } |
| | |
| | | // Create the new RDN with the provided information. |
| | | String name = attributeName.toString(); |
| | | String lowerName = toLowerCase(name); |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(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.getDefaultAttributeType(name); |
| | | } |
| | | |
| | | AttributeType attrType = getAttributeType(lowerName, name); |
| | | RDN rdn = new RDN(attrType, name, parsedValue.toByteString()); |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | private static AttributeType getAttributeType(String lowerName, String name) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(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.getDefaultAttributeType(name); |
| | | } |
| | | return attrType; |
| | | } |
| | | |
| | | /** |
| | | * Parses an attribute name from the provided DN string starting at |
| | |
| | | attributeOptions.add(attrType.substring(semicolonPos+1)); |
| | | } |
| | | |
| | | |
| | | // Get the attribute type for the specified name. |
| | | AttributeType attributeType = |
| | | DirectoryServer.getAttributeType(lowerType.toString()); |
| | | if (attributeType == null) |
| | | { |
| | | String typeStr = attrType.substring(0, lowerType.length()); |
| | | attributeType = |
| | | DirectoryServer.getDefaultAttributeType(typeStr); |
| | | } |
| | | |
| | | |
| | | // Get the attribute value. |
| | | AttributeType attributeType = getAttributeType(attrType, lowerType); |
| | | String valueStr = filterString.substring(equalPos+1, endPos); |
| | | if (valueStr.length() == 0) |
| | | { |
| | |
| | | |
| | | |
| | | // Get the attribute type for the specified name. |
| | | attributeType = |
| | | DirectoryServer.getAttributeType(lowerType.toString()); |
| | | if (attributeType == null) |
| | | { |
| | | String typeStr = attrType.substring(0, lowerType.length()); |
| | | attributeType = |
| | | DirectoryServer.getDefaultAttributeType(typeStr); |
| | | } |
| | | |
| | | attributeType = getAttributeType(attrType, lowerType); |
| | | |
| | | // If there is anything left, then it should be ":dn" and/or ":" |
| | | // followed by the matching rule ID. |
| | |
| | | dnAttributes); |
| | | } |
| | | |
| | | |
| | | private static AttributeType getAttributeType(String attrType, StringBuilder lowerType) |
| | | { |
| | | AttributeType attributeType = DirectoryServer.getAttributeType(lowerType.toString()); |
| | | if (attributeType == null) |
| | | { |
| | | String typeStr = attrType.substring(0, lowerType.length()); |
| | | attributeType = DirectoryServer.getDefaultAttributeType(typeStr); |
| | | } |
| | | return attributeType; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the filter type for this search filter. |
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | } |
| | | |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName, attrName); |
| | | if (! importConfig.includeAttribute(attrType)) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | |
| | | { |
| | | EnumTargetOperator op = EnumTargetOperator.createOperator(eqOperator); |
| | | TargetAttr targetAttr = TargetAttr.decode(op, targetAttrString); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attribute); |
| | | if (attrType == null) { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attribute); |
| | | } |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attribute, true); |
| | | assertEquals(TargetAttr.isApplicable(attrType, targetAttr), expectedResult); |
| | | } |
| | | } |
| | |
| | | getRootConnection().processModify(dn, mods); |
| | | } |
| | | |
| | | /** |
| | | * Return the attribute type corresponding to the attribute type string. |
| | | * |
| | | * @param attrTypeString The attribute type string name. |
| | | * |
| | | * @return An attribute type object pertaining to the string. |
| | | * |
| | | */ |
| | | private AttributeType getAttrType(String attrTypeString) { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrTypeString); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrTypeString); |
| | | } |
| | | return attrType; |
| | | return DirectoryServer.getAttributeType(attrTypeString, true); |
| | | } |
| | | |
| | | private void deleteEntries(String... dns) throws Exception{ |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private void deleteSubtree(String... dns) throws Exception |
| | | { |
| | | Control control = new SubtreeDeleteControl(true); |
| | |
| | | Attributes.create(attrName, attrValues))); |
| | | } |
| | | |
| | | /** |
| | | * Return the attribute type corresponding to the attribute type string. |
| | | * |
| | | * @param attrTypeString The attribute type string name. |
| | | * |
| | | * @return An attribute type object pertaining to the string. |
| | | */ |
| | | private AttributeType getAttrType(String attrTypeString) { |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(attrTypeString); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrTypeString); |
| | | } |
| | | return attrType; |
| | | return DirectoryServer.getAttributeType(attrTypeString, true); |
| | | } |
| | | |
| | | /** |