| | |
| | | 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(); |