| | |
| | | |
| | | import java.util.Collection; |
| | | |
| | | import org.forgerock.opendj.ldap.Assertion; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | /** |
| | | * This class provides default implementation of MatchingRule. A |
| | |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAssertionValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | // Default implementation is to use attribute value normalization. |
| | | return normalizeAttributeValue(value); |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Assertion getAssertion(final ByteSequence value) |
| | | throws DecodeException |
| | | { |
| | | final ByteString assertionValue = normalizeAssertionValue(value); |
| | | return new Assertion() |
| | | { |
| | | |
| | | @Override |
| | | public ConditionResult matches(ByteSequence attributeValue) |
| | | { |
| | | return valuesMatch(attributeValue, assertionValue); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isObsolete() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | * Indicates whether the provided attribute value should be |
| | | * considered a match for the given assertion value. This will only |
| | | * be used for the purpose of extensible matching. Subclasses |
| | | * should define more specific methods that are appropriate to the |
| | | * matching rule type. |
| | | * |
| | | * @param attributeValue |
| | | * The attribute value in a form that has been normalized |
| | | * according to this matching rule. |
| | | * @param assertionValue |
| | | * The assertion value in a form that has been normalized |
| | | * according to this matching rule. |
| | | * @return {@code TRUE} if the attribute value should be considered |
| | | * a match for the provided assertion value, {@code FALSE} |
| | | * if it does not match, or {@code UNDEFINED} if the result |
| | | * is undefined. |
| | | */ |
| | | @Override |
| | | public ConditionResult valuesMatch( |
| | | protected ConditionResult valuesMatch( |
| | | ByteSequence attributeValue, ByteSequence assertionValue) |
| | | { |
| | | //Default implementation of most rule types. |
| | |
| | | import java.util.Collection; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.types.IndexConfig; |
| | | |
| | | |
| | |
| | | * construct the index query. |
| | | * @return The index query appropriate for the provided attribute |
| | | * value assertion. |
| | | * @throws DirectoryException |
| | | * @throws DecodeException |
| | | * If an error occurs while generating the index query. |
| | | */ |
| | | <T> T createIndexQuery(ByteSequence assertionValue, |
| | | IndexQueryFactory<T> factory) throws DirectoryException; |
| | | IndexQueryFactory<T> factory) throws DecodeException; |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | | |
| | | |
| | | import java.util.Collection; |
| | | |
| | | import org.forgerock.opendj.ldap.Assertion; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This interface defines the set of methods that must be implemented |
| | |
| | | * @param value |
| | | * The assertion value to be normalized. |
| | | * @return The normalized version of the provided value. |
| | | * @throws DirectoryException |
| | | * @throws DecodeException |
| | | * If the provided value is invalid according to the |
| | | * associated attribute syntax. |
| | | */ |
| | | ByteString normalizeAssertionValue(ByteSequence value) |
| | | throws DirectoryException; |
| | | throws DecodeException; |
| | | |
| | | |
| | | |
| | |
| | | */ |
| | | Syntax getSyntax(); |
| | | |
| | | |
| | | /** |
| | | * Whole class to be replaced by the equivalent SDK class. |
| | | * |
| | | * @param value |
| | | * the value |
| | | * @return SDK syntax |
| | | * @throws DecodeException |
| | | * if problem |
| | | */ |
| | | Assertion getAssertion(final ByteSequence value) throws DecodeException; |
| | | |
| | | /** |
| | | * Indicates whether this matching rule is declared "OBSOLETE". The |
| | |
| | | * @param value |
| | | * The value to be normalized. |
| | | * @return The normalized version of the provided value. |
| | | * @throws DirectoryException |
| | | * @throws DecodeException |
| | | * If the provided value is invalid according to the |
| | | * associated attribute syntax. |
| | | */ |
| | | ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the provided attribute value should be |
| | | * considered a match for the given assertion value. This will only |
| | | * be used for the purpose of extensible matching. Subclasses |
| | | * should define more specific methods that are appropriate to the |
| | | * matching rule type. |
| | | * |
| | | * @param attributeValue |
| | | * The attribute value in a form that has been normalized |
| | | * according to this matching rule. |
| | | * @param assertionValue |
| | | * The assertion value in a form that has been normalized |
| | | * according to this matching rule. |
| | | * @return {@code TRUE} if the attribute value should be considered |
| | | * a match for the provided assertion value, {@code FALSE} |
| | | * if it does not match, or {@code UNDEFINED} if the result |
| | | * is undefined. |
| | | */ |
| | | ConditionResult valuesMatch( |
| | | ByteSequence attributeValue, ByteSequence assertionValue); |
| | | |
| | | |
| | | throws DecodeException; |
| | | |
| | | /** |
| | | * Appends a string representation of this matching rule in the |
| | |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | | |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | |
| | | /** |
| | | * This class defines the set of methods and structures that must be |
| | |
| | | * |
| | | * @return The normalized form of the value fragment. |
| | | * |
| | | * @throws DirectoryException If the provided value fragment is |
| | | * @throws DecodeException If the provided value fragment is |
| | | * not acceptable according to the |
| | | * associated syntax. |
| | | */ |
| | | public abstract ByteString normalizeSubstring( |
| | | ByteSequence substring) throws DirectoryException; |
| | | ByteSequence substring) throws DecodeException; |
| | | |
| | | |
| | | |
| | |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.authorization.dseecompat; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import static org.opends.messages.AccessControlMessages. |
| | | WARN_PATTERN_DN_TYPE_CONTAINS_SUBSTRINGS; |
| | | import static org.opends.messages.AccessControlMessages. |
| | | WARN_PATTERN_DN_TYPE_WILDCARD_IN_MULTIVALUED_RDN; |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | import java.util.TreeMap; |
| | | import java.util.Set; |
| | | import java.util.Iterator; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.AccessControlMessages.*; |
| | | |
| | | /** |
| | | * This class is used to match RDN patterns containing wildcards in either |
| | | * the attribute types or the attribute values. |
| | |
| | | return mr.areEqual(thisNormValue, thatNormValue); |
| | | } |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | | return false; |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import java.util.*; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.ApproximateMatchingRule; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | | * An implementation of an Indexer for attribute approximate matching. |
| | |
| | | * used to name an index created using this object. |
| | | * @return A string representation of this object. |
| | | */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return attributeType.getNameOrOID() + ".approximate"; |
| | |
| | | * |
| | | * @return A byte array comparator. |
| | | */ |
| | | @Override |
| | | public Comparator<byte[]> getComparator() |
| | | { |
| | | return comparator; |
| | |
| | | * @param entry The entry. |
| | | * @param keys The set into which the generated keys will be inserted. |
| | | */ |
| | | @Override |
| | | public void indexEntry(Entry entry, Set<byte[]> keys) |
| | | { |
| | | List<Attribute> attrList = |
| | |
| | | * @param newEntry The new entry contents. |
| | | * @param modifiedKeys The map into which the modified keys will be inserted. |
| | | */ |
| | | @Override |
| | | public void replaceEntry(Entry oldEntry, Entry newEntry, |
| | | Map<byte[], Boolean> modifiedKeys) |
| | | { |
| | |
| | | * @param mods The set of modifications that were applied to the entry. |
| | | * @param modifiedKeys The map into which the modified keys will be inserted. |
| | | */ |
| | | @Override |
| | | public void modifyEntry(Entry oldEntry, Entry newEntry, |
| | | List<Modification> mods, |
| | | Map<byte[], Boolean> modifiedKeys) |
| | |
| | | |
| | | keys.add(keyBytes); |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | |
| | | modifiedKeys.remove(keyBytes); |
| | | } |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn; |
| | | import org.opends.server.admin.std.server.LocalDBIndexCfg; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.monitors.DatabaseEnvironmentMonitor; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import com.sleepycat.je.*; |
| | |
| | | * Open the attribute index. |
| | | * |
| | | * @throws DatabaseException if a JE database error occurs while |
| | | * openning the index. |
| | | * opening the index. |
| | | */ |
| | | public void open() throws DatabaseException |
| | | { |
| | |
| | | } |
| | | return idSet; |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | return new EntryIDSet(); |
| | |
| | | } |
| | | return idSet; |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | return new EntryIDSet(); |
| | |
| | | } |
| | | return idSet; |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | return new EntryIDSet(); |
| | |
| | | |
| | | return results; |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | return new EntryIDSet(); |
| | |
| | | // Read the range: lower <= keys <= upper. |
| | | return orderingIndex.readRange(lower, upper, true, true); |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | return new EntryIDSet(); |
| | |
| | | } |
| | | return idSet; |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | return new EntryIDSet(); |
| | |
| | | } |
| | | return idSet; |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | return IndexQuery.createNullIndexQuery().evaluate(null); |
| | |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.OrderingMatchingRule; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * An implementation of an Indexer for attribute ordering. |
| | | */ |
| | |
| | | * used to name an index created using this object. |
| | | * @return A string representation of this object. |
| | | */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return attributeType.getNameOrOID() + ".ordering"; |
| | |
| | | * |
| | | * @return A byte array comparator. |
| | | */ |
| | | @Override |
| | | public Comparator<byte[]> getComparator() |
| | | { |
| | | return orderingRule; |
| | |
| | | * @param entry The entry. |
| | | * @param keys The set into which the generated keys will be inserted. |
| | | */ |
| | | @Override |
| | | public void indexEntry(Entry entry, Set<byte[]> keys) |
| | | { |
| | | List<Attribute> attrList = |
| | |
| | | * @param newEntry The new entry contents. |
| | | * @param modifiedKeys The map into which the modified keys will be inserted. |
| | | */ |
| | | @Override |
| | | public void replaceEntry(Entry oldEntry, Entry newEntry, |
| | | Map<byte[], Boolean> modifiedKeys) |
| | | { |
| | |
| | | * @param mods The set of modifications that were applied to the entry. |
| | | * @param modifiedKeys The map into which the modified keys will be inserted. |
| | | */ |
| | | @Override |
| | | public void modifyEntry(Entry oldEntry, Entry newEntry, |
| | | List<Modification> mods, |
| | | Map<byte[], Boolean> modifiedKeys) |
| | |
| | | |
| | | keys.add(keyBytes); |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | |
| | | modifiedKeys.remove(keyBytes); |
| | | } |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | import java.util.*; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.SubstringMatchingRule; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | | * An implementation of an Indexer for attribute substrings. |
| | |
| | | * used to name an index created using this object. |
| | | * @return A string representation of this object. |
| | | */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return attributeType.getNameOrOID() + ".substring"; |
| | |
| | | * |
| | | * @return A byte array comparator. |
| | | */ |
| | | @Override |
| | | public Comparator<byte[]> getComparator() |
| | | { |
| | | return comparator; |
| | |
| | | * @param entry The entry. |
| | | * @param keys The set into which the generated keys will be inserted. |
| | | */ |
| | | @Override |
| | | public void indexEntry(Entry entry, Set<byte[]> keys) |
| | | { |
| | | List<Attribute> attrList = |
| | |
| | | * @param newEntry The new entry contents. |
| | | * @param modifiedKeys The map into which the modified keys will be inserted. |
| | | */ |
| | | @Override |
| | | public void replaceEntry(Entry oldEntry, Entry newEntry, |
| | | Map<byte[], Boolean> modifiedKeys) |
| | | { |
| | |
| | | * @param mods The set of modifications that were applied to the entry. |
| | | * @param modifiedKeys The map into which the modified keys will be inserted. |
| | | */ |
| | | @Override |
| | | public void modifyEntry(Entry oldEntry, Entry newEntry, |
| | | List<Modification> mods, |
| | | Map<byte[], Boolean> modifiedKeys) |
| | |
| | | |
| | | substringKeys(normalizedBytes, keys); |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | |
| | | |
| | | substringKeys(normalizedBytes, modifiedKeys, insert); |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.api.ApproximateMatchingRule; |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.api.OrderingMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | |
| | | OrderingMatchingRule orderingRule = |
| | | attr.getAttributeType().getOrderingMatchingRule(); |
| | | |
| | | normalizedBytes = |
| | | orderingRule.normalizeAttributeValue(value.getValue()).toByteArray(); |
| | | normalizedBytes = normalizeAttributeValue(orderingRule, value); |
| | | |
| | | DatabaseEntry key = new DatabaseEntry(normalizedBytes); |
| | | try |
| | |
| | | ApproximateMatchingRule approximateRule = |
| | | attr.getAttributeType().getApproximateMatchingRule(); |
| | | |
| | | normalizedBytes = |
| | | approximateRule.normalizeAttributeValue(value.getValue()).toByteArray(); |
| | | normalizedBytes = normalizeAttributeValue(approximateRule, value); |
| | | |
| | | DatabaseEntry key = new DatabaseEntry(normalizedBytes); |
| | | try |
| | |
| | | } |
| | | } |
| | | |
| | | private byte[] normalizeAttributeValue(MatchingRule matchingRule, |
| | | AttributeValue value) throws DirectoryException |
| | | { |
| | | try |
| | | { |
| | | return matchingRule.normalizeAttributeValue(value.getValue()) |
| | | .toByteArray(); |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | e.getMessageObject(), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Get the parent DN of a given DN. |
| | | * |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.Assertion; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | |
| | | switch (matchType) |
| | | { |
| | | case EQUALITY_MATCH_TYPE: |
| | | if ((attributeType != null) && (type != null) && |
| | | attributeType.equals(type) && (rawAssertionValue != null) && |
| | | (value != null) && (equalityMatchingRule != null)) |
| | | if (attributeType != null |
| | | && attributeType.equals(type) |
| | | && rawAssertionValue != null |
| | | && value != null |
| | | && equalityMatchingRule != null) |
| | | { |
| | | try |
| | | { |
| | |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | return false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | return false; |
| | | |
| | | |
| | | case SUBSTRINGS_TYPE: |
| | | if ((attributeType != null) && (type != null) && |
| | | attributeType.equals(type) && (substringMatchingRule != null)) |
| | | if (attributeType != null |
| | | && attributeType.equals(type) |
| | | && substringMatchingRule != null) |
| | | { |
| | | try |
| | | { |
| | |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | return false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | return false; |
| | | |
| | | |
| | | case GREATER_OR_EQUAL_TYPE: |
| | | if ((attributeType != null) && (type != null) && |
| | | attributeType.equals(type) && (assertionValue != null) && |
| | | (value != null) && (orderingMatchingRule != null)) |
| | | if (attributeType != null |
| | | && attributeType.equals(type) |
| | | && assertionValue != null |
| | | && value != null |
| | | && orderingMatchingRule != null) |
| | | { |
| | | try |
| | | { |
| | | return (orderingMatchingRule.compareValues( |
| | | return orderingMatchingRule.compareValues( |
| | | assertionValue.getNormalizedValue(), |
| | | orderingMatchingRule.normalizeAttributeValue( |
| | | value.getValue())) >= 0); |
| | | value.getValue())) >= 0; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | return false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | return false; |
| | | |
| | | |
| | | case LESS_OR_EQUAL_TYPE: |
| | | if ((attributeType != null) && (type != null) && |
| | | attributeType.equals(type) && (assertionValue != null) && |
| | | (value != null) && (orderingMatchingRule != null)) |
| | | if (attributeType != null |
| | | && attributeType.equals(type) |
| | | && assertionValue != null |
| | | && value != null |
| | | && orderingMatchingRule != null) |
| | | { |
| | | try |
| | | { |
| | | return (orderingMatchingRule.compareValues( |
| | | return orderingMatchingRule.compareValues( |
| | | assertionValue.getNormalizedValue(), |
| | | orderingMatchingRule.normalizeAttributeValue( |
| | | value.getValue())) <= 0); |
| | | value.getValue())) <= 0; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | return false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | return false; |
| | | |
| | | |
| | | case PRESENT_TYPE: |
| | | return ((attributeType != null) && (type != null) && |
| | | attributeType.equals(type)); |
| | | return attributeType != null && attributeType.equals(type); |
| | | |
| | | |
| | | case APPROXIMATE_MATCH_TYPE: |
| | | if ((attributeType != null) && (type != null) && |
| | | attributeType.equals(type) && (assertionValue != null) && |
| | | (value != null) && (approximateMatchingRule != null)) |
| | | if (attributeType != null |
| | | && attributeType.equals(type) |
| | | && assertionValue != null |
| | | && value != null |
| | | && approximateMatchingRule != null) |
| | | { |
| | | try |
| | | { |
| | |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | return false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | return false; |
| | | |
| | | |
| | | case EXTENSIBLE_MATCH_TYPE: |
| | | if ((assertionValue == null) || (value == null)) |
| | | if (assertionValue == null || value == null) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | { |
| | | ByteString nv1 = |
| | | matchingRule.normalizeAttributeValue(value.getValue()); |
| | | ByteString nv2 = |
| | | matchingRule.normalizeAttributeValue(assertionValue.getValue()); |
| | | |
| | | return (matchingRule.valuesMatch(nv1, nv2) == ConditionResult.TRUE); |
| | | Assertion assertion = matchingRule.getAssertion(assertionValue.getValue()); |
| | | return assertion.matches(nv1) == ConditionResult.TRUE; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | |
| | | import java.util.StringTokenizer; |
| | | import java.util.Collection; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | { |
| | | boolean hasEscape = false; |
| | | byte[] valueBytes = getBytes(valueStr); |
| | | for (int i=0; i < valueBytes.length; i++) |
| | | for (byte valueByte : valueBytes) |
| | | { |
| | | if (valueBytes[i] == 0x5C) // The backslash character |
| | | if (valueByte == 0x5C) // The backslash character |
| | | { |
| | | hasEscape = true; |
| | | break; |
| | |
| | | // Parse out the attribute value. |
| | | byte[] valueBytes = getBytes(filterString.substring(equalPos+1, endPos)); |
| | | boolean hasEscape = false; |
| | | for (int i=0; i < valueBytes.length; i++) |
| | | for (byte valueByte : valueBytes) |
| | | { |
| | | if (valueBytes[i] == 0x5C) |
| | | if (valueByte == 0x5C) |
| | | { |
| | | hasEscape = true; |
| | | break; |
| | |
| | | * |
| | | * @return The filter type for this search filter. |
| | | */ |
| | | @Override |
| | | public FilterType getFilterType() |
| | | { |
| | | return filterType; |
| | |
| | | * @return The set of subordinate filter components for AND and OR searches, |
| | | * or <CODE>null</CODE> if this is not an AND or OR search. |
| | | */ |
| | | @Override |
| | | public ArrayList<RawFilter> getFilterComponents() |
| | | { |
| | | return filterComponents; |
| | |
| | | * @return The subordinate filter component for NOT searches, or |
| | | * <CODE>null</CODE> if this is not a NOT search. |
| | | */ |
| | | @Override |
| | | public RawFilter getNOTComponent() |
| | | { |
| | | return notComponent; |
| | |
| | | * @return The attribute type for this search filter, or <CODE>null</CODE> if |
| | | * there is none. |
| | | */ |
| | | @Override |
| | | public String getAttributeType() |
| | | { |
| | | return attributeType; |
| | |
| | | * @return The assertion value for this search filter, or <CODE>null</CODE> |
| | | * if there is none. |
| | | */ |
| | | @Override |
| | | public ByteString getAssertionValue() |
| | | { |
| | | return assertionValue; |
| | |
| | | * @return The subInitial component for this substring filter, or |
| | | * <CODE>null</CODE> if there is none. |
| | | */ |
| | | @Override |
| | | public ByteString getSubInitialElement() |
| | | { |
| | | return subInitialElement; |
| | |
| | | * @return The set of subAny elements for this substring filter, or |
| | | * <CODE>null</CODE> if there are none. |
| | | */ |
| | | @Override |
| | | public ArrayList<ByteString> getSubAnyElements() |
| | | { |
| | | return subAnyElements; |
| | |
| | | * @return The subFinal element for this substring filter, or |
| | | * <CODE>null</CODE> if there is none. |
| | | */ |
| | | @Override |
| | | public ByteString getSubFinalElement() |
| | | { |
| | | return subFinalElement; |
| | |
| | | * @return The matching rule ID for this extensible match filter, or |
| | | * <CODE>null</CODE> if there is none. |
| | | */ |
| | | @Override |
| | | public String getMatchingRuleID() |
| | | { |
| | | return matchingRuleID; |
| | |
| | | * @return The value of the DN attributes flag for this extensibleMatch |
| | | * filter. |
| | | */ |
| | | @Override |
| | | public boolean getDNAttributes() |
| | | { |
| | | return dnAttributes; |
| | |
| | | * @throws DirectoryException If a problem occurs while attempting to |
| | | * construct the search filter. |
| | | */ |
| | | @Override |
| | | public SearchFilter toSearchFilter() |
| | | throws DirectoryException |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | ByteString normalizedValue = mr.normalizeAttributeValue(assertionValue); |
| | | value = AttributeValues.create(assertionValue, |
| | | normalizedValue); |
| | | try |
| | | { |
| | | ByteString normalizedValue = |
| | | mr.normalizeAttributeValue(assertionValue); |
| | | value = AttributeValues.create(assertionValue, normalizedValue); |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | e.getMessageObject(), e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | * |
| | | * @param buffer The buffer to which the information should be appended. |
| | | */ |
| | | @Override |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | switch (filterType) |
| | |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.hexStringToByteArray; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | |
| | | import org.opends.server.api.AbstractMatchingRule; |
| | | import org.opends.server.api.OrderingMatchingRule; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.AbstractMatchingRule; |
| | | import org.opends.server.api.OrderingMatchingRule; |
| | | |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * Used to establish an order between historical information and index them. |
| | |
| | | * @param value2 second value to compare |
| | | * @return 0 when equals, -1 or 1 to establish order |
| | | */ |
| | | @Override |
| | | public int compareValues(ByteSequence value1, ByteSequence value2) |
| | | { |
| | | return value1.compareTo(value2); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Collection<String> getNames() |
| | | { |
| | | return Collections.singleton("historicalCsnOrderingMatch"); |
| | |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | /* |
| | | * Change the format of the value to index and start with the serverId. In |
| | | * that manner, the search response time is optimised for a particular |
| | | * that manner, the search response time is optimized for a particular |
| | | * serverId. The format of the key is now : serverId + timestamp + seqNum |
| | | */ |
| | | try |
| | |
| | | { |
| | | // This should never occur in practice since these attributes are managed |
| | | // internally. |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | WARN_INVALID_SYNC_HIST_VALUE.get(value), e); |
| | | throw DecodeException.error(WARN_INVALID_SYNC_HIST_VALUE.get(value), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public int compare(byte[] b1, byte[] b2) |
| | | { |
| | | /* |
| | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | // We will not alter the value in any way. |
| | | return value.toByteString(); |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | try |
| | | { |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw de; |
| | | throw DecodeException.error(de.getMessageObject(), de); |
| | | case WARN: |
| | | logger.error(de.getMessageObject()); |
| | | return ByteString.valueOf(value.toString()); |
| | | default: |
| | | return ByteString.valueOf(value.toString()); |
| | | break; |
| | | } |
| | | return ByteString.valueOf(value.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | String valueString = value.toString().toUpperCase(); |
| | | |
| | | int length = valueString.length(); |
| | | if (length < 3) |
| | | { |
| | | return reportInvalidSyntax(valueString, |
| | | WARN_ATTR_SYNTAX_BIT_STRING_TOO_SHORT.get(value)); |
| | | reportInvalidSyntax(WARN_ATTR_SYNTAX_BIT_STRING_TOO_SHORT.get(value)); |
| | | return ByteString.valueOf(valueString); |
| | | } |
| | | |
| | | if ((valueString.charAt(0) != '\'') || |
| | | (valueString.charAt(length-2) != '\'') || |
| | | (valueString.charAt(length-1) != 'B')) |
| | | { |
| | | return reportInvalidSyntax(valueString, |
| | | WARN_ATTR_SYNTAX_BIT_STRING_NOT_QUOTED.get(value)); |
| | | reportInvalidSyntax(WARN_ATTR_SYNTAX_BIT_STRING_NOT_QUOTED.get(value)); |
| | | return ByteString.valueOf(valueString); |
| | | } |
| | | |
| | | for (int i=1; i < (length-2); i++) |
| | |
| | | // These characters are fine. |
| | | break; |
| | | default: |
| | | |
| | | return reportInvalidSyntax(valueString, |
| | | WARN_ATTR_SYNTAX_BIT_STRING_INVALID_BIT.get(value, valueString.charAt(i))); |
| | | reportInvalidSyntax(WARN_ATTR_SYNTAX_BIT_STRING_INVALID_BIT.get( |
| | | value, valueString.charAt(i))); |
| | | return ByteString.valueOf(valueString); |
| | | } |
| | | } |
| | | |
| | | return ByteString.valueOf(valueString); |
| | | } |
| | | |
| | | private ByteString reportInvalidSyntax(String valueString, LocalizableMessage message) |
| | | throws DirectoryException |
| | | private void reportInvalidSyntax(LocalizableMessage message) |
| | | throws DecodeException |
| | | { |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | case WARN: |
| | | logger.error(message); |
| | | return ByteString.valueOf(valueString); |
| | | default: |
| | | return ByteString.valueOf(valueString); |
| | | case REJECT: |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | logger.error(message); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | String valueString = value.toString().toUpperCase(); |
| | | if (valueString.equals("TRUE") || valueString.equals("YES") || |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | logger.error(message); |
| | | return ByteString.valueOf(valueString); |
| | | default: |
| | | return ByteString.valueOf(valueString); |
| | | break; |
| | | } |
| | | return ByteString.valueOf(valueString); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.schema.StringPrepProfile.*; |
| | | |
| | | |
| | | /** |
| | | * This class defines the caseExactMatch matching rule defined in X.520 and |
| | | * referenced in RFC 4519. |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD); |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD); |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logger.error(message); |
| | | logged = true; |
| | | } |
| | | |
| | | buffer.delete(pos, pos+1); |
| | | break; |
| | | |
| | | default: |
| | | buffer.delete(pos, pos+1); |
| | | break; |
| | | } |
| | | buffer.delete(pos, pos + 1); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.SubstringMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | buffer.append(value.toString().trim()); |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logger.error(message); |
| | | logged = true; |
| | | } |
| | | |
| | | buffer.delete(pos, pos+1); |
| | | break; |
| | | |
| | | default: |
| | | buffer.delete(pos, pos+1); |
| | | break; |
| | | } |
| | | buffer.delete(pos, pos+1); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * @return The normalized form of the value fragment. |
| | | * |
| | | * @throws DirectoryException If the provided value fragment is not |
| | | * @throws DecodeException If the provided value fragment is not |
| | | * acceptable according to the associated syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeSubstring(ByteSequence substring) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | // In this case, the process for normalizing a substring is the same as |
| | | // normalizing a full value with the exception that it may include an |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logger.error(message); |
| | | logged = true; |
| | | } |
| | | |
| | | buffer.delete(pos, pos+1); |
| | | break; |
| | | |
| | | default: |
| | | buffer.delete(pos, pos+1); |
| | | break; |
| | | } |
| | | buffer.delete(pos, pos + 1); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.AbstractMatchingRule; |
| | | import org.opends.server.api.OrderingMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD); |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.SubstringMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD); |
| | |
| | | * |
| | | * @return The normalized form of the value fragment. |
| | | * |
| | | * @throws DirectoryException If the provided value fragment is not |
| | | * @throws DecodeException If the provided value fragment is not |
| | | * acceptable according to the associated syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeSubstring(ByteSequence substring) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | // In this case, the process for normalizing a substring is the same as |
| | | // normalizing a full value with the exception that it may include an |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, CASE_FOLD); |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.schema.StringPrepProfile.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class implements the caseIgnoreIA5Match matching rule defined in RFC |
| | | * 2252. |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, CASE_FOLD); |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logger.error(message); |
| | | logged = true; |
| | | } |
| | | |
| | | buffer.delete(pos, pos+1); |
| | | break; |
| | | |
| | | default: |
| | | buffer.delete(pos, pos+1); |
| | | break; |
| | | } |
| | | buffer.delete(pos, pos+1); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.SubstringMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, CASE_FOLD); |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logger.error(message); |
| | | logged = true; |
| | | } |
| | | |
| | | buffer.delete(pos, pos+1); |
| | | break; |
| | | |
| | | default: |
| | | buffer.delete(pos, pos+1); |
| | | break; |
| | | } |
| | | buffer.delete(pos, pos + 1); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * @return The normalized form of the value fragment. |
| | | * |
| | | * @throws DirectoryException If the provided value fragment is not |
| | | * @throws DecodeException If the provided value fragment is not |
| | | * acceptable according to the associated syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeSubstring(ByteSequence substring) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | // In this case, the process for normalizing a substring is the same as |
| | | // normalizing a full value with the exception that it may include an |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logger.error(message); |
| | | logged = true; |
| | | } |
| | | |
| | | buffer.delete(pos, pos+1); |
| | | break; |
| | | |
| | | default: |
| | | buffer.delete(pos, pos+1); |
| | | break; |
| | | } |
| | | buffer.delete(pos, pos+1); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, CASE_FOLD); |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.SubstringMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, CASE_FOLD); |
| | |
| | | * |
| | | * @return The normalized form of the value fragment. |
| | | * |
| | | * @throws DirectoryException If the provided value fragment is not |
| | | * @throws DecodeException If the provided value fragment is not |
| | | * acceptable according to the associated syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeSubstring(ByteSequence substring) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | // In this case, the process for normalizing a substring is the same as |
| | | // normalizing a full value with the exception that it may include an |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.AbstractMatchingRule; |
| | | import org.opends.server.api.OrderingMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, CASE_FOLD); |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.SubstringMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, CASE_FOLD); |
| | |
| | | * |
| | | * @return The normalized form of the value fragment. |
| | | * |
| | | * @throws DirectoryException If the provided value fragment is not |
| | | * @throws DecodeException If the provided value fragment is not |
| | | * acceptable according to the associated syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeSubstring(ByteSequence substring) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | // In this case, the process for normalizing a substring is the same as |
| | | // normalizing a full value with the exception that it may include an |
| | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.asn1.GSERException; |
| | | import org.opends.server.protocols.asn1.GSERParser; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | // The normalized form of this value is the GSER encoded .... |
| | | final BigInteger serialNumber; |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | logger.error(message); |
| | | |
| | | certificateIssuer= toLowerCase(dnstring); |
| | | break; |
| | | |
| | | default: |
| | | certificateIssuer= toLowerCase(dnstring); |
| | | break; |
| | | } |
| | | certificateIssuer= toLowerCase(dnstring); |
| | | } |
| | | |
| | | // Create the encoded value |
| | |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAssertionValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | // validate and normalize the GSER structure |
| | | // according to the definitions from RFC 4523, Appendix A.1 |
| | |
| | | { |
| | | LocalizableMessage message = ERR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND |
| | | .get(GSER_ID_SERIALNUMBER); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | // The value for the serialNumber |
| | |
| | | { |
| | | LocalizableMessage message = ERR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND |
| | | .get(GSER_ID_ISSUER); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | // expecting "rdnSequence:" |
| | |
| | | { |
| | | LocalizableMessage message = ERR_CERTIFICATE_MATCH_IDENTIFIER_NOT_FOUND |
| | | .get(GSER_ID_RDNSEQUENCE); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | // now the issuer dn |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | logger.error(message); |
| | | break; |
| | |
| | | { |
| | | LocalizableMessage message = ERR_CERTIFICATE_MATCH_GSER_INVALID.get( |
| | | getExceptionMessage(e)); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | // Normalize the DN |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | logger.error(message); |
| | | |
| | | certificateIssuer= toLowerCase(dnstring); |
| | | break; |
| | | |
| | | default: |
| | | certificateIssuer= toLowerCase(dnstring); |
| | | break; |
| | | } |
| | | certificateIssuer = toLowerCase(dnstring); |
| | | } |
| | | |
| | | // Create the encoded value |
| | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.meta.CollationMatchingRuleCfgDefn.MatchingRuleType; |
| | | import org.opends.server.admin.std.server.CollationMatchingRuleCfg; |
| | |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class is a factory class for Collation matching rules. It |
| | |
| | | |
| | | |
| | | /** |
| | | * Evaluates and converts 2 consecutive characters of the provided string |
| | | * starting at startPos and converts them into a single escaped char. |
| | | * |
| | | * @param hexString |
| | | * The hexadecimal string containing the escape sequence. |
| | | * @param startPos |
| | | * The starting position of the hexadecimal escape sequence. |
| | | * @return The escaped character |
| | | * @throws DecodeException |
| | | * If the provided string contains invalid hexadecimal digits . |
| | | */ |
| | | private static char hexToEscapedChar(String hexString, int startPos) |
| | | throws DecodeException |
| | | { |
| | | // The two positions must be the hex characters that |
| | | // comprise the escaped value. |
| | | if ((startPos + 1) >= hexString.length()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE.get(hexString, |
| | | startPos + 1); |
| | | throw DecodeException.error(message); |
| | | } |
| | | byte byteValue = 0; |
| | | switch (hexString.charAt(startPos)) |
| | | { |
| | | case 0x30: // '0' |
| | | break; |
| | | case 0x31: // '1' |
| | | byteValue = (byte) 0x10; |
| | | break; |
| | | case 0x32: // '2' |
| | | byteValue = (byte) 0x20; |
| | | break; |
| | | case 0x33: // '3' |
| | | byteValue = (byte) 0x30; |
| | | break; |
| | | case 0x34: // '4' |
| | | byteValue = (byte) 0x40; |
| | | break; |
| | | case 0x35: // '5' |
| | | byteValue = (byte) 0x50; |
| | | break; |
| | | case 0x36: // '6' |
| | | byteValue = (byte) 0x60; |
| | | break; |
| | | case 0x37: // '7' |
| | | byteValue = (byte) 0x70; |
| | | break; |
| | | case 0x38: // '8' |
| | | byteValue = (byte) 0x80; |
| | | break; |
| | | case 0x39: // '9' |
| | | byteValue = (byte) 0x90; |
| | | break; |
| | | case 0x41: // 'A' |
| | | case 0x61: // 'a' |
| | | byteValue = (byte) 0xA0; |
| | | break; |
| | | case 0x42: // 'B' |
| | | case 0x62: // 'b' |
| | | byteValue = (byte) 0xB0; |
| | | break; |
| | | case 0x43: // 'C' |
| | | case 0x63: // 'c' |
| | | byteValue = (byte) 0xC0; |
| | | break; |
| | | case 0x44: // 'D' |
| | | case 0x64: // 'd' |
| | | byteValue = (byte) 0xD0; |
| | | break; |
| | | case 0x45: // 'E' |
| | | case 0x65: // 'e' |
| | | byteValue = (byte) 0xE0; |
| | | break; |
| | | case 0x46: // 'F' |
| | | case 0x66: // 'f' |
| | | byteValue = (byte) 0xF0; |
| | | break; |
| | | default: |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE.get(hexString, startPos); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | switch (hexString.charAt(++startPos)) |
| | | { |
| | | case 0x30: // '0' |
| | | break; |
| | | case 0x31: // '1' |
| | | byteValue |= (byte) 0x01; |
| | | break; |
| | | case 0x32: // '2' |
| | | byteValue |= (byte) 0x02; |
| | | break; |
| | | case 0x33: // '3' |
| | | byteValue |= (byte) 0x03; |
| | | break; |
| | | case 0x34: // '4' |
| | | byteValue |= (byte) 0x04; |
| | | break; |
| | | case 0x35: // '5' |
| | | byteValue |= (byte) 0x05; |
| | | break; |
| | | case 0x36: // '6' |
| | | byteValue |= (byte) 0x06; |
| | | break; |
| | | case 0x37: // '7' |
| | | byteValue |= (byte) 0x07; |
| | | break; |
| | | case 0x38: // '8' |
| | | byteValue |= (byte) 0x08; |
| | | break; |
| | | case 0x39: // '9' |
| | | byteValue |= (byte) 0x09; |
| | | break; |
| | | case 0x41: // 'A' |
| | | case 0x61: // 'a' |
| | | byteValue |= (byte) 0x0A; |
| | | break; |
| | | case 0x42: // 'B' |
| | | case 0x62: // 'b' |
| | | byteValue |= (byte) 0x0B; |
| | | break; |
| | | case 0x43: // 'C' |
| | | case 0x63: // 'c' |
| | | byteValue |= (byte) 0x0C; |
| | | break; |
| | | case 0x44: // 'D' |
| | | case 0x64: // 'd' |
| | | byteValue |= (byte) 0x0D; |
| | | break; |
| | | case 0x45: // 'E' |
| | | case 0x65: // 'e' |
| | | byteValue |= (byte) 0x0E; |
| | | break; |
| | | case 0x46: // 'F' |
| | | case 0x66: // 'f' |
| | | byteValue |= (byte) 0x0F; |
| | | break; |
| | | default: |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE.get(hexString, startPos); |
| | | throw DecodeException.error(message); |
| | | } |
| | | return (char) byteValue; |
| | | } |
| | | |
| | | /** |
| | | * Collation Extensible matching rule. |
| | | */ |
| | | private abstract class CollationMatchingRule |
| | |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | CollationKey key = collator.getCollationKey(value.toString()); |
| | | return ByteString.wrap(key.toByteArray()); |
| | |
| | | */ |
| | | @Override |
| | | public <T> T createIndexQuery(ByteSequence assertionValue, |
| | | IndexQueryFactory<T> factory) throws DirectoryException |
| | | IndexQueryFactory<T> factory) throws DecodeException |
| | | { |
| | | // Normalize the assertion value. |
| | | return factory.createExactMatchQuery(indexer |
| | |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | CollationKey key = collator.getCollationKey(value.toString()); |
| | | return ByteString.wrap(key.toByteArray()); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Parses the assertion from a given value. |
| | | * |
| | | * @param value |
| | | * The value that needs to be parsed. |
| | | * @return The parsed Assertion object containing the |
| | | * @throws org.opends.server.types.DirectoryException |
| | | */ |
| | | private Assertion parseAssertion(ByteSequence value) |
| | | throws DirectoryException |
| | | private Assertion parseAssertion(ByteSequence value) throws DecodeException |
| | | { |
| | | // Get a string representation of the value. |
| | | String filterString = value.toString(); |
| | |
| | | // If there were no asterisks, then this isn't a substring filter. |
| | | if (asteriskPositions.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_SUBSTRING_NO_ASTERISKS.get(filterString, |
| | | 0, endPos); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message); |
| | | throw DecodeException.error( |
| | | ERR_SEARCH_FILTER_SUBSTRING_NO_ASTERISKS.get(filterString, 0, endPos)); |
| | | } |
| | | |
| | | // If the value starts with an asterisk, then there is no |
| | |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAssertionValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | Assertion assertion = parseAssertion(value); |
| | | String subInitial = assertion.getInitial(); |
| | |
| | | */ |
| | | @Override |
| | | public <T> T createIndexQuery(ByteSequence assertionValue, |
| | | IndexQueryFactory<T> factory) throws DirectoryException |
| | | IndexQueryFactory<T> factory) throws DecodeException |
| | | { |
| | | Assertion assertion = parseAssertion(assertionValue); |
| | | String subInitial = assertion.getInitial(); |
| | |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | CollationKey key = collator.getCollationKey(value.toString()); |
| | | return ByteString.wrap(key.toByteArray()); |
| | |
| | | */ |
| | | @Override |
| | | public <T> T createIndexQuery(ByteSequence assertionValue, |
| | | IndexQueryFactory<T> factory) throws DirectoryException |
| | | IndexQueryFactory<T> factory) throws DecodeException |
| | | { |
| | | return factory.createRangeMatchQuery(indexer |
| | | .getExtensibleIndexID(), ByteString.empty(), |
| | |
| | | */ |
| | | @Override |
| | | public <T> T createIndexQuery(ByteSequence assertionValue, |
| | | IndexQueryFactory<T> factory) throws DirectoryException |
| | | IndexQueryFactory<T> factory) throws DecodeException |
| | | { |
| | | // Read the range: lower < keys <= upper. |
| | | return factory.createRangeMatchQuery(indexer |
| | |
| | | */ |
| | | @Override |
| | | public <T> T createIndexQuery(ByteSequence assertionValue, |
| | | IndexQueryFactory<T> factory) throws DirectoryException |
| | | IndexQueryFactory<T> factory) throws DecodeException |
| | | { |
| | | return factory.createRangeMatchQuery(indexer |
| | | .getExtensibleIndexID(), normalizeAttributeValue(assertionValue), |
| | |
| | | */ |
| | | @Override |
| | | public <T> T createIndexQuery(ByteSequence assertionValue, |
| | | IndexQueryFactory<T> factory) throws DirectoryException |
| | | IndexQueryFactory<T> factory) throws DecodeException |
| | | { |
| | | // Read the range: lower <= keys < upper. |
| | | return factory.createRangeMatchQuery(indexer |
| | |
| | | @Override |
| | | public final void getKeys(AttributeValue value, Set<byte[]> keys) |
| | | { |
| | | ByteString key; |
| | | try |
| | | { |
| | | key = matchingRule.normalizeAttributeValue(value.getValue()); |
| | | ByteString key = matchingRule.normalizeAttributeValue(value.getValue()); |
| | | keys.add(key.toByteArray()); |
| | | } |
| | | catch (DirectoryException de) |
| | | catch (DecodeException e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, CASE_FOLD); |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AcceptRejectWarn; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | // Since the normalization for DNs is so complex, it will be handled |
| | | // elsewhere. |
| | |
| | | if (DirectoryServer.getSyntaxEnforcementPolicy() == |
| | | AcceptRejectWarn.REJECT) |
| | | { |
| | | throw de; |
| | | throw DecodeException.error(de.getMessageObject(), de); |
| | | } |
| | | |
| | | return bestEffortNormalize(toLowerCase(value.toString())); |
| | |
| | | if (DirectoryServer.getSyntaxEnforcementPolicy() == |
| | | AcceptRejectWarn.REJECT) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_ATTR_SYNTAX_DN_INVALID.get(value, e)); |
| | | throw DecodeException.error(ERR_ATTR_SYNTAX_DN_INVALID.get(value, e)); |
| | | } |
| | | else |
| | | { |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.ApproximateMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines an approximate matching rule based on the Double Metaphone |
| | | * algorithm. The Metaphone and Double Metaphone algorithms were originally |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | String valueString = value.toString(); |
| | | int length = valueString.length(); |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | try |
| | | { |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw de; |
| | | |
| | | throw DecodeException.error(de.getMessageObject(), de); |
| | | case WARN: |
| | | logger.error(de.getMessageObject()); |
| | | return value.toByteString(); |
| | | |
| | | default: |
| | | return value.toByteString(); |
| | | break; |
| | | } |
| | | return value.toByteString(); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.AbstractMatchingRule; |
| | | import org.opends.server.api.OrderingMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | try |
| | | { |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw de; |
| | | |
| | | throw DecodeException.error(de.getMessageObject(), de); |
| | | case WARN: |
| | | logger.error(de.getMessageObject()); |
| | | return value.toByteString(); |
| | | |
| | | default: |
| | | return value.toByteString(); |
| | | break; |
| | | } |
| | | return value.toByteString(); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | int length = value.length(); |
| | | StringBuilder buffer = new StringBuilder(length); |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO.get(value); |
| | | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logged = true; |
| | | logger.error(message); |
| | | } |
| | | break; |
| | | } |
| | | logged = reportInvalidSyntax(logged, message); |
| | | } |
| | | break; |
| | | case 1: |
| | |
| | | if (buffer.charAt(0) == '-') |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO.get(value); |
| | | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logged = true; |
| | | logger.error(message); |
| | | } |
| | | break; |
| | | } |
| | | logged = reportInvalidSyntax(logged, message); |
| | | } |
| | | else |
| | | { |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_MISPLACED_DASH.get(value); |
| | | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logged = true; |
| | | logger.error(message); |
| | | } |
| | | break; |
| | | } |
| | | logged = reportInvalidSyntax(logged, message); |
| | | } |
| | | break; |
| | | default: |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER.get( |
| | | value, ((char) value.byteAt(i)), i); |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logged = true; |
| | | logger.error(message); |
| | | } |
| | | break; |
| | | } |
| | | logged = reportInvalidSyntax(logged, message); |
| | | } |
| | | } |
| | | |
| | | if (buffer.length() == 0) |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_EMPTY_VALUE.get(value); |
| | | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logged = true; |
| | | logger.error(message); |
| | | } |
| | | |
| | | buffer.append("0"); |
| | | break; |
| | | |
| | | default: |
| | | buffer.append("0"); |
| | | break; |
| | | } |
| | | logged = reportInvalidSyntax( |
| | | logged, WARN_ATTR_SYNTAX_INTEGER_EMPTY_VALUE.get(value)); |
| | | buffer.append("0"); |
| | | } |
| | | else if ((buffer.length() == 1) && (buffer.charAt(0) == '-')) |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_DASH_NEEDS_VALUE.get(value); |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logged = true; |
| | | logger.error(message); |
| | | } |
| | | |
| | | buffer.setCharAt(0, '0'); |
| | | break; |
| | | |
| | | default: |
| | | buffer.setCharAt(0, '0'); |
| | | break; |
| | | } |
| | | logged = reportInvalidSyntax( |
| | | logged, WARN_ATTR_SYNTAX_INTEGER_DASH_NEEDS_VALUE.get(value)); |
| | | buffer.setCharAt(0, '0'); |
| | | } |
| | | |
| | | return ByteString.valueOf(buffer.toString()); |
| | | } |
| | | |
| | | private boolean reportInvalidSyntax(boolean logged, LocalizableMessage message) |
| | | throws DecodeException |
| | | { |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logged = true; |
| | | logger.error(message); |
| | | } |
| | | break; |
| | | } |
| | | return logged; |
| | | } |
| | | } |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | toLowerCase(value, buffer, true); |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.AbstractMatchingRule; |
| | | import org.opends.server.api.OrderingMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | int length = value.length(); |
| | | StringBuilder buffer = new StringBuilder(length); |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO.get(value); |
| | | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logged = true; |
| | | logger.error(message); |
| | | } |
| | | break; |
| | | } |
| | | logged = reportInvalidSyntax(logged, message); |
| | | } |
| | | break; |
| | | case 1: |
| | |
| | | if (buffer.charAt(0) == '-') |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_INITIAL_ZERO.get(value); |
| | | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logged = true; |
| | | logger.error( |
| | | message); |
| | | } |
| | | break; |
| | | } |
| | | logged = reportInvalidSyntax(logged, message); |
| | | } |
| | | else |
| | | { |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_MISPLACED_DASH.get(value); |
| | | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logged = true; |
| | | logger.error( |
| | | message); |
| | | } |
| | | break; |
| | | } |
| | | logged = reportInvalidSyntax(logged, message); |
| | | } |
| | | break; |
| | | default: |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_INVALID_CHARACTER.get( |
| | | value, ((char) value.byteAt(i)), i); |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logged = true; |
| | | logger.error( |
| | | message); |
| | | } |
| | | break; |
| | | } |
| | | logged = reportInvalidSyntax(logged, message); |
| | | } |
| | | } |
| | | |
| | | if (buffer.length() == 0) |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_EMPTY_VALUE.get(value); |
| | | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logged = true; |
| | | logger.error(message); |
| | | } |
| | | |
| | | buffer.append("0"); |
| | | break; |
| | | |
| | | default: |
| | | buffer.append("0"); |
| | | break; |
| | | } |
| | | logged = reportInvalidSyntax(logged, message); |
| | | buffer.append("0"); |
| | | } |
| | | else if ((buffer.length() == 1) && (buffer.charAt(0) == '-')) |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_INTEGER_DASH_NEEDS_VALUE.get(value); |
| | | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logged = true; |
| | | logger.error(message); |
| | | } |
| | | |
| | | buffer.setCharAt(0, '0'); |
| | | break; |
| | | |
| | | default: |
| | | buffer.setCharAt(0, '0'); |
| | | break; |
| | | } |
| | | logged = reportInvalidSyntax(logged, message); |
| | | buffer.setCharAt(0, '0'); |
| | | } |
| | | |
| | | return ByteString.valueOf(buffer.toString()); |
| | | } |
| | | |
| | | private boolean reportInvalidSyntax(boolean logged, LocalizableMessage message) |
| | | throws DecodeException |
| | | { |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logged = true; |
| | | logger.error(message); |
| | | } |
| | | break; |
| | | } |
| | | return logged; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.std.server.AttributeSyntaxCfg; |
| | | import org.opends.server.api.*; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.CommonSchemaElements; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.LDAPSyntaxDescription; |
| | | import org.opends.server.types.Schema; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, CASE_FOLD); |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.schema.StringPrepProfile.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class implements the numericStringMatch matching rule defined in X.520 |
| | | * and referenced in RFC 2252. It allows for values with numeric digits and |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD); |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logger.error(message); |
| | | logged = true; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.AbstractMatchingRule; |
| | | import org.opends.server.api.OrderingMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | |
| | | import static org.opends.server.schema.StringPrepProfile.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This implements defines the numericStringOrderingMatch matching rule defined |
| | | * in X.520 and referenced in RFC 2252. |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD); |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logger.error(message); |
| | | logged = true; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.SubstringMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD); |
| | |
| | | // This is an illegal character. Either log it or reject it. |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_NUMERIC_STRING_ILLEGAL_CHAR.get( |
| | | value, c, pos); |
| | | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logger.error(message); |
| | | logged = true; |
| | | } |
| | | } |
| | | logged = reportInvalidSyntax(logged, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | private boolean reportInvalidSyntax(boolean logged, LocalizableMessage message) |
| | | throws DecodeException |
| | | { |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | | logger.error(message); |
| | | logged = true; |
| | | } |
| | | break; |
| | | } |
| | | return logged; |
| | | } |
| | | |
| | | /** |
| | | * Normalizes the provided value fragment into a form that can be used to |
| | | * efficiently compare values. |
| | |
| | | * |
| | | * @return The normalized form of the value fragment. |
| | | * |
| | | * @throws DirectoryException If the provided value fragment is not |
| | | * @throws DecodeException If the provided value fragment is not |
| | | * acceptable according to the associated syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeSubstring(ByteSequence substring) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | return normalizeAttributeValue(substring); |
| | | } |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.NameForm; |
| | | import org.opends.server.types.ObjectClass; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | toLowerCase(value, buffer, true); |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_ATTR_SYNTAX_OID_INVALID_VALUE.get( |
| | | lowerValue, invalidReason)); |
| | | throw DecodeException.error( |
| | | ERR_ATTR_SYNTAX_OID_INVALID_VALUE.get(lowerValue, invalidReason)); |
| | | } |
| | | |
| | | case WARN: |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.NameForm; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.util.ServerConstants; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | toLowerCase(value, buffer, true); |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | return value.toByteString(); |
| | | } |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.AbstractMatchingRule; |
| | | import org.opends.server.api.OrderingMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | return value.toByteString(); |
| | | } |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.SubstringMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | return value.toByteString(); |
| | | } |
| | |
| | | * |
| | | * @return The normalized form of the value fragment. |
| | | * |
| | | * @throws DirectoryException If the provided value fragment is not |
| | | * @throws DecodeException If the provided value fragment is not |
| | | * acceptable according to the associated syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeSubstring(ByteSequence substring) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | // This is exactly the same as normalizing a full value. |
| | | return substring.toByteString(); |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | toLowerCase(value, buffer, true); |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | toLowerCase(value, buffer, true); |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | String valueString = value.toString(); |
| | | int valueLength = valueString.length(); |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.SubstringMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | String valueString = value.toString(); |
| | | int valueLength = valueString.length(); |
| | |
| | | * |
| | | * @return The normalized form of the value fragment. |
| | | * |
| | | * @throws DirectoryException If the provided value fragment is not |
| | | * @throws DecodeException If the provided value fragment is not |
| | | * acceptable according to the associated syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeSubstring(ByteSequence substring) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | // In this case, the logic used to normalize a substring is identical to the |
| | | // logic used to normalize a full value. |
| | | ByteString value = normalizeAttributeValue(substring); |
| | | if (value.length() == 0) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | LocalizableMessage.EMPTY); |
| | | throw DecodeException.error(LocalizableMessage.EMPTY); |
| | | } |
| | | return value; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.admin.std.server.MatchingRuleCfg; |
| | | import org.opends.server.api.*; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.IndexConfig; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | try |
| | | { |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw de; |
| | | throw DecodeException.error(de.getMessageObject(), de); |
| | | |
| | | case WARN: |
| | | logger.error(de.getMessageObject()); |
| | | return value.toByteString(); |
| | | |
| | | default: |
| | | return value.toByteString(); |
| | | break; |
| | | } |
| | | return value.toByteString(); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAssertionValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | /** |
| | | An assertion value may contain one of the following: |
| | |
| | | { |
| | | //Log the message and throw an exception. |
| | | logger.error(message); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | throw DecodeException.error(message); |
| | | } |
| | | else |
| | | { |
| | |
| | | */ |
| | | @Override |
| | | public <T> T createIndexQuery(ByteSequence assertionValue, |
| | | IndexQueryFactory<T> factory) throws DirectoryException |
| | | IndexQueryFactory<T> factory) throws DecodeException |
| | | { |
| | | return factory.createRangeMatchQuery(indexer |
| | | .getExtensibleIndexID(), normalizeAssertionValue(assertionValue), |
| | |
| | | */ |
| | | @Override |
| | | public <T> T createIndexQuery(ByteSequence assertionValue, |
| | | IndexQueryFactory<T> factory) throws DirectoryException |
| | | IndexQueryFactory<T> factory) throws DecodeException |
| | | { |
| | | return factory.createRangeMatchQuery(indexer |
| | | .getExtensibleIndexID(), ByteString.empty(), |
| | |
| | | @Override |
| | | public final void getKeys(AttributeValue value, Set<byte[]> keys) |
| | | { |
| | | ByteString key; |
| | | try |
| | | { |
| | | key = matchingRule.normalizeAttributeValue(value.getValue()); |
| | | ByteString key = matchingRule.normalizeAttributeValue(value.getValue()); |
| | | keys.add(key.toByteArray()); |
| | | } |
| | | catch (DirectoryException de) |
| | | catch (DecodeException de) |
| | | { |
| | | //don't do anything. |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAssertionValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | /** |
| | | An assertion value may contain one or all of the following: |
| | |
| | | if(message !=null) |
| | | { |
| | | logger.error(message); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | throw DecodeException.error(message); |
| | | } |
| | | else |
| | | { |
| | |
| | | //A future date is allowed. |
| | | LocalizableMessage message = WARN_ATTR_INVALID_YEAR_ASSERTION_FORMAT.get(value, year); |
| | | logger.warn(message); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | switch(month) |
| | |
| | | default: |
| | | LocalizableMessage message = WARN_ATTR_INVALID_MONTH_ASSERTION_FORMAT.get(value, month); |
| | | logger.warn(message); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | boolean invalidDate = false; |
| | |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_INVALID_DATE_ASSERTION_FORMAT.get(value, date); |
| | | logger.warn(message); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | if(!(hour >=-1 && hour <=23)) |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_INVALID_HOUR_ASSERTION_FORMAT.get(value, date); |
| | | logger.warn(message); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | LocalizableMessage message = WARN_ATTR_INVALID_HOUR_ASSERTION_FORMAT.get(value, date); |
| | | logger.warn(message); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | if(!(minute >=-1 && minute <=59)) |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_INVALID_MINUTE_ASSERTION_FORMAT.get(value, date); |
| | | logger.warn(message); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | if(!(second >=-1 && second <=60)) //Consider leap seconds. |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_INVALID_SECOND_ASSERTION_FORMAT.get(value, date); |
| | | logger.warn(message); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public <T> T createIndexQuery(ByteSequence assertionValue, |
| | | IndexQueryFactory<T> factory) throws DirectoryException |
| | | IndexQueryFactory<T> factory) throws DecodeException |
| | | { |
| | | //Build the information from the assertion value. |
| | | byte[] arr = normalizeAssertionValue(assertionValue).toByteArray(); |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | if (value.length() != 36) |
| | | { |
| | | return reportInvalidAttrSyntax(value, |
| | | WARN_ATTR_SYNTAX_UUID_INVALID_LENGTH.get(value, value.length())); |
| | | reportInvalidSyntax(WARN_ATTR_SYNTAX_UUID_INVALID_LENGTH.get(value, value.length())); |
| | | return value.toByteString(); |
| | | } |
| | | |
| | | StringBuilder builder = new StringBuilder(36); |
| | |
| | | case 23: |
| | | if (c != '-') |
| | | { |
| | | return reportInvalidAttrSyntax(value, |
| | | WARN_ATTR_SYNTAX_UUID_EXPECTED_DASH.get(value, i, c)); |
| | | reportInvalidSyntax(WARN_ATTR_SYNTAX_UUID_EXPECTED_DASH.get(value, i, c)); |
| | | return value.toByteString(); |
| | | } |
| | | builder.append(c); |
| | | break; |
| | |
| | | builder.append('f'); |
| | | break; |
| | | default: |
| | | return reportInvalidAttrSyntax(value, |
| | | WARN_ATTR_SYNTAX_UUID_EXPECTED_HEX.get(value, i, value.byteAt(i))); |
| | | reportInvalidSyntax(WARN_ATTR_SYNTAX_UUID_EXPECTED_HEX.get(value, i, value.byteAt(i))); |
| | | return value.toByteString(); |
| | | } |
| | | } |
| | | } |
| | |
| | | return ByteString.valueOf(builder.toString()); |
| | | } |
| | | |
| | | private ByteString reportInvalidAttrSyntax(ByteSequence value, LocalizableMessage message) |
| | | throws DirectoryException |
| | | private void reportInvalidSyntax(LocalizableMessage message) |
| | | throws DecodeException |
| | | { |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | logger.error(message); |
| | | return value.toByteString(); |
| | | default: |
| | | return value.toByteString(); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.AbstractMatchingRule; |
| | | import org.opends.server.api.OrderingMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | if (value.length() != 36) |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_UUID_INVALID_LENGTH.get(value, value.length()); |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | case WARN: |
| | | logger.error(message); |
| | | return value.toByteString(); |
| | | default: |
| | | return value.toByteString(); |
| | | } |
| | | reportInvalidSyntax(WARN_ATTR_SYNTAX_UUID_INVALID_LENGTH.get(value, value.length())); |
| | | return value.toByteString(); |
| | | } |
| | | |
| | | StringBuilder builder = new StringBuilder(36); |
| | |
| | | case 23: |
| | | if (c != '-') |
| | | { |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_UUID_EXPECTED_DASH.get(value, i, c); |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | case WARN: |
| | | logger.error(message); |
| | | return value.toByteString(); |
| | | default: |
| | | return value.toByteString(); |
| | | } |
| | | reportInvalidSyntax(WARN_ATTR_SYNTAX_UUID_EXPECTED_DASH.get(value, i, c)); |
| | | return value.toByteString(); |
| | | } |
| | | builder.append(c); |
| | | break; |
| | |
| | | builder.append('f'); |
| | | break; |
| | | default: |
| | | LocalizableMessage message = WARN_ATTR_SYNTAX_UUID_EXPECTED_HEX.get(value, i, c); |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | case WARN: |
| | | logger.error(message); |
| | | return value.toByteString(); |
| | | default: |
| | | return value.toByteString(); |
| | | } |
| | | reportInvalidSyntax(WARN_ATTR_SYNTAX_UUID_EXPECTED_HEX.get(value, i, c)); |
| | | return value.toByteString(); |
| | | } |
| | | } |
| | | } |
| | |
| | | return ByteString.valueOf(builder.toString()); |
| | | } |
| | | |
| | | private void reportInvalidSyntax(LocalizableMessage message) |
| | | throws DecodeException |
| | | { |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | logger.error(message); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class implements the uniqueMemberMatch matching rule defined in X.520 |
| | | * and referenced in RFC 2252. It is based on the name and optional UID syntax, |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | String valueString = value.toString().trim(); |
| | | int valueLength = valueString.length(); |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | logger.error(message); |
| | | |
| | | valueBuffer.append(toLowerCase(valueString).substring(0, dnEndPos)); |
| | | break; |
| | | |
| | | default: |
| | | valueBuffer.append(toLowerCase(valueString).substring(0, dnEndPos)); |
| | | break; |
| | | } |
| | | valueBuffer.append(toLowerCase(valueString).substring(0, dnEndPos)); |
| | | } |
| | | |
| | | |
| | |
| | | switch (DirectoryServer.getSyntaxEnforcementPolicy()) |
| | | { |
| | | case REJECT: |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | throw DecodeException.error(message); |
| | | case WARN: |
| | | if (! logged) |
| | | { |
| | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | // We will not alter the value in any way |
| | | return value.toByteString(); |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | // The normalized form of this matching rule is exactly equal to the |
| | | // non-normalized form, except that the scheme needs to be converted to |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, CASE_FOLD); |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | |
| | |
| | | * Construct a new DelayedNormalizationValue. |
| | | * |
| | | * @param attributeType The attribute type. |
| | | * @param value The value of the attriute. |
| | | * @param value The value of the attribute. |
| | | */ |
| | | private DelayedNormalizationValue( |
| | | AttributeType attributeType, ByteString value) |
| | |
| | | ResultCode.INAPPROPRIATE_MATCHING, message); |
| | | } |
| | | |
| | | normalizedValue = equalityMatchingRule.normalizeAttributeValue(value); |
| | | try |
| | | { |
| | | normalizedValue = equalityMatchingRule.normalizeAttributeValue(value); |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | e.getMessageObject(), e); |
| | | } |
| | | } |
| | | |
| | | return normalizedValue; |
| | |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.admin.std.server.DirectoryStringAttributeSyntaxCfg; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.std.server.DirectoryStringAttributeSyntaxCfg; |
| | | import org.opends.server.api.ApproximateMatchingRule; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | |
| | | // that would kill performance. |
| | | String valueString = attributeType.getDefinition(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | attributeTypeSet.add(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | | } |
| | | |
| | | |
| | | private ByteString normalizeAttributeValue(ByteString rawValue) |
| | | throws DirectoryException |
| | | { |
| | | try |
| | | { |
| | | return normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | e.getMessageObject(), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Deregisters the provided attribute type definition with this |
| | |
| | | { |
| | | String valueString = attributeType.getDefinition(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | attributeTypeSet.remove(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | // that would kill performance. |
| | | String valueString = objectClass.getDefinition(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | objectClassSet.add(AttributeValues.create(rawValue, normValue)); |
| | | } |
| | | } |
| | |
| | | { |
| | | String valueString = objectClass.getDefinition(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | objectClassSet.remove(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | // that would kill performance. |
| | | String valueString = syntax.toString(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | syntaxSet.add(AttributeValues.create(rawValue, normValue)); |
| | | } |
| | | } |
| | |
| | | { |
| | | String valueString = syntax.toString(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | syntaxSet.remove(AttributeValues.create(rawValue, normValue)); |
| | | } |
| | | catch (Exception e) |
| | |
| | | // match) that would kill performance. |
| | | String valueString = matchingRule.toString(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | matchingRuleSet.add( |
| | | AttributeValues.create(rawValue, normValue)); |
| | | } |
| | |
| | | { |
| | | String valueString = matchingRule.toString(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | matchingRuleSet.remove(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | // that would kill performance. |
| | | String valueString = matchingRule.toString(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | matchingRuleSet.add(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | { |
| | | String valueString = matchingRule.toString(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | matchingRuleSet.remove(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | // that would kill performance. |
| | | String valueString = matchingRule.toString(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | matchingRuleSet.add(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | { |
| | | String valueString = matchingRule.toString(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | matchingRuleSet.remove(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | // that would kill performance. |
| | | String valueString = matchingRule.toString(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | matchingRuleSet.add(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | { |
| | | String valueString = matchingRule.toString(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | matchingRuleSet.remove(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | // that would kill performance. |
| | | String valueString = matchingRule.toString(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | matchingRuleSet.add(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | { |
| | | String valueString = matchingRule.toString(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | matchingRuleSet.remove(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | // that would kill performance. |
| | | String valueString = matchingRule.toString(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = normalizationMatchingRule.normalizeAttributeValue( |
| | | rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | matchingRuleSet.add( |
| | | AttributeValues.create(rawValue, normValue)); |
| | | } |
| | |
| | | { |
| | | String valueString = matchingRule.toString(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | matchingRuleSet.remove(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | // that would kill performance. |
| | | String valueString = matchingRuleUse.getDefinition(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | matchingRuleUseSet.add(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | { |
| | | String valueString = matchingRuleUse.getDefinition(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | matchingRuleUseSet.remove(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | // that would kill performance. |
| | | String valueString = ditContentRule.getDefinition(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | ditContentRuleSet.add(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | { |
| | | String valueString = ditContentRule.getDefinition(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | ditContentRuleSet.remove(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | // that would kill performance. |
| | | String valueString = ditStructureRule.getDefinition(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | ditStructureRuleSet.add(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | { |
| | | String valueString = ditStructureRule.getDefinition(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | ditStructureRuleSet.remove(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | // that would kill performance. |
| | | String valueString = nameForm.getDefinition(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | nameFormSet.add(AttributeValues.create(rawValue, normValue)); |
| | | } |
| | | } |
| | |
| | | { |
| | | String valueString = nameForm.getDefinition(); |
| | | ByteString rawValue = ByteString.valueOf(valueString); |
| | | ByteString normValue = |
| | | normalizationMatchingRule.normalizeAttributeValue(rawValue); |
| | | ByteString normValue = normalizeAttributeValue(rawValue); |
| | | nameFormSet.remove(AttributeValues.create(rawValue, |
| | | normValue)); |
| | | } |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.Assertion; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.api.SubstringMatchingRule; |
| | |
| | | } |
| | | else |
| | | { |
| | | value = AttributeValues.create(userValue, |
| | | mr.normalizeAttributeValue(userValue)); |
| | | try |
| | | { |
| | | value = AttributeValues.create( |
| | | userValue, mr.normalizeAttributeValue(userValue)); |
| | | } |
| | | catch (DecodeException e) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | e.getMessageObject(), e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | // Normalize the assertion value using the matching rule. |
| | | ByteString normalizedValue; |
| | | Assertion assertion; |
| | | try |
| | | { |
| | | normalizedValue = |
| | | matchingRule. |
| | | normalizeAssertionValue(assertionValue.getValue()); |
| | | assertion = matchingRule.getAssertion(assertionValue.getValue()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | { |
| | | ByteString nv = |
| | | matchingRule.normalizeAttributeValue(v.getValue()); |
| | | ConditionResult r = |
| | | matchingRule.valuesMatch(nv, normalizedValue); |
| | | ConditionResult r = assertion.matches(nv); |
| | | switch (r) |
| | | { |
| | | case TRUE: |
| | |
| | | { |
| | | ByteString nv = |
| | | matchingRule.normalizeAttributeValue(v.getValue()); |
| | | ConditionResult r = |
| | | matchingRule.valuesMatch(nv, normalizedValue); |
| | | ConditionResult r = assertion.matches(nv); |
| | | switch (r) |
| | | { |
| | | case TRUE: |
| | |
| | | try |
| | | { |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v.getValue()); |
| | | ConditionResult r = |
| | | matchingRule.valuesMatch(nv, normalizedValue); |
| | | ConditionResult r = assertion.matches(nv); |
| | | switch (r) |
| | | { |
| | | case TRUE: |
| | |
| | | { |
| | | ByteString nv = |
| | | matchingRule.normalizeAttributeValue(v.getValue()); |
| | | ConditionResult r = |
| | | matchingRule.valuesMatch(nv, normalizedValue); |
| | | ConditionResult r = assertion.matches(nv); |
| | | switch (r) |
| | | { |
| | | case TRUE: |
| | |
| | | AttributeValue v = rdn.getAttributeValue(i); |
| | | ByteString nv = |
| | | matchingRule.normalizeAttributeValue(v.getValue()); |
| | | ConditionResult r = |
| | | matchingRule.valuesMatch(nv, normalizedValue); |
| | | ConditionResult r = assertion.matches(nv); |
| | | switch (r) |
| | | { |
| | | case TRUE: |
| | |
| | | { |
| | | try |
| | | { |
| | | ConditionResult cr = mr.valuesMatch( |
| | | mr.normalizeAttributeValue(assertionValue.getValue()), |
| | | mr.normalizeAttributeValue(f.assertionValue.getValue())); |
| | | if (cr != ConditionResult.TRUE) |
| | | { |
| | | return false; |
| | | } |
| | | Assertion assertion = mr.getAssertion(f.assertionValue.getValue()); |
| | | return assertion.matches(mr.normalizeAttributeValue(assertionValue.getValue())) == ConditionResult.TRUE; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.messages.UtilityMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Evaluates and converts 2 consequetive characters of the provided |
| | | * string starting at startPos and converts them into a single escaped |
| | | * char. |
| | | * |
| | | * @param hexString |
| | | * The hexadecimal string containing the escape sequence. |
| | | * @param startPos |
| | | * The starting position of the hexadecimal escape sequence. |
| | | * @return The escaped character |
| | | * @throws DirectoryException |
| | | * If the provided string contains invalid hexadecimal |
| | | * digits . |
| | | */ |
| | | public static char hexToEscapedChar(String hexString, int startPos) |
| | | throws DirectoryException |
| | | { |
| | | // The two positions must be the hex characters that |
| | | // comprise the escaped value. |
| | | if ((startPos + 1) >= hexString.length()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE.get(hexString, |
| | | startPos + 1); |
| | | |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | byte byteValue = 0; |
| | | switch (hexString.charAt(startPos)) |
| | | { |
| | | case 0x30: // '0' |
| | | break; |
| | | case 0x31: // '1' |
| | | byteValue = (byte) 0x10; |
| | | break; |
| | | case 0x32: // '2' |
| | | byteValue = (byte) 0x20; |
| | | break; |
| | | case 0x33: // '3' |
| | | byteValue = (byte) 0x30; |
| | | break; |
| | | case 0x34: // '4' |
| | | byteValue = (byte) 0x40; |
| | | break; |
| | | case 0x35: // '5' |
| | | byteValue = (byte) 0x50; |
| | | break; |
| | | case 0x36: // '6' |
| | | byteValue = (byte) 0x60; |
| | | break; |
| | | case 0x37: // '7' |
| | | byteValue = (byte) 0x70; |
| | | break; |
| | | case 0x38: // '8' |
| | | byteValue = (byte) 0x80; |
| | | break; |
| | | case 0x39: // '9' |
| | | byteValue = (byte) 0x90; |
| | | break; |
| | | case 0x41: // 'A' |
| | | case 0x61: // 'a' |
| | | byteValue = (byte) 0xA0; |
| | | break; |
| | | case 0x42: // 'B' |
| | | case 0x62: // 'b' |
| | | byteValue = (byte) 0xB0; |
| | | break; |
| | | case 0x43: // 'C' |
| | | case 0x63: // 'c' |
| | | byteValue = (byte) 0xC0; |
| | | break; |
| | | case 0x44: // 'D' |
| | | case 0x64: // 'd' |
| | | byteValue = (byte) 0xD0; |
| | | break; |
| | | case 0x45: // 'E' |
| | | case 0x65: // 'e' |
| | | byteValue = (byte) 0xE0; |
| | | break; |
| | | case 0x46: // 'F' |
| | | case 0x66: // 'f' |
| | | byteValue = (byte) 0xF0; |
| | | break; |
| | | default: |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE.get(hexString, |
| | | startPos); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | |
| | | switch (hexString.charAt(++startPos)) |
| | | { |
| | | case 0x30: // '0' |
| | | break; |
| | | case 0x31: // '1' |
| | | byteValue |= (byte) 0x01; |
| | | break; |
| | | case 0x32: // '2' |
| | | byteValue |= (byte) 0x02; |
| | | break; |
| | | case 0x33: // '3' |
| | | byteValue |= (byte) 0x03; |
| | | break; |
| | | case 0x34: // '4' |
| | | byteValue |= (byte) 0x04; |
| | | break; |
| | | case 0x35: // '5' |
| | | byteValue |= (byte) 0x05; |
| | | break; |
| | | case 0x36: // '6' |
| | | byteValue |= (byte) 0x06; |
| | | break; |
| | | case 0x37: // '7' |
| | | byteValue |= (byte) 0x07; |
| | | break; |
| | | case 0x38: // '8' |
| | | byteValue |= (byte) 0x08; |
| | | break; |
| | | case 0x39: // '9' |
| | | byteValue |= (byte) 0x09; |
| | | break; |
| | | case 0x41: // 'A' |
| | | case 0x61: // 'a' |
| | | byteValue |= (byte) 0x0A; |
| | | break; |
| | | case 0x42: // 'B' |
| | | case 0x62: // 'b' |
| | | byteValue |= (byte) 0x0B; |
| | | break; |
| | | case 0x43: // 'C' |
| | | case 0x63: // 'c' |
| | | byteValue |= (byte) 0x0C; |
| | | break; |
| | | case 0x44: // 'D' |
| | | case 0x64: // 'd' |
| | | byteValue |= (byte) 0x0D; |
| | | break; |
| | | case 0x45: // 'E' |
| | | case 0x65: // 'e' |
| | | byteValue |= (byte) 0x0E; |
| | | break; |
| | | case 0x46: // 'F' |
| | | case 0x66: // 'f' |
| | | byteValue |= (byte) 0x0F; |
| | | break; |
| | | default: |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_INVALID_ESCAPED_BYTE.get(hexString, |
| | | startPos); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | return (char) byteValue; |
| | | } |
| | | |
| | | /** |
| | | * Add all of the superior objectclasses to the specified objectclass |
| | | * map if they don't already exist. Used by add and import-ldif to |
| | | * add missing superior objectclasses to entries that don't have them. |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.schema.CaseIgnoreEqualityMatchingRuleFactory; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | return caseIgnoreMatchingRule.normalizeAttributeValue(value); |
| | | } |
| | |
| | | package org.opends.server.schema; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | CertificateExactMatchingRule rule = getRule(); |
| | | |
| | | // normalize the provided assertion values |
| | | rule.normalizeAssertionValue(ByteString.valueOf(value)); |
| | | rule.getAssertion(ByteString.valueOf(value)); |
| | | } |
| | | |
| | | |
| | |
| | | * Test that invalid assertion values are rejected. |
| | | */ |
| | | @Test(dataProvider= "certificateExactMatchInvalidAssertionValues", |
| | | expectedExceptions={ DirectoryException.class }) |
| | | expectedExceptions={ DecodeException.class }) |
| | | public void certificateExactMatchingRuleInvalidAssertionValues(String value) |
| | | throws Exception |
| | | { |
| | |
| | | CertificateExactMatchingRule rule = getRule(); |
| | | |
| | | // normalize the provided assertion value |
| | | rule.normalizeAssertionValue(ByteString.valueOf(value)); |
| | | rule.getAssertion(ByteString.valueOf(value)); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.ApproximateMatchingRule; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | |
| | | * |
| | | * @return The normalized version of the provided value. |
| | | * |
| | | * @throws DirectoryException If the provided value is invalid according to |
| | | * @throws DecodeException If the provided value is invalid according to |
| | | * the associated attribute syntax. |
| | | */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(ByteSequence value) |
| | | throws DirectoryException |
| | | throws DecodeException |
| | | { |
| | | // Any value is acceptable, so we can just return a copy of the |
| | | // value. |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.forgerock.opendj.ldap.Assertion; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.EqualityMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AcceptRejectWarn; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | fail("The matching rule : " + rule.getNameOrOID() |
| | | + " should detect that value \"" + value + "\" is invalid"); |
| | | } |
| | | catch (DirectoryException ignored) |
| | | catch (DecodeException ignored) |
| | | { |
| | | } |
| | | } |
| | |
| | | // normalize the 2 provided values and check that they are equals |
| | | ByteString normalizedValue1 = |
| | | rule.normalizeAttributeValue(ByteString.valueOf(value1)); |
| | | ByteString normalizedValue2 = |
| | | rule.normalizeAttributeValue(ByteString.valueOf(value2)); |
| | | Assertion assertion = rule.getAssertion(ByteString.valueOf(value2)); |
| | | |
| | | ConditionResult liveResult = |
| | | rule.valuesMatch(normalizedValue1, normalizedValue2); |
| | | ConditionResult liveResult = assertion.matches(normalizedValue1); |
| | | assertEquals(liveResult, ConditionResult.valueOf(result)); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.api.OrderingMatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AcceptRejectWarn; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Test The Ordering matching rules and the Ordering matching rule api. |
| | | */ |
| | |
| | | try |
| | | { |
| | | ruleInstance.normalizeAttributeValue(ByteString.valueOf(value)); |
| | | } catch (DirectoryException e) { |
| | | } catch (DecodeException e) { |
| | | // that's the expected path : the matching rule has detected that |
| | | // the value is incorrect. |
| | | return; |
| | |
| | | } |
| | | } |
| | | |
| | | private void dummy () |
| | | { |
| | | |
| | | Object a = new Object[][] { |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | }; |
| | | |
| | | } |
| | | |
| | | |
| | | private Object dummy_invalid() |
| | | { |
| | | return new Object[][] { |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | }; |
| | | } |
| | | } |
| | |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2010-2014 ForgeRock AS. |
| | | */ |
| | | |
| | | |
| | | package org.opends.server.schema; |
| | | |
| | | import java.util.Calendar; |
| | | import java.util.GregorianCalendar; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | import java.util.TimeZone; |
| | | |
| | | import org.forgerock.opendj.ldap.*; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.util.TimeThread; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.schema.GeneralizedTimeSyntax.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This class tests various time-based matching rules. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public final class TimeBasedMatchingRuleTest |
| | | extends SchemaTestCase |
| | | { |
| | |
| | | { |
| | | MatchingRule partialTimeRule = DirectoryServer.getMatchingRule( |
| | | EXT_PARTIAL_DATE_TIME_NAME.toLowerCase()); |
| | | ByteString str = partialTimeRule.normalizeAssertionValue(ByteString.valueOf(assertionValue)); |
| | | assertEquals(partialTimeRule.valuesMatch(ByteString.valueOf(attributeValue), str), ConditionResult.TRUE); |
| | | Assertion assertion = partialTimeRule.getAssertion(ByteString.valueOf(assertionValue)); |
| | | assertEquals(assertion.matches(ByteString.valueOf(attributeValue)), ConditionResult.TRUE); |
| | | } |
| | | |
| | | |
| | |
| | | MatchingRule relativeTimeLTRule = |
| | | DirectoryServer.getOrderingMatchingRule( |
| | | EXT_OMR_RELATIVE_TIME_LT_ALT_NAME.toLowerCase()); |
| | | boolean exception = false; |
| | | try |
| | | { |
| | | relativeTimeLTRule.normalizeAssertionValue(ByteString.valueOf(assertion)); |
| | | relativeTimeLTRule.getAssertion(ByteString.valueOf(assertion)); |
| | | // An invalid value can't get away without throwing exception. |
| | | assertTrue(isValid); |
| | | } |
| | | catch(DirectoryException e) |
| | | catch (DecodeException e) |
| | | { |
| | | //invalid values will throw an exception. |
| | | exception = true; |
| | | assertTrue(!isValid); |
| | | } |
| | | if(!isValid) |
| | | { |
| | | //An invalid value can't get away without throwing exception. |
| | | assertTrue(exception); |
| | | assertFalse(isValid); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | MatchingRule partialDTRule = |
| | | DirectoryServer.getMatchingRule(EXT_PARTIAL_DATE_TIME_OID); |
| | | boolean exception = false; |
| | | try |
| | | { |
| | | partialDTRule.normalizeAssertionValue(ByteString.valueOf(assertion)); |
| | | partialDTRule.getAssertion(ByteString.valueOf(assertion)); |
| | | assertTrue(isValid); |
| | | } |
| | | catch(DirectoryException e) |
| | | catch (DecodeException e) |
| | | { |
| | | //invalid values will throw an exception. |
| | | exception = true; |
| | | assertTrue(!isValid); |
| | | } |
| | | if(!isValid) |
| | | { |
| | | assertTrue(exception); |
| | | assertFalse(isValid); |
| | | } |
| | | } |
| | | |