DirectoryServer.java: Removed getAttributeTypeOrDefault(String lowerName, String upperName), replaced by getAttributeTypeOrDefault(String lowerName)
| | |
| | | final org.opends.server.types.Attribute attribute = |
| | | LDIFReader.parseAttrDescription(wholeName); |
| | | final String attrName = attribute.getName(); |
| | | final String lowerName = toLowerCase(attrName); |
| | | |
| | | // See if this is an objectclass or an attribute. Then get the |
| | | // corresponding definition and add the value to the appropriate hash. |
| | | if (lowerName.equals("objectclass")) |
| | | if (attrName.equalsIgnoreCase("objectclass")) |
| | | { |
| | | for (Object value : getAttributeValues(attrName)) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(lowerName, attrName); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName); |
| | | AttributeBuilder builder = new AttributeBuilder(attribute, true); |
| | | for (Object value : getAttributeValues(attrName)) |
| | | { |
| | |
| | | { |
| | | final Attribute attribute = parseAttrDescription(wholeName); |
| | | final String attrName = attribute.getName(); |
| | | final String lowerName = toLowerCase(attrName); |
| | | |
| | | // See if this is an objectclass or an attribute. Then get the |
| | | // corresponding definition and add the value to the appropriate hash. |
| | | if (lowerName.equals("objectclass")) |
| | | if (attrName.equalsIgnoreCase("objectclass")) |
| | | { |
| | | for (Object value : csr.getAttributeValues(attrName)) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(lowerName, attrName); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName); |
| | | AttributeBuilder builder = new AttributeBuilder(attribute, true); |
| | | for (Object value : csr.getAttributeValues(attrName)) |
| | | { |
| | |
| | | case 2: |
| | | // It is probably "changeNumber=xxx,cn=changelog", use equality filter |
| | | // But it also could be "<service-id>,cn=changelog" so need to check on attribute |
| | | equalityFilter = buildSearchFilterFrom(baseDN, CHANGE_NUMBER_ATTR_LC, CHANGE_NUMBER_ATTR); |
| | | equalityFilter = buildSearchFilterFrom(baseDN, CHANGE_NUMBER_ATTR); |
| | | break; |
| | | default: |
| | | // "replicationCSN=xxx,<service-id>,cn=changelog" : use equality filter |
| | | equalityFilter = buildSearchFilterFrom(baseDN, "replicationcsn", "replicationCSN"); |
| | | equalityFilter = buildSearchFilterFrom(baseDN, "replicationCSN"); |
| | | break; |
| | | } |
| | | |
| | |
| | | * @return the search filter or {@code null} if attribute is not present in |
| | | * the provided DN |
| | | */ |
| | | private SearchFilter buildSearchFilterFrom(final DN baseDN, final String lowerCaseAttr, final String upperCaseAttr) |
| | | private SearchFilter buildSearchFilterFrom(final DN baseDN, final String attrName) |
| | | { |
| | | final RDN rdn = baseDN.rdn(); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(lowerCaseAttr, upperCaseAttr); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName); |
| | | 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.getAttributeTypeOrDefault(attrNameLowercase, attrNameUppercase); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrNameUppercase); |
| | | final Attribute a = addByType |
| | | ? Attributes.create(attrType, attrValue) |
| | | : Attributes.create(attrNameUppercase, attrValue); |
| | |
| | | Map<AttributeType, List<Attribute>> dseOperationalAttrs = new HashMap<>(); |
| | | |
| | | Attribute publicNamingContextAttr = createAttribute( |
| | | ATTR_NAMING_CONTEXTS, ATTR_NAMING_CONTEXTS_LC, |
| | | DirectoryServer.getPublicNamingContexts().keySet()); |
| | | ATTR_NAMING_CONTEXTS, DirectoryServer.getPublicNamingContexts().keySet()); |
| | | addAttribute(publicNamingContextAttr, dseUserAttrs, dseOperationalAttrs); |
| | | |
| | | // Add the "ds-private-naming-contexts" attribute. |
| | | Attribute privateNamingContextAttr = createAttribute( |
| | | ATTR_PRIVATE_NAMING_CONTEXTS, ATTR_PRIVATE_NAMING_CONTEXTS, |
| | | DirectoryServer.getPrivateNamingContexts().keySet()); |
| | | ATTR_PRIVATE_NAMING_CONTEXTS, DirectoryServer.getPrivateNamingContexts().keySet()); |
| | | addAttribute(privateNamingContextAttr, dseUserAttrs, dseOperationalAttrs); |
| | | |
| | | // Add the "supportedControl" attribute. |
| | | Attribute supportedControlAttr = createAttribute(ATTR_SUPPORTED_CONTROL, |
| | | ATTR_SUPPORTED_CONTROL_LC, DirectoryServer.getSupportedControls()); |
| | | DirectoryServer.getSupportedControls()); |
| | | addAttribute(supportedControlAttr, dseUserAttrs, dseOperationalAttrs); |
| | | |
| | | // Add the "supportedExtension" attribute. |
| | | Attribute supportedExtensionAttr = createAttribute( |
| | | ATTR_SUPPORTED_EXTENSION, ATTR_SUPPORTED_EXTENSION_LC, DirectoryServer |
| | | .getSupportedExtensions().keySet()); |
| | | ATTR_SUPPORTED_EXTENSION, DirectoryServer.getSupportedExtensions().keySet()); |
| | | addAttribute(supportedExtensionAttr, dseUserAttrs, dseOperationalAttrs); |
| | | |
| | | // Add the "supportedFeature" attribute. |
| | | Attribute supportedFeatureAttr = createAttribute(ATTR_SUPPORTED_FEATURE, |
| | | ATTR_SUPPORTED_FEATURE_LC, DirectoryServer.getSupportedFeatures()); |
| | | DirectoryServer.getSupportedFeatures()); |
| | | addAttribute(supportedFeatureAttr, dseUserAttrs, dseOperationalAttrs); |
| | | |
| | | // Add the "supportedSASLMechanisms" attribute. |
| | | Attribute supportedSASLMechAttr = createAttribute( |
| | | ATTR_SUPPORTED_SASL_MECHANISMS, ATTR_SUPPORTED_SASL_MECHANISMS_LC, |
| | | DirectoryServer.getSupportedSASLMechanisms().keySet()); |
| | | ATTR_SUPPORTED_SASL_MECHANISMS, DirectoryServer.getSupportedSASLMechanisms().keySet()); |
| | | addAttribute(supportedSASLMechAttr, dseUserAttrs, dseOperationalAttrs); |
| | | |
| | | // Add the "supportedLDAPVersions" attribute. |
| | |
| | | versionStrings.add(ldapVersion.toString()); |
| | | } |
| | | Attribute supportedLDAPVersionAttr = createAttribute( |
| | | ATTR_SUPPORTED_LDAP_VERSION, ATTR_SUPPORTED_LDAP_VERSION_LC, versionStrings); |
| | | ATTR_SUPPORTED_LDAP_VERSION, versionStrings); |
| | | addAttribute(supportedLDAPVersionAttr, dseUserAttrs, dseOperationalAttrs); |
| | | |
| | | // Add the "supportedAuthPasswordSchemes" attribute. |
| | | Attribute supportedAuthPWSchemesAttr = createAttribute( |
| | | ATTR_SUPPORTED_AUTH_PW_SCHEMES, ATTR_SUPPORTED_AUTH_PW_SCHEMES_LC, |
| | | DirectoryServer.getAuthPasswordStorageSchemes().keySet()); |
| | | ATTR_SUPPORTED_AUTH_PW_SCHEMES, DirectoryServer.getAuthPasswordStorageSchemes().keySet()); |
| | | addAttribute(supportedAuthPWSchemesAttr, dseUserAttrs, dseOperationalAttrs); |
| | | |
| | | |
| | |
| | | |
| | | // Add the "supportedTLSProtocols" attribute. |
| | | Attribute supportedTLSProtocolsAttr = createAttribute( |
| | | ATTR_SUPPORTED_TLS_PROTOCOLS, ATTR_SUPPORTED_TLS_PROTOCOLS_LC, |
| | | supportedTlsProtocols); |
| | | ATTR_SUPPORTED_TLS_PROTOCOLS, supportedTlsProtocols); |
| | | addAttribute(supportedTLSProtocolsAttr, dseUserAttrs, dseOperationalAttrs); |
| | | |
| | | // Add the "supportedTLSCiphers" attribute. |
| | | Attribute supportedTLSCiphersAttr = createAttribute( |
| | | ATTR_SUPPORTED_TLS_CIPHERS, ATTR_SUPPORTED_TLS_CIPHERS_LC, |
| | | supportedTlsCiphers); |
| | | ATTR_SUPPORTED_TLS_CIPHERS, supportedTlsCiphers); |
| | | addAttribute(supportedTLSCiphersAttr, dseUserAttrs, dseOperationalAttrs); |
| | | |
| | | addAll(staticDSEAttributes, dseUserAttrs, dseOperationalAttrs); |
| | |
| | | * |
| | | * @param name |
| | | * The name for the attribute. |
| | | * @param lowerName |
| | | * The name for the attribute formatted in all lowercase |
| | | * characters. |
| | | * @param values |
| | | * The set of values to use for the attribute. |
| | | * @return The constructed attribute. |
| | | */ |
| | | private Attribute createAttribute(String name, String lowerName, |
| | | Collection<? extends Object> values) |
| | | private Attribute createAttribute(String name, Collection<? extends Object> values) |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(lowerName, name); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(name); |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(type, name); |
| | | builder.addAllStrings(values); |
| | |
| | | private Attribute getSingleAttribute(Entry taskEntry, String attrName, Arg1<Object> noEntryErrorMsg, |
| | | Arg1<Object> multipleEntriesErrorMsg, Arg1<Object> noAttrValueErrorMsg) throws DirectoryException |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName.toLowerCase(), attrName); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName); |
| | | List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList.isEmpty()) |
| | | { |
| | |
| | | String messageString = buffer.toString(); |
| | | logMessages.add(messageString); |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | ATTR_TASK_LOG_MESSAGES.toLowerCase(), ATTR_TASK_LOG_MESSAGES); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_LOG_MESSAGES); |
| | | |
| | | final List<Attribute> attrList = taskEntry.getAttribute(type); |
| | | ByteString value = ByteString.valueOfUtf8(messageString); |
| | |
| | | throws DirectoryException |
| | | { |
| | | // Get the name of the class that implements the task logic. |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_CLASS.toLowerCase(), ATTR_TASK_CLASS); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_CLASS); |
| | | List<Attribute> attrList = entry.getAttribute(attrType); |
| | | if (attrList.isEmpty()) |
| | | { |
| | |
| | | */ |
| | | public ConfigAttribute getConfigAttribute(ConfigAttribute stub) throws ConfigException |
| | | { |
| | | String attrName = stub.getName(); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName.toLowerCase(), attrName); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(stub.getName()); |
| | | List<Attribute> attrList = entry.getAttribute(attrType); |
| | | return !attrList.isEmpty() ? stub.getConfigAttribute(attrList) : null; |
| | | } |
| | |
| | | { |
| | | // It's possible that this is a monitor attribute rather than a configurable |
| | | // one. Check all of those. |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(name.toLowerCase(), name); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(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.getAttributeTypeOrDefault(name.toLowerCase(), name); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(name); |
| | | |
| | | monitorLoop: |
| | | for (MonitorProvider<? extends MonitorProviderCfg> monitor : |
| | |
| | | { |
| | | if (attributeType == null && rawAttributeType != null) |
| | | { |
| | | String lowerName = toLowerCase(rawAttributeType); |
| | | attributeType = DirectoryServer.getAttributeTypeOrDefault(lowerName, rawAttributeType); |
| | | attributeType = DirectoryServer.getAttributeTypeOrDefault(rawAttributeType); |
| | | } |
| | | return attributeType; |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 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 getAttributeTypeOrDefault(String lowerName, String upperName) |
| | | { |
| | | return getAttributeType(upperName, getDefaultAttributeSyntax()); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the attribute type for the provided name or OID. It will return a generated |
| | | * placeholder version with the name or OID if the requested attribute type is not defined in the |
| | | * schema. |
| | |
| | | return authFailureTimes; |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_FAILURE_TIME_LC, OP_ATTR_PWPOLICY_FAILURE_TIME); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_FAILURE_TIME); |
| | | try |
| | | { |
| | | authFailureTimes = getGeneralizedTimes(type); |
| | |
| | | failureTimes.add(highestFailureTime); |
| | | |
| | | // And the attribute in the user entry |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_FAILURE_TIME_LC, OP_ATTR_PWPOLICY_FAILURE_TIME); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(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.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_FAILURE_TIME_LC, OP_ATTR_PWPOLICY_FAILURE_TIME); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_FAILURE_TIME); |
| | | modifications.add(new Modification(ModificationType.REPLACE, Attributes.empty(type), true)); |
| | | } |
| | | |
| | |
| | | return failureLockedTime; |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_LOCKED_TIME_LC, OP_ATTR_PWPOLICY_LOCKED_TIME); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_LOCKED_TIME); |
| | | try |
| | | { |
| | | failureLockedTime = getGeneralizedTime(userEntry, type); |
| | |
| | | |
| | | failureLockedTime = time; |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_LOCKED_TIME_LC, OP_ATTR_PWPOLICY_LOCKED_TIME); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(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.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_LOCKED_TIME_LC, OP_ATTR_PWPOLICY_LOCKED_TIME); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_LOCKED_TIME); |
| | | modifications.add(new Modification(ModificationType.REPLACE, Attributes.empty(type), true)); |
| | | } |
| | | |
| | |
| | | return false; |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_RESET_REQUIRED_LC, OP_ATTR_PWPOLICY_RESET_REQUIRED); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_RESET_REQUIRED); |
| | | try |
| | | { |
| | | mustChangePassword = getBoolean(userEntry, type); |
| | |
| | | return; // requested state matches current state |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_RESET_REQUIRED_LC, OP_ATTR_PWPOLICY_RESET_REQUIRED); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_RESET_REQUIRED); |
| | | this.mustChangePassword = ConditionResult.not(this.mustChangePassword); |
| | | if (mustChangePassword) |
| | | { |
| | |
| | | { |
| | | if (graceLoginTimes == null) |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME_LC, OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); |
| | | try |
| | | { |
| | | graceLoginTimes = getGeneralizedTimes(type); |
| | |
| | | long highestGraceTime = computeHighestTime(graceTimes); |
| | | graceTimes.add(highestGraceTime); // graceTimes == this.graceLoginTimes |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME_LC, OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(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.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME_LC, OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); |
| | | modifications.add(new Modification(ModificationType.REPLACE, Attributes.empty(type), true)); |
| | | } |
| | | |
| | |
| | | if (semicolonPos > 0) |
| | | { |
| | | String baseName = attributeType.substring(0, semicolonPos); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(toLowerCase(baseName), baseName); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(baseName); |
| | | options = new HashSet<>(); |
| | | StringTokenizer tokenizer = |
| | | new StringTokenizer(attributeType.substring(semicolonPos+1), ";"); |
| | |
| | | else |
| | | { |
| | | options = null; |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(toLowerCase(attributeType), attributeType); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(attributeType); |
| | | } |
| | | } |
| | | |
| | |
| | | HashSet<AttributeType> attributes = new HashSet<>(); |
| | | for (String attrName : attributeStrings) |
| | | { |
| | | attributes.add(DirectoryServer.getAttributeTypeOrDefault(attrName.toLowerCase(), attrName)); |
| | | attributes.add(DirectoryServer.getAttributeTypeOrDefault(attrName)); |
| | | } |
| | | return attributes; |
| | | } |
| | |
| | | final HashSet<AttributeType> attrTypes = new HashSet<>(attrNames.size()); |
| | | for (String attrName : attrNames) |
| | | { |
| | | attrTypes.add(DirectoryServer.getAttributeTypeOrDefault(attrName.toLowerCase(), attrName)); |
| | | attrTypes.add(DirectoryServer.getAttributeTypeOrDefault(attrName)); |
| | | } |
| | | return attrTypes; |
| | | } |
| | |
| | | Set<AttributeType> results = new HashSet<>(); |
| | | for (String attrName : attributeArg.getValues()) |
| | | { |
| | | results.add(DirectoryServer.getAttributeTypeOrDefault(attrName.toLowerCase(), attrName)); |
| | | results.add(DirectoryServer.getAttributeTypeOrDefault(attrName)); |
| | | } |
| | | return results; |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | excludeAttributes.add(DirectoryServer.getAttributeTypeOrDefault(lowerName, attrName)); |
| | | excludeAttributes.add(DirectoryServer.getAttributeTypeOrDefault(attrName)); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | includeAttributes.add(DirectoryServer.getAttributeTypeOrDefault(lowerName, attrName)); |
| | | includeAttributes.add(DirectoryServer.getAttributeTypeOrDefault(attrName)); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private static AttributeType getAttributeTypeOrDefault(String attributeName) |
| | | { |
| | | return DirectoryServer.getAttributeTypeOrDefault(toLowerCase(attributeName), attributeName); |
| | | return DirectoryServer.getAttributeTypeOrDefault(attributeName); |
| | | } |
| | | |
| | | /** The attribute type for this attribute. */ |
| | |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | /** |
| | | * This class contains various methods for manipulating |
| | |
| | | } |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | | private static AttributeType getAttributeTypeOrDefault(String attributeName) |
| | | { |
| | | return DirectoryServer.getAttributeTypeOrDefault(toLowerCase(attributeName), attributeName); |
| | | } |
| | | } |
| | |
| | | |
| | | private static RDN newRDN(ByteString attrName, ByteString value) |
| | | { |
| | | String lowerName = toLC(attrName); |
| | | String attributeNameString = attrName.toString(); |
| | | AttributeType attrType = getAttributeTypeOrDefault(lowerName, attributeNameString); |
| | | |
| | | return new RDN(attrType, attributeNameString, value); |
| | | String name = attrName.toString(); |
| | | AttributeType attrType = getAttributeTypeOrDefault(name); |
| | | return new RDN(attrType, name, value); |
| | | } |
| | | |
| | | private static void addValue(ByteString attributeName, RDN rdn, ByteString empty) |
| | | { |
| | | String lowerName = toLC(attributeName); |
| | | String attributeNameString = attributeName.toString(); |
| | | AttributeType attrType = getAttributeTypeOrDefault(lowerName, attributeNameString); |
| | | |
| | | rdn.addValue(attrType, attributeNameString, empty); |
| | | } |
| | | |
| | | private static String toLC(ByteString attributeName) |
| | | { |
| | | StringBuilder lowerName = new StringBuilder(); |
| | | toLowerCase(attributeName, lowerName, true); |
| | | return lowerName.toString(); |
| | | String name = attributeName.toString(); |
| | | AttributeType attrType = getAttributeTypeOrDefault(name); |
| | | rdn.addValue(attrType, name, empty); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | private static RDN newRDN(StringBuilder attributeName, ByteString value) |
| | | { |
| | | String name = attributeName.toString(); |
| | | String lowerName = toLowerCase(name); |
| | | AttributeType attrType = getAttributeTypeOrDefault(lowerName, name); |
| | | |
| | | String name = attributeName.toString(); |
| | | AttributeType attrType = getAttributeTypeOrDefault(name); |
| | | return new RDN(attrType, name, value); |
| | | } |
| | | |
| | | private static void addValue(StringBuilder attributeName, RDN rdn, ByteString empty) |
| | | { |
| | | String name = attributeName.toString(); |
| | | String lowerName = toLowerCase(name); |
| | | AttributeType attrType = getAttributeTypeOrDefault(lowerName, name); |
| | | |
| | | AttributeType attrType = getAttributeTypeOrDefault(name); |
| | | rdn.addValue(attrType, name, empty); |
| | | } |
| | | |
| | |
| | | // Create the new RDN with the provided information. However, |
| | | // don't return it yet because this could be a multi-valued RDN. |
| | | String name = attributeName.toString(); |
| | | String lowerName = toLowerCase(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); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(name); |
| | | |
| | | RDN rdn = new RDN(attrType, name, parsedValue.toByteString()); |
| | | |
| | |
| | | if (pos >= length) |
| | | { |
| | | name = attributeName.toString(); |
| | | lowerName = toLowerCase(name); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(lowerName.toString(), name); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(name); |
| | | |
| | | rdn.addValue(attrType, name, ByteString.empty()); |
| | | return rdn; |
| | |
| | | |
| | | // Update the RDN to include the new attribute/value. |
| | | name = attributeName.toString(); |
| | | lowerName = toLowerCase(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); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(name); |
| | | |
| | | rdn.addValue(attrType, name, parsedValue.toByteString()); |
| | | |
| | |
| | | String attrDescr = line.substring(0, colonPos); |
| | | final Attribute attribute = parseAttrDescription(attrDescr); |
| | | final String attrName = attribute.getName(); |
| | | final String lowerName = toLowerCase(attrName); |
| | | |
| | | // Now parse the attribute value. |
| | | ByteString value = parseSingleValue(lines, line, entryDN, |
| | | colonPos, attrName); |
| | | ByteString value = parseSingleValue(lines, line, entryDN, colonPos, attrName); |
| | | |
| | | // See if this is an objectclass or an attribute. Then get the |
| | | // corresponding definition and add the value to the appropriate hash. |
| | | if (lowerName.equals("objectclass")) |
| | | if (attrName.equalsIgnoreCase("objectclass")) |
| | | { |
| | | if (! importConfig.includeObjectClasses()) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(lowerName, attrName); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName); |
| | | if (! importConfig.includeAttribute(attrType)) |
| | | { |
| | | if (logger.isTraceEnabled()) |