mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Nicolas Capponi
06.50.2014 4cb8262e95fde77e6a0d2c84f1aa118e3b1ee850
OPENDJ-1591 CR-5092 Switch server to SDK matching rules

- replace org.opends.server.api.MatchingRule (server) by
org.forgerock.opendj.ldap.schema.MatchingRule (SDK)

- add HistoricalCsnOrderingMatchingRuleImpl class

- modify matching rule factories to return SDK or SDK-compatible
matching rules

- refactor AttributeIndex class to skip most of the code specific to
extensible matching rules

- modify VLVKeyComparator class to serialize oids list instead of
matching rules list

- re-implement DN and RDN equals(), hashCode() and compareTo()
methods to behave like SDK equivalent methods
4 files deleted
2 files added
171 files modified
6940 ■■■■ changed files
opendj3-server-dev/replace.rb 62 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/MatchingRulePanel.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewAttributePanel.java 19 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/SchemaBrowserRightPanel.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/StandardAttributePanel.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/nodes/MatchingRuleTreeNode.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/renderer/SchemaElementComboBoxCellRenderer.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/util/SchemaLoader.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java 14 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/api/AttributeSyntax.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/api/AuthenticationPolicyState.java 6 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/api/Backend.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/api/Group.java 6 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/api/MatchingRuleFactory.java 1 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/api/VirtualAttributeProvider.java 1 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/PatternRDN.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/ApproximateIndexer.java 6 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/AttributeIndex.java 639 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/EqualityIndexer.java 6 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/JEExtensibleIndexer.java 23 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/OrderingIndexer.java 6 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/SortValuesSet.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/SubstringIndexer.java 6 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/VLVIndex.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/VLVKeyComparator.java 36 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/VerifyJob.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/controls/MatchedValuesFilter.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/controls/ServerSideSortRequestControl.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java 127 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/core/GroupManager.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/core/MatchingRuleConfigManager.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/core/PasswordPolicyFactory.java 19 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/core/PasswordPolicyState.java 39 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/extensions/DynamicGroup.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/extensions/EntryDNVirtualAttributeProvider.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/extensions/EntryUUIDVirtualAttributeProvider.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/extensions/HasSubordinatesVirtualAttributeProvider.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyFactory.java 24 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/extensions/NumSubordinatesVirtualAttributeProvider.java 15 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/extensions/PasswordPolicyStateExtendedOperation.java 122 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/extensions/StaticGroup.java 17 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/extensions/VirtualStaticGroup.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/protocols/ldap/LDAPFilter.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRule.java 182 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRuleFactory.java 16 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRuleImpl.java 247 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/AciSyntax.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/AttributeTypeSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordEqualityMatchingRule.java 205 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordEqualityMatchingRuleFactory.java 24 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordExactEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/BinarySyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/BitStringEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/BitStringSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/BooleanEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/BooleanSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CaseExactEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CaseExactIA5EqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CaseExactIA5SubstringMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CaseExactOrderingMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CaseExactSubstringMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreIA5EqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreIA5SubstringMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreListEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreListSubstringMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreOrderingMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreSubstringMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CertificateExactAssertionSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CertificateExactMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CertificateListSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CertificatePairSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CertificateSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java 1765 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/CountryStringSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/DITContentRuleSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/DITStructureRuleSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/DeliveryMethodSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/DirectoryStringFirstComponentEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/DirectoryStringSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/DistinguishedNameEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/DistinguishedNameSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/DoubleMetaphoneApproximateMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/EnhancedGuideSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/FaxNumberSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/FaxSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeOrderingMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/GuideSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/IA5StringSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/IntegerEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/IntegerFirstComponentEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/IntegerOrderingMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/IntegerSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/JPEGSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/KeywordEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/LDAPSyntaxDescriptionSyntax.java 175 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/MatchingRuleSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/MatchingRuleUseSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/NameAndOptionalUIDSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/NameFormSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/NumericStringEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/NumericStringOrderingMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/NumericStringSubstringMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/NumericStringSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/OIDSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/ObjectClassSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierEqualityMatchingRule.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierFirstComponentEqualityMatchingRule.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierFirstComponentEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/OctetStringEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/OctetStringOrderingMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/OctetStringSubstringMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/OctetStringSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/OtherMailboxSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/PostalAddressSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/PresentationAddressEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/PresentationAddressSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/PrintableStringSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/ProtocolInformationEqualityMatchingRuleFactory.java 9 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/ProtocolInformationSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/SubstringAssertionSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/SubtreeSpecificationSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/SupportedAlgorithmSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/TelephoneNumberEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/TelephoneNumberSubstringMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/TelephoneNumberSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/TeletexTerminalIdentifierSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/TelexNumberSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/TimeBasedMatchingRuleFactory.java 1043 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/UTCTimeSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/UUIDEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/UUIDOrderingMatchingRuleFactory.java 15 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/UUIDSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/UniqueMemberEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordEqualityMatchingRuleFactory.java 9 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordExactEqualityMatchingRuleFactory.java 12 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordSyntax.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/schema/WordEqualityMatchingRuleFactory.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/types/AbstractAttribute.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/types/AttributeBuilder.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/types/AttributeType.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/types/DN.java 147 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/types/DirectoryConfig.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/types/Entry.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/types/MatchingRuleUse.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/types/RDN.java 49 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/types/Schema.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/types/SearchFilter.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/types/SortKey.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java 90 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaTestMatchingRule.java 216 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaTestMatchingRuleImpl.java 133 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestVLVIndex.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/controls/MatchedValuesControlTest.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/VirtualStaticGroupTestCase.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java 21 ●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/AttributeTypeSyntaxTest.java 14 ●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/AuthPasswordEqualityMatchingRuleTest.java 58 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/CollationMatchingRuleFactoryTest.java 95 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualLengthApproximateMatchingRule.java 180 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/GenericSchemaTestCase.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/LDAPSyntaxTest.java 7 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/StringPrepProfileTestCase.java 8 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/TimeBasedMatchingRuleFactoryTest.java 233 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/TimeBasedMatchingRuleTest.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tasks/AddSchemaFileTaskTestCase.java 34 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestAttributeType.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestDN.java 58 ●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestRDN.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/replace.rb
@@ -7,10 +7,14 @@
#
# To define a new replacement, add a new constant like VALIDATOR.
#
# It should be a ruby Hash with three mandatory keys and one optional key:
# It should be a ruby Hash with three mandatory keys and two optional key.
#
# The mandatory keys are:
#
#  :dirs => a list of directory to run replacements. All subdirs are processed.
#
#  :extensions => a list of file extensions. Only file with these extensions are processed.
#
#  :replacements => a list of replacements, lines are processed 2 by 2
#    - first line gives the pattern to replace, as a ruby regexp (see http://rubular.com/ for help and tool)
#    - second line gives the replacement string, using \1, \2, ... to insert matching groups. This is a string,
@@ -19,8 +23,16 @@
#    It is ok to leave a new line to separate each pair of line for readability.
#    It is ok to use a comment in the array (use # as first non blank character of line).
#
# The optional key is :stopwords => a list of stopword. If any word in this list appears in a file name, the file
#   is not processed. Use it to exclude some files or directory that must not be processed.
# The optional keys are:
#
#   :whitelist => a list of mandatory words. If any word in this list appears in a file name, the file
#       is processed, otherwise it is ignored. Use it to explicitely indicates files to process.
#
#   :stoplist => a list of stop words. If any word in this list appears in a file name, the file
#       is not processed. Use it to exclude some files or directory that must not be processed.
#
#   Note that if you use both whitelist and stoplist, a word in stoplist can prevent processing a file even if it
#   matches the whitelist content.
#
# Once you have define your replacement, add the constant in REPLACEMENTS array. it will be taken into account when
# running the program (run it at root of project) with command: ./replace.rb
@@ -38,7 +50,7 @@
  MRULES_TO_SDK = {
    :dirs => JAVA_DIRS + SNMP_DIR,
    :extensions => ["java"],
    :stopwords => ["MatchingRule"],
    :stoplist => ["MatchingRule"],
    :replacements =>
      [
        /import org.opends.server.api.MatchingRule;/,
@@ -50,7 +62,6 @@
  MRULES_FACTORIES = {
    :dirs => ["src/server/org/opends/server/schema"],
    :extensions => ["java"],
    :stopwords => [],
    :replacements =>
      [
        /import org.opends.server.api.MatchingRule;/,
@@ -71,10 +82,21 @@
       ]
  }
  MRULES_API_PACKAGE = {
    :dirs => ["src/server/org/opends/server/api"],
    :extensions => ["java"],
    :stoplist => ["MatchingRule.java"],
    :replacements =>
      [
        /\bMatchingRule\b/,
        "org.forgerock.opendj.ldap.schema.MatchingRule",
      ]
  }
  MRULES = {
    :dirs => JAVA_DIRS + SNMP_DIR,
    :extensions => ["java"],
    :stopwords => ["MatchingRule"],
    :stoplist => ["MatchingRule"],
    :replacements =>
      [
@@ -91,7 +113,7 @@
  SYNTAX = {
    :dirs => JAVA_DIRS + SNMP_DIR,
    :extensions => ["java"],
    :stopwords => ["Syntax"],
    :stoplist => ["Syntax"],
    :replacements =>
      [
@@ -116,7 +138,7 @@
  ATTRTYPE = {
    :dirs => JAVA_DIRS + SNMP_DIR,
    :extensions => ["java"],
    :stopwords => [],
    :stoplist => [],
    :replacements =>
      [
@@ -136,7 +158,7 @@
  NEW_CONFIG = {
    :dirs => JAVA_DIRS + SNMP_DIR,
    :extensions => ["java"],
    :stopwords => ["org/opends/server/admin", "api/Config", "MatchingRuleConfigManager"],
    :stoplist => ["org/opends/server/admin", "api/Config", "MatchingRuleConfigManager"],
    :replacements =>
      [
        /import org.opends.server.admin.std.server\.([^;]+);/,
@@ -360,7 +382,7 @@
  ###############################  List of replacements to run #################################
  REPLACEMENTS = [ MRULES_TO_SDK, MRULES_FACTORIES ]
  REPLACEMENTS = [ MRULES_TO_SDK, MRULES_FACTORIES, MRULES_API_PACKAGE ]
  ################################### Processing methods ########################################
@@ -368,20 +390,22 @@
  def run
    REPLACEMENTS.each { |repl|
      puts "Replacing " + Replace.constants.find{ |name| Replace.const_get(name)==repl }.to_s
      stopwords = repl[:stopwords] || ["--nostopword--"]
      replace_dirs(repl[:replacements], repl[:dirs], stopwords, repl[:extensions])
      stoplist = repl[:stoplist] || []
      whitelist = repl[:whitelist] || []
      replace_dirs(repl[:replacements], repl[:dirs], stoplist, whitelist, repl[:extensions])
    }
  end
  # Process replacements on the provided directories
  def replace_dirs(replacements, dirs, stopwords, extensions)
  def replace_dirs(replacements, dirs, stoplist, whitelist, extensions)
    count_files = 0
    count_total = 0
    dirs.each { |directory|
      files = files_under_directory(directory, extensions)
      files.each { |file|
        exclude_file = stopwords.any? { |stopword| file.include?(stopword) }
        next if exclude_file
        filename_has_stopword = stoplist.any? { |stopword| file.include?(stopword) }
        filename_has_whiteword = whitelist.any? { |whiteword| file.include?(whiteword) }
        next if filename_has_stopword || (!whitelist.empty? && !filename_has_whiteword)
        count = replace_file(file, replacements)
        if count > 0
          count_files += 1
@@ -421,15 +445,15 @@
  # Process provided directories
  # Expects a processing block accepting a file as argument and returning a count of changes dones
  def process_dirs(dirs, stopwords, extensions)
  def process_dirs(dirs, stoplist, whitelist, extensions)
    count_files = 0
    count_total = 0
    dirs.each { |directory|
      files = files_under_directory(directory, extensions)
      files.each { |file|
        puts file.to_s + "  stopwords:" + stopwords.to_s
        exclude_file = stopwords.any? { |stopword| file.include?(stopword) }
        next if exclude_file
        filename_has_stopword = stoplist.any? { |stopword| file.include?(stopword) }
        filename_has_whiteword = whitelist.any? { |whiteword| file.include?(whiteword) }
        next if filename_has_stopword || (!whitelist.empty? && !filename_has_whiteword)
        count = yield file # call the block
        if count > 0
          count_files += 1
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
@@ -89,7 +89,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.types.AttributeType;
import org.opends.server.types.CommonSchemaElements;
import org.opends.server.types.ObjectClass;
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
@@ -85,7 +85,7 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/MatchingRulePanel.java
@@ -40,11 +40,12 @@
import javax.swing.JList;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.ui.components.TitlePanel;
import org.opends.guitools.controlpanel.util.LowerCaseComparator;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.api.*;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Schema;
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewAttributePanel.java
@@ -32,15 +32,28 @@
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.swing.*;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.event.ConfigurationElementCreatedListener;
@@ -50,7 +63,7 @@
import org.opends.guitools.controlpanel.ui.renderer.SchemaElementComboBoxCellRenderer;
import org.opends.guitools.controlpanel.util.LowerCaseComparator;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.api.*;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.config.ConfigConstants;
import org.opends.server.types.AttributeType;
import org.opends.server.types.ObjectClass;
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/SchemaBrowserRightPanel.java
@@ -43,7 +43,7 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.types.AttributeType;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/StandardAttributePanel.java
@@ -51,7 +51,7 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.types.AttributeType;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/nodes/MatchingRuleTreeNode.java
@@ -22,11 +22,12 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui.nodes;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
/**
 * Class of the nodes that represent a matching rule in the 'Manage Schema'
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/renderer/SchemaElementComboBoxCellRenderer.java
@@ -34,7 +34,7 @@
import javax.swing.JList;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.opends.server.types.CommonSchemaElements;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/util/SchemaLoader.java
@@ -36,7 +36,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.config.ConfigConstants;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
@@ -112,13 +112,9 @@
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.ui.UIFactory;
import org.opends.quicksetup.util.Utils;
import org.opends.server.api.ApproximateMatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.ConfigHandler;
import org.opends.server.api.EqualityMatchingRule;
import org.opends.server.api.MatchingRule;
import org.opends.server.api.OrderingMatchingRule;
import org.opends.server.api.SubstringMatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.config.ConfigEntry;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
@@ -2716,7 +2712,7 @@
   * @return {@code true} if this matching rule is an equality mathing rule.
   */
  public static boolean isEqualityMatchingRule(MatchingRule matchingRule) {
    return matchingRule instanceof EqualityMatchingRule;
    return false;
  }
  /**
@@ -2727,7 +2723,7 @@
   * @return {@code true} if this matching rule is an approximate mathing rule.
   */
  public static boolean isApproximateMatchingRule(MatchingRule matchingRule) {
    return matchingRule instanceof ApproximateMatchingRule;
    return false;
  }
  /**
@@ -2738,7 +2734,7 @@
   * @return {@code true} if this matching rule is a substring mathing rule.
   */
  public static boolean isSubstringMatchingRule(MatchingRule matchingRule) {
    return matchingRule instanceof SubstringMatchingRule;
    return false;
  }
  /**
@@ -2749,7 +2745,7 @@
   * @return {@code true} if this matching rule is an ordering mathing rule.
   */
  public static boolean isOrderingMatchingRule(MatchingRule matchingRule) {
    return matchingRule instanceof OrderingMatchingRule;
    return false;
  }
}
opendj3-server-dev/src/server/org/opends/server/api/AttributeSyntax.java
@@ -29,13 +29,14 @@
import java.util.List;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.types.InitializationException;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.i18n.LocalizableMessageBuilder;
opendj3-server-dev/src/server/org/opends/server/api/AuthenticationPolicyState.java
@@ -32,9 +32,9 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.GeneralizedTime;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.core.DirectoryServer;
import org.opends.server.schema.GeneralizedTimeSyntax;
import org.opends.server.types.*;
import static org.opends.messages.CoreMessages.*;
@@ -200,9 +200,7 @@
        final ByteString v = a.iterator().next();
        try
        {
          MatchingRule rule = attributeType.getEqualityMatchingRule();
          ByteString normValue = rule.normalizeAttributeValue(v);
          timeValue = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(normValue);
          timeValue = GeneralizedTime.valueOf(v.toString()).getTimeInMillis();
        }
        catch (final Exception e)
        {
opendj3-server-dev/src/server/org/opends/server/api/Backend.java
@@ -36,6 +36,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.admin.Configuration;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
@@ -284,8 +285,7 @@
   *          matching rule should be considered indexed, or
   *          {@code false} if not.
   */
  private boolean isIndexed(AttributeType attributeType,
                           MatchingRule matchingRule)
  private boolean isIndexed(AttributeType attributeType, MatchingRule matchingRule)
  {
    return false; // FIXME This should be overridden by the JE Backend at least!
  }
opendj3-server-dev/src/server/org/opends/server/api/Group.java
@@ -29,11 +29,13 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.opends.server.admin.std.server.GroupImplementationCfg;
import org.opends.server.core.ServerContext;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
@@ -148,6 +150,8 @@
   * default constructor and initialized with the
   * {@code initializeGroupImplementation} method.
   *
   * @param serverContext
   *            The server context.
   * @param  groupEntry  The entry containing the definition for the
   *                     group to be created.
   *
@@ -157,7 +161,7 @@
   * @throws  DirectoryException  If a problem occurs while trying to
   *                              create the group instance.
   */
  public abstract Group newInstance(Entry groupEntry)
  public abstract Group<T> newInstance(ServerContext serverContext, Entry groupEntry)
         throws DirectoryException;
opendj3-server-dev/src/server/org/opends/server/api/MatchingRuleFactory.java
@@ -32,6 +32,7 @@
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.types.InitializationException;
opendj3-server-dev/src/server/org/opends/server/api/VirtualAttributeProvider.java
@@ -36,6 +36,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.admin.std.server.VirtualAttributeCfg;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.Attribute;
opendj3-server-dev/src/server/org/opends/server/authorization/dseecompat/PatternRDN.java
@@ -37,7 +37,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java
@@ -68,7 +68,7 @@
import org.opends.server.api.AlertGenerator;
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.config.ConfigEntry;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.AddOperation;
opendj3-server-dev/src/server/org/opends/server/backends/jeb/ApproximateIndexer.java
@@ -34,7 +34,7 @@
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.spi.IndexingOptions;
import org.opends.server.api.ExtensibleIndexer;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.types.AttributeType;
/**
@@ -63,14 +63,14 @@
  @Override
  public String getIndexID()
  {
    throw new RuntimeException("Code is not implemented");
    return "approximate";
  }
  /** {@inheritDoc} */
  @Override
  public String getExtensibleIndexID()
  {
    return "approximate";
    throw new RuntimeException("Code is not implemented");
  }
  /** {@inheritDoc} */
opendj3-server-dev/src/server/org/opends/server/backends/jeb/AttributeIndex.java
@@ -45,8 +45,7 @@
import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn.IndexType;
import org.opends.server.admin.std.server.LocalDBIndexCfg;
import org.opends.server.api.ExtensibleIndexer;
import org.opends.server.api.ExtensibleMatchingRule;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.monitors.DatabaseEnvironmentMonitor;
import org.opends.server.types.*;
@@ -112,14 +111,14 @@
  private final Map<String, Index> nameToIndexes;
  private final IndexQueryFactory<IndexQuery> indexQueryFactory;
  /**
   * The ExtensibleMatchingRuleIndex instance for ExtensibleMatchingRule
   * indexes.
   */
  private ExtensibleMatchingRuleIndex extensibleIndexes;
  private int cursorEntryLimit = 100000;
  /**
   * The mapping from extensible index types (e.g. "substring" or "shared") to list of indexes.
   */
  private Map<String, Collection<Index>> extensibleIndexesMapping;
  /**
   * Create a new attribute index object.
   *
   * @param entryContainer The entryContainer of this attribute index.
@@ -179,7 +178,6 @@
      nameToIndexes.put(IndexType.APPROXIMATE.toString(), approximateIndex);
    }
    indexQueryFactory = new IndexQueryFactoryImpl(nameToIndexes, config);
    if (indexConfig.getIndexType().contains(IndexType.EXTENSIBLE))
    {
@@ -188,39 +186,36 @@
      {
        throw new ConfigException(ERR_CONFIG_INDEX_TYPE_NEEDS_MATCHING_RULE.get(attrType, "extensible"));
      }
      extensibleIndexes = new ExtensibleMatchingRuleIndex();
      // Iterate through the Set and create the index only if necessary.
      // Collation equality and Ordering matching rules share the same
      // indexer and index.
      // A Collation substring matching rule is treated differently
      // as it uses a separate indexer and index.
      for(String ruleName:extensibleRules)
      for (final String ruleName : extensibleRules)
      {
        ExtensibleMatchingRule rule = DirectoryServer.getExtensibleMatchingRule(toLowerCase(ruleName));
        MatchingRule rule = DirectoryServer.getMatchingRule(toLowerCase(ruleName));
        if(rule == null)
        {
          logger.error(ERR_CONFIG_INDEX_TYPE_NEEDS_VALID_MATCHING_RULE, attrType, ruleName);
          continue;
        }
        Map<String,Index> indexMap = new HashMap<String,Index>();
        for (ExtensibleIndexer indexer : rule.getIndexers())
        for (org.forgerock.opendj.ldap.spi.Indexer indexer : rule.getIndexers())
        {
          String indexID = attrType.getNameOrOID() + "." + indexer.getIndexID();
          if(!extensibleIndexes.isIndexPresent(indexID))
          final String indexId = indexer.getIndexID();
          if (!nameToIndexes.containsKey(indexId))
          {
            //There is no index available for this index id. Create a new index.
            String indexName = entryContainer.getDatabasePrefix() + "_" + indexID;
            Index extIndex = newExtensibleIndex(indexName, attrType, indexEntryLimit, indexer);
            extensibleIndexes.addIndex(extIndex, indexID);
            final String indexName = name + "." + indexId;
            final Index extIndex = newExtensibleIndex(indexName, attrType, indexEntryLimit, indexer);
            nameToIndexes.put(indexId, extIndex);
          }
          extensibleIndexes.addRule(indexID, rule);
          indexMap.put(indexer.getExtensibleIndexID(), extensibleIndexes.getIndex(indexID));
        }
        IndexQueryFactory<IndexQuery> factory = new IndexQueryFactoryImpl(indexMap, config);
        extensibleIndexes.addQueryFactory(rule, factory);
      }
    }
    indexQueryFactory = new IndexQueryFactoryImpl(nameToIndexes, config);
    extensibleIndexesMapping = computeExtensibleIndexesMapping();
  }
  private Index newIndex(String indexName, int indexEntryLimit, Indexer indexer)
@@ -230,20 +225,20 @@
  }
  private Index buildExtIndex(String name, AttributeType attrType,
      int indexEntryLimit, MatchingRule rule, ExtensibleIndexer extIndexer) throws ConfigException
      int indexEntryLimit, MatchingRule rule, org.forgerock.opendj.ldap.spi.Indexer extIndexer) throws ConfigException
  {
    if (rule == null)
    {
      throw new ConfigException(ERR_CONFIG_INDEX_TYPE_NEEDS_MATCHING_RULE.get(
          attrType, extIndexer.getExtensibleIndexID()));
          attrType, extIndexer.getIndexID()));
    }
    final String indexName = name + "." + extIndexer.getExtensibleIndexID();
    final String indexName = name + "." + extIndexer.getIndexID();
    return newExtensibleIndex(indexName, attrType, indexEntryLimit, extIndexer);
  }
  private Index newExtensibleIndex(String indexName, AttributeType attrType,
      int indexEntryLimit, ExtensibleIndexer extIndexer)
      int indexEntryLimit, org.forgerock.opendj.ldap.spi.Indexer extIndexer)
  {
    JEExtensibleIndexer indexer = new JEExtensibleIndexer(attrType, extIndexer);
    return newIndex(indexName, indexEntryLimit, indexer);
@@ -261,14 +256,6 @@
    {
      index.open();
    }
    if(extensibleIndexes!=null)
    {
      for(Index extensibleIndex:extensibleIndexes.getIndexes())
      {
        extensibleIndex.open();
      }
    }
    indexConfig.addChangeListener(this);
  }
@@ -281,11 +268,6 @@
  public void close() throws DatabaseException
  {
    Utils.closeSilently(nameToIndexes.values());
    if(extensibleIndexes!=null)
    {
      Utils.closeSilently(extensibleIndexes.getIndexes());
    }
    indexConfig.removeChangeListener(this);
    // The entryContainer is responsible for closing the JE databases.
  }
@@ -342,18 +324,6 @@
        success = false;
      }
    }
    if (extensibleIndexes != null)
    {
      for (Index index : extensibleIndexes.getIndexes())
      {
        if (!index.addEntry(buffer, entryID, entry, options))
        {
          success = false;
        }
      }
    }
    return success;
  }
@@ -381,18 +351,6 @@
        success = false;
      }
    }
    if (extensibleIndexes != null)
    {
      for (Index index : extensibleIndexes.getIndexes())
      {
        if (!index.addEntry(txn, entryID, entry, options))
        {
          success = false;
        }
      }
    }
    return success;
  }
@@ -413,14 +371,6 @@
    {
      index.removeEntry(buffer, entryID, entry, options);
    }
    if (extensibleIndexes != null)
    {
      for (Index index : extensibleIndexes.getIndexes())
      {
        index.removeEntry(buffer, entryID, entry, options);
      }
    }
  }
  /**
@@ -440,14 +390,6 @@
    {
      index.removeEntry(txn, entryID, entry, options);
    }
    if (extensibleIndexes != null)
    {
      for (Index index : extensibleIndexes.getIndexes())
      {
        index.removeEntry(txn, entryID, entry, options);
      }
    }
  }
  /**
@@ -474,14 +416,6 @@
    {
      index.modifyEntry(txn, entryID, oldEntry, newEntry, mods, options);
    }
    if (extensibleIndexes != null)
    {
      for (Index index : extensibleIndexes.getIndexes())
      {
        index.modifyEntry(txn, entryID, oldEntry, newEntry, mods, options);
      }
    }
  }
  /**
@@ -508,14 +442,6 @@
    {
      index.modifyEntry(buffer, entryID, oldEntry, newEntry, mods, options);
    }
    if(extensibleIndexes!=null)
    {
      for (Index index : extensibleIndexes.getIndexes())
      {
        index.modifyEntry(buffer, entryID, oldEntry, newEntry, mods, options);
      }
    }
  }
  /**
@@ -916,14 +842,6 @@
    {
      index.closeCursor();
    }
    if(extensibleIndexes!=null)
    {
      for(Index extensibleIndex:extensibleIndexes.getIndexes())
      {
        extensibleIndex.closeCursor();
      }
    }
  }
  /**
@@ -940,14 +858,6 @@
    {
      entryLimitExceededCount += index.getEntryLimitExceededCount();
    }
    if (extensibleIndexes != null)
    {
      for(Index extensibleIndex:extensibleIndexes.getIndexes())
      {
        entryLimitExceededCount += extensibleIndex.getEntryLimitExceededCount();
      }
    }
    return entryLimitExceededCount;
  }
@@ -958,11 +868,6 @@
  public void listDatabases(List<DatabaseContainer> dbList)
  {
    dbList.addAll(nameToIndexes.values());
    if(extensibleIndexes!=null)
    {
      dbList.addAll(extensibleIndexes.getIndexes());
    }
  }
  /**
@@ -1036,12 +941,11 @@
      AttributeType attrType = cfg.getAttribute();
      String name = entryContainer.getDatabasePrefix() + "_" + attrType.getNameOrOID();
      final int indexEntryLimit = cfg.getIndexEntryLimit();
      final JEIndexConfig config = new JEIndexConfig(cfg.getSubstringLength());
      Index presenceIndex = nameToIndexes.get(IndexType.PRESENCE.toString());
      if (cfg.getIndexType().contains(IndexType.PRESENCE))
      {
        if(presenceIndex == null)
        if (presenceIndex == null)
        {
          Indexer presenceIndexer = new PresenceIndexer(attrType);
          presenceIndex = newIndex(name + ".presence", indexEntryLimit, presenceIndexer);
@@ -1051,7 +955,7 @@
        else
        {
          // already exists. Just update index entry limit.
          if(presenceIndex.setIndexEntryLimit(indexEntryLimit))
          if (presenceIndex.setIndexEntryLimit(indexEntryLimit))
          {
            adminActionRequired.set(true);
            messages.add(NOTE_JEB_CONFIG_INDEX_ENTRY_LIMIT_REQUIRES_REBUILD.get(presenceIndex.getName()));
@@ -1074,123 +978,55 @@
      if (cfg.getIndexType().contains(IndexType.EXTENSIBLE))
      {
        Set<String> extensibleRules = cfg.getIndexExtensibleMatchingRule();
        Set<ExtensibleMatchingRule> validRules = new HashSet<ExtensibleMatchingRule>();
        if(extensibleIndexes == null)
        final Set<String> extensibleRules = cfg.getIndexExtensibleMatchingRule();
        final Set<MatchingRule> validRules = new HashSet<MatchingRule>();
        final Set<String> validIndexIds = new HashSet<String>();
        for (String ruleName: extensibleRules)
        {
          extensibleIndexes = new ExtensibleMatchingRuleIndex();
        }
        for(String ruleName:extensibleRules)
        {
          ExtensibleMatchingRule rule = DirectoryServer.getExtensibleMatchingRule(toLowerCase(ruleName));
          if(rule == null)
          MatchingRule rule = DirectoryServer.getMatchingRule(toLowerCase(ruleName));
          if (rule == null)
          {
            logger.error(ERR_CONFIG_INDEX_TYPE_NEEDS_VALID_MATCHING_RULE, attrType, ruleName);
            continue;
          }
          validRules.add(rule);
          Map<String,Index> indexMap = new HashMap<String,Index>();
          for (ExtensibleIndexer indexer : rule.getIndexers())
          for (org.forgerock.opendj.ldap.spi.Indexer indexer : rule.getIndexers())
          {
            String indexID = attrType.getNameOrOID() + "." + indexer.getIndexID();
            if(!extensibleIndexes.isIndexPresent(indexID))
            String indexId = indexer.getIndexID();
            validIndexIds.add(indexId);
            if (!nameToIndexes.containsKey(indexId))
            {
              String indexName =  entryContainer.getDatabasePrefix() + "_" + indexID;
              String indexName =  name + "." + indexId;
              Index extIndex = newExtensibleIndex(indexName, attrType, indexEntryLimit, indexer);
              extensibleIndexes.addIndex(extIndex,indexID);
              nameToIndexes.put(indexId, extIndex);
              openIndex(extIndex, adminActionRequired, messages);
            }
            else
            {
              Index extensibleIndex = extensibleIndexes.getIndex(indexID);
              if(extensibleIndex.setIndexEntryLimit(indexEntryLimit))
              Index extensibleIndex = nameToIndexes.get(indexId);
              if (extensibleIndex.setIndexEntryLimit(indexEntryLimit))
              {
                adminActionRequired.set(true);
                messages.add(NOTE_JEB_CONFIG_INDEX_ENTRY_LIMIT_REQUIRES_REBUILD.get(extensibleIndex.getName()));
              }
              if (indexConfig.getSubstringLength() != cfg.getSubstringLength())
              {
                extensibleIndex.setIndexer(
                    new JEExtensibleIndexer(attrType, indexer));
              }
            }
            extensibleIndexes.addRule(indexID, rule);
            indexMap.put(indexer.getExtensibleIndexID(), extensibleIndexes.getIndex(indexID));
          }
          IndexQueryFactory<IndexQuery> factory = new IndexQueryFactoryImpl(indexMap, config);
          extensibleIndexes.addQueryFactory(rule, factory);
        }
        //Some rules might have been removed from the configuration.
        Set<ExtensibleMatchingRule> deletedRules =
            new HashSet<ExtensibleMatchingRule>(extensibleIndexes.getRules());
        deletedRules.removeAll(validRules);
        if(deletedRules.size() > 0)
        {
          entryContainer.exclusiveLock.lock();
          try
          {
            for(ExtensibleMatchingRule rule:deletedRules)
            {
              Set<ExtensibleMatchingRule> rules = new HashSet<ExtensibleMatchingRule>();
              List<String> ids = new ArrayList<String>();
              for (ExtensibleIndexer indexer : rule.getIndexers())
              {
                String id = attrType.getNameOrOID()  + "." + indexer.getIndexID();
                ids.add(id);
                rules.addAll(extensibleIndexes.getRules(id));
              }
              if(rules.isEmpty())
              {
                //Rule has been already deleted.
                continue;
              }
              //If all the rules are part of the deletedRules, delete this index
              if(deletedRules.containsAll(rules))
              {
                //it is safe to delete this index as it is not shared.
                for(String indexID : ids)
                {
                  Index extensibleIndex = extensibleIndexes.getIndex(indexID);
                  entryContainer.deleteDatabase(extensibleIndex);
                  extensibleIndexes.deleteIndex(indexID);
                  extensibleIndexes.deleteRule(indexID);
                }
              }
              else
              {
                for(String indexID : ids)
                {
                  extensibleIndexes.deleteRule(rule, indexID);
                }
                extensibleIndex.setIndexer(new JEExtensibleIndexer(attrType, indexer));
              }
            }
          }
          finally
          {
            entryContainer.exclusiveLock.unlock();
          }
        }
        removeIndexesForExtensibleMatchingRules(validRules, validIndexIds);
      }
      else
      {
        if(extensibleIndexes != null)
        {
          entryContainer.exclusiveLock.lock();
          try
          {
            for(Index extensibleIndex:extensibleIndexes.getIndexes())
            {
              entryContainer.deleteDatabase(extensibleIndex);
            }
            extensibleIndexes.deleteAll();
          }
          finally
          {
            entryContainer.exclusiveLock.unlock();
          }
        }
        final Set<MatchingRule> validRules = Collections.emptySet();
        final Set<String> validIndexIds = Collections.emptySet();
        removeIndexesForExtensibleMatchingRules(validRules, validIndexIds);
      }
      extensibleIndexesMapping = computeExtensibleIndexesMapping();
      indexConfig = cfg;
      return new ConfigChangeResult(ResultCode.SUCCESS, adminActionRequired.get(), messages);
@@ -1203,6 +1039,60 @@
    }
  }
  /** Remove indexes which do not correspond to valid rules. */
  private void removeIndexesForExtensibleMatchingRules(Set<MatchingRule> validRules, Set<String> validIndexIds)
  {
    final Set<MatchingRule> rulesToDelete = getCurrentExtensibleMatchingRules();
    rulesToDelete.removeAll(validRules);
    if (!rulesToDelete.isEmpty())
    {
      entryContainer.exclusiveLock.lock();
      try
      {
        for (MatchingRule rule: rulesToDelete)
        {
          final List<String> indexIdsToRemove = new ArrayList<String>();
          for (org.forgerock.opendj.ldap.spi.Indexer indexer : rule.getIndexers())
          {
            final String indexId = indexer.getIndexID();
            if (!validIndexIds.contains(indexId))
            {
              indexIdsToRemove.add(indexId);
            }
          }
          // Delete indexes which are not used
          for (String indexId : indexIdsToRemove)
          {
            Index index = nameToIndexes.get(indexId);
            if (index != null)
            {
              entryContainer.deleteDatabase(index);
              nameToIndexes.remove(index);
            }
          }
        }
      }
      finally
      {
        entryContainer.exclusiveLock.unlock();
      }
    }
  }
  private Set<MatchingRule> getCurrentExtensibleMatchingRules()
  {
    final Set<MatchingRule> rules = new HashSet<MatchingRule>();
    for (String ruleName : indexConfig.getIndexExtensibleMatchingRule())
    {
        final MatchingRule rule = DirectoryServer.getMatchingRule(toLowerCase(ruleName));
        if (rule != null)
        {
          rules.add(rule);
        }
    }
    return rules;
  }
  private void applyChangeToIndex(LocalDBIndexCfg cfg, AttributeType attrType,
      String name, IndexType indexType, ExtensibleIndexer indexer,
      AtomicBoolean adminActionRequired, ArrayList<LocalizableMessage> messages)
@@ -1255,7 +1145,7 @@
      int indexEntryLimit, ExtensibleIndexer indexer,
      AtomicBoolean adminActionRequired, ArrayList<LocalizableMessage> messages)
  {
    final String indexName = name + "." + indexer.getExtensibleIndexID();
    final String indexName = name + "." + indexer.getIndexID();
    Index index = newExtensibleIndex(indexName, attrType, indexEntryLimit, indexer);
    return openIndex(index, adminActionRequired, messages);
  }
@@ -1287,14 +1177,6 @@
    {
      index.setTrusted(txn, trusted);
    }
    if(extensibleIndexes!=null)
    {
      for(Index extensibleIndex:extensibleIndexes.getIndexes())
      {
        extensibleIndex.setTrusted(txn, trusted);
      }
    }
  }
  /**
@@ -1310,18 +1192,6 @@
        return false;
      }
    }
    if(extensibleIndexes!=null)
    {
      for(Index extensibleIndex:extensibleIndexes.getIndexes())
      {
        if (!extensibleIndex.isTrusted())
        {
          return false;
        }
      }
    }
    return true;
  }
@@ -1336,14 +1206,6 @@
    {
      index.setRebuildStatus(rebuildRunning);
    }
    if(extensibleIndexes!=null)
    {
      for(Index extensibleIndex:extensibleIndexes.getIndexes())
      {
        extensibleIndex.setRebuildStatus(rebuildRunning);
      }
    }
  }
  /**
@@ -1404,19 +1266,48 @@
  }
  /**
   * Return the mapping of  extensible index types and indexes.
   * Return the mapping of extensible index types and indexes.
   *
   * @return The Map of extensible index types and indexes.
   * @return The map containing entries (extensible index type, list of indexes)
   */
  public Map<String,Collection<Index>> getExtensibleIndexes()
  public Map<String, Collection<Index>> getExtensibleIndexes()
  {
    if (extensibleIndexes != null)
    {
      return extensibleIndexes.getIndexMap();
    }
    return Collections.emptyMap();
    return extensibleIndexesMapping;
  }
  private Map<String, Collection<Index>> computeExtensibleIndexesMapping()
  {
    final Collection<Index> substring = new ArrayList<Index>();
    final Collection<Index> shared = new ArrayList<Index>();
    for (Map.Entry<String, Index> entry : nameToIndexes.entrySet())
    {
      final String indexId = entry.getKey();
      if (isDefaultIndex(indexId)) {
        continue;
      }
      if (indexId.endsWith(EXTENSIBLE_INDEXER_ID_SUBSTRING))
      {
        substring.add(entry.getValue());
      }
      else
      {
        shared.add(entry.getValue());
      }
    }
    final Map<String, Collection<Index>> indexMap = new HashMap<String,Collection<Index>>();
    indexMap.put(EXTENSIBLE_INDEXER_ID_SUBSTRING, substring);
    indexMap.put(EXTENSIBLE_INDEXER_ID_SHARED, shared);
    return Collections.unmodifiableMap(indexMap);
  }
  private boolean isDefaultIndex(String indexId)
  {
    return indexId.equals(IndexType.EQUALITY.toString())
        || indexId.equals(IndexType.PRESENCE.toString())
        || indexId.equals(IndexType.SUBSTRING.toString())
        || indexId.equals(IndexType.ORDERING.toString())
        || indexId.equals(IndexType.APPROXIMATE.toString());
  }
  /**
   * Retrieves all the indexes used by this attribute index.
@@ -1425,17 +1316,9 @@
   * index.
   */
  public Collection<Index> getAllIndexes() {
    LinkedHashSet<Index> indexes = new LinkedHashSet<Index>();
    indexes.addAll(nameToIndexes.values());
    if(extensibleIndexes!=null)
    {
      indexes.addAll(extensibleIndexes.getIndexes());
    }
    return indexes;
    return new LinkedHashSet<Index>(nameToIndexes.values());
  }
  /**
   * Retrieve the entry IDs that might match an extensible filter.
   *
@@ -1468,11 +1351,9 @@
      return evaluateEqualityFilter(filter, debugBuffer, monitor);
    }
    ExtensibleMatchingRule rule = DirectoryServer.getExtensibleMatchingRule(matchRuleOID);
    IndexQueryFactory<IndexQuery> factory = null;
    if (extensibleIndexes == null || (factory = extensibleIndexes.getQueryFactory(rule)) == null)
    MatchingRule rule = DirectoryServer.getMatchingRule(matchRuleOID);
    if (!ruleHasAtLeasOneIndex(rule))
    {
      // There is no index on this matching rule.
      if (monitor.isFilterUseEnabled())
      {
        monitor.updateStats(filter, INFO_JEB_INDEX_FILTER_MATCHING_RULE_NOT_INDEXED.get(
@@ -1486,17 +1367,17 @@
      if (debugBuffer != null)
      {
        debugBuffer.append("[INDEX:");
        for (ExtensibleIndexer indexer : rule.getIndexers())
        for (org.forgerock.opendj.ldap.spi.Indexer indexer : rule.getIndexers())
        {
          debugBuffer.append(" ")
                     .append(filter.getAttributeType().getNameOrOID())
                     .append(".")
                     .append(indexer.getIndexID());
            debugBuffer.append(" ")
              .append(filter.getAttributeType().getNameOrOID())
              .append(".")
              .append(indexer.getIndexID());
        }
        debugBuffer.append("]");
      }
      ByteString assertionValue = filter.getAssertionValue();
      IndexQuery indexQuery = rule.createIndexQuery(assertionValue, factory);
      final IndexQuery indexQuery = rule.getAssertion(filter.getAssertionValue()).createIndexQuery(indexQueryFactory);
      LocalizableMessageBuilder debugMessage = monitor.isFilterUseEnabled() ? new LocalizableMessageBuilder() : null;
      EntryIDSet results = indexQuery.evaluate(debugMessage);
      if (monitor.isFilterUseEnabled())
@@ -1519,232 +1400,18 @@
    }
  }
  /**
   * This class manages all the configured extensible matching rules and
   * their corresponding indexes.
   */
  private static class ExtensibleMatchingRuleIndex
  private boolean ruleHasAtLeasOneIndex(MatchingRule rule)
  {
    /**
      * The mapping of index ID and Index database.
      */
    private final Map<String,Index> id2IndexMap;
    /**
     * The mapping of Index ID and Set the matching rules.
     */
    private final Map<String,Set<ExtensibleMatchingRule>> id2RulesMap;
    /**
     * The Map of configured ExtensibleMatchingRule and the corresponding
     * IndexQueryFactory.
     */
    private final Map<ExtensibleMatchingRule,
            IndexQueryFactory<IndexQuery>> rule2FactoryMap;
    /**
     * Creates a new instance of ExtensibleMatchingRuleIndex.
     */
    private ExtensibleMatchingRuleIndex()
    boolean ruleHasAtLeastOneIndex = false;
    for (org.forgerock.opendj.ldap.spi.Indexer indexer : rule.getIndexers())
    {
      id2IndexMap = new HashMap<String,Index>();
      id2RulesMap = new HashMap<String,Set<ExtensibleMatchingRule>>();
      rule2FactoryMap = new HashMap<ExtensibleMatchingRule,
              IndexQueryFactory<IndexQuery>>();
    }
    /**
     * Returns all configured ExtensibleMatchingRule instances.
     * @return A Set  of extensible matching rules.
     */
    private Set<ExtensibleMatchingRule> getRules()
    {
      return rule2FactoryMap.keySet();
    }
    /**
     * Returns  ExtensibleMatchingRule instances for an index.
     * @param indexID The index ID of an extensible matching rule index.
     * @return A Set of extensible matching rules corresponding to
     *                 an index ID.
     */
    private Set<ExtensibleMatchingRule> getRules(String indexID)
    {
      Set<ExtensibleMatchingRule> rules = id2RulesMap.get(indexID);
      if (rules != null)
      if (nameToIndexes.containsKey(indexer.getIndexID()))
      {
        return Collections.unmodifiableSet(rules);
        ruleHasAtLeastOneIndex = true;
        break;
      }
      return Collections.emptySet();
    }
    /**
     * Returns whether an index is present or not.
     * @param indexID The index ID of an extensible matching rule index.
     * @return True if an index is present. False if there is no matching index.
     */
    private boolean isIndexPresent(String indexID)
    {
      return id2IndexMap.containsKey(indexID);
    }
    /**
     * Returns the index corresponding to an index ID.
     * @param indexID The ID of an index.
     * @return The extensible rule index corresponding to the index ID.
     */
    private Index getIndex(String indexID)
    {
      return id2IndexMap.get(indexID);
    }
    /**
     * Adds a new matching Rule and the name of the associated index.
     * @indexName Name of the index.
     * @rule An ExtensibleMatchingRule instance that needs to be indexed.
     */
    private void addRule(String indexName,ExtensibleMatchingRule rule)
    {
      Set<ExtensibleMatchingRule> rules = id2RulesMap.get(indexName);
      if(rules == null)
      {
        rules = new HashSet<ExtensibleMatchingRule>();
        id2RulesMap.put(indexName, rules);
      }
      rules.add(rule);
    }
    /**
     * Adds a new Index and its name.
     * @param index The extensible matching rule index.
     * @indexName The name of the index.
     */
    private void addIndex(Index index,String indexName)
    {
      id2IndexMap.put(indexName, index);
    }
    /**
     * Returns all the configured extensible indexes.
     * @return All the available extensible matching rule indexes.
     */
    private Collection<Index> getIndexes()
    {
      return Collections.unmodifiableCollection(id2IndexMap.values());
    }
    /**
     * Returns a map of all the configured extensible indexes and their types.
     * @return A map of all the available extensible matching rule indexes
     *             and their types.
     */
    private Map<String,Collection<Index>> getIndexMap()
    {
      if(id2IndexMap.isEmpty())
      {
        return Collections.emptyMap();
      }
      Collection<Index> substring = new ArrayList<Index>();
      Collection<Index> shared = new ArrayList<Index>();
      for(Map.Entry<String,Index> entry :  id2IndexMap.entrySet())
      {
        String indexID = entry.getKey();
        if(indexID.endsWith(EXTENSIBLE_INDEXER_ID_SUBSTRING))
        {
          substring.add(entry.getValue());
        }
        else
        {
          shared.add(entry.getValue());
        }
      }
      Map<String,Collection<Index>> indexMap =
              new HashMap<String,Collection<Index>>();
      indexMap.put(EXTENSIBLE_INDEXER_ID_SUBSTRING, substring);
      indexMap.put(EXTENSIBLE_INDEXER_ID_SHARED, shared);
      return Collections.unmodifiableMap(indexMap);
    }
    /**
     * Deletes an index corresponding to the index ID.
     * @param indexID Name of the index.
     */
    private void deleteIndex(String indexID)
    {
      id2IndexMap.remove(indexID);
    }
    /**
     * Deletes an extensible matching rule from the list of available rules.
     * @param rule The ExtensibleMatchingRule that needs to be removed.
     * @param indexID The name of the index corresponding to the rule.
     */
    private void deleteRule(ExtensibleMatchingRule rule,String indexID)
    {
      Set<ExtensibleMatchingRule> rules = id2RulesMap.get(indexID);
      rules.remove(rule);
      if(rules.isEmpty())
      {
        id2RulesMap.remove(indexID);
      }
      rule2FactoryMap.remove(rule);
    }
    /**
     * Adds an ExtensibleMatchingRule and its corresponding IndexQueryFactory.
     * @param rule An ExtensibleMatchingRule that needs to be added.
     * @param query A query factory matching the rule.
     */
    private void addQueryFactory(ExtensibleMatchingRule rule,
            IndexQueryFactory<IndexQuery> query)
    {
      rule2FactoryMap.put(rule, query);
    }
    /**
     * Returns the query factory associated with the rule.
     * @param rule An ExtensibleMatchingRule that needs to be searched.
     * @return An IndexQueryFactory corresponding to the matching rule.
     */
    private IndexQueryFactory<IndexQuery> getQueryFactory(
            ExtensibleMatchingRule rule)
    {
      return rule2FactoryMap.get(rule);
    }
    /**
     * Deletes  extensible matching rules from the list of available rules.
     * @param indexID The name of the index corresponding to the rules.
     */
    private void deleteRule(String indexID)
    {
      Set<ExtensibleMatchingRule> rules  = id2RulesMap.get(indexID);
      for (ExtensibleMatchingRule rule : rules)
      {
        rule2FactoryMap.remove(rule);
      }
      rules.clear();
      id2RulesMap.remove(indexID);
    }
    /**
     * Deletes all references to matching rules and the indexes.
     */
    private void deleteAll()
    {
      id2IndexMap.clear();
      id2RulesMap.clear();
      rule2FactoryMap.clear();
    }
    return ruleHasAtLeastOneIndex;
  }
  /**
opendj3-server-dev/src/server/org/opends/server/backends/jeb/EqualityIndexer.java
@@ -34,7 +34,7 @@
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.spi.IndexingOptions;
import org.opends.server.api.ExtensibleIndexer;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.types.AttributeType;
/**
@@ -63,14 +63,14 @@
  @Override
  public String getIndexID()
  {
    throw new RuntimeException("Code is not implemented");
    return "equality";
  }
  /** {@inheritDoc} */
  @Override
  public String getExtensibleIndexID()
  {
    return "equality";
    throw new RuntimeException("Code is not implemented");
  }
  /** {@inheritDoc} */
opendj3-server-dev/src/server/org/opends/server/backends/jeb/JEExtensibleIndexer.java
@@ -35,14 +35,13 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.spi.IndexingOptions;
import org.opends.server.api.ExtensibleIndexer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
/**
 *This class implements an Indexer for extensible matching rules in JE Backend.
 * This class implements an Indexer for extensible matching rules in JE Backend.
 */
public final class JEExtensibleIndexer extends Indexer
{
@@ -54,15 +53,11 @@
   */
  private final AttributeType attributeType;
  /**
   * The extensible indexer which will generate the keys
   * for the associated  extensible matching rule.
   * The indexer which will generate the keys
   * for the associated extensible matching rule.
   */
  private final ExtensibleIndexer extensibleIndexer;
  private final org.forgerock.opendj.ldap.spi.Indexer indexer;
  /**
   * Creates a new extensible indexer for JE backend.
@@ -71,19 +66,17 @@
   *                                            required.
   * @param extensibleIndexer The extensible indexer to be used.
   */
  public JEExtensibleIndexer(AttributeType attributeType,
          ExtensibleIndexer extensibleIndexer)
  public JEExtensibleIndexer(AttributeType attributeType, org.forgerock.opendj.ldap.spi.Indexer extensibleIndexer)
  {
    this.attributeType = attributeType;
    this.extensibleIndexer = extensibleIndexer;
    this.indexer = extensibleIndexer;
  }
  /** {@inheritDoc} */
  @Override
  public String toString()
  {
    return attributeType.getNameOrOID() + "."
            + extensibleIndexer.getExtensibleIndexID();
    return attributeType.getNameOrOID() + "." + indexer.getIndexID();
  }
  /** {@inheritDoc} */
@@ -142,7 +135,7 @@
        {
          try
          {
            extensibleIndexer.createKeys(null, value, options, keys);
            indexer.createKeys(null, value, options, keys);
          }
          catch (DecodeException e)
          {
opendj3-server-dev/src/server/org/opends/server/backends/jeb/OrderingIndexer.java
@@ -34,7 +34,7 @@
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.spi.IndexingOptions;
import org.opends.server.api.ExtensibleIndexer;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.types.AttributeType;
/**
@@ -64,14 +64,14 @@
  @Override
  public String getIndexID()
  {
    throw new RuntimeException("Code is not implemented");
    return "ordering";
  }
  /** {@inheritDoc} */
  @Override
  public String getExtensibleIndexID()
  {
    return "ordering";
    throw new RuntimeException("Code is not implemented");
  }
  /** {@inheritDoc} */
opendj3-server-dev/src/server/org/opends/server/backends/jeb/SortValuesSet.java
@@ -30,7 +30,7 @@
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.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.SortKey;
opendj3-server-dev/src/server/org/opends/server/backends/jeb/SubstringIndexer.java
@@ -34,7 +34,7 @@
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.spi.IndexingOptions;
import org.opends.server.api.ExtensibleIndexer;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.types.AttributeType;
/**
@@ -60,14 +60,14 @@
  @Override
  public String getIndexID()
  {
    throw new RuntimeException("Code is not implemented");
    return "substring";
  }
  /** {@inheritDoc} */
  @Override
  public String getExtensibleIndexID()
  {
    return "substring";
    throw new RuntimeException("Code is not implemented");
  }
  /** {@inheritDoc} */
opendj3-server-dev/src/server/org/opends/server/backends/jeb/VLVIndex.java
@@ -42,7 +42,7 @@
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.meta.LocalDBVLVIndexCfgDefn.Scope;
import org.opends.server.admin.std.server.LocalDBVLVIndexCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.controls.ServerSideSortRequestControl;
import org.opends.server.controls.VLVRequestControl;
import org.opends.server.controls.VLVResponseControl;
opendj3-server-dev/src/server/org/opends/server/backends/jeb/VLVKeyComparator.java
@@ -26,16 +26,17 @@
 */
package org.opends.server.backends.jeb;
import java.io.Serializable;
import java.util.Comparator;
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.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.DirectoryException;
import com.sleepycat.je.DatabaseComparator;
import com.sleepycat.je.DatabaseException;
/**
@@ -43,7 +44,7 @@
 * made up the sort values and the entry ID of the largest entry in the sorted
 * set stored in the data for the key.
 */
public class VLVKeyComparator implements Comparator<byte[]>, Serializable
public class VLVKeyComparator implements DatabaseComparator
{
  /**
   * The serial version identifier required to satisfy the compiler because this
@@ -53,7 +54,15 @@
   */
  static final long serialVersionUID = 1585167927344130604L;
  private MatchingRule[] orderingRules;
  /** Matching rules are not serializable. */
  private transient MatchingRule[] orderingRules;
  /**
   * Only oids of matching rules are recorded for serialization. Oids allow to
   * retrieve matching rules after deserialization, through
   * {@code initialize(ClassLoader)} method.
   */
  private String[] orderingRuleOids;
  private boolean[] ascending;
@@ -68,6 +77,11 @@
  public VLVKeyComparator(MatchingRule[] orderingRules, boolean[] ascending)
  {
    this.orderingRules = orderingRules;
    this.orderingRuleOids = new String[orderingRules.length];
    for (int i = 0; i < orderingRules.length; i++)
    {
      orderingRuleOids[i] = orderingRules[i].getOID();
    }
    this.ascending = ascending;
  }
@@ -331,4 +345,18 @@
    // of available values and the entry ID is not available. Just return 0.
    return 0;
  }
  /** {@inheritDoc} */
  @Override
  public void initialize(ClassLoader loader)
  {
    if (orderingRules == null)
    {
      orderingRules = new MatchingRule[orderingRuleOids.length];
      for (int i = 0; i < orderingRuleOids.length; i++)
      {
        orderingRules[i] = DirectoryServer.getSchema().getMatchingRule(orderingRuleOids[i]);
      }
    }
  }
}
opendj3-server-dev/src/server/org/opends/server/backends/jeb/VerifyJob.java
@@ -35,7 +35,7 @@
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.spi.IndexingOptions;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.opends.server.util.ServerConstants;
opendj3-server-dev/src/server/org/opends/server/controls/MatchedValuesFilter.java
@@ -39,7 +39,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.util.Reject;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.*;
opendj3-server-dev/src/server/org/opends/server/controls/ServerSideSortRequestControl.java
@@ -33,7 +33,7 @@
import java.util.StringTokenizer;
import java.io.IOException;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.io.*;
import org.opends.server.protocols.ldap.LDAPResultCode;
opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
@@ -99,14 +99,13 @@
import org.opends.server.api.EntryCache;
import org.opends.server.api.ExportTaskListener;
import org.opends.server.api.ExtendedOperationHandler;
import org.opends.server.api.ExtensibleMatchingRule;
import org.opends.server.api.Extension;
import org.opends.server.api.IdentityMapper;
import org.opends.server.api.ImportTaskListener;
import org.opends.server.api.InitializationCompletedListener;
import org.opends.server.api.InvokableComponent;
import org.opends.server.api.KeyManagerProvider;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.api.MonitorProvider;
import org.opends.server.api.PasswordGenerator;
@@ -223,6 +222,7 @@
import com.forgerock.opendj.util.OperatingSystem;
import static org.forgerock.util.Reject.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.CoreMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
@@ -2743,45 +2743,6 @@
    return directoryServer.schema.getMatchingRule(lowerName);
  }
  /**
   * Registers the provided approximate matching rule with the Directory
   * Server.
   *
   * @param  matchingRule       The matching rule to register with the server.
   * @param  overwriteExisting  Indicates whether to overwrite an existing
   *                            mapping if there are any conflicts (i.e.,
   *                            another matching rule with the same OID or
   *                            name).
   *
   * @throws  DirectoryException  If a conflict is encountered and the
   *                              <CODE>overwriteExisting</CODE> flag is set to
   *                              <CODE>false</CODE>
   */
  public static void registerApproximateMatchingRule(MatchingRule
                                                          matchingRule,
                                                     boolean overwriteExisting)
         throws DirectoryException
  {
    directoryServer.schema.registerMatchingRule(matchingRule, overwriteExisting);
  }
  /**
   * Deregisters the provided approximate matching rule with the Directory
   * Server.
   *
   * @param  matchingRule  The matching rule to deregister with the server.
   */
  public static void deregisterApproximateMatchingRule(MatchingRule
                                                            matchingRule)
  {
    directoryServer.schema.deregisterMatchingRule(matchingRule);
  }
  /**
   * Retrieves the equality matching rule with the specified name or OID.
   *
@@ -2793,7 +2754,7 @@
   */
  public static MatchingRule getEqualityMatchingRule(String lowerName)
  {
    return directoryServer.schema.getMatchingRule(lowerName);
    return getMatchingRule(lowerName);
  }
  /**
@@ -2807,39 +2768,7 @@
   */
  public static MatchingRule getOrderingMatchingRule(String lowerName)
  {
    return directoryServer.schema.getMatchingRule(lowerName);
  }
  /**
   * Registers the provided ordering matching rule with the Directory Server.
   *
   * @param  matchingRule       The matching rule to register with the server.
   * @param  overwriteExisting  Indicates whether to overwrite an existing
   *                            mapping if there are any conflicts (i.e.,
   *                            another matching rule with the same OID or
   *                            name).
   *
   * @throws  DirectoryException  If a conflict is encountered and the
   *                              <CODE>overwriteExisting</CODE> flag is set to
   *                              <CODE>false</CODE>
   */
  public static void registerOrderingMatchingRule(
      MatchingRule matchingRule, boolean overwriteExisting)
      throws DirectoryException
  {
    directoryServer.schema.registerMatchingRule(matchingRule, overwriteExisting);
  }
  /**
   * Deregisters the provided ordering matching rule with the Directory Server.
   *
   * @param  matchingRule  The matching rule to deregister with the server.
   */
  public static void deregisterOrderingMatchingRule(MatchingRule
                                                    matchingRule)
  {
    directoryServer.schema.deregisterMatchingRule(matchingRule);
    return getMatchingRule(lowerName);
  }
  /**
@@ -2853,53 +2782,7 @@
   */
  public static MatchingRule getSubstringMatchingRule(String lowerName)
  {
    return directoryServer.schema.getMatchingRule(lowerName);
  }
  /**
   * Registers the provided substring matching rule with the Directory Server.
   *
   * @param  matchingRule       The matching rule to register with the server.
   * @param  overwriteExisting  Indicates whether to overwrite an existing
   *                            mapping if there are any conflicts (i.e.,
   *                            another matching rule with the same OID or
   *                            name).
   *
   * @throws  DirectoryException  If a conflict is encountered and the
   *                              <CODE>overwriteExisting</CODE> flag is set to
   *                              <CODE>false</CODE>
   */
  public static void registerSubstringMatchingRule(
      MatchingRule matchingRule, boolean overwriteExisting)
      throws DirectoryException
  {
    directoryServer.schema.registerMatchingRule(matchingRule, overwriteExisting);
  }
  /**
   * Deregisters the provided substring matching rule with the Directory Server.
   *
   * @param  matchingRule  The matching rule to deregister with the server.
   */
  public static void deregisterSubstringMatchingRule(MatchingRule
                                                     matchingRule)
  {
    directoryServer.schema.deregisterMatchingRule(matchingRule);
  }
  /**
   * Retrieves the extensible matching rule with the specified name or OID.
   *
   * @param  lowerName  The lowercase name or OID for the extensible matching
   *                rule  to retrieve.
   *
   * @return  The requested extensible matching rule, or <CODE>null</CODE> if no
   *          such matching rule has been defined in the server.
   */
  public static ExtensibleMatchingRule
          getExtensibleMatchingRule(String lowerName)
  {
    return (ExtensibleMatchingRule) directoryServer.schema.getMatchingRule(lowerName);
    return getMatchingRule(lowerName);
  }
  /**
opendj3-server-dev/src/server/org/opends/server/core/GroupManager.java
@@ -628,7 +628,7 @@
          {
            try
            {
              Group<?> groupInstance = groupImplementation.newInstance(entry);
              Group<?> groupInstance = groupImplementation.newInstance(null, entry);
              groupInstances.put(entry.getName(), groupInstance);
              refreshToken++;
            }
@@ -982,7 +982,7 @@
      {
        if (groupImplementation.isGroupDefinition(entry))
        {
          Group<?> groupInstance = groupImplementation.newInstance(entry);
          Group<?> groupInstance = groupImplementation.newInstance(null, entry);
          lock.writeLock().lock();
          try
opendj3-server-dev/src/server/org/opends/server/core/MatchingRuleConfigManager.java
@@ -35,6 +35,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.util.Utils;
import org.opends.server.admin.ClassPropertyDefinition;
import org.opends.server.admin.server.ConfigurationAddListener;
@@ -44,7 +45,6 @@
import org.opends.server.admin.std.meta.MatchingRuleCfgDefn;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.admin.std.server.RootCfg;
import org.opends.server.api.MatchingRule;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.AttributeType;
import org.opends.server.types.ConfigChangeResult;
opendj3-server-dev/src/server/org/opends/server/core/PasswordPolicyFactory.java
@@ -46,8 +46,8 @@
import org.opends.server.api.*;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.schema.GeneralizedTimeSyntax;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.GeneralizedTime;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
@@ -335,22 +335,7 @@
        if (requireChangeBy != null)
        {
          ByteString valueString = ByteString.valueOf(requireChangeBy);
          GeneralizedTimeSyntax syntax = (GeneralizedTimeSyntax)
              serverContext.getSchema().getSyntax(SYNTAX_GENERALIZED_TIME_OID, false);
          if (syntax == null)
          {
            requireChangeByTime = GeneralizedTimeSyntax
                .decodeGeneralizedTimeValue(valueString);
          }
          else
          {
            valueString = syntax.getEqualityMatchingRule().normalizeAttributeValue(
                valueString);
            requireChangeByTime = GeneralizedTimeSyntax
                .decodeGeneralizedTimeValue(valueString);
          }
          requireChangeByTime = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis();
        }
      }
      catch (Exception e)
opendj3-server-dev/src/server/org/opends/server/core/PasswordPolicyState.java
@@ -27,23 +27,51 @@
package org.opends.server.core;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import java.util.TreeMap;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.GeneralizedTime;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.std.meta.PasswordPolicyCfgDefn;
import org.opends.server.api.*;
import org.opends.server.api.AccountStatusNotificationHandler;
import org.opends.server.api.AuthenticationPolicyState;
import org.opends.server.api.PasswordGenerator;
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.api.PasswordValidator;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.schema.AuthPasswordSyntax;
import org.opends.server.schema.GeneralizedTimeSyntax;
import org.opends.server.schema.UserPasswordSyntax;
import org.opends.server.types.*;
import org.opends.server.types.AccountStatusNotification;
import org.opends.server.types.AccountStatusNotificationProperty;
import org.opends.server.types.AccountStatusNotificationType;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
import org.opends.server.types.Operation;
import org.opends.server.types.RawModification;
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.config.ConfigConstants.*;
@@ -222,15 +250,13 @@
    List<Attribute> attrList = userEntry.getAttribute(attributeType);
    if (attrList != null)
    {
      final MatchingRule rule = attributeType.getEqualityMatchingRule();
      for (Attribute a : attrList)
      {
        for (ByteString v : a)
        {
          try
          {
            ByteString normValue = rule.normalizeAttributeValue(v);
            timeValues.add(GeneralizedTimeSyntax.decodeGeneralizedTimeValue(normValue));
            timeValues.add(GeneralizedTime.valueOf(v.toString()).getTimeInMillis());
          }
          catch (Exception e)
          {
@@ -3194,7 +3220,6 @@
    {
      for (Attribute a : attrList)
      {
        boolean usesAuthPasswordSyntax = passwordPolicy.isAuthPasswordSyntax();
        ByteString insecurePassword = null;
        for (ByteString v : a)
        {
opendj3-server-dev/src/server/org/opends/server/extensions/DynamicGroup.java
@@ -37,6 +37,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.admin.std.server.DynamicGroupImplementationCfg;
import org.opends.server.api.Group;
import org.opends.server.core.ServerContext;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.Attribute;
@@ -132,7 +133,7 @@
   * {@inheritDoc}
   */
  @Override()
  public DynamicGroup newInstance(Entry groupEntry)
  public DynamicGroup newInstance(ServerContext serverContext, Entry groupEntry)
         throws DirectoryException
  {
    ifNull(groupEntry);
opendj3-server-dev/src/server/org/opends/server/extensions/EntryDNVirtualAttributeProvider.java
@@ -34,7 +34,7 @@
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.admin.std.server.EntryDNVirtualAttributeCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
opendj3-server-dev/src/server/org/opends/server/extensions/EntryUUIDVirtualAttributeProvider.java
@@ -35,7 +35,7 @@
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.std.server.EntryUUIDVirtualAttributeCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.Attribute;
opendj3-server-dev/src/server/org/opends/server/extensions/HasSubordinatesVirtualAttributeProvider.java
@@ -35,7 +35,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.std.server.HasSubordinatesVirtualAttributeCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
opendj3-server-dev/src/server/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyFactory.java
@@ -37,23 +37,29 @@
import javax.net.ssl.*;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.GeneralizedTime;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.meta.LDAPPassThroughAuthenticationPolicyCfgDefn.MappingPolicy;
import org.opends.server.admin.std.server.LDAPPassThroughAuthenticationPolicyCfg;
import org.opends.server.api.*;
import org.opends.server.api.AuthenticationPolicy;
import org.opends.server.api.AuthenticationPolicyFactory;
import org.opends.server.api.AuthenticationPolicyState;
import org.opends.server.api.DirectoryThread;
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.api.TrustManagerProvider;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.ldap.*;
import org.opends.server.schema.GeneralizedTimeSyntax;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.schema.UserPasswordSyntax;
import org.opends.server.tools.LDAPReader;
@@ -1846,31 +1852,21 @@
              // Ignore any attributes with options.
              if (!attribute.hasOptions())
              {
                MatchingRule rule =
                    attribute.getAttributeType().getEqualityMatchingRule();
                for (ByteString value : attribute)
                {
                  try
                  {
                    ByteString normValue = rule.normalizeAttributeValue(value);
                    long cachedPasswordTime = GeneralizedTimeSyntax
                            .decodeGeneralizedTimeValue(normValue);
                    long cachedPasswordTime = GeneralizedTime.valueOf(value.toString()).getTimeInMillis();
                    long currentTime = provider.getCurrentTimeMS();
                    long expiryTime = cachedPasswordTime
                        + (cfg.getCachedPasswordTTL() * 1000);
                    foundValidCachedPasswordTime = (expiryTime > currentTime);
                  }
                  catch (DecodeException e)
                  catch (LocalizedIllegalArgumentException e)
                  {
                    // Fall-through and give up immediately.
                    logger.traceException(e);
                  }
                  catch (DirectoryException e)
                  {
                    // Fall-through and give up immediately.
                    logger.traceException(e);
                  }
                  break foundCachedPasswordTime;
                }
              }
opendj3-server-dev/src/server/org/opends/server/extensions/NumSubordinatesVirtualAttributeProvider.java
@@ -32,11 +32,9 @@
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.admin.std.server.NumSubordinatesVirtualAttributeCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.MatchingRule;
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
@@ -115,19 +113,16 @@
  @Override()
  public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value)
  {
    Backend backend = DirectoryServer.getBackend(entry.getName());
    MatchingRule eqRule = rule.getAttributeType().getEqualityMatchingRule();
    Backend<?> backend = DirectoryServer.getBackend(entry.getName());
    try
    {
      String nv = eqRule.normalizeAttributeValue(value).toString();
      long count = backend.numSubordinates(entry.getName(), false);
      return count >= 0 && Long.parseLong(nv) == count;
      return count >= 0 && Long.parseLong(value.toString()) == count;
    }
    catch (DecodeException e)
    catch (NumberFormatException e)
    {
      logger.traceException(e);
      return false;
        logger.traceException(e);
        return false;
    }
    catch (DirectoryException e)
    {
opendj3-server-dev/src/server/org/opends/server/extensions/PasswordPolicyStateExtendedOperation.java
@@ -32,6 +32,7 @@
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.io.ASN1;
@@ -39,6 +40,7 @@
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.GeneralizedTime;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.admin.std.server.PasswordPolicyStateExtendedOperationHandlerCfg;
@@ -49,7 +51,9 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import static org.opends.server.protocols.internal.Requests.*;
import org.opends.server.schema.GeneralizedTimeSyntax;
import org.opends.server.types.*;
@@ -1139,18 +1143,14 @@
        {
          try
          {
            ByteString valueString =
                ByteString.valueOf(opValues.get(0));
            long time = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(
                valueString);
            ByteString valueString = ByteString.valueOf(opValues.get(0));
            long time = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis();
            pwpState.setAccountExpirationTime(time);
          }
          catch (DirectoryException de)
          catch (LocalizedIllegalArgumentException e)
          {
            operation.appendErrorMessage(
                ERR_PWPSTATE_EXTOP_BAD_ACCT_EXP_VALUE.get(
                    opValues.get(0),
                    de.getMessageObject()));
                ERR_PWPSTATE_EXTOP_BAD_ACCT_EXP_VALUE.get(opValues.get(0), e.getMessageObject()));
            operation.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
            return false;
          }
@@ -1188,18 +1188,14 @@
        {
          try
          {
            ByteString valueString =
                ByteString.valueOf(opValues.get(0));
            long time = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(
                valueString);
            ByteString valueString = ByteString.valueOf(opValues.get(0));
            long time = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis();
            pwpState.setPasswordChangedTime(time);
          }
          catch (DirectoryException de)
          catch (LocalizedIllegalArgumentException e)
          {
            operation.appendErrorMessage(
                ERR_PWPSTATE_EXTOP_BAD_PWCHANGETIME_VALUE.get(
                    opValues.get(0),
                    de.getMessageObject()));
                ERR_PWPSTATE_EXTOP_BAD_PWCHANGETIME_VALUE.get(opValues.get(0), e.getMessageObject()));
            operation.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
            return false;
          }
@@ -1233,18 +1229,14 @@
        {
          try
          {
            ByteString valueString =
                ByteString.valueOf(opValues.get(0));
            long time = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(
                valueString);
            ByteString valueString = ByteString.valueOf(opValues.get(0));
            long time = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis();
            pwpState.setWarnedTime(time);
          }
          catch (DirectoryException de)
          catch (LocalizedIllegalArgumentException e)
          {
            operation.appendErrorMessage(
                ERR_PWPSTATE_EXTOP_BAD_PWWARNEDTIME_VALUE.get(
                    opValues.get(0),
                    de.getMessageObject()));
                ERR_PWPSTATE_EXTOP_BAD_PWWARNEDTIME_VALUE.get(opValues.get(0), e.getMessageObject()));
            operation.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
            return false;
          }
@@ -1292,23 +1284,19 @@
        {
          try
          {
            ByteString valueString =
                ByteString.valueOf(opValues.get(0));
            long time = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(
                valueString);
            ByteString valueString = ByteString.valueOf(opValues.get(0));
            long time = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis();
            List<Long> authFailureTimes = pwpState.getAuthFailureTimes();
            ArrayList<Long> newFailureTimes =
                new ArrayList<Long>(authFailureTimes.size()+1);
            ArrayList<Long> newFailureTimes = new ArrayList<Long>(authFailureTimes.size()+1);
            newFailureTimes.addAll(authFailureTimes);
            newFailureTimes.add(time);
            pwpState.setAuthFailureTimes(newFailureTimes);
          }
          catch (DirectoryException de)
          catch (LocalizedIllegalArgumentException e)
          {
            LocalizableMessage message = ERR_PWPSTATE_EXTOP_BAD_AUTH_FAILURE_TIME.get(
                opValues.get(0),
                de.getMessageObject());
            operation.setResultCode(de.getResultCode());
            LocalizableMessage message =
                ERR_PWPSTATE_EXTOP_BAD_AUTH_FAILURE_TIME.get(opValues.get(0), e.getMessageObject());
            operation.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
            operation.appendErrorMessage(message);
            return false;
          }
@@ -1327,21 +1315,17 @@
        else
        {
          ArrayList<Long> valueList = new ArrayList<Long>(opValues.size());
          for (String s : opValues)
          for (String value : opValues)
          {
            try
            {
              valueList.add(
                  GeneralizedTimeSyntax.decodeGeneralizedTimeValue(
                      ByteString.valueOf(s)));
              valueList.add(GeneralizedTime.valueOf(value).getTimeInMillis());
            }
            catch (DirectoryException de)
            catch (LocalizedIllegalArgumentException e)
            {
              LocalizableMessage message =
                  ERR_PWPSTATE_EXTOP_BAD_AUTH_FAILURE_TIME.get(
                      s,
                      de.getMessageObject());
              operation.setResultCode(de.getResultCode());
                  ERR_PWPSTATE_EXTOP_BAD_AUTH_FAILURE_TIME.get(value, e.getMessageObject());
              operation.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
              operation.appendErrorMessage(message);
              return false;
            }
@@ -1385,18 +1369,14 @@
        {
          try
          {
            ByteString valueString =
                ByteString.valueOf(opValues.get(0));
            long time = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(
                valueString);
            ByteString valueString = ByteString.valueOf(opValues.get(0));
            long time = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis();
            pwpState.setLastLoginTime(time);
          }
          catch (DirectoryException de)
          catch (LocalizedIllegalArgumentException e)
          {
            operation.appendErrorMessage(
                ERR_PWPSTATE_EXTOP_BAD_LAST_LOGIN_TIME.get(
                    opValues.get(0),
                    de.getMessageObject()));
                ERR_PWPSTATE_EXTOP_BAD_LAST_LOGIN_TIME.get(opValues.get(0), e.getMessageObject()));
            operation.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
            return false;
          }
@@ -1485,23 +1465,19 @@
        {
          try
          {
            ByteString valueString =
                ByteString.valueOf(opValues.get(0));
            long time = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(
                valueString);
            ByteString valueString = ByteString.valueOf(opValues.get(0));
            long time = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis();
            List<Long> authFailureTimes = pwpState.getGraceLoginTimes();
            ArrayList<Long> newGraceTimes =
                new ArrayList<Long>(authFailureTimes.size()+1);
            ArrayList<Long> newGraceTimes = new ArrayList<Long>(authFailureTimes.size()+1);
            newGraceTimes.addAll(authFailureTimes);
            newGraceTimes.add(time);
            pwpState.setGraceLoginTimes(newGraceTimes);
          }
          catch (DirectoryException de)
          catch (LocalizedIllegalArgumentException e)
          {
            LocalizableMessage message = ERR_PWPSTATE_EXTOP_BAD_GRACE_LOGIN_TIME.get(
                opValues.get(0),
                de.getMessageObject());
            operation.setResultCode(de.getResultCode());
            LocalizableMessage message =
                ERR_PWPSTATE_EXTOP_BAD_GRACE_LOGIN_TIME.get(opValues.get(0), e.getMessageObject());
            operation.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
            operation.appendErrorMessage(message);
            return false;
          }
@@ -1524,15 +1500,13 @@
          {
            try
            {
              valueList.add(
                  GeneralizedTimeSyntax.decodeGeneralizedTimeValue(
                      ByteString.valueOf(s)));
              valueList.add(GeneralizedTime.valueOf(s).getTimeInMillis());
            }
            catch (DirectoryException de)
            catch (LocalizedIllegalArgumentException e)
            {
              LocalizableMessage message = ERR_PWPSTATE_EXTOP_BAD_GRACE_LOGIN_TIME.get(
                  s, de.getMessageObject());
              operation.setResultCode(de.getResultCode());
                  s, e.getMessageObject());
              operation.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
              operation.appendErrorMessage(message);
              return false;
            }
@@ -1572,18 +1546,16 @@
        {
          try
          {
            ByteString valueString =
                ByteString.valueOf(opValues.get(0));
            long time = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(
                valueString);
            ByteString valueString = ByteString.valueOf(opValues.get(0));
            long time = GeneralizedTime.valueOf(valueString.toString()).getTimeInMillis();
            pwpState.setRequiredChangeTime(time);
          }
          catch (DirectoryException de)
          catch (LocalizedIllegalArgumentException e)
          {
            operation.appendErrorMessage(
                ERR_PWPSTATE_EXTOP_BAD_REQUIRED_CHANGE_TIME.get(
                    opValues.get(0),
                    de.getMessageObject()));
                    e.getMessageObject()));
            operation.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
            return false;
          }
opendj3-server-dev/src/server/org/opends/server/extensions/StaticGroup.java
@@ -47,6 +47,7 @@
import org.opends.server.api.Group;
import org.opends.server.core.ModifyOperationBasis;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
@@ -102,6 +103,8 @@
  /** Passed to the group manager to see if the nested group list needs to be refreshed. */
  private long nestedGroupRefreshToken = DirectoryServer.getGroupManager().refreshToken();
  private ServerContext serverContext;
  /**
   * Creates an uninitialized static group. This is intended for internal use
   * only, to allow {@code GroupManager} to dynamically create a group.
@@ -121,11 +124,13 @@
   * @param  memberDNs            The set of the DNs of the members for this
   *                              group.
   */
  private StaticGroup(DN groupEntryDN, AttributeType memberAttributeType, LinkedHashSet<CompactDn> memberDNs)
  private StaticGroup(ServerContext serverContext, DN groupEntryDN, AttributeType memberAttributeType,
      LinkedHashSet<CompactDn> memberDNs)
  {
    super();
    ifNull(groupEntryDN, memberAttributeType, memberDNs);
    this.serverContext       = serverContext;
    this.groupEntryDN        = groupEntryDN;
    this.memberAttributeType = memberAttributeType;
    this.memberDNs           = memberDNs;
@@ -141,7 +146,7 @@
  /** {@inheritDoc} */
  @Override()
  public StaticGroup newInstance(Entry groupEntry) throws DirectoryException
  public StaticGroup newInstance(ServerContext serverContext, Entry groupEntry) throws DirectoryException
  {
    ifNull(groupEntry);
@@ -200,7 +205,6 @@
      }
    }
    LinkedHashSet<CompactDn> someMemberDNs = new LinkedHashSet<CompactDn>(membersCount);
    if (memberAttrList != null)
    {
      for (Attribute a : memberAttrList)
@@ -220,7 +224,7 @@
        }
      }
    }
    return new StaticGroup(groupEntry.getName(), someMemberAttributeType, someMemberDNs);
    return new StaticGroup(serverContext, groupEntry.getName(), someMemberAttributeType, someMemberDNs);
  }
  /** {@inheritDoc} */
@@ -516,8 +520,7 @@
  /** {@inheritDoc} */
  @Override()
  public void addMember(Entry userEntry)
         throws UnsupportedOperationException, DirectoryException
  public void addMember(Entry userEntry) throws UnsupportedOperationException, DirectoryException
  {
    ifNull(userEntry);
@@ -614,7 +617,7 @@
   *            The DN
   * @return the compact representation of the DN
   */
  static CompactDn toCompactDn(DN dn)
  private CompactDn toCompactDn(DN dn)
  {
    return Converters.from(dn).compact();
  }
opendj3-server-dev/src/server/org/opends/server/extensions/VirtualStaticGroup.java
@@ -36,6 +36,7 @@
import org.opends.server.admin.std.server.VirtualStaticGroupImplementationCfg;
import org.opends.server.api.Group;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.types.Attribute;
@@ -127,7 +128,7 @@
   * {@inheritDoc}
   */
  @Override()
  public VirtualStaticGroup newInstance(Entry groupEntry)
  public VirtualStaticGroup newInstance(ServerContext serverContext, Entry groupEntry)
         throws DirectoryException
  {
    ifNull(groupEntry);
opendj3-server-dev/src/server/org/opends/server/protocols/ldap/LDAPFilter.java
@@ -38,7 +38,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
opendj3-server-dev/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRule.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRuleFactory.java
@@ -30,10 +30,13 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.opends.server.types.InitializationException;
 /**
@@ -47,8 +50,6 @@
  //Associated Matching Rule.
  private MatchingRule matchingRule;
 /**
  * {@inheritDoc}
  */
@@ -56,11 +57,14 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new HistoricalCsnOrderingMatchingRule();
   final String oid = "1.3.6.1.4.1.26027.1.4.4";
   matchingRule = new SchemaBuilder(CoreSchema.getInstance()).buildMatchingRule(oid)
       .names("historicalCsnOrderingMatch")
       .syntaxOID("1.3.6.1.4.1.1466.115.121.1.40")
       .implementation(new HistoricalCsnOrderingMatchingRuleImpl())
       .addToSchema().toSchema().getMatchingRule(oid);
 }
 /**
  * {@inheritDoc}
  */
opendj3-server-dev/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRuleImpl.java
New file
@@ -0,0 +1,247 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2014 ForgeRock AS.
 */
package org.opends.server.replication.plugin;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteSequence;
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.schema.MatchingRuleImpl;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.spi.IndexQueryFactory;
import org.forgerock.opendj.ldap.spi.Indexer;
import org.forgerock.opendj.ldap.spi.IndexingOptions;
import static org.forgerock.opendj.ldap.Assertion.*;
import static org.opends.messages.ReplicationMessages.*;
import static org.opends.server.util.StaticUtils.*;
/**
 * Matching rule used to establish an order between historical information and index them.
 */
public final class HistoricalCsnOrderingMatchingRuleImpl implements MatchingRuleImpl
{
  private static final String ORDERING_ID = "ordering";
  private final Collection<? extends Indexer> indexers = Collections.singleton(new HistoricalIndexer());
  /** Indexer for the matching rule. */
  private final class HistoricalIndexer implements Indexer
  {
    @Override
    public void createKeys(Schema schema, ByteSequence value, IndexingOptions options, Collection<ByteString> keys)
        throws DecodeException
    {
      keys.add(normalizeAttributeValue(schema, value));
    }
    @Override
    public String getIndexID()
    {
      return ORDERING_ID;
    }
  }
  /**
   * Compare two ByteString values containing historical information.
   *
   * @param value1 first value to compare
   * @param value2 second value to compare
   * @return 0 when equals, -1 or 1 to establish order
   */
  private int compareValues(ByteSequence value1, ByteSequence value2)
  {
    /*
     * See OPENDJ-992: do not use StaticUtils.compare() because it performs
     * unsigned comparisons whereas the 2.4 implementation (below) performs
     * signed comparisons. Changes to indexing comparators require that the
     * index be rebuilt, otherwise the DB can fail unexpectedly.
     */
    int minLength = Math.min(value1.length(), value2.length());
    for (int i = 0; i < minLength; i++)
    {
      final byte b1 = value1.byteAt(i);
      final byte b2 = value2.byteAt(i);
      if (b1 < b2)
      {
        return -1;
      }
      else if (b1 > b2)
      {
        return 1;
      }
    }
    if (value1.length() == value2.length())
    {
      return 0;
    }
    else if (value1.length() < value2.length())
    {
      return -1;
    }
    else
    {
      return 1;
    }
  }
  /** {@inheritDoc} */
  @Override
  public ByteString normalizeAttributeValue(Schema schema, ByteSequence value) throws DecodeException
  {
    /*
     * Change the format of the value to index and start with the serverId. In
     * that manner, the search response time is optimized for a particular
     * serverId. The format of the key is now : serverId + timestamp + seqNum
     */
    try
    {
      int csnIndex = value.toString().indexOf(':') + 1;
      String csn = value.subSequence(csnIndex, csnIndex + 28).toString();
      ByteStringBuilder builder = new ByteStringBuilder(14);
      builder.append(hexStringToByteArray(csn.substring(16, 20)));
      builder.append(hexStringToByteArray(csn.substring(0, 16)));
      builder.append(hexStringToByteArray(csn.substring(20, 28)));
      return builder.toByteString();
    }
    catch (Exception e)
    {
      // This should never occur in practice since these attributes are managed
      // internally.
      throw DecodeException.error(WARN_INVALID_SYNC_HIST_VALUE.get(value), e);
    }
  }
  /** {@inheritDoc} */
  @Override
  public Comparator<ByteSequence> comparator(Schema schema)
  {
    return new Comparator<ByteSequence>()
    {
      @Override
      public int compare(final ByteSequence o1, final ByteSequence o2)
      {
        return compareValues(o1, o2);
      }
    };
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getAssertion(final Schema schema, final ByteSequence value) throws DecodeException
  {
    final ByteString normAssertion = normalizeAttributeValue(schema, value);
    return new Assertion()
    {
      @Override
      public ConditionResult matches(final ByteSequence attributeValue)
      {
        return ConditionResult.valueOf(compareValues(attributeValue, normAssertion) < 0);
      }
      @Override
      public <T> T createIndexQuery(IndexQueryFactory<T> factory) throws DecodeException
      {
        return factory.createRangeMatchQuery(ORDERING_ID, ByteString.empty(), normAssertion, false, false);
      }
    };
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getSubstringAssertion(Schema schema, ByteSequence subInitial,
      List<? extends ByteSequence> subAnyElements, ByteSequence subFinal) throws DecodeException
  {
    return UNDEFINED_ASSERTION;
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getGreaterOrEqualAssertion(Schema schema, ByteSequence value) throws DecodeException
  {
    final ByteString normAssertion = normalizeAttributeValue(schema, value);
    return new Assertion()
    {
      @Override
      public ConditionResult matches(final ByteSequence normalizedAttributeValue)
      {
        return ConditionResult.valueOf(compareValues(normalizedAttributeValue, normAssertion) >= 0);
      }
      @Override
      public <T> T createIndexQuery(IndexQueryFactory<T> factory) throws DecodeException
      {
        return factory.createRangeMatchQuery(ORDERING_ID, normAssertion, ByteString.empty(), true, false);
      }
    };
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getLessOrEqualAssertion(Schema schema, ByteSequence value) throws DecodeException
  {
    final ByteString normAssertion = normalizeAttributeValue(schema, value);
    return new Assertion()
    {
      @Override
      public ConditionResult matches(final ByteSequence normalizedAttributeValue)
      {
        return ConditionResult.valueOf(compareValues(normalizedAttributeValue, normAssertion) <= 0);
      }
      @Override
      public <T> T createIndexQuery(IndexQueryFactory<T> factory) throws DecodeException
      {
        return factory.createRangeMatchQuery(ORDERING_ID, ByteString.empty(), normAssertion, false, true);
      }
    };
  }
  /** {@inheritDoc} */
  @Override
  public Collection<? extends Indexer> getIndexers()
  {
    return indexers;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isIndexingSupported()
  {
    return !indexers.isEmpty();
  }
}
opendj3-server-dev/src/server/org/opends/server/schema/AciSyntax.java
@@ -29,7 +29,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
@@ -82,7 +82,7 @@
         throws ConfigException
  {
    defaultEqualityMatchingRule =
         DirectoryServer.getEqualityMatchingRule(EMR_CASE_IGNORE_IA5_OID);
         DirectoryServer.getMatchingRule(EMR_CASE_IGNORE_IA5_OID);
    if (defaultEqualityMatchingRule == null)
    {
      logger.error(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, EMR_CASE_IGNORE_IA5_OID, SYNTAX_ACI_NAME);
opendj3-server-dev/src/server/org/opends/server/schema/AttributeTypeSyntax.java
@@ -42,7 +42,7 @@
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.AttributeTypeDescriptionAttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordEqualityMatchingRule.java
@@ -28,96 +28,63 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.forgerock.i18n.slf4j.LocalizedLogger;
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.opends.server.api.EqualityMatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRuleImpl;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.spi.IndexQueryFactory;
import org.forgerock.opendj.ldap.spi.Indexer;
import org.forgerock.opendj.ldap.spi.IndexingOptions;
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.core.DirectoryServer;
import static org.opends.server.schema.SchemaConstants.*;
import static org.forgerock.opendj.ldap.Assertion.*;
import static org.opends.server.core.DirectoryServer.*;
/**
 * This class implements the authPasswordMatch matching rule defined in RFC
 * 3112.
 */
class AuthPasswordEqualityMatchingRule
       extends EqualityMatchingRule
class AuthPasswordEqualityMatchingRule implements MatchingRuleImpl
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  private static final String EQUALITY_ID = "equality";
  /**
   * Creates a new instance of this authPasswordMatch matching rule.
   */
  public AuthPasswordEqualityMatchingRule()
  private final Collection<? extends Indexer> indexers = Collections.singleton(new Indexer()
  {
    super();
  }
    @Override
    public void createKeys(Schema schema, ByteSequence value, IndexingOptions options, Collection<ByteString> keys)
        throws DecodeException
    {
      keys.add(normalizeAttributeValue(schema, value));
    }
    @Override
    public String getIndexID()
    {
      return EQUALITY_ID;
    }
  });
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public Collection<String> getNames()
  public Comparator<ByteSequence> comparator(Schema schema)
  {
    return Collections.singleton(EMR_AUTH_PASSWORD_NAME);
    return ByteSequence.COMPARATOR;
  }
  /**
   * Retrieves the OID for this matching rule.
   *
   * @return  The OID for this matching rule.
   */
  @Override
  public String getOID()
  {
    return EMR_AUTH_PASSWORD_OID;
  }
  /**
   * Retrieves the description for this matching rule.
   *
   * @return  The description for this matching rule, or <CODE>null</CODE> if
   *          there is none.
   */
  @Override
  public String getDescription()
  {
    // There is no standard description for this matching rule.
    return EMR_AUTH_PASSWORD_DESCRIPTION;
  }
  /**
   * Retrieves the OID of the syntax with which this matching rule is
   * associated.
   *
   * @return  The OID of the syntax with which this matching rule is associated.
   */
  @Override
  public String getSyntaxOID()
  {
    return SYNTAX_AUTH_PASSWORD_OID;
  }
  /**
   * Retrieves the normalized form of the provided value, which is best suited
   * for efficiently performing matching operations on that value.
   *
   * @param schema The schema.
   * @param  value  The value to be normalized.
   *
   * @return  The normalized version of the provided value.
@@ -126,55 +93,90 @@
   *                              the associated attribute syntax.
   */
  @Override
  public ByteString normalizeAttributeValue(ByteSequence value)
         throws DecodeException
  public ByteString normalizeAttributeValue(Schema schema, ByteSequence value) throws DecodeException
  {
    // We will not alter the value in any way.
    return value.toByteString();
  }
  /**
   * 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.  Other forms of matching against equality matching
   * rules should use the <CODE>areEqual</CODE> method.
   *
   * @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</CODE> if the attribute value should be considered a
   *          match for the provided assertion value, or <CODE>false</CODE> if
   *          not.
   */
  /** {@inheritDoc} */
  @Override
  public ConditionResult valuesMatch(ByteSequence attributeValue,
                                     ByteSequence assertionValue)
  public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue) throws DecodeException
  {
    return new Assertion()
    {
      final ByteString normalizedAssertionValue = normalizeAttributeValue(schema, assertionValue);
      @Override
      public ConditionResult matches(final ByteSequence normalizedAttributeValue)
      {
        return valuesMatch(normalizedAttributeValue, normalizedAssertionValue);
      }
      @Override
      public <T> T createIndexQuery(IndexQueryFactory<T> factory) throws DecodeException
      {
        return factory.createExactMatchQuery(EQUALITY_ID, normalizedAssertionValue);
      }
    };
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getSubstringAssertion(Schema schema, ByteSequence subInitial,
      List<? extends ByteSequence> subAnyElements, ByteSequence subFinal) throws DecodeException
  {
    return UNDEFINED_ASSERTION;
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getGreaterOrEqualAssertion(Schema schema, ByteSequence value) throws DecodeException
  {
    return UNDEFINED_ASSERTION;
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getLessOrEqualAssertion(Schema schema, ByteSequence value) throws DecodeException
  {
    return UNDEFINED_ASSERTION;
  }
  /** {@inheritDoc} */
  @Override
  public Collection<? extends Indexer> getIndexers()
  {
    return indexers;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isIndexingSupported()
  {
    return indexers.isEmpty();
  }
  private ConditionResult valuesMatch(ByteSequence attributeValue, ByteSequence assertionValue)
  {
    // We must be able to decode the attribute value using the authentication
    // password syntax.
    StringBuilder[] authPWComponents;
    try
    {
      authPWComponents =
           AuthPasswordSyntax.decodeAuthPassword(attributeValue.toString());
      authPWComponents = AuthPasswordSyntax.decodeAuthPassword(attributeValue.toString());
    }
    catch (Exception e)
    {
      logger.traceException(e);
      return ConditionResult.FALSE;
    }
    // The first element of the array will be the scheme.  Make sure that we
    // support the requested scheme.
    PasswordStorageScheme storageScheme =
         DirectoryServer.getAuthPasswordStorageScheme(
              authPWComponents[0].toString());
    PasswordStorageScheme<?> storageScheme = getAuthPasswordStorageScheme(authPWComponents[0].toString());
    if (storageScheme == null)
    {
      // It's not a scheme that we can support.
@@ -188,30 +190,5 @@
                                          authPWComponents[2].toString()));
  }
  /**
   * Generates a hash code for the provided attribute value.  This version of
   * the method will simply create a hash code from the normalized form of the
   * attribute value.  For matching rules explicitly designed to work in cases
   * where byte-for-byte comparisons of normalized values is not sufficient for
   * determining equality (e.g., if the associated attribute syntax is based on
   * hashed or encrypted values), then this method must be overridden to provide
   * an appropriate implementation for that case.
   *
   * @param  attributeValue  The attribute value for which to generate the hash
   *                         code.
   *
   * @return  The hash code generated for the provided attribute value.
   */
  @Override
  public int generateHashCode(ByteSequence attributeValue)
  {
    // Because of the variable encoding that may be used, we have no way of
    // comparing two auth password values by hash code and therefore we'll
    // always return the same value so that the valuesMatch method will be
    // invoked to make the determination.
    return 1;
  }
}
opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordEqualityMatchingRuleFactory.java
@@ -28,12 +28,16 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
import static org.opends.server.schema.SchemaConstants.*;
/**
 * This class is a factory class for {@link AuthPasswordEqualityMatchingRule}.
 */
@@ -41,9 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
 //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
 /**
  * {@inheritDoc}
@@ -52,16 +54,18 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new AuthPasswordEqualityMatchingRule();
   matchingRule = new SchemaBuilder(CoreSchema.getInstance()).buildMatchingRule(EMR_AUTH_PASSWORD_OID)
       .names(EMR_AUTH_PASSWORD_NAME)
       .syntaxOID(SYNTAX_AUTH_PASSWORD_OID).description(EMR_AUTH_PASSWORD_DESCRIPTION)
       .implementation(new AuthPasswordEqualityMatchingRule())
       .addToSchema().toSchema().getMatchingRule(EMR_AUTH_PASSWORD_OID);
 }
 /**
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordExactEqualityMatchingRuleFactory.java
@@ -31,10 +31,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -46,7 +47,7 @@
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -57,7 +58,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new AuthPasswordExactEqualityMatchingRule();
   matchingRule = CoreSchema.getAuthPasswordExactMatchingRule();
 }
@@ -66,7 +67,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/AuthPasswordSyntax.java
@@ -31,7 +31,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/BinarySyntax.java
@@ -32,7 +32,7 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import static org.opends.messages.SchemaMessages.*;
opendj3-server-dev/src/server/org/opends/server/schema/BitStringEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new BitStringEqualityMatchingRule();
   matchingRule = CoreSchema.getBitStringMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/BitStringSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
opendj3-server-dev/src/server/org/opends/server/schema/BooleanEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -56,7 +57,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule =  new BooleanEqualityMatchingRule();
   matchingRule = CoreSchema.getBooleanMatchingRule();
 }
@@ -65,7 +66,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/BooleanSyntax.java
@@ -32,7 +32,7 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.util.ServerConstants;
opendj3-server-dev/src/server/org/opends/server/schema/CaseExactEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -56,7 +57,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new CaseExactEqualityMatchingRule();
   matchingRule = CoreSchema.getCaseExactMatchingRule();
 }
@@ -65,7 +66,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/CaseExactIA5EqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -43,7 +44,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -54,7 +55,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new CaseExactIA5EqualityMatchingRule();
   matchingRule = CoreSchema.getCaseExactIA5MatchingRule();
 }
@@ -63,7 +64,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/CaseExactIA5SubstringMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -43,7 +44,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -54,7 +55,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new CaseExactIA5SubstringMatchingRule();
   matchingRule = CoreSchema.getInstance().getMatchingRule(SchemaConstants.SMR_CASE_EXACT_IA5_OID);
 }
@@ -63,7 +64,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/CaseExactOrderingMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -43,7 +44,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -54,7 +55,7 @@
  public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
  {
    matchingRule =  new CaseExactOrderingMatchingRule();
    matchingRule = CoreSchema.getCaseExactOrderingMatchingRule();
  }
@@ -63,7 +64,7 @@
   * {@inheritDoc}
   */
  @Override
  public final Collection<MatchingRule> getMatchingRules()
  public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
  {
    return Collections.singleton(matchingRule);
  }
opendj3-server-dev/src/server/org/opends/server/schema/CaseExactSubstringMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -43,7 +44,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -54,7 +55,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new CaseExactSubstringMatchingRule();
   matchingRule = CoreSchema.getCaseExactSubstringsMatchingRule();
 }
@@ -63,7 +64,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new CaseIgnoreEqualityMatchingRule();
   matchingRule = CoreSchema.getCaseIgnoreMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreIA5EqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
{
  //Associated MatchingRule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new CaseIgnoreIA5EqualityMatchingRule();
   matchingRule = CoreSchema.getCaseIgnoreIA5MatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreIA5SubstringMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -43,7 +44,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new CaseIgnoreIA5SubstringMatchingRule();
   matchingRule = CoreSchema.getCaseIgnoreIA5SubstringsMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreListEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new CaseIgnoreListEqualityMatchingRule();
   matchingRule = CoreSchema.getCaseIgnoreListMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreListSubstringMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -43,7 +44,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
 //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -54,7 +55,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new CaseIgnoreListSubstringMatchingRule();
   matchingRule = CoreSchema.getCaseIgnoreListSubstringsMatchingRule();
 }
@@ -63,7 +64,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreOrderingMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -43,7 +44,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
 //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -54,7 +55,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new CaseIgnoreOrderingMatchingRule();
   matchingRule = CoreSchema.getCaseIgnoreOrderingMatchingRule();
 }
@@ -63,7 +64,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/CaseIgnoreSubstringMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule =  new CaseIgnoreSubstringMatchingRule();
   matchingRule =  CoreSchema.getCaseIgnoreSubstringsMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/CertificateExactAssertionSyntax.java
@@ -31,7 +31,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/CertificateExactMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -56,7 +57,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new CertificateExactMatchingRule();
   matchingRule = CoreSchema.getCertificateExactMatchingRule();
 }
@@ -65,7 +66,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/CertificateListSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/CertificatePairSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/CertificateSyntax.java
@@ -35,7 +35,7 @@
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.CertificateAttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java
@@ -26,55 +26,34 @@
 */
package org.opends.server.schema;
import java.nio.CharBuffer;
import java.text.CollationKey;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteSequence;
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.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.spi.IndexQueryFactory;
import org.forgerock.opendj.ldap.spi.IndexingOptions;
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.api.AbstractMatchingRule;
import org.opends.server.api.ExtensibleIndexer;
import org.opends.server.api.ExtensibleMatchingRule;
import org.opends.server.api.MatchingRule;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.api.OrderingMatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.util.StaticUtils;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.CoreMessages.*;
import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.util.ServerConstants.*;
/**
 * This class is a factory class for Collation matching rules. It
@@ -87,25 +66,6 @@
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  // Whether equality matching rules are enabled.
  private boolean equalityMatchingRuleType;
  // Whether less-than matching rules are enabled.
  private boolean lessThanMatchingRuleType;
  // Whether less-than-equal-to matching rules are enabled.
  private boolean lessThanEqualToMatchingRuleType;
  // Whether less-than-equal-to matching rules are enabled.
  private boolean greaterThanMatchingRuleType;
  // Whether greater-than matching rules are enabled.
  private boolean greaterThanEqualToMatchingRuleType;
  // Whether greater-than-equal-to matching rules are enabled.
  private boolean substringMatchingRuleType;
  // Stores the list of available locales on this JVM.
  private static final Set<Locale> supportedLocales = new HashSet<Locale>(
      Arrays.asList(Locale.getAvailableLocales()));
@@ -118,7 +78,6 @@
      new HashMap<String, MatchingRule>();
  /**
   * Creates a new instance of CollationMatchingRuleFactory.
   */
@@ -127,19 +86,15 @@
    super();
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public final Collection<MatchingRule> getMatchingRules()
  public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
  {
    return Collections.unmodifiableCollection(matchingRules.values());
  }
  /**
   * Adds a new mapping of OID and MatchingRule.
   *
@@ -153,22 +108,6 @@
    matchingRules.put(oid, matchingRule);
  }
  /**
   * Returns the Matching rule for the specified OID.
   *
   * @param oid
   *          OID of the matching rule to be searched.
   * @return MatchingRule corresponding to an OID.
   */
  private MatchingRule getMatchingRule(String oid)
  {
    return matchingRules.get(oid);
  }
  /**
   * Clears the Map containing matching Rules.
   */
@@ -177,63 +116,6 @@
    matchingRules.clear();
  }
  /**
   * Reads the configuration and initializes matching rule types.
   *
   * @param ruleTypes
   *          The Set containing allowed matching rule types.
   */
  private void initializeMatchingRuleTypes(SortedSet<MatchingRuleType> ruleTypes)
  {
    for (MatchingRuleType type : ruleTypes)
    {
      switch (type)
      {
      case EQUALITY:
        equalityMatchingRuleType = true;
        break;
      case LESS_THAN:
        lessThanMatchingRuleType = true;
        break;
      case LESS_THAN_OR_EQUAL_TO:
        lessThanEqualToMatchingRuleType = true;
        break;
      case GREATER_THAN:
        greaterThanMatchingRuleType = true;
        break;
      case GREATER_THAN_OR_EQUAL_TO:
        greaterThanEqualToMatchingRuleType = true;
        break;
      case SUBSTRING:
        substringMatchingRuleType = true;
        break;
      default:
        // No default values allowed.
      }
    }
  }
  /**
   * Creates a new Collator instance.
   *
   * @param locale
   *          Locale for the collator
   * @return Returns a new Collator instance
   */
  private Collator createCollator(Locale locale)
  {
    Collator collator = Collator.getInstance(locale);
    collator.setStrength(Collator.PRIMARY);
    collator.setDecomposition(Collator.FULL_DECOMPOSITION);
    return collator;
  }
  /**
   * {@inheritDoc}
   */
@@ -241,7 +123,7 @@
  public void initializeMatchingRule(CollationMatchingRuleCfg configuration)
      throws ConfigException, InitializationException
  {
    initializeMatchingRuleTypes(configuration.getMatchingRuleType());
    final Schema coreSchema = CoreSchema.getInstance();
    for (String collation : configuration.getCollation())
    {
      CollationMapper mapper = new CollationMapper(collation);
@@ -257,12 +139,22 @@
      Locale locale = getLocale(languageTag);
      if (locale != null)
      {
        createLessThanMatchingRule(mapper, locale);
        createLessThanOrEqualToMatchingRule(mapper, locale);
        createEqualityMatchingRule(mapper, locale);
        createGreaterThanOrEqualToMatchingRule(mapper, locale);
        createGreaterThanMatchingRule(mapper, locale);
        createSubstringMatchingRule(mapper, locale);
        try
        {
          final int[] numericSuffixes = { 1, 2, 3, 4, 5, 6 };
          for (int suffix : numericSuffixes)
          {
            final String oid =  nOID + "." + suffix;
            addMatchingRule(oid, coreSchema.getMatchingRule(oid));
          }
          // the default (equality) matching rule
          addMatchingRule(nOID, coreSchema.getMatchingRule(nOID));
        }
        catch (Exception e)
        {
          logger.error(LocalizableMessage.raw("Error when adding a collation matching rule with oid %s, tag %s: %s",
              nOID, languageTag, e.getMessage()));
        }
      }
      else
      {
@@ -327,19 +219,13 @@
    // Clear the associated matching rules.
    resetRules();
    initializeMatchingRuleTypes(configuration.getMatchingRuleType());
    final Schema coreSchema = CoreSchema.getInstance();
    for (String collation : configuration.getCollation())
    {
      // validation has already been performed in isConfigurationChangeAcceptable()
      CollationMapper mapper = new CollationMapper(collation);
      String languageTag = mapper.getLanguageTag();
      Locale locale = getLocale(languageTag);
      createLessThanMatchingRule(mapper, locale);
      createLessThanOrEqualToMatchingRule(mapper, locale);
      createEqualityMatchingRule(mapper, locale);
      createGreaterThanOrEqualToMatchingRule(mapper, locale);
      createGreaterThanMatchingRule(mapper, locale);
      createSubstringMatchingRule(mapper, locale);
      String nOID = mapper.getNumericOID();
      addMatchingRule(nOID, coreSchema.getMatchingRule(nOID));
    }
    try
@@ -360,8 +246,6 @@
    return new ConfigChangeResult(resultCode, adminActionRequired, messages);
  }
  /**
   * {@inheritDoc}
   */
@@ -415,191 +299,6 @@
  }
  private Collection<String> copyNames(MatchingRule matchingRule)
  {
    Collection<String> defaultNames = new HashSet<String>();
    if (matchingRule != null)
    {
      defaultNames.addAll(matchingRule.getNames());
    }
    return defaultNames;
  }
  /**
   * Creates Less-than Matching Rule.
   *
   * @param mapper
   *          CollationMapper containing OID and the language Tag.
   * @param locale
   *          Locale value
   */
  private void createLessThanMatchingRule(CollationMapper mapper, Locale locale)
  {
    if (!lessThanMatchingRuleType) return;
    String oid = mapper.getNumericOID() + ".1";
    String lTag = mapper.getLanguageTag();
    Collection<String> names = copyNames(getMatchingRule(oid));
    names.add(lTag + ".lt");
    names.add(lTag + ".1");
    MatchingRule matchingRule =
        new CollationLessThanMatchingRule(oid, names, locale);
    addMatchingRule(oid, matchingRule);
  }
  /**
   * Creates Less-Than-Equal-To Matching Rule.
   *
   * @param mapper
   *          CollationMapper containing OID and the language Tag.
   * @param locale
   *          Locale value
   */
  private void createLessThanOrEqualToMatchingRule(
      CollationMapper mapper, Locale locale)
  {
    if (!lessThanEqualToMatchingRuleType) return;
    String oid = mapper.getNumericOID() + ".2";
    String lTag = mapper.getLanguageTag();
    Collection<String> names = copyNames(getMatchingRule(oid));
    names.add(lTag + ".lte");
    names.add(lTag + ".2");
    MatchingRule matchingRule =
        new CollationLessThanOrEqualToMatchingRule(oid, names, locale);
    addMatchingRule(oid, matchingRule);
  }
  /**
   * Creates Equality Matching Rule.
   *
   * @param mapper
   *          CollationMapper containing OID and the language Tag.
   * @param locale
   *          Locale value
   */
  private void createEqualityMatchingRule(CollationMapper mapper, Locale locale)
  {
    if (!equalityMatchingRuleType)
    {
      return;
    }
    // Register the default OID as equality matching rule.
    String lTag = mapper.getLanguageTag();
    String nOID = mapper.getNumericOID();
    Collection<String> defaultNames = copyNames(getMatchingRule(nOID));
    defaultNames.add(lTag);
    MatchingRule matchingRule =
        new CollationEqualityMatchingRule(nOID, defaultNames, locale);
    addMatchingRule(nOID, matchingRule);
    // Register OID.3 as the equality matching rule.
    String OID = mapper.getNumericOID() + ".3";
    Collection<String> names = copyNames(getMatchingRule(OID));
    names.add(lTag + ".eq");
    names.add(lTag + ".3");
    MatchingRule equalityMatchingRule =
        new CollationEqualityMatchingRule(OID, names, locale);
    addMatchingRule(OID, equalityMatchingRule);
  }
  /**
   * Creates Greater-than-equal-to Matching Rule.
   *
   * @param mapper
   *          CollationMapper containing OID and the language Tag.
   * @param locale
   *          Locale value
   */
  private void createGreaterThanOrEqualToMatchingRule(
      CollationMapper mapper, Locale locale)
  {
    if (!greaterThanEqualToMatchingRuleType) return;
    String oid = mapper.getNumericOID() + ".4";
    String lTag = mapper.getLanguageTag();
    Collection<String> names = copyNames(getMatchingRule(oid));
    names.add(lTag + ".gte");
    names.add(lTag + ".4");
    MatchingRule matchingRule =
        new CollationGreaterThanOrEqualToMatchingRule(oid, names, locale);
    addMatchingRule(oid, matchingRule);
  }
  /**
   * Creates Greater-than Matching Rule.
   *
   * @param mapper
   *          CollationMapper containing OID and the language Tag.
   * @param locale
   *          Locale value
   */
  private void createGreaterThanMatchingRule(CollationMapper mapper,
      Locale locale)
  {
    if (!greaterThanMatchingRuleType) return;
    String oid = mapper.getNumericOID() + ".5";
    String lTag = mapper.getLanguageTag();
    Collection<String> names = copyNames(getMatchingRule(oid));
    names.add(lTag + ".gt");
    names.add(lTag + ".5");
    MatchingRule matchingRule =
        new CollationGreaterThanMatchingRule(oid, names, locale);
    addMatchingRule(oid, matchingRule);
  }
  /**
   * Creates substring Matching Rule.
   *
   * @param mapper
   *          CollationMapper containing OID and the language Tag.
   * @param locale
   *          Locale value
   */
  private void createSubstringMatchingRule(CollationMapper mapper,
      Locale locale)
  {
    if (!substringMatchingRuleType) return;
    String oid = mapper.getNumericOID() + ".6";
    String lTag = mapper.getLanguageTag();
    Collection<String> names = copyNames(getMatchingRule(oid));
    names.add(lTag + ".sub");
    names.add(lTag + ".6");
    MatchingRule matchingRule =
        new CollationSubstringMatchingRule(oid, names, locale);
    addMatchingRule(oid, matchingRule);
  }
  /**
   * Verifies if the locale is supported by the JVM.
   *
@@ -648,1424 +347,6 @@
  /**
   * 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
          extends AbstractMatchingRule
          implements ExtensibleMatchingRule
  {
    // Names for this class.
    private final Collection<String> names;
    // Collator for performing equality match.
    protected final Collator collator;
    // Numeric OID of the rule.
    private final String nOID;
    // Locale associated with this rule.
    private final Locale locale;
    // Indexer of this rule.
    protected ExtensibleIndexer indexer;
    /**
     * Constructs a new CollationMatchingRule.
     *
     * @param nOID
     *          OID of the collation matching rule
     * @param names
     *          names of this matching rule
     * @param locale
     *          Locale of the collation matching rule
     */
    private CollationMatchingRule(String nOID,
        Collection<String> names, Locale locale)
    {
      this.names = names;
      this.collator = createCollator(locale);
      this.locale = locale;
      this.nOID = nOID;
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public Collection<String> getNames()
    {
      return Collections.unmodifiableCollection(names);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public String getOID()
    {
      return nOID;
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public String getDescription()
    {
      // There is no standard description for this matching rule.
      return null;
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public String getSyntaxOID()
    {
      return SYNTAX_DIRECTORY_STRING_OID;
    }
    /**
     * Returns the name of the index database for this matching rule. An
     * index name for this rule will be based upon the Locale. This will
     * ensure that multiple collation matching rules corresponding to
     * the same Locale can share the same index database.
     *
     * @return The name of the index for this matching rule.
     */
    public String getIndexName()
    {
      String language = locale.getLanguage();
      String country = locale.getCountry();
      String variant = locale.getVariant();
      StringBuilder builder = new StringBuilder(language);
      if (country != null && country.length() > 0)
      {
        builder.append("_");
        builder.append(locale.getCountry());
      }
      if (variant != null && variant.length() > 0)
      {
        builder.append("_");
        builder.append(locale.getVariant());
      }
      return builder.toString();
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public Collection<ExtensibleIndexer> getIndexers()
    {
      if (indexer == null)
      {
        // The default implementation contains shared indexer and
        // doesn't use the config.
        indexer = new CollationSharedExtensibleIndexer(this);
      }
      return Collections.singletonList(indexer);
    }
  }
  /**
   * Collation rule for Equality matching rule.
   */
  private final class CollationEqualityMatchingRule
          extends CollationMatchingRule
          implements OrderingMatchingRule
  {
    /**
     * The serial version identifier required to satisfy the compiler because
     * this class implements the <CODE>java.io.Serializable</CODE> interface.
     * This value was generated using the <CODE>serialver</CODE> command-line
     * utility included with the Java SDK.
     */
    private static final long serialVersionUID = 3990778178484159862L;
    /**
     * Constructs a new CollationEqualityMatchingRule.
     *
     * @param nOID
     *          OID of the collation matching rule
     * @param names
     *          names of this matching rule
     * @param locale
     *          Locale of the collation matching rule
     */
    private CollationEqualityMatchingRule(String nOID,
        Collection<String> names, Locale locale)
    {
      super(nOID, names, locale);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public ByteString normalizeAttributeValue(ByteSequence value)
        throws DecodeException
    {
      CollationKey key = collator.getCollationKey(value.toString());
      return ByteString.wrap(key.toByteArray());
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public ConditionResult valuesMatch(ByteSequence attributeValue,
        ByteSequence assertionValue)
    {
      return ConditionResult.valueOf(assertionValue.equals(attributeValue));
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public <T> T createIndexQuery(ByteSequence assertionValue,
        IndexQueryFactory<T> factory) throws DecodeException
    {
      // Normalize the assertion value.
      return factory.createExactMatchQuery(indexer
          .getExtensibleIndexID(), normalizeAttributeValue(assertionValue));
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public int compare(byte[] arg0, byte[] arg1)
    {
      return StaticUtils.compare(arg0, arg1);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public int compareValues(ByteSequence value1, ByteSequence value2)
    {
      return value1.compareTo(value2);
    }
  }
  /**
   * Collation rule for Substring matching rule.
   */
  private final class CollationSubstringMatchingRule extends
      CollationMatchingRule
  {
    // Substring Indexer associated with this instance.
    private CollationSubstringExtensibleIndexer subIndexer;
    /**
     * Constructs a new CollationSubstringMatchingRule.
     *
     * @param nOID
     *          OID of the collation matching rule
     * @param names
     *          names of this matching rule
     * @param locale
     *          Locale of the collation matching rule
     */
    private CollationSubstringMatchingRule(String nOID,
        Collection<String> names, Locale locale)
    {
      super(nOID, names, locale);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public ByteString normalizeAttributeValue(ByteSequence value)
        throws DecodeException
    {
      CollationKey key = collator.getCollationKey(value.toString());
      return ByteString.wrap(key.toByteArray());
    }
    /**
     * Utility class which abstracts a substring assertion value.
     */
    private final class Assertion
    {
      // Initial part of the substring filter.
      private String subInitial;
      // any parts of the substring filter.
      private List<String> subAny;
      // Final part of the substring filter.
      private String subFinal;
      /**
       * Creates a new instance of Assertion.
       *
       * @param subInitial
       *          Initial part of the filter.
       * @param subAny
       *          Any part of the filter.
       * @param subFinal
       *          Final part of the filter.
       */
      private Assertion(String subInitial, List<String> subAny,
          String subFinal)
      {
        this.subInitial = subInitial;
        this.subAny = subAny;
        this.subFinal = subFinal;
      }
      /**
       * Returns the Initial part of the assertion.
       *
       * @return Initial part of assertion.
       */
      private String getInitial()
      {
        return subInitial;
      }
      /**
       * Returns the any part of the assertion.
       *
       * @return Any part of the assertion.
       */
      private List<String> getAny()
      {
        return subAny;
      }
      /**
       * Returns the final part of the assertion.
       *
       * @return Final part of the assertion.
       */
      private String getFinal()
      {
        return subFinal;
      }
    }
    private Assertion parseAssertion(ByteSequence value) throws DecodeException
    {
      // Get a string representation of the value.
      String filterString = value.toString();
      int endPos = filterString.length();
      // Find the locations of all the asterisks in the value. Also,
      // check to see if there are any escaped values, since they will
      // need special treatment.
      boolean hasEscape = false;
      LinkedList<Integer> asteriskPositions = new LinkedList<Integer>();
      for (int i = 0; i < endPos; i++)
      {
        if (filterString.charAt(i) == 0x2A) // The asterisk.
        {
          asteriskPositions.add(i);
        }
        else if (filterString.charAt(i) == 0x5C) // The backslash.
        {
          hasEscape = true;
        }
      }
      // If there were no asterisks, then this isn't a substring filter.
      if (asteriskPositions.isEmpty())
      {
        throw DecodeException.error(
            ERR_SEARCH_FILTER_SUBSTRING_NO_ASTERISKS.get(filterString, 0, endPos));
      }
      // If the value starts with an asterisk, then there is no
      // subInitial component. Otherwise, parse out the subInitial.
      String subInitial;
      int firstPos = asteriskPositions.removeFirst();
      if (firstPos == 0)
      {
        subInitial = null;
      }
      else
      {
        if (hasEscape)
        {
          CharBuffer buffer = CharBuffer.allocate(firstPos);
          for (int i = 0; i < firstPos; i++)
          {
            if (filterString.charAt(i) == 0x5C)
            {
              char escapeValue = hexToEscapedChar(filterString, i + 1);
              i += 2; // Move to the next sequence.
              buffer.put(escapeValue);
            }
            else
            {
              buffer.put(filterString.charAt(i));
            }
          }
          char[] subInitialChars = new char[buffer.position()];
          buffer.flip();
          buffer.get(subInitialChars);
          subInitial = new String(subInitialChars);
        }
        else
        {
          subInitial = filterString.substring(0, firstPos);
        }
      }
      // Next, process through the rest of the asterisks to get the
      // subAny values.
      List<String> subAny = new ArrayList<String>();
      for (int asteriskPos : asteriskPositions)
      {
        int length = asteriskPos - firstPos - 1;
        if (hasEscape)
        {
          CharBuffer buffer = CharBuffer.allocate(length);
          for (int i = firstPos + 1; i < asteriskPos; i++)
          {
            if (filterString.charAt(i) == 0x5C)
            {
              char escapeValue = hexToEscapedChar(filterString, i + 1);
              i += 2; // Move to the next sequence.
              buffer.put(escapeValue);
            }
            else
            {
              buffer.put(filterString.charAt(i));
            }
          }
          char[] subAnyChars = new char[buffer.position()];
          buffer.flip();
          buffer.get(subAnyChars);
          subAny.add(new String(subAnyChars));
        }
        else
        {
          subAny.add(filterString.substring(firstPos + 1, firstPos
              + length + 1));
        }
        firstPos = asteriskPos;
      }
      // Finally, see if there is anything after the last asterisk,
      // which would be the subFinal value.
      String subFinal;
      if (firstPos == (endPos - 1))
      {
        subFinal = null;
      }
      else
      {
        int length = endPos - firstPos - 1;
        if (hasEscape)
        {
          CharBuffer buffer = CharBuffer.allocate(length);
          for (int i = firstPos + 1; i < endPos; i++)
          {
            if (filterString.charAt(i) == 0x5C)
            {
              char escapeValue = hexToEscapedChar(filterString, i + 1);
              i += 2; // Move to the next sequence.
              buffer.put(escapeValue);
            }
            else
            {
              buffer.put(filterString.charAt(i));
            }
          }
          char[] subFinalChars = new char[buffer.position()];
          buffer.flip();
          buffer.get(subFinalChars);
          subFinal = new String(subFinalChars);
        }
        else
        {
          subFinal =
              filterString.substring(firstPos + 1, length + firstPos
                  + 1);
        }
      }
      return new Assertion(subInitial, subAny, subFinal);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public ByteString normalizeAssertionValue(ByteSequence value)
        throws DecodeException
    {
      Assertion assertion = parseAssertion(value);
      String subInitial = assertion.getInitial();
      // Normalize the Values in the following format:
      // initialLength, initial, numberofany, anyLength1, any1,
      // anyLength2, any2, ..., anyLengthn, anyn, finalLength, final
      List<Integer> normalizedList = new ArrayList<Integer>();
      if (subInitial == null)
      {
        normalizedList.add(0);
      }
      else
      {
        addLengthAndBytes(subInitial, normalizedList);
      }
      List<String> subAny = assertion.getAny();
      if (subAny.isEmpty())
      {
        normalizedList.add(0);
      }
      else
      {
        normalizedList.add(subAny.size());
        for (String any : subAny)
        {
          addLengthAndBytes(any, normalizedList);
        }
      }
      String subFinal = assertion.getFinal();
      if (subFinal == null)
      {
        normalizedList.add(0);
      }
      else
      {
        addLengthAndBytes(subFinal, normalizedList);
      }
      byte[] normalizedBytes = new byte[normalizedList.size()];
      for (int i = 0; i < normalizedList.size(); i++)
      {
        normalizedBytes[i] = normalizedList.get(i).byteValue();
      }
      return ByteString.wrap(normalizedBytes);
    }
    private void addLengthAndBytes(String substring,
        List<Integer> normalizedList)
    {
      CollationKey key = collator.getCollationKey(substring);
      byte[] substrBytes = key.toByteArray();
      // Last 4 bytes are 0s with PRIMARY strength.
      int length = substrBytes.length - 4;
      normalizedList.add(length);
      for (int i = 0; i < length; i++)
      {
        normalizedList.add((int) substrBytes[i]);
      }
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public ConditionResult valuesMatch(ByteSequence attributeValue,
        ByteSequence assertionValue)
    { // FIXME Code similar to
      // AbstractSubstringMatchingRuleImpl.DefaultSubstringAssertion.matches()
      int valueLength = attributeValue.length() - 4;
      int valuePos = 0; // position in the value bytes array.
      // First byte is the length of subInitial.
      int subInitialLength = 0xFF & assertionValue.byteAt(0);
      if (subInitialLength != 0)
      {
        if (subInitialLength > valueLength)
        {
          return ConditionResult.FALSE;
        }
        for (; valuePos < subInitialLength; valuePos++)
        {
          if (attributeValue.byteAt(valuePos) != assertionValue
              .byteAt(valuePos + 1))
          {
            return ConditionResult.FALSE;
          }
        }
      }
      int assertPos = subInitialLength + 1;
      int anySize = 0xFF & assertionValue.byteAt(assertPos++);
      if (anySize != 0)
      {
        while (anySize-- > 0)
        {
          int anyLength = 0xFF & assertionValue.byteAt(assertPos++);
          int end = valueLength - anyLength;
          boolean match = false;
          for (; valuePos <= end; valuePos++)
          {
            if (assertionValue.byteAt(assertPos) == attributeValue
                .byteAt(valuePos))
            {
              boolean subMatch = true;
              for (int i = 1; i < anyLength; i++)
              {
                if (assertionValue.byteAt(assertPos + i) != attributeValue
                    .byteAt(valuePos + i))
                {
                  subMatch = false;
                  break;
                }
              }
              if (subMatch)
              {
                match = subMatch;
                break;
              }
            }
          }
          if (match)
          {
            valuePos += anyLength;
          }
          else
          {
            return ConditionResult.FALSE;
          }
          assertPos = assertPos + anyLength;
        }
      }
      int finalLength = 0xFF & assertionValue.byteAt(assertPos++);
      if (finalLength != 0)
      {
        if ((valueLength - finalLength) < valuePos)
        {
          return ConditionResult.FALSE;
        }
        if (finalLength != assertionValue.length() - assertPos)
        {
          // Some issue with the encoding.
          return ConditionResult.FALSE;
        }
        valuePos = valueLength - finalLength;
        for (int i = 0; i < finalLength; i++, valuePos++)
        {
          if (assertionValue.byteAt(assertPos + i) != attributeValue
              .byteAt(valuePos))
          {
            return ConditionResult.FALSE;
          }
        }
      }
      return ConditionResult.TRUE;
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public final Collection<ExtensibleIndexer> getIndexers()
    {
      List<ExtensibleIndexer> indexers = new ArrayList<ExtensibleIndexer>();
      if (subIndexer == null)
      {
        subIndexer = new CollationSubstringExtensibleIndexer(this);
      }
      if (indexer == null)
      {
        indexer = new CollationSharedExtensibleIndexer(this);
      }
      indexers.add(subIndexer);
      indexers.add(indexer);
      return indexers;
    }
    /**
     * Makes a byte array representing a substring index key for one
     * substring of a value.
     *
     * @param value
     *          The String containing the value.
     * @param pos
     *          The starting position of the substring.
     * @param len
     *          The length of the substring.
     * @return A byte string containing a substring key.
     */
    private ByteString makeSubstringKey(String value, int pos, int len)
    {
      String sub = value.substring(pos, pos + len);
      CollationKey col = collator.getCollationKey(sub);
      byte[] key = col.toByteArray();
      // truncate the key
      return ByteString.wrap(key).subSequence(0, key.length - 4);
    }
    /**
     * Uses an equality index to retrieve the entry IDs that might
     * contain a given initial substring.
     *
     * @param bytes
     *          A normalized initial substring of an attribute value.
     * @return The candidate entry IDs.
     */
    private <T> T matchInitialSubstring(String value,
        IndexQueryFactory<T> factory)
    {
      // Use the shared equality indexer.
      return createRangeMatchQuery(value, factory, this.indexer);
    }
    private <T> T createRangeMatchQuery(String value,
        IndexQueryFactory<T> factory, ExtensibleIndexer indexer)
    { // FIXME Code similar to
      // AbstractSubstringMatchingRuleImpl.DefaultSubstringAssertion.rangeMatch()
      ByteString lower = makeSubstringKey(value, 0, value.length());
      ByteStringBuilder upper = new ByteStringBuilder(lower);
      for (int i = upper.length() - 1; i >= 0; i--)
      {
        if (upper.byteAt(i) == 0xFF)
        {
          // We have to carry the overflow to the more significant byte.
          upper.setByte(i, (byte) 0);
        }
        else
        {
          // No overflow, we can stop.
          upper.setByte(i, (byte) (upper.byteAt(i) + 1));
          break;
        }
      }
      // Read the range: lower <= keys < upper.
      return factory.createRangeMatchQuery(
          indexer.getExtensibleIndexID(), lower, upper, true, false);
    }
    /**
     * Retrieves the Index Records that might contain a given substring.
     *
     * @param value
     *          A String representing the attribute value.
     * @param factory
     *          An IndexQueryFactory which issues calls to the backend.
     * @param substrLength
     *          The length of the substring.
     * @return The candidate entry IDs.
     */
    private <T> T matchSubstring(String value, IndexQueryFactory<T> factory)
    { // FIXME Code similar to
      // AbstractSubstringMatchingRuleImpl.DefaultSubstringAssertion.substringMatch()
      int substrLength = factory.getIndexingOptions().substringKeySize();
      if (value.length() < substrLength)
      {
        return createRangeMatchQuery(value, factory, subIndexer);
      }
      List<T> queryList = new ArrayList<T>();
      Set<ByteString> set = new TreeSet<ByteString>();
      for (int first = 0, last = substrLength;
           last <= value.length();
           first++, last++)
      {
        set.add(makeSubstringKey(value, first, substrLength));
      }
      for (ByteString keyBytes : set)
      {
        queryList.add(factory.createExactMatchQuery(
            subIndexer.getExtensibleIndexID(), keyBytes));
      }
      return factory.createIntersectionQuery(queryList);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public <T> T createIndexQuery(ByteSequence assertionValue,
        IndexQueryFactory<T> factory) throws DecodeException
    { // FIXME Code similar to
      // AbstractSubstringMatchingRuleImpl.DefaultSubstringAssertion.createIndexQuery()?
      Assertion assertion = parseAssertion(assertionValue);
      String subInitial = assertion.getInitial();
      List<String> subAny = assertion.getAny();
      String subFinal = assertion.getFinal();
      List<T> queries = new ArrayList<T>();
      if (subInitial == null && subAny.isEmpty() && subFinal == null)
      {
        // Can happen with a filter like "cn:en.6:=*".
        // Just return an empty record.
        return factory.createMatchAllQuery();
      }
      List<String> elements = new ArrayList<String>();
      if (subInitial != null)
      {
        // Always use the shared indexer for initial match.
        queries.add(matchInitialSubstring(subInitial, factory));
      }
      if (subAny != null && subAny.size() > 0)
      {
        elements.addAll(subAny);
      }
      if (subFinal != null)
      {
        elements.add(subFinal);
      }
      for (String element : elements)
      {
        queries.add(matchSubstring(element, factory));
      }
      return factory.createIntersectionQuery(queries);
    }
  }
  /**
   * An abstract Collation rule for Ordering matching rule.
   */
  private abstract class CollationOrderingMatchingRule
          extends CollationMatchingRule
          implements OrderingMatchingRule
  {
    /**
     * The serial version identifier required to satisfy the compiler because
     * this class implements the <CODE>java.io.Serializable</CODE> interface.
     * This value was generated using the <CODE>serialver</CODE> command-line
     * utility included with the Java SDK.
     */
    private static final long serialVersionUID = 7354051060508436941L;
    /**
     * Constructs a new CollationOrderingMatchingRule.
     *
     * @param nOID
     *          OID of the collation matching rule
     * @param names
     *          names of this matching rule
     * @param locale
     *          Locale of the collation matching rule
     */
    private CollationOrderingMatchingRule(String nOID,
        Collection<String> names, Locale locale)
    {
      super(nOID, names, locale);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public ByteString normalizeAttributeValue(ByteSequence value)
        throws DecodeException
    {
      CollationKey key = collator.getCollationKey(value.toString());
      return ByteString.wrap(key.toByteArray());
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public int compare(byte[] arg0, byte[] arg1)
    {
      return StaticUtils.compare(arg0, arg1);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public int compareValues(ByteSequence value1, ByteSequence value2)
    {
      return value1.compareTo(value2);
    }
  }
  /**
   * Collation matching rule for Less-than matching rule.
   */
  private final class CollationLessThanMatchingRule extends
      CollationOrderingMatchingRule
  {
    /**
     * The serial version identifier required to satisfy the compiler because
     * this class implements the <CODE>java.io.Serializable</CODE> interface.
     * This value was generated using the <CODE>serialver</CODE> command-line
     * utility included with the Java SDK.
     */
    private static final long serialVersionUID = -7578406829946732713L;
    /**
     * Constructs a new CollationLessThanMatchingRule.
     *
     * @param nOID
     *          OID of the collation matching rule
     * @param names
     *          names of this matching rule
     * @param locale
     *          Locale of the collation matching rule
     */
    private CollationLessThanMatchingRule(String nOID,
        Collection<String> names, Locale locale)
    {
      super(nOID, names, locale);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public ConditionResult valuesMatch(ByteSequence attributeValue,
        ByteSequence assertionValue)
    {
      int ret = attributeValue.compareTo(assertionValue);
      return ConditionResult.valueOf(ret < 0);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public <T> T createIndexQuery(ByteSequence assertionValue,
        IndexQueryFactory<T> factory) throws DecodeException
    {
      return factory.createRangeMatchQuery(indexer
          .getExtensibleIndexID(), ByteString.empty(),
          normalizeAttributeValue(assertionValue), false, false);
    }
  }
  /**
   * Collation rule for less-than-equal-to matching rule.
   */
  private final class CollationLessThanOrEqualToMatchingRule extends
      CollationOrderingMatchingRule
  {
    /**
     * The serial version identifier required to satisfy the compiler because
     * this class implements the <CODE>java.io.Serializable</CODE> interface.
     * This value was generated using the <CODE>serialver</CODE> command-line
     * utility included with the Java SDK.
     */
    private static final long serialVersionUID = 7222067708233629974L;
    /**
     * Constructs a new CollationLessThanOrEqualToMatchingRule.
     *
     * @param nOID
     *          OID of the collation matching rule
     * @param names
     *          names of this matching rule
     * @param locale
     *          Locale of the collation matching rule
     */
    private CollationLessThanOrEqualToMatchingRule(String nOID,
        Collection<String> names, Locale locale)
    {
      super(nOID, names, locale);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public ConditionResult valuesMatch(ByteSequence attributeValue,
        ByteSequence assertionValue)
    {
      int ret = attributeValue.compareTo(assertionValue);
      return ConditionResult.valueOf(ret <= 0);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public <T> T createIndexQuery(ByteSequence assertionValue,
        IndexQueryFactory<T> factory) throws DecodeException
    {
      // Read the range: lower < keys <= upper.
      return factory.createRangeMatchQuery(indexer
          .getExtensibleIndexID(), ByteString.empty(),
          normalizeAttributeValue(assertionValue), false, true);
    }
  }
  /**
   * Collation rule for greater-than matching rule.
   */
  private final class CollationGreaterThanMatchingRule extends
      CollationOrderingMatchingRule
  {
    /**
     * The serial version identifier required to satisfy the compiler because
     * this class implements the <CODE>java.io.Serializable</CODE> interface.
     * This value was generated using the <CODE>serialver</CODE> command-line
     * utility included with the Java SDK.
     */
    private static final long serialVersionUID = 1204368277332957024L;
    /**
     * Constructs a new CollationGreaterThanMatchingRule.
     *
     * @param nOID
     *          OID of the collation matching rule
     * @param names
     *          names of this matching rule
     * @param locale
     *          Locale of the collation matching rule
     */
    private CollationGreaterThanMatchingRule(String nOID,
        Collection<String> names, Locale locale)
    {
      super(nOID, names, locale);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public ConditionResult valuesMatch(ByteSequence attributeValue,
        ByteSequence assertionValue)
    {
      int ret = attributeValue.compareTo(assertionValue);
      return ConditionResult.valueOf(ret > 0);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public <T> T createIndexQuery(ByteSequence assertionValue,
        IndexQueryFactory<T> factory) throws DecodeException
    {
      return factory.createRangeMatchQuery(indexer
          .getExtensibleIndexID(), normalizeAttributeValue(assertionValue),
          ByteString.empty(), false, false);
    }
  }
  /**
   * Collation rule for greater-than-equal-to matching rule.
   */
  private final class CollationGreaterThanOrEqualToMatchingRule extends
      CollationOrderingMatchingRule
  {
    /**
     * The serial version identifier required to satisfy the compiler because
     * this class implements the <CODE>java.io.Serializable</CODE> interface.
     * This value was generated using the <CODE>serialver</CODE> command-line
     * utility included with the Java SDK.
     */
    private static final long serialVersionUID = -5212358378014047933L;
    /**
     * Constructs a new CollationGreaterThanOrEqualToMatchingRule.
     *
     * @param nOID
     *          OID of the collation matching rule
     * @param names
     *          names of this matching rule
     * @param locale
     *          Locale of the collation matching rule
     */
    private CollationGreaterThanOrEqualToMatchingRule(String nOID,
        Collection<String> names, Locale locale)
    {
      super(nOID, names, locale);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public ConditionResult valuesMatch(ByteSequence attributeValue,
        ByteSequence assertionValue)
    {
      int ret = attributeValue.compareTo(assertionValue);
      return ConditionResult.valueOf(ret >= 0);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public <T> T createIndexQuery(ByteSequence assertionValue,
        IndexQueryFactory<T> factory) throws DecodeException
    {
      // Read the range: lower <= keys < upper.
      return factory.createRangeMatchQuery(indexer
          .getExtensibleIndexID(), normalizeAttributeValue(assertionValue),
          ByteString.empty(), true, false);
    }
  }
  /**
   * Extensible Indexer class for Collation Matching rules which share
   * the same index. This Indexer is shared by Equality and Ordering
   * Collation Matching Rules.
   */
  private final class CollationSharedExtensibleIndexer extends
      ExtensibleIndexer
  {
    /**
     * The Extensible Matching Rule.
     */
    private final CollationMatchingRule matchingRule;
    /**
     * Creates a new instance of CollationSharedExtensibleIndexer.
     *
     * @param matchingRule
     *          The Collation Matching Rule.
     */
    private CollationSharedExtensibleIndexer(
        CollationMatchingRule matchingRule)
    {
      this.matchingRule = matchingRule;
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public String getExtensibleIndexID()
    {
      return EXTENSIBLE_INDEXER_ID_SHARED;
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public final void createKeys(Schema schema, ByteSequence value,
        IndexingOptions options, Collection<ByteString> keys)
        throws DecodeException
    {
      keys.add(matchingRule.normalizeAttributeValue(value));
    }
    /** {@inheritDoc} */
    @Override
    public String getIndexID()
    {
      return matchingRule.getIndexName() + "." + getExtensibleIndexID();
    }
  }
  /**
   * Extensible Indexer class for Collation Substring Matching rules.
   * This Indexer is used by Substring Collation Matching Rules.
   */
  private final class CollationSubstringExtensibleIndexer extends
      ExtensibleIndexer
  {
    private final CollationSubstringMatchingRule matchingRule;
    /**
     * Creates a new instance of CollationSubstringExtensibleIndexer.
     *
     * @param matchingRule
     *          The CollationSubstringMatching Rule.
     */
    private CollationSubstringExtensibleIndexer(
        CollationSubstringMatchingRule matchingRule)
    {
      this.matchingRule = matchingRule;
    }
    /** {@inheritDoc} */
    @Override
    public void createKeys(Schema schema, ByteSequence value,
        IndexingOptions options, Collection<ByteString> keys)
    { // TODO merge with AbstractSubstringMatchingRuleImpl.SubstringIndexer.createKeys();
      String normValue = value.toString();
      int keyLength = options.substringKeySize();
      for (int i = 0, remain = normValue.length(); remain > 0; i++, remain--)
      {
        int len = Math.min(keyLength, remain);
        keys.add(matchingRule.makeSubstringKey(normValue, i, len));
      }
    }
    /** {@inheritDoc} */
    @Override
    public String getIndexID()
    {
      return matchingRule.getIndexName() + "." + getExtensibleIndexID();
    }
    /** {@inheritDoc} */
    @Override
    public String getExtensibleIndexID()
    {
      return EXTENSIBLE_INDEXER_ID_SUBSTRING;
    }
  }
  /**
   * A utility class for extracting the OID and Language Tag from the
   * configuration entry.
   */
opendj3-server-dev/src/server/org/opends/server/schema/CountryStringSyntax.java
@@ -33,7 +33,7 @@
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.CountryStringAttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/DITContentRuleSyntax.java
@@ -37,7 +37,7 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/DITStructureRuleSyntax.java
@@ -35,7 +35,7 @@
import java.util.List;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/DeliveryMethodSyntax.java
@@ -33,7 +33,7 @@
import java.util.StringTokenizer;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/DirectoryStringFirstComponentEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new DirectoryStringFirstComponentEqualityMatchingRule();
   matchingRule = CoreSchema.getDirectoryStringFirstComponentMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/DirectoryStringSyntax.java
@@ -35,7 +35,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.DirectoryStringAttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.ConfigChangeResult;
opendj3-server-dev/src/server/org/opends/server/schema/DistinguishedNameEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule =  new DistinguishedNameEqualityMatchingRule();
   matchingRule =  CoreSchema.getDistinguishedNameMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/DistinguishedNameSyntax.java
@@ -33,7 +33,7 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteSequence;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.DN;
opendj3-server-dev/src/server/org/opends/server/schema/DoubleMetaphoneApproximateMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new DoubleMetaphoneApproximateMatchingRule();
   matchingRule = CoreSchema.getInstance().getMatchingRule("1.3.6.1.4.1.26027.1.4.1");
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/EnhancedGuideSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/FaxNumberSyntax.java
@@ -32,7 +32,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/FaxSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -45,7 +46,7 @@
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -56,7 +57,7 @@
  public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
  {
    matchingRule = new GeneralizedTimeEqualityMatchingRule();
    matchingRule = CoreSchema.getGeneralizedTimeMatchingRule();
  }
@@ -65,7 +66,7 @@
  * {@inheritDoc}
  */
 @Override
  public final Collection<MatchingRule> getMatchingRules()
  public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
  {
    return Collections.singleton(matchingRule);
  }
opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeOrderingMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -45,7 +46,7 @@
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -56,7 +57,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new GeneralizedTimeOrderingMatchingRule();
   matchingRule = CoreSchema.getGeneralizedTimeOrderingMatchingRule();
 }
@@ -65,7 +66,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/GeneralizedTimeSyntax.java
@@ -37,7 +37,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/GuideSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/IA5StringSyntax.java
@@ -29,7 +29,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/IntegerEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new IntegerEqualityMatchingRule();
   matchingRule = CoreSchema.getIntegerMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/IntegerFirstComponentEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new IntegerFirstComponentEqualityMatchingRule();
   matchingRule = CoreSchema.getIntegerFirstComponentMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/IntegerOrderingMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule =  new IntegerOrderingMatchingRule();
   matchingRule = CoreSchema.getIntegerOrderingMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/IntegerSyntax.java
@@ -31,7 +31,7 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteSequence;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/JPEGSyntax.java
@@ -34,7 +34,7 @@
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.JPEGAttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/KeywordEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -45,7 +46,7 @@
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -56,7 +57,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new KeywordEqualityMatchingRule();
   matchingRule = CoreSchema.getKeywordMatchingRule();
 }
@@ -65,7 +66,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/LDAPSyntaxDescriptionSyntax.java
@@ -27,9 +27,8 @@
package org.opends.server.schema;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
@@ -41,11 +40,12 @@
import org.forgerock.opendj.config.server.ConfigException;
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.AttributeSyntax;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.CommonSchemaElements;
import org.opends.server.types.DirectoryException;
@@ -54,8 +54,6 @@
import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.schema.SchemaConstants.*;
import static com.forgerock.opendj.util.StringPrepProfile.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
/**
@@ -68,9 +66,6 @@
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  // The default equality matching rule for this syntax.
  private MatchingRule defaultEqualityMatchingRule;
@@ -1438,9 +1433,23 @@
    @Override
    public MatchingRule getOrderingMatchingRule()
    {
      if(orderingMatchingRule == null)
      if (orderingMatchingRule == null)
      {
        orderingMatchingRule = new EnumOrderingMatchingRule(this, oid);
        /*
         * It is not sufficient to build the enum matching rule alone here, we
         * need to build enum syntax as well otherwise the schema is not valid. The
         * enum matching rule is automatically built with the enum syntax by the
         * builder.
         */
        String[] enumerations = new String[entries.size()];
        Iterator<ByteSequence> it = entries.iterator();
        for (int i=0; i < entries.size(); i++)
        {
          enumerations[i] = it.next().toString();
        }
        SchemaBuilder builder = new SchemaBuilder(CoreSchema.getInstance()).addEnumerationSyntax(
            oid, getDescription(), true, enumerations);
        orderingMatchingRule = builder.toSchema().getMatchingRule(OMR_OID_GENERIC_ENUM + "." + oid);
        try
        {
          DirectoryServer.registerMatchingRule(orderingMatchingRule, false);
@@ -1496,149 +1505,5 @@
      return approximateMatchingRule;
    }
    //Returns the associated data structure containing the enum
    //values.
    private LinkedList<ByteSequence> getEnumValues()
    {
      return entries;
    }
    /**
      * Implementation of an Enum Ordering matching rule.
      */
    private final class EnumOrderingMatchingRule
       extends AbstractOrderingMatchingRule
    {
      //The enumeration syntax instance.
      private EnumSyntax syntax;
      //The oid of the matching rule.
      private String oid;
      //The name of the matching rule.
      private String name;
      static final long serialVersionUID = -2624642267131703408L;
      /**
       * Creates a new instance.
       */
      private EnumOrderingMatchingRule(EnumSyntax syntax,String oid)
      {
        super();
        this.syntax = syntax;
        this.oid = OMR_OID_GENERIC_ENUM + "." + oid;
        this.name = OMR_GENERIC_ENUM_NAME + oid;
      }
      /**
      * {@inheritDoc}
      */
      @Override
      public int compare(byte[] arg0, byte[] arg1)
      {
        return compareValues(ByteString.wrap(arg0),ByteString.wrap(arg1));
      }
      /**
      * {@inheritDoc}
      */
      @Override
      public int compareValues(ByteSequence value1, ByteSequence value2)
      {
        LinkedList<ByteSequence> enumValues = syntax.getEnumValues();
        return enumValues.indexOf(value1) - enumValues.indexOf(value2);
      }
      /**
       * {@inheritDoc}
       */
      @Override
      public Collection<String> getNames()
      {
        return Collections.singleton(name);
      }
       /**
       * {@inheritDoc}
       */
      @Override
      public String getOID()
      {
        return oid;
      }
      /**
       * {@inheritDoc}
       */
      @Override
      public String getSyntaxOID()
      {
        return SYNTAX_DIRECTORY_STRING_OID;
      }
      /**
       * {@inheritDoc}
       */
      @Override
      public ByteString normalizeAttributeValue(ByteSequence value)
              throws DecodeException
      {
        StringBuilder buffer = new StringBuilder();
        prepareUnicode(buffer, value, TRIM, CASE_FOLD);
        int bufferLength = buffer.length();
        if (bufferLength == 0)
        {
          if (value.length() > 0)
          {
            // This should only happen if the value is composed entirely
            // of spaces. In that case, the normalized value is a single space.
            return SINGLE_SPACE_VALUE;
          }
          else
          {
            // The value is empty, so it is already normalized.
            return ByteString.empty();
          }
        }
        // Replace any consecutive spaces with a single space.
        for (int pos = bufferLength-1; pos > 0; pos--)
        {
          if (buffer.charAt(pos) == ' ')
          {
            if (buffer.charAt(pos-1) == ' ')
            {
              buffer.delete(pos, pos+1);
            }
          }
        }
        return ByteString.valueOf(buffer.toString());
      }
    }
  }
}
opendj3-server-dev/src/server/org/opends/server/schema/MatchingRuleSyntax.java
@@ -35,7 +35,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
opendj3-server-dev/src/server/org/opends/server/schema/MatchingRuleUseSyntax.java
@@ -36,7 +36,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/NameAndOptionalUIDSyntax.java
@@ -29,7 +29,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/NameFormSyntax.java
@@ -37,7 +37,7 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/NumericStringEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule =  new NumericStringEqualityMatchingRule();
   matchingRule = CoreSchema.getNumericStringMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/NumericStringOrderingMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
 //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule =  new NumericStringOrderingMatchingRule();
   matchingRule = CoreSchema.getNumericStringOrderingMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/NumericStringSubstringMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -56,7 +57,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new NumericStringSubstringMatchingRule();
   matchingRule = CoreSchema.getNumericStringSubstringsMatchingRule();
 }
@@ -65,7 +66,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/NumericStringSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/OIDSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/ObjectClassSyntax.java
@@ -39,7 +39,7 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierEqualityMatchingRule.java
@@ -35,7 +35,7 @@
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.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.opends.server.types.NameForm;
opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new ObjectIdentifierEqualityMatchingRule();
   matchingRule = CoreSchema.getObjectIdentifierMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierFirstComponentEqualityMatchingRule.java
@@ -36,7 +36,7 @@
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.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.opends.server.types.NameForm;
opendj3-server-dev/src/server/org/opends/server/schema/ObjectIdentifierFirstComponentEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new ObjectIdentifierFirstComponentEqualityMatchingRule();
   matchingRule = CoreSchema.getObjectIdentifierFirstComponentMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/OctetStringEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new OctetStringEqualityMatchingRule();
   matchingRule = CoreSchema.getOctetStringMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/OctetStringOrderingMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -56,7 +57,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
    matchingRule =  new OctetStringOrderingMatchingRule();
    matchingRule = CoreSchema.getOctetStringOrderingMatchingRule();
 }
@@ -65,7 +66,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/OctetStringSubstringMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -45,7 +46,7 @@
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -56,7 +57,7 @@
  public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
  {
    matchingRule = new OctetStringSubstringMatchingRule();
    matchingRule = CoreSchema.getOctetStringSubstringsMatchingRule();
  }
@@ -65,7 +66,7 @@
   * {@inheritDoc}
   */
  @Override
  public final Collection<MatchingRule> getMatchingRules()
  public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
  {
    return Collections.singleton(matchingRule);
  }
opendj3-server-dev/src/server/org/opends/server/schema/OctetStringSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/OtherMailboxSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/PostalAddressSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/PresentationAddressEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
    matchingRule = new PresentationAddressEqualityMatchingRule();
    matchingRule = CoreSchema.getPresentationAddressMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/PresentationAddressSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/PrintableStringSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/ProtocolInformationEqualityMatchingRuleFactory.java
@@ -30,9 +30,10 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.types.InitializationException;
@@ -45,7 +46,7 @@
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -56,7 +57,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new ProtocolInformationEqualityMatchingRule();
   matchingRule = CoreSchema.getProtocolInformationMatchingRule();
 }
@@ -65,7 +66,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/ProtocolInformationSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/SubstringAssertionSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/SubtreeSpecificationSyntax.java
@@ -34,7 +34,7 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteSequence;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.DN;
opendj3-server-dev/src/server/org/opends/server/schema/SupportedAlgorithmSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/TelephoneNumberEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -56,7 +57,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new TelephoneNumberEqualityMatchingRule();
   matchingRule = CoreSchema.getTelephoneNumberMatchingRule();
 }
@@ -65,7 +66,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/TelephoneNumberSubstringMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -45,7 +46,7 @@
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -56,7 +57,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new TelephoneNumberSubstringMatchingRule();
   matchingRule = CoreSchema.getTelephoneNumberSubstringsMatchingRule();
 }
@@ -65,7 +66,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/TelephoneNumberSyntax.java
@@ -34,7 +34,7 @@
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.TelephoneNumberAttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/TeletexTerminalIdentifierSyntax.java
@@ -32,7 +32,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/TelexNumberSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
opendj3-server-dev/src/server/org/opends/server/schema/TimeBasedMatchingRuleFactory.java
@@ -26,47 +26,17 @@
 */
package org.opends.server.schema;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TimeZone;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteSequence;
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.schema.Schema;
import org.forgerock.opendj.ldap.spi.IndexQueryFactory;
import org.forgerock.opendj.ldap.spi.IndexingOptions;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.AbstractMatchingRule;
import org.opends.server.api.ExtensibleIndexer;
import org.opends.server.api.ExtensibleMatchingRule;
import org.opends.server.api.MatchingRule;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.api.OrderingMatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.util.StaticUtils;
import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.schema.GeneralizedTimeSyntax.*;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static org.opends.server.util.TimeThread.*;
/**
 * This class acts as a factory for time-based matching rules.
@@ -75,49 +45,23 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /** Greater-than RelativeTimeMatchingRule. */
  private MatchingRule greaterThanRTMRule;
  /** Less-than RelativeTimeMatchingRule. */
  private MatchingRule lessThanRTMRule;
  /** PartialDayAndTimeMatchingRule. */
  private MatchingRule partialDTMatchingRule;
  /** A Collection of matching rules managed by this factory. */
  private Set<MatchingRule> matchingRules;
  private static final TimeZone TIME_ZONE_UTC_OBJ =
      TimeZone.getTimeZone(TIME_ZONE_UTC);
  /** Constants for generating keys. */
  private static final char SECOND = 's';
  private static final char MINUTE = 'm';
  private static final char HOUR = 'h';
  private static final char MONTH = 'M';
  private static final char DATE = 'D';
  private static final char YEAR = 'Y';
  /** {@inheritDoc} */
  @Override
  public void initializeMatchingRule(MatchingRuleCfg configuration)
          throws ConfigException, InitializationException
  {
    matchingRules = new HashSet<MatchingRule>();
    greaterThanRTMRule = new RelativeTimeGTOrderingMatchingRule();
    matchingRules.add(greaterThanRTMRule);
    lessThanRTMRule = new RelativeTimeLTOrderingMatchingRule();
    matchingRules.add(lessThanRTMRule);
    partialDTMatchingRule = new PartialDateAndTimeMatchingRule();
    matchingRules.add(partialDTMatchingRule);
    // relative time greater than
    matchingRules.add(CoreSchema.getInstance().getMatchingRule("1.3.6.1.4.1.26027.1.4.5"));
    // relative time less than
    matchingRules.add(CoreSchema.getInstance().getMatchingRule("1.3.6.1.4.1.26027.1.4.6"));
    // partial date and time
    matchingRules.add(CoreSchema.getInstance().getMatchingRule("1.3.6.1.4.1.26027.1.4.7"));
  }
  /** {@inheritDoc} */
  @Override
  public Collection<MatchingRule> getMatchingRules()
@@ -125,975 +69,4 @@
    return Collections.unmodifiableCollection(matchingRules);
  }
  /**
   * This class defines a matching rule which is used for time-based searches.
   */
  private  abstract class TimeBasedMatchingRule extends AbstractMatchingRule
          implements ExtensibleMatchingRule
  {
    /** {@inheritDoc} */
    @Override
    public String getDescription()
    {
      //There is no standard definition.
      return null;
    }
    /** {@inheritDoc} */
    @Override
    public String getSyntaxOID()
    {
       return SYNTAX_GENERALIZED_TIME_OID;
    }
    /** {@inheritDoc} */
    @Override
    public ByteString normalizeAttributeValue(ByteSequence value)
            throws DecodeException
    {
      try
      {
        long timestamp = decodeGeneralizedTimeValue(value);
        return ByteString.valueOf(timestamp);
      }
      catch (DirectoryException de)
      {
        switch (DirectoryServer.getSyntaxEnforcementPolicy())
        {
          case REJECT:
            throw DecodeException.error(de.getMessageObject(), de);
          case WARN:
            logger.error(de.getMessageObject());
            break;
        }
        return value.toByteString();
      }
    }
  }
 /**
  * This class defines a matching rule which matches  the relative time for
  * time-based searches.
  */
  private abstract class RelativeTimeOrderingMatchingRule
          extends TimeBasedMatchingRule
          implements OrderingMatchingRule
  {
    /**
     * The serial version identifier required to satisfy the compiler because
     * this class implements the <CODE>java.io.Serializable</CODE> interface.
     * This value was generated using the <CODE>serialver</CODE> command-line
     * utility included with the Java SDK.
     */
    private static final long serialVersionUID = -3501812894473163490L;
    /**
     * Indexer associated with this instance.
     */
    protected ExtensibleIndexer indexer;
    /** {@inheritDoc} */
    @Override
    public ByteString normalizeAssertionValue(ByteSequence value)
        throws DecodeException
    {
      /**
      An assertion value may contain one of the following:
      s = second
      m = minute
      h = hour
      d = day
      w = week
      An example assertion is OID:=(-)1d, where a '-' means that the user
      intends to search only the expired events. In this example we are
      searching for an event expired 1 day back.
      Use this method to parse, validate and normalize the assertion value
      into a format to be recognized by the valuesMatch routine. This method
      takes the assertion value, adds/substracts it to/from the current time
      and calculates a time which will be used as a relative time by inherited
       rules.
      */
      int index = 0;
      boolean signed = false;
      byte firstByte = value.byteAt(0);
      if(firstByte == '-')
      {
        //Turn the sign on to go back in past.
        signed = true;
        index = 1;
      }
      else if(firstByte == '+')
      {
        //'+" is not required but we won't reject it either.
        index = 1;
      }
      long second = 0;
      long minute = 0;
      long hour = 0;
      long day = 0;
      long week = 0;
      boolean containsTimeUnit = false;
      int number = 0;
      for(; index<value.length(); index++)
      {
        byte b = value.byteAt(index);
        if(isDigit((char)b))
        {
          number = multiplyByTenThenAddUnits(number, b);
        }
        else
        {
          LocalizableMessage message = null;
          if(containsTimeUnit)
          {
            //We already have time unit found by now.
            message = WARN_ATTR_CONFLICTING_ASSERTION_FORMAT.get(value);
          }
          else
          {
            switch(b)
            {
              case 's':
                second = number;
                break;
              case 'm':
                minute = number;
                break;
              case 'h':
                hour = number;
                break;
              case 'd':
                day = number;
                break;
              case 'w':
                week = number;
                break;
              default:
                message = WARN_ATTR_INVALID_RELATIVE_TIME_ASSERTION_FORMAT.get(value, (char) b);
            }
          }
          if(message !=null)
          {
            //Log the message and throw an exception.
            logger.error(message);
            throw DecodeException.error(message);
          }
          containsTimeUnit = true;
          number = 0;
        }
      }
      if(!containsTimeUnit)
      {
        //There was no time unit so assume it is seconds.
        second = number;
      }
      long delta = (second + minute*60 +  hour*3600 + day*24*3600 +
              week*7*24*3600)*1000 ;
      long now = getTime();
      return ByteString.valueOf(signed ? now - delta : now + delta);
    }
    /** {@inheritDoc} */
    @Override
    public int compareValues(ByteSequence value1, ByteSequence value2)
    {
      return value1.compareTo(value2);
    }
    /** {@inheritDoc} */
    @Override
    public int compare(byte[] arg0, byte[] arg1)
    {
      return StaticUtils.compare(arg0, arg1);
    }
    /** {@inheritDoc} */
    @Override
    public Collection<ExtensibleIndexer> getIndexers()
    {
      if(indexer == null)
      {
        indexer = new RelativeTimeExtensibleIndexer(this);
      }
      return Collections.singletonList(indexer);
    }
  }
 /**
  * This class defines a matching rule which calculates the "greater-than"
  * relative time for time-based searches.
  */
  private final class RelativeTimeGTOrderingMatchingRule
          extends RelativeTimeOrderingMatchingRule
  {
    /** All the names for this matching rule. */
    private final List<String> names;
    /**
     * The serial version identifier required to satisfy the compiler because
     * this class implements the <CODE>java.io.Serializable</CODE> interface.
     * This value was generated using the <CODE>serialver</CODE> command-line
     * utility included with the Java SDK.
     */
     private static final long serialVersionUID = 7247241496402474136L;
    RelativeTimeGTOrderingMatchingRule()
    {
      names = new ArrayList<String>();
      names.add(EXT_OMR_RELATIVE_TIME_GT_NAME);
      names.add(EXT_OMR_RELATIVE_TIME_GT_ALT_NAME);
    }
    /** {@inheritDoc} */
    @Override
    public Collection<String> getNames()
    {
      return Collections.unmodifiableList(names);
    }
    /** {@inheritDoc} */
    @Override
    public String getOID()
    {
      return EXT_OMR_RELATIVE_TIME_GT_OID;
    }
    /** {@inheritDoc} */
    @Override
    public ConditionResult valuesMatch(ByteSequence attributeValue,
        ByteSequence assertionValue)
    {
      int ret = compareValues(attributeValue, assertionValue);
      return ConditionResult.valueOf(ret > 0);
    }
    /** {@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);
        }
        @Override
        public <T> T createIndexQuery(IndexQueryFactory<T> factory)
            throws DecodeException
        {
          return factory.createRangeMatchQuery(indexer.getExtensibleIndexID(),
              assertionValue, ByteString.empty(), false, false);
        }
      };
    }
    /** {@inheritDoc} */
    @Override
    public <T> T createIndexQuery(ByteSequence assertionValue,
        IndexQueryFactory<T> factory) throws DecodeException
    {
      return getAssertion(assertionValue).createIndexQuery(factory);
    }
  }
  /**
  * This class defines a matching rule which calculates the "less-than"
  * relative time for time-based searches.
  */
  private final class RelativeTimeLTOrderingMatchingRule
          extends RelativeTimeOrderingMatchingRule
  {
    /** All the names for this matching rule. */
    private final List<String> names;
    /**
     * The serial version identifier required to satisfy the compiler because
     * this class implements the <CODE>java.io.Serializable</CODE> interface.
     * This value was generated using the <CODE>serialver</CODE> command-line
     * utility included with the Java SDK.
     */
   private static final long serialVersionUID = -5122459830973558441L;
    RelativeTimeLTOrderingMatchingRule()
    {
      names = new ArrayList<String>();
      names.add(EXT_OMR_RELATIVE_TIME_LT_NAME);
      names.add(EXT_OMR_RELATIVE_TIME_LT_ALT_NAME);
    }
    /** {@inheritDoc} */
    @Override
    public Collection<String> getNames()
    {
      return Collections.unmodifiableList(names);
    }
    /** {@inheritDoc} */
    @Override
    public String getOID()
    {
      return EXT_OMR_RELATIVE_TIME_LT_OID;
    }
    /** {@inheritDoc} */
    @Override
    public ConditionResult valuesMatch(ByteSequence attributeValue,
        ByteSequence assertionValue)
    {
      int ret = compareValues(attributeValue, assertionValue);
      return ConditionResult.valueOf(ret < 0);
    }
    /** {@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);
        }
        @Override
        public <T> T createIndexQuery(IndexQueryFactory<T> factory)
            throws DecodeException
        {
          return factory.createRangeMatchQuery(indexer.getExtensibleIndexID(),
              ByteString.empty(), assertionValue, false, false);
        }
      };
    }
    /** {@inheritDoc} */
    @Override
    public <T> T createIndexQuery(ByteSequence assertionValue,
        IndexQueryFactory<T> factory) throws DecodeException
    {
      return getAssertion(assertionValue).createIndexQuery(factory);
    }
  }
  /**
   * Extensible Indexer class for Relative Time Matching rules which share
   * the same index. This Indexer is shared by both greater than and less than
   * Relative Time Matching Rules.
   */
  private final class RelativeTimeExtensibleIndexer extends
      ExtensibleIndexer
  {
    /**
     * The Extensible Matching Rule.
     */
    private final RelativeTimeOrderingMatchingRule matchingRule;
    /**
     * Creates a new instance of RelativeTimeExtensibleIndexer.
     *
     * @param matchingRule The relative time Matching Rule.
     */
    private RelativeTimeExtensibleIndexer(
        RelativeTimeOrderingMatchingRule matchingRule)
    {
      this.matchingRule = matchingRule;
    }
    /** {@inheritDoc} */
    @Override
    public String getExtensibleIndexID()
    {
      return EXTENSIBLE_INDEXER_ID_DEFAULT;
    }
    /** {@inheritDoc} */
    @Override
    public final void createKeys(Schema schema, ByteSequence value2,
        IndexingOptions options, Collection<ByteString> keys)
        throws DecodeException
    {
      keys.add(matchingRule.normalizeAttributeValue(value2));
    }
    /** {@inheritDoc} */
    @Override
    public String getIndexID()
    {
      return RELATIVE_TIME_INDEX_NAME + "." + getExtensibleIndexID();
    }
  }
  /**
   * This class performs the partial date and time matching capabilities.
   */
  private final class PartialDateAndTimeMatchingRule
          extends TimeBasedMatchingRule
  {
    /**
     * Indexer associated with this instance.
     */
    private ExtensibleIndexer indexer;
    /** {@inheritDoc} */
    @Override
    public String getOID()
    {
      return EXT_PARTIAL_DATE_TIME_OID;
    }
    /** {@inheritDoc} */
    @Override
    public Collection<String> getNames()
    {
      return Collections.singleton(EXT_PARTIAL_DATE_TIME_NAME);
    }
    /** {@inheritDoc} */
    @Override
    public ByteString normalizeAssertionValue(ByteSequence value)
        throws DecodeException
    {
     /**
      An assertion value may contain one or all of the following:
      D = day
      M = month
      Y = year
      h = hour
      m = month
      s = second
      An example assertion is OID:=04M. In this example we are
      searching for entries corresponding to month of april.
      Use this method to parse, validate and normalize the assertion value
      into a format to be recognized by the compare routine. The normalized
      value is actually the format of : smhDMY.
      */
      final int initDate = 0;
      final int initVal = -1;
      int second = initVal;
      int minute = initVal;
      int hour = initVal;
      int date = initDate;
      int month = initVal;
      int year = initDate;
      int number = 0;
      int length = value.length();
      for(int index=0; index<length; index++)
      {
        byte b = value.byteAt(index);
        if(isDigit((char)b))
        {
          number = multiplyByTenThenAddUnits(number, b);
        }
        else
        {
          LocalizableMessage message = null;
          switch(b)
          {
            case 's':
              if (second != initVal)
              {
                 message = WARN_ATTR_DUPLICATE_SECOND_ASSERTION_FORMAT.get(value, date);
              }
              else
              {
                second = number;
              }
              break;
            case 'm':
              if (minute != initVal)
              {
                 message = WARN_ATTR_DUPLICATE_MINUTE_ASSERTION_FORMAT.get(value, date);
              }
              else
              {
                minute = number;
              }
              break;
            case 'h':
              if (hour != initVal)
              {
                 message = WARN_ATTR_DUPLICATE_HOUR_ASSERTION_FORMAT.get(value, date);
              }
              else
              {
                hour = number;
              }
              break;
            case 'D':
              if(number == 0)
              {
                message = WARN_ATTR_INVALID_DATE_ASSERTION_FORMAT.get(value, number);
              }
            else if (date != initDate)
              {
                message = WARN_ATTR_DUPLICATE_DATE_ASSERTION_FORMAT.get(value, date);
              }
              else
              {
                date = number;
              }
              break;
            case 'M':
              if (number == 0)
              {
                message = WARN_ATTR_INVALID_MONTH_ASSERTION_FORMAT.get(value, number);
              }
              else if (month != initVal)
              {
                message = WARN_ATTR_DUPLICATE_MONTH_ASSERTION_FORMAT.get(value, month);
              }
              else
              {
                month = number;
              }
              break;
            case 'Y':
              if(number == 0)
              {
                message = WARN_ATTR_INVALID_YEAR_ASSERTION_FORMAT.get(value, number);
              }
              else if (year != initDate)
              {
                message = WARN_ATTR_DUPLICATE_YEAR_ASSERTION_FORMAT.get(value, year);
              }
              else
              {
                year = number;
              }
              break;
            default:
              message = WARN_ATTR_INVALID_PARTIAL_TIME_ASSERTION_FORMAT.get(value, (char) b);
          }
          if(message !=null)
          {
            logger.error(message);
            throw DecodeException.error(message);
          }
          number = 0;
        }
      }
      month = toCalendarMonth(month, value);
      //Validate year, month , date , hour, minute and second in that order.
      // -1 values are allowed when these values have not been provided
      if (year < 0)
      {
        //A future date is allowed.
        logAndThrow(WARN_ATTR_INVALID_YEAR_ASSERTION_FORMAT.get(value, year));
      }
      if (isDateInvalid(date, month, year))
      {
        logAndThrow(WARN_ATTR_INVALID_DATE_ASSERTION_FORMAT.get(value, date));
      }
      if (hour < initVal || hour > 23)
      {
        logAndThrow(WARN_ATTR_INVALID_HOUR_ASSERTION_FORMAT.get(value, hour));
      }
      if (minute < initVal || minute > 59)
      {
        logAndThrow(WARN_ATTR_INVALID_MINUTE_ASSERTION_FORMAT.get(value, minute));
      }
      if (second < initVal || second > 60) // Consider leap seconds.
      {
        logAndThrow(WARN_ATTR_INVALID_SECOND_ASSERTION_FORMAT.get(value, second));
      }
      // Since we reached here we have a valid assertion value.
      // Construct a normalized value in the order: SECOND MINUTE HOUR  DATE MONTH YEAR.
      ByteBuffer bb = ByteBuffer.allocate(6*4);
      bb.putInt(second);
      bb.putInt(minute);
      bb.putInt(hour);
      bb.putInt(date);
      bb.putInt(month);
      bb.putInt(year);
      return ByteString.wrap(bb.array());
    }
    private void logAndThrow(LocalizableMessage message) throws DecodeException
    {
      logger.warn(message);
      throw DecodeException.error(message);
    }
    private boolean isDateInvalid(int date, int month, int year)
    {
      switch (date)
      {
      case 29:
        return month == Calendar.FEBRUARY && !isLeapYear(year);
      case 30:
        return month == Calendar.FEBRUARY;
      case 31:
        return month != -1 && month != Calendar.JANUARY
            && month != Calendar.MARCH && month != Calendar.MAY
            && month != Calendar.JULY && month != Calendar.AUGUST
            && month != Calendar.OCTOBER && month != Calendar.DECEMBER;
      default:
        return date < 0 || date > 31;
      }
    }
    private boolean isLeapYear(int year)
    {
      if (year % 400 == 0)
      {
        return true;
      }
      if (year % 100 == 0)
      {
        return false;
      }
      return year % 4 == 0;
    }
    private int toCalendarMonth(int month, ByteSequence value) throws DecodeException
    {
      switch (month)
      {
      case -1:
        // just allow this.
        return -1;
      case 1:
        return Calendar.JANUARY;
      case 2:
        return Calendar.FEBRUARY;
      case 3:
        return Calendar.MARCH;
      case 4:
        return Calendar.APRIL;
      case 5:
        return Calendar.MAY;
      case 6:
        return Calendar.JUNE;
      case 7:
        return Calendar.JULY;
      case 8:
        return Calendar.AUGUST;
      case 9:
        return Calendar.SEPTEMBER;
      case 10:
        return Calendar.OCTOBER;
      case 11:
        return Calendar.NOVEMBER;
      case 12:
        return Calendar.DECEMBER;
      default:
        LocalizableMessage message = WARN_ATTR_INVALID_MONTH_ASSERTION_FORMAT.get(value, month);
        logger.warn(message);
        throw DecodeException.error(message);
      }
    }
    /** {@inheritDoc} */
    @Override
    public ConditionResult valuesMatch(ByteSequence attributeValue,
        ByteSequence assertionValue)
    {
      // Build the information from the attribute value.
      GregorianCalendar cal = new GregorianCalendar(TIME_ZONE_UTC_OBJ);
      cal.setLenient(false);
      cal.setTimeInMillis(((ByteString) attributeValue).toLong());
      int second = cal.get(Calendar.SECOND);
      int minute = cal.get(Calendar.MINUTE);
      int hour = cal.get(Calendar.HOUR_OF_DAY);
      int date = cal.get(Calendar.DATE);
      int month = cal.get(Calendar.MONTH);
      int year = cal.get(Calendar.YEAR);
      //Build the information from the assertion value.
      ByteBuffer bb = ByteBuffer.wrap(assertionValue.toByteArray());
      int assertSecond = bb.getInt(0);
      int assertMinute = bb.getInt(4);
      int assertHour = bb.getInt(8);
      int assertDate = bb.getInt(12);
      int assertMonth = bb.getInt(16);
      int assertYear = bb.getInt(20);
      // All the non-zero and non -1 values should match.
      if ((assertSecond != -1 && assertSecond != second)
          || (assertMinute != -1 && assertMinute != minute)
          || (assertHour != -1 && assertHour != hour)
          || (assertDate != 0 && assertDate != date)
          || (assertMonth != -1 && assertMonth != month)
          || (assertYear != 0 && assertYear != year))
      {
        return ConditionResult.FALSE;
      }
     return ConditionResult.TRUE;
    }
    /** {@inheritDoc} */
    @Override
    public Collection<ExtensibleIndexer> getIndexers()
    {
      if(indexer == null)
      {
        indexer = new PartialDateAndTimeExtensibleIndexer(this);
      }
      return Collections.singletonList(indexer);
    }
    /** {@inheritDoc} */
    @Override
    public <T> T createIndexQuery(ByteSequence assertionValue,
            IndexQueryFactory<T> factory) throws DecodeException
    {
      //Build the information from the assertion value.
      byte[] arr = normalizeAssertionValue(assertionValue).toByteArray();
      ByteBuffer bb = ByteBuffer.wrap(arr);
      int assertSecond = bb.getInt(0);
      int assertMinute = bb.getInt(4);
      int assertHour = bb.getInt(8);
      int assertDate = bb.getInt(12);
      int assertMonth = bb.getInt(16);
      int assertYear = bb.getInt(20);
      List<T> queries = new ArrayList<T>();
      if(assertSecond >= 0)
      {
        queries.add(createExactMatchQuery(factory, assertSecond, SECOND));
      }
      if(assertMinute >=0)
      {
        queries.add(createExactMatchQuery(factory, assertMinute, MINUTE));
      }
      if(assertHour >=0)
      {
        queries.add(createExactMatchQuery(factory, assertHour, HOUR));
      }
      if(assertDate >0)
      {
        queries.add(createExactMatchQuery(factory, assertDate, DATE));
      }
      if(assertMonth >=0)
      {
        queries.add(createExactMatchQuery(factory, assertMonth, MONTH));
      }
      if(assertYear > 0)
      {
        queries.add(createExactMatchQuery(factory, assertYear, YEAR));
      }
      return factory.createIntersectionQuery(queries);
    }
    private <T> T createExactMatchQuery(IndexQueryFactory<T> factory,
        int assertionValue, char type)
    {
      return factory.createExactMatchQuery(
          indexer.getExtensibleIndexID(), getKey(assertionValue, type));
    }
    /**
     * Decomposes an attribute value into a set of partial date and time index
     * keys.
     *
     * @param attValue
     *          The normalized attribute value
     * @param set
     *          A set into which the keys will be inserted.
     */
    private void timeKeys(ByteSequence attributeValue, Collection<ByteString> keys)
    {
      long timeInMS = 0L;
      try
      {
        timeInMS = decodeGeneralizedTimeValue(attributeValue);
      }
      catch(DirectoryException de)
      {
        //If the schema check is on this should never reach here. If not then we
        //would return from here.
        return;
      }
      //Build the information from the attribute value.
      GregorianCalendar cal = new GregorianCalendar(TIME_ZONE_UTC_OBJ);
      cal.setTimeInMillis(timeInMS);
      addKeyIfNotZero(keys, cal, Calendar.SECOND, SECOND);
      addKeyIfNotZero(keys, cal, Calendar.MINUTE, MINUTE);
      addKeyIfNotZero(keys, cal, Calendar.HOUR_OF_DAY, HOUR);
      addKeyIfNotZero(keys, cal, Calendar.DATE, DATE);
      addKeyIfNotZero(keys, cal, Calendar.MONTH, MONTH);
      addKeyIfNotZero(keys, cal, Calendar.YEAR, YEAR);
    }
    private void addKeyIfNotZero(Collection<ByteString> keys,
        GregorianCalendar cal, int calField, char type)
    {
      int value = cal.get(calField);
      if (value >= 0)
      {
        keys.add(getKey(value, type));
      }
    }
    private ByteString getKey(int value, char type)
    {
      ByteStringBuilder builder = new ByteStringBuilder();
      builder.append(type);
      builder.append(value);
      return builder.toByteString();
    }
  }
  private int multiplyByTenThenAddUnits(int number, byte b)
  {
    switch (b)
    {
    case '0':
      return number * 10;
    case '1':
      return number * 10 + 1;
    case '2':
      return number * 10 + 2;
    case '3':
      return number * 10 + 3;
    case '4':
      return number * 10 + 4;
    case '5':
      return number * 10 + 5;
    case '6':
      return number * 10 + 6;
    case '7':
      return number * 10 + 7;
    case '8':
      return number * 10 + 8;
    case '9':
      return number * 10 + 9;
    }
    return number;
  }
   /**
   * Extensible Indexer class for Partial Date and Time Matching rules.
   */
  private final class PartialDateAndTimeExtensibleIndexer extends
      ExtensibleIndexer
  {
    /** The partial date and Time matching Rule. */
    private final PartialDateAndTimeMatchingRule matchingRule;
    /**
     * Creates a new instance of PartialDateAndTimeExtensibleIndexer.
     *
     * @param matchingRule
     *          The PartialDateAndTime Rule.
     */
    private PartialDateAndTimeExtensibleIndexer(
        PartialDateAndTimeMatchingRule matchingRule)
    {
      this.matchingRule = matchingRule;
    }
    /** {@inheritDoc} */
    @Override
    public void createKeys(Schema schema, ByteSequence value,
        IndexingOptions options, Collection<ByteString> keys)
    {
      matchingRule.timeKeys(value, keys);
    }
    /** {@inheritDoc} */
    @Override
    public String getIndexID()
    {
      return PARTIAL_DATE_TIME_INDEX_NAME + "." + getExtensibleIndexID();
    }
    /** {@inheritDoc} */
    @Override
    public String getExtensibleIndexID()
    {
      return EXTENSIBLE_INDEXER_ID_DEFAULT;
    }
  }
}
opendj3-server-dev/src/server/org/opends/server/schema/UTCTimeSyntax.java
@@ -36,7 +36,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/UUIDEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
 // Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new UUIDEqualityMatchingRule();
   matchingRule = CoreSchema.getUUIDMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/UUIDOrderingMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -43,7 +44,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -54,16 +55,14 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new UUIDOrderingMatchingRule();
   matchingRule = CoreSchema.getUUIDOrderingMatchingRule();
 }
 /**
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/UUIDSyntax.java
@@ -30,7 +30,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/UniqueMemberEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
 /**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new UniqueMemberEqualityMatchingRule();
   matchingRule = CoreSchema.getUniqueMemberMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordEqualityMatchingRuleFactory.java
@@ -30,10 +30,12 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.types.InitializationException;
/**
@@ -56,7 +58,10 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new UserPasswordEqualityMatchingRule();
   // TODO: either delete completely UserPasswordEqualityMatchingRule or re-implement it
   // using SDK classes
   // Meanwhile, just returning UserPasswordExactEqualityMatchingRule instead
   matchingRule = CoreSchema.getInstance().getMatchingRule("1.3.6.1.4.1.26027.1.4.2");
 }
opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordExactEqualityMatchingRuleFactory.java
@@ -30,10 +30,12 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -55,7 +57,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new UserPasswordExactEqualityMatchingRule();
   matchingRule = CoreSchema.getInstance().getMatchingRule("1.3.6.1.4.1.26027.1.4.2");
 }
@@ -64,7 +66,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/schema/UserPasswordSyntax.java
@@ -31,7 +31,7 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.AttributeSyntax;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/schema/WordEqualityMatchingRuleFactory.java
@@ -30,10 +30,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.InitializationException;
/**
@@ -44,7 +45,7 @@
        extends MatchingRuleFactory<MatchingRuleCfg>
{
  //Associated Matching Rule.
  private MatchingRule matchingRule;
  private org.forgerock.opendj.ldap.schema.MatchingRule matchingRule;
@@ -55,7 +56,7 @@
 public final void initializeMatchingRule(MatchingRuleCfg configuration)
         throws ConfigException, InitializationException
 {
   matchingRule = new WordEqualityMatchingRule();
   matchingRule = CoreSchema.getWordMatchingRule();
 }
@@ -64,7 +65,7 @@
  * {@inheritDoc}
  */
 @Override
 public final Collection<MatchingRule> getMatchingRules()
 public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
 {
    return Collections.singleton(matchingRule);
 }
opendj3-server-dev/src/server/org/opends/server/types/AbstractAttribute.java
@@ -31,7 +31,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import static org.opends.server.util.StaticUtils.*;
opendj3-server-dev/src/server/org/opends/server/types/AttributeBuilder.java
@@ -46,7 +46,7 @@
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.util.Reject;
import org.forgerock.util.Utils;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import static org.opends.server.util.StaticUtils.*;
opendj3-server-dev/src/server/org/opends/server/types/AttributeType.java
@@ -33,7 +33,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import static org.forgerock.util.Reject.*;
opendj3-server-dev/src/server/org/opends/server/types/DN.java
@@ -2554,32 +2554,28 @@
    {
      return true;
    }
    if (!(o instanceof DN))
    if (o instanceof DN)
    {
      return false;
    }
    try
    {
      return (toNormalizedString().equals(
          ((DN) o).toNormalizedString()));
    }
    catch (Exception e)
    {
      // This most likely means that the object was null or wasn't a
      // DN.  In either case, it's faster to assume that it is and
      // return false on an exception than to perform the checks to
      // see if it meets the appropriate
      // conditions.
      logger.traceException(e);
      return false;
    }
      DN other = (DN) o;
      if (numComponents == other.numComponents)
      {
        if (numComponents == 0)
        {
          return true;
        }
        for (int i = 0; i < numComponents; i++)
        {
          if (!rdnComponents[i].equals(other.rdnComponents[i]))
          {
            return false;
          }
        }
        return true;
      }
     }
     return false;
  }
  /**
   * Retrieves the hash code for this DN.  The hash code will be the
   * sum of the hash codes for all the RDN components.
@@ -2589,11 +2585,21 @@
  @Override
  public int hashCode()
  {
    return toNormalizedString().hashCode();
      if (numComponents == 0) {
          return 0;
      }
      int length = numComponents - 1;
      int hash = 31 * rdnComponents[length].hashCode();
      if (numComponents > 1)
      {
          for (int i = 0; i < length; i++)
          {
            hash += rdnComponents[i].hashCode();
          }
      }
      return hash;
  }
  /**
   * Retrieves a string representation of this DN.
   *
@@ -2723,57 +2729,60 @@
  /**
   * Compares this DN with the provided DN based on a natural order.
   * This order will be first hierarchical (ancestors will come before
   * descendants) and then alphabetical by attribute name(s) and
   * value(s).
   * Compares this DN with the provided DN based on a natural order. This order
   * will be first hierarchical (ancestors will come before descendants) and
   * then alphabetical by attribute name(s) and value(s).
   *
   * @param  dn  The DN against which to compare this DN.
   *
   * @return  A negative integer if this DN should come before the
   *          provided DN, a positive integer if this DN should come
   *          after the provided DN, or zero if there is no difference
   *          with regard to ordering.
   * @param other
   *          The DN against which to compare this DN.
   * @return A negative integer if this DN should come before the provided DN, a
   *         positive integer if this DN should come after the provided DN, or
   *         zero if there is no difference with regard to ordering.
   */
  @Override
  public int compareTo(DN dn)
  public int compareTo(DN other)
  {
    if (equals(dn))
    if (isRootDN())
    {
      return 0;
      /** root DN always come first. */
      return other.isRootDN() ? 0 : -1;
    }
    else if (isRootDN())
    {
      return -1;
    }
    else if (dn.isRootDN())
    {
      return 1;
    }
    else if (isAncestorOf(dn))
    {
      return -1;
    }
    else if (isDescendantOf(dn))
    {
      return 1;
    }
    else
    {
      int minComps = Math.min(numComponents, dn.numComponents);
      for (int i=0; i < minComps; i++)
      {
        RDN r1 = rdnComponents[rdnComponents.length-1-i];
        RDN r2 = dn.rdnComponents[dn.rdnComponents.length-1-i];
        int result = r1.compareTo(r2);
        if (result != 0)
        {
          return result;
        }
      }
      return 0;
    if (other.isRootDN())
    {
      // this comes after other.
      return 1;
    }
    int size1 = numComponents - 1;
    int size2 = other.numComponents - 1;
    while (size1 >= 0 && size2 >= 0)
    {
      RDN rdn1 = getRDN(size1);
      RDN rdn2 = other.getRDN(size2);
      size1--;
      size2--;
      int result = rdn1.compareTo(rdn2);
      if (result > 0)
      {
        return 1;
      }
      else if (result < 0)
      {
        return -1;
      }
    }
    // Check remaining sizes
    if (size1 > size2)
    {
      return 1;
    }
    else if (size1 < size2)
    {
      return -1;
    }
    return 0;
  }
}
opendj3-server-dev/src/server/org/opends/server/types/DirectoryConfig.java
@@ -38,7 +38,7 @@
import org.opends.server.api.ConfigHandler;
import org.opends.server.api.ExtendedOperationHandler;
import org.opends.server.api.InvokableComponent;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.SASLMechanismHandler;
import org.opends.server.api.ServerShutdownListener;
import org.opends.server.config.ConfigEntry;
opendj3-server-dev/src/server/org/opends/server/types/Entry.java
@@ -44,7 +44,7 @@
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.opends.server.api.CompressedSchema;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.ProtocolElement;
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.core.DirectoryServer;
opendj3-server-dev/src/server/org/opends/server/types/MatchingRuleUse.java
@@ -33,7 +33,7 @@
import java.util.Set;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import static org.forgerock.util.Reject.*;
import static org.opends.server.util.ServerConstants.*;
opendj3-server-dev/src/server/org/opends/server/types/RDN.java
@@ -34,7 +34,7 @@
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.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import static org.opends.messages.CoreMessages.*;
@@ -900,18 +900,13 @@
    {
      return true;
    }
    if (o == null || !(o instanceof RDN))
    if (o instanceof RDN)
    {
      return false;
      return compareTo((RDN) o) == 0;
    }
    RDN rdn = (RDN) o;
    return toNormalizedString().equals(rdn.toNormalizedString());
    return false;
  }
  /**
   * Retrieves the hash code for this RDN.  It will be calculated as
   * the sum of the hash codes of the types and values.
@@ -921,7 +916,34 @@
  @Override
  public int hashCode()
  {
    return toNormalizedString().hashCode();
    // Avoid an algorithm that requires the AVAs to be sorted.
    int hash = 0;
    for (int i = 0; i < attributeNames.length; i++)
    {
      hash += attributeTypes[i].hashCode() * 31 + getEqualityNormalizedValue(i).hashCode();
    }
    return hash;
  }
  /** Returns normalized value for attribute at provided position. */
  private ByteString getEqualityNormalizedValue(int position)
  {
    final MatchingRule matchingRule = attributeTypes[position].getEqualityMatchingRule();
    ByteString attributeValue = attributeValues[position];
    if (matchingRule != null)
    {
      try
      {
        attributeValue = matchingRule.normalizeAttributeValue(attributeValue);
      }
      catch (final DecodeException de)
      {
        // Unable to normalize, use default
        attributeValue = attributeValues[position];
      }
    }
    return attributeValue;
  }
@@ -1064,8 +1086,6 @@
      }
  }
  /**
   * Compares this RDN with the provided RDN based on an alphabetic
   * comparison of the attribute names and values.
@@ -1096,11 +1116,6 @@
      }
    }
    if (equals(rdn))
    {
      return 0;
    }
    TreeMap<String,AttributeType> typeMap1 =
         new TreeMap<String,AttributeType>();
    TreeMap<String, ByteString> valueMap1 = new TreeMap<String, ByteString>();
opendj3-server-dev/src/server/org/opends/server/types/Schema.java
@@ -45,7 +45,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.std.server.DirectoryStringAttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SchemaConfigManager;
import org.opends.server.schema.AttributeTypeSyntax;
opendj3-server-dev/src/server/org/opends/server/types/SearchFilter.java
@@ -43,7 +43,7 @@
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import static org.opends.messages.CoreMessages.*;
opendj3-server-dev/src/server/org/opends/server/types/SortKey.java
@@ -28,7 +28,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
/**
 * This class defines a data structure that may be used as a sort key.
opendj3-server-dev/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
@@ -45,7 +45,7 @@
import org.opends.server.api.AuthenticationPolicy;
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.api.SynchronizationProvider;
import org.opends.server.api.plugin.PluginResult;
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java
@@ -27,24 +27,29 @@
package org.opends.server.backends;
import java.io.File;
import java.util.Locale;
import java.util.Map;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.*;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.protocols.internal.SearchRequest;
import static org.opends.server.protocols.internal.Requests.*;
import org.opends.server.tools.LDAPModify;
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.util.StaticUtils.*;
import static org.testng.Assert.*;
@@ -1087,9 +1092,7 @@
  public void testAddAttributeTypeObsoleteEMR()
         throws Exception
  {
    SchemaTestMatchingRule matchingRule =
         new SchemaTestMatchingRule("testAddATObsoleteEMRMatch",
                                    "1.3.6.1.4.1.26027.1.999.20", true);
    MatchingRule matchingRule = getMatchingRule("testAddATObsoleteEMRMatch", "1.3.6.1.4.1.26027.1.999.20", true);
    DirectoryServer.registerMatchingRule(matchingRule, false);
@@ -1515,9 +1518,7 @@
  public void testRemoveAttributeTypeReferencedByMRU()
         throws Exception
  {
    SchemaTestMatchingRule matchingRule =
         new SchemaTestMatchingRule("testRemoveATRefByMRUMatch",
                                    "1.3.6.1.4.1.26027.1.999.17");
    MatchingRule matchingRule = getMatchingRule("testRemoveATRefByMRUMatch", "1.3.6.1.4.1.26027.1.999.17", false);
    DirectoryServer.registerMatchingRule(matchingRule, false);
@@ -4682,7 +4683,18 @@
    assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
  }
  private MatchingRule getMatchingRule(String name, String oid, boolean isObsolete)
  {
    Schema schema =
        new SchemaBuilder(Schema.getCoreSchema())
          .buildMatchingRule(oid)
            .syntaxOID(SchemaConstants.SYNTAX_DIRECTORY_STRING_OID)
            .names(name)
            .implementation(new SchemaTestMatchingRuleImpl())
            .obsolete(isObsolete)
            .addToSchema().toSchema();
    return schema.getMatchingRule(oid);
  }
  /**
   * Tests the behavior of the schema backend when attempting to add a new
@@ -4694,12 +4706,9 @@
  public void testAddMatchingRuleUseSuccessful()
         throws Exception
  {
    SchemaTestMatchingRule matchingRule =
         new SchemaTestMatchingRule("testAddMRUSuccessfulMatch",
                                    "1.3.6.1.4.1.26027.1.999.10");
    MatchingRule matchingRule = getMatchingRule("testAddMRUSuccessfulMatch", "1.3.6.1.4.1.26027.1.999.10", false);
    DirectoryServer.registerMatchingRule(matchingRule, false);
    String path = TestCaseUtils.createTempFile(
         "dn: cn=schema",
         "changetype: modify",
@@ -4739,9 +4748,7 @@
  public void testAddMatchingRuleUseToAltSchemaFile()
         throws Exception
  {
    SchemaTestMatchingRule matchingRule =
         new SchemaTestMatchingRule("testAddMRUToAltSchemaFileMatch",
                                    "1.3.6.1.4.1.26027.1.999.18");
    MatchingRule matchingRule = getMatchingRule("testAddMRUToAltSchemaFileMatch", "1.3.6.1.4.1.26027.1.999.18", false);
    DirectoryServer.registerMatchingRule(matchingRule, false);
@@ -4779,8 +4786,6 @@
    assertTrue(schemaFile.exists());
  }
  /**
   * Tests the behavior of the schema backend when attempting to replace an
   * existing matching rule use.
@@ -4791,12 +4796,9 @@
  public void testReplaceMatchingRuleUseSuccessful()
         throws Exception
  {
    SchemaTestMatchingRule matchingRule =
         new SchemaTestMatchingRule("testReplaceMRUSuccessfulMatch",
                                    "1.3.6.1.4.1.26027.1.999.11");
    MatchingRule matchingRule = getMatchingRule("testReplaceMRUSuccessfulMatch", "1.3.6.1.4.1.26027.1.999.11", false);
    DirectoryServer.registerMatchingRule(matchingRule, false);
    String path = TestCaseUtils.createTempFile(
         "dn: cn=schema",
         "changetype: modify",
@@ -4843,9 +4845,7 @@
  public void testRemoveAndAddMatchingRuleUse()
         throws Exception
  {
    SchemaTestMatchingRule matchingRule =
         new SchemaTestMatchingRule("testRemoveAndAddMRUMatch",
                                    "1.3.6.1.4.1.26027.1.999.12");
    MatchingRule matchingRule = getMatchingRule("testRemoveAndAddMRUMatch", "1.3.6.1.4.1.26027.1.999.12", false);
    DirectoryServer.registerMatchingRule(matchingRule, false);
@@ -4888,8 +4888,6 @@
    assertTrue(mru.hasName("testremoveandaddmru"));
  }
  /**
   * Tests the behavior of the schema backend when attempting to add a matching
   * rule use that references the same matching rule as another matching rule
@@ -4901,12 +4899,9 @@
  public void testAddMatchingRuleUseMRConflict()
         throws Exception
  {
    SchemaTestMatchingRule matchingRule =
         new SchemaTestMatchingRule("testAddMRUMRConflictMatch",
                                    "1.3.6.1.4.1.26027.1.999.14");
    MatchingRule matchingRule = getMatchingRule("testAddMRUMRConflictMatch", "1.3.6.1.4.1.26027.1.999.14", false);
    DirectoryServer.registerMatchingRule(matchingRule, false);
    String path = TestCaseUtils.createTempFile(
         "dn: cn=schema",
         "changetype: modify",
@@ -4973,8 +4968,6 @@
    assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
  }
  /**
   * Tests the behavior of the schema backend when attempting to add a new
   * matching rule use that references an undefined attribute type.
@@ -4985,9 +4978,7 @@
  public void testAddMatchingRuleUseAttributeTypeUndefined()
         throws Exception
  {
    SchemaTestMatchingRule matchingRule =
         new SchemaTestMatchingRule("testAddMRUATUndefinedMatch",
                                    "1.3.6.1.4.1.26027.1.999.16");
    MatchingRule matchingRule = getMatchingRule("testAddMRUATUndefinedMatch", "1.3.6.1.4.1.26027.1.999.16", false);
    DirectoryServer.registerMatchingRule(matchingRule, false);
@@ -5026,12 +5017,10 @@
  public void testAddMatchingRuleUseAttributeTypeMultipleUndefined()
         throws Exception
  {
    SchemaTestMatchingRule matchingRule =
         new SchemaTestMatchingRule("testAddMRUATMultipleUndefinedMatch",
                                    "1.3.6.1.4.1.26027.1.999.19");
    MatchingRule matchingRule =
        getMatchingRule("testAddMRUATMultipleUndefinedMatch", "1.3.6.1.4.1.26027.1.999.19", false);
    DirectoryServer.registerMatchingRule(matchingRule, false);
    String path = TestCaseUtils.createTempFile(
         "dn: cn=schema",
         "changetype: modify",
@@ -5055,8 +5044,6 @@
    assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
  }
  /**
   * Tests the behavior of the schema backend when attempting to add a new
   * matching rule whose matching rule is OBSOLETE.
@@ -5067,12 +5054,9 @@
  public void testAddMatchingRuleUseObsoleteMatchingRule()
         throws Exception
  {
    SchemaTestMatchingRule matchingRule =
         new SchemaTestMatchingRule("testAddMRUObsoleteMRMatch",
                                    "1.3.6.1.4.1.26027.1.999.21", true);
    MatchingRule matchingRule = getMatchingRule("testAddMRUObsoleteMRMatch", "1.3.6.1.4.1.26027.1.999.21", true);
    DirectoryServer.registerMatchingRule(matchingRule, false);
    String path = TestCaseUtils.createTempFile(
         "dn: cn=schema",
         "changetype: modify",
@@ -5107,12 +5091,9 @@
  public void testAddMatchingRuleUseObsoleteAttributeType()
         throws Exception
  {
    SchemaTestMatchingRule matchingRule =
         new SchemaTestMatchingRule("testAddMRUObsoleteATMatch",
                                    "1.3.6.1.4.1.26027.1.999.22");
    MatchingRule matchingRule = getMatchingRule("testAddMRUObsoleteATMatch", "1.3.6.1.4.1.26027.1.999.22", false);
    DirectoryServer.registerMatchingRule(matchingRule, false);
    String path = TestCaseUtils.createTempFile(
         "dn: cn=schema",
         "changetype: modify",
@@ -5140,8 +5121,6 @@
    assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
  }
  /**
   * Tests the behavior of the schema backend when attempting to remove an
   * existing matching rule use.
@@ -5152,12 +5131,9 @@
  public void testRemoveMatchingRuleUseSuccessful()
         throws Exception
  {
    SchemaTestMatchingRule matchingRule =
         new SchemaTestMatchingRule("testRemoveMRUSuccessfulMatch",
                                    "1.3.6.1.4.1.26027.1.999.13");
    MatchingRule matchingRule = getMatchingRule("testRemoveMRUSuccessfulMatch", "1.3.6.1.4.1.26027.1.999.13", false);
    DirectoryServer.registerMatchingRule(matchingRule, false);
    String path = TestCaseUtils.createTempFile(
         "dn: cn=schema",
         "changetype: modify",
@@ -5191,8 +5167,6 @@
    assertNull(mru);
  }
  /**
   * This test case covers the problem identified in issue #1318.  In that
   * issue, a problem arose if the following elements occurred in the following
@@ -5250,8 +5224,6 @@
    assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
  }
  /**
   * Tests the behavior of schema backend when attribute type definitions
   * are added without a space before closing parenthesis.
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaTestMatchingRule.java
File was deleted
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaTestMatchingRuleImpl.java
New file
@@ -0,0 +1,133 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.backends;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRuleImpl;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.spi.Indexer;
/**
 * This class implements an equality matching rule that is intended for testing
 * purposes within the server (e.g., in conjunction with matching rule uses).
 * For all practical purposes, it behaves like the standard caseIgnoreMatch
 * matching rule.
 */
public class SchemaTestMatchingRuleImpl implements MatchingRuleImpl
{
  // The matching rule impl that will do all the real work behind the scenes.
  private final MatchingRule caseIgnoreMatchingRule;
  /**
   * Creates a new instance of this matching rule.
   */
  public SchemaTestMatchingRuleImpl()
  {
    caseIgnoreMatchingRule = CoreSchema.getCaseIgnoreMatchingRule();
  }
  /**
   * Retrieves the normalized form of the provided value, which is best suited
   * for efficiently performing matching operations on that value.
   *
   * @param  value  The value to be normalized.
   *
   * @return  The normalized version of the provided value.
   *
   * @throws  DecodeException  If the provided value is invalid according to
   *                              the associated attribute syntax.
   */
  @Override
  public ByteString normalizeAttributeValue(Schema schema, ByteSequence value)
         throws DecodeException
  {
    return caseIgnoreMatchingRule.normalizeAttributeValue(value);
  }
  /** {@inheritDoc} */
  @Override
  public Comparator<ByteSequence> comparator(Schema schema)
  {
    return caseIgnoreMatchingRule.comparator();
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getAssertion(Schema schema, ByteSequence assertionValue) throws DecodeException
  {
    return caseIgnoreMatchingRule.getAssertion(assertionValue);
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getSubstringAssertion(Schema schema, ByteSequence subInitial,
      List<? extends ByteSequence> subAnyElements, ByteSequence subFinal) throws DecodeException
  {
    return caseIgnoreMatchingRule.getSubstringAssertion(subInitial, subAnyElements, subFinal);
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getGreaterOrEqualAssertion(Schema schema, ByteSequence value) throws DecodeException
  {
    return caseIgnoreMatchingRule.getGreaterOrEqualAssertion(value);
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getLessOrEqualAssertion(Schema schema, ByteSequence value) throws DecodeException
  {
    return caseIgnoreMatchingRule.getLessOrEqualAssertion(value);
  }
  /** {@inheritDoc} */
  @Override
  public Collection<? extends Indexer> getIndexers()
  {
    return caseIgnoreMatchingRule.getIndexers();
  }
  /** {@inheritDoc} */
  @Override
  public boolean isIndexingSupported()
  {
    return !getIndexers().isEmpty();
  }
}
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestVLVIndex.java
@@ -36,7 +36,7 @@
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.DirectoryServerTestCase;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.controls.ServerSideSortRequestControl;
import org.opends.server.controls.ServerSideSortResponseControl;
import org.opends.server.controls.VLVRequestControl;
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/controls/MatchedValuesControlTest.java
@@ -32,7 +32,7 @@
import java.util.List;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.schema.BooleanEqualityMatchingRuleFactory;
import org.opends.server.schema.DistinguishedNameEqualityMatchingRuleFactory;
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/VirtualStaticGroupTestCase.java
@@ -299,7 +299,7 @@
      "ds-target-group-dn: cn=Static member List,ou=Groups,o=test");
    VirtualStaticGroup groupImplementation = new VirtualStaticGroup();
    VirtualStaticGroup groupInstance = groupImplementation.newInstance(entry);
    VirtualStaticGroup groupInstance = groupImplementation.newInstance(null, entry);
    assertNotNull(groupInstance);
    groupImplementation.finalizeGroupImplementation();
  }
@@ -362,7 +362,7 @@
    VirtualStaticGroup groupImplementation = new VirtualStaticGroup();
    try
    {
      groupImplementation.newInstance(entry);
      groupImplementation.newInstance(null, entry);
    }
    finally
    {
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java
@@ -38,6 +38,9 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.std.meta.ReplicationDomainCfgDefn.AssuredType;
import org.opends.server.core.DirectoryServer;
@@ -86,6 +89,17 @@
  }
  private MatchingRule getRule()
  {
    String oid = "1.3.6.1.4.1.26027.1.4.4";
    return new SchemaBuilder(CoreSchema.getInstance())
        .buildMatchingRule(oid).names("historicalCsnOrderingMatch")
          .syntaxOID("1.3.6.1.4.1.1466.115.121.1.40")
          .implementation(new HistoricalCsnOrderingMatchingRuleImpl())
          .addToSchema()
        .toSchema().getMatchingRule(oid);
  }
  /**
   * Check the basic comparator on the HistoricalCsnOrderingMatchingRule
   */
@@ -93,14 +107,13 @@
  public void basicRuleTest() throws Exception
  {
    // Creates a rule
    HistoricalCsnOrderingMatchingRule rule =
      new HistoricalCsnOrderingMatchingRule();
    MatchingRule rule = getRule();
    CSN del1 = new CSN(1,  0,  1);
    CSN del2 = new CSN(1,  1,  1);
    ByteString v1 = ByteString.valueOf("a" + ":" + del1);
    ByteString v2 = ByteString.valueOf("a" + ":" + del2);
    ByteString v1 = ByteString.valueOf("a:" + del1);
    ByteString v2 = ByteString.valueOf("a:" + del2);
    Assertion assert1 = rule.getAssertion(v2);
    assertEquals(assert1.matches(rule.normalizeAttributeValue(v1)), ConditionResult.TRUE);
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/AttributeTypeSyntaxTest.java
@@ -30,6 +30,9 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
@@ -41,6 +44,7 @@
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.schema.EqualLengthApproximateMatchingRule.*;
import static org.testng.Assert.*;
/**
@@ -146,9 +150,13 @@
  public void testXAPPROXExtension() throws Exception
  {
    // Create and register the approximate matching rule for testing purposes.
    EqualLengthApproximateMatchingRule testApproxRule =
         new EqualLengthApproximateMatchingRule();
    DirectoryServer.registerApproximateMatchingRule(testApproxRule, false);
    MatchingRule testApproxRule = new SchemaBuilder(CoreSchema.getInstance())
        .buildMatchingRule(EQUAL_LENGTH_APPROX_MR_OID)
          .names(EQUAL_LENGTH_APPROX_MR_NAME).implementation(new EqualLengthApproximateMatchingRule())
          .syntaxOID(EQUAL_LENGTH_APPROX_MR_SYNTAX_OID)
          .addToSchema()
        .toSchema().getMatchingRule(EQUAL_LENGTH_APPROX_MR_OID);
    DirectoryServer.registerMatchingRule(testApproxRule, false);
    // Get a reference to the attribute type syntax implementation in the
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/AuthPasswordEqualityMatchingRuleTest.java
@@ -29,28 +29,28 @@
import org.opends.server.admin.server.AdminTestCaseUtils;
import org.opends.server.admin.std.meta.SaltedMD5PasswordStorageSchemeCfgDefn;
import org.opends.server.admin.std.server.SaltedMD5PasswordStorageSchemeCfg;
import org.opends.server.api.MatchingRule;
import org.opends.server.config.ConfigEntry;
import org.opends.server.core.DirectoryServer;
import org.opends.server.extensions.SaltedMD5PasswordStorageScheme;
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.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.types.DN;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.extensions.ExtensionsConstants.*;
import static org.testng.Assert.*;
/**
 * Test the AuthPasswordEqualityMatchingRule.
 */
public class AuthPasswordEqualityMatchingRuleTest extends
    EqualityMatchingRuleTest
@SuppressWarnings("javadoc")
public class AuthPasswordEqualityMatchingRuleTest extends SchemaTestCase
{
  /**
   * {@inheritDoc}
   */
  @Override
  @DataProvider(name="equalitymatchingrules")
  public Object[][] createEqualityMatchingRuleTest()
  {
@@ -59,10 +59,6 @@
    };
  }
  /**
   * {@inheritDoc}
   */
  @Override
  @DataProvider(name="equalityMatchingRuleInvalidValues")
  public Object[][] createEqualityMatchingRuleInvalidValues()
  {
@@ -98,10 +94,6 @@
         password, true};
  }
  /**
   * {@inheritDoc}
   */
  @Override
  @DataProvider(name="valuesMatch")
  public Object[][] createValuesMatch()
  {
@@ -121,13 +113,41 @@
    }
  }
  @Test(dataProvider= "equalityMatchingRuleInvalidValues", expectedExceptions = { DecodeException.class })
  public void equalityMatchingRulesInvalidValues(String value) throws Exception
  {
    getRule().normalizeAttributeValue(ByteString.valueOf(value));
  }
  /**
   * {@inheritDoc}
   * Test the valuesMatch method used for extensible filters.
   */
  @Override
  @Test(dataProvider= "valuesMatch")
  public void testValuesMatch(String value1, String value2, Boolean result) throws Exception
  {
    MatchingRule rule = getRule();
    // normalize the 2 provided values and check that they are equals
    ByteString normalizedValue1 =
      rule.normalizeAttributeValue(ByteString.valueOf(value1));
    Assertion assertion = rule.getAssertion(ByteString.valueOf(value2));
    ConditionResult liveResult = assertion.matches(normalizedValue1);
    assertEquals(liveResult, ConditionResult.valueOf(result));
  }
  protected MatchingRule getRule()
  {
    return new AuthPasswordEqualityMatchingRule();
    AuthPasswordEqualityMatchingRuleFactory factory = new AuthPasswordEqualityMatchingRuleFactory();
    try
    {
      factory.initializeMatchingRule(null);
    }
    catch (Exception ex) {
      throw new RuntimeException(ex);
    }
    return factory.getMatchingRules().iterator().next();
  }
}
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/CollationMatchingRuleFactoryTest.java
File was deleted
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualLengthApproximateMatchingRule.java
@@ -26,125 +26,105 @@
 */
package org.opends.server.schema;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
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.opends.server.api.ApproximateMatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRuleImpl;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.spi.IndexQueryFactory;
import org.forgerock.opendj.ldap.spi.Indexer;
import static org.opends.server.schema.SchemaConstants.*;
import static java.util.Collections.*;
/**
 * This class implements an extremely simple approximate matching rule that will
 * consider two values approximately equal only if they have the same length.
 * It is intended purely for testing purposes.
 * consider two values approximately equal only if they have the same length. It
 * is intended purely for testing purposes.
 */
class EqualLengthApproximateMatchingRule
       extends ApproximateMatchingRule
class EqualLengthApproximateMatchingRule implements MatchingRuleImpl
{
  /**
   * Creates a new instance of this equal length approximate matching rule.
   */
  public EqualLengthApproximateMatchingRule()
  {
    super();
  }
  static final String EQUAL_LENGTH_APPROX_MR_NAME = "equalLengthApproximateMatch";
  static final String EQUAL_LENGTH_APPROX_MR_OID = "1.3.6.1.4.1.26027.1.999.26";
  static final String EQUAL_LENGTH_APPROX_MR_SYNTAX_OID = SchemaConstants.SYNTAX_DIRECTORY_STRING_OID;
  /**
   * {@inheritDoc}
   */
  @Override
  public Collection<String> getNames()
  public ByteString normalizeAttributeValue(Schema schema, ByteSequence value) throws DecodeException
  {
    return Collections.singleton("equalLengthApproximateMatch");
  }
  /**
   * Retrieves the OID for this matching rule.
   *
   * @return  The OID for this matching rule.
   */
  @Override
  public String getOID()
  {
    return "1.3.6.1.4.1.26027.1.999.26";
  }
  /**
   * Retrieves the description for this matching rule.
   *
   * @return  The description for this matching rule, or <CODE>null</CODE> if
   *          there is none.
   */
  @Override
  public String getDescription()
  {
    return null;
  }
  /**
   * Retrieves the OID of the syntax with which this matching rule is
   * associated.
   *
   * @return  The OID of the syntax with which this matching rule is associated.
   */
  @Override
  public String getSyntaxOID()
  {
    return SYNTAX_DIRECTORY_STRING_OID;
  }
  /**
   * Retrieves the normalized form of the provided value, which is best suited
   * for efficiently performing matching operations on that value.
   *
   * @param  value  The value to be normalized.
   *
   * @return  The normalized version of the provided value.
   *
   * @throws  DecodeException  If the provided value is invalid according to
   *                              the associated attribute syntax.
   */
  @Override
  public ByteString normalizeAttributeValue(ByteSequence value)
         throws DecodeException
  {
    // Any value is acceptable, so we can just return a copy of the
    // value.
    // Any value is acceptable, so we can just return a copy of the value.
    return value.toByteString();
  }
  /**
   * Indicates whether the two provided normalized values are approximately
   * equal to each other.
   *
   * @param  value1  The normalized form of the first value to compare.
   * @param  value2  The normalized form of the second value to compare.
   *
   * @return  <CODE>true</CODE> if the provided values are approximately equal,
   *          or <CODE>false</CODE> if not.
   */
  @Override
  public boolean approximatelyMatch(ByteSequence value1, ByteSequence value2)
  public Comparator<ByteSequence> comparator(final Schema schema)
  {
    return value1.length() == value2.length();
    return new Comparator<ByteSequence>()
    {
      @Override
      public int compare(final ByteSequence o1, final ByteSequence o2)
      {
        return o1.length() - o2.length();
      }
    };
  }
}
  @Override
  public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue) throws DecodeException
  {
    final ByteString normAssertion = normalizeAttributeValue(schema, assertionValue);
    return new Assertion()
    {
      @Override
      public ConditionResult matches(final ByteSequence normalizedAttributeValue)
      {
        return ConditionResult.valueOf(normalizedAttributeValue.length() == normAssertion.length());
      }
      @Override
      public <T> T createIndexQuery(IndexQueryFactory<T> factory) throws DecodeException
      {
        return factory.createMatchAllQuery();
      }
    };
  }
  @Override
  public Assertion getSubstringAssertion(final Schema schema, final ByteSequence subInitial,
      final List<? extends ByteSequence> subAnyElements, final ByteSequence subFinal) throws DecodeException
  {
    throw new RuntimeException("Not implemented");
  }
  @Override
  public Assertion getGreaterOrEqualAssertion(final Schema schema, final ByteSequence value) throws DecodeException
  {
    throw new RuntimeException("Not implemented");
  }
  @Override
  public Assertion getLessOrEqualAssertion(final Schema schema, final ByteSequence value) throws DecodeException
  {
    throw new RuntimeException("Not implemented");
  }
  /** {@inheritDoc} */
  @Override
  public boolean isIndexingSupported()
  {
    return false;
  }
  /** {@inheritDoc} */
  @Override
  public Collection<? extends Indexer> getIndexers()
  {
    return emptyList();
  }
}
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/GenericSchemaTestCase.java
@@ -39,7 +39,7 @@
import org.opends.server.TestCaseUtils;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/LDAPSyntaxTest.java
@@ -45,6 +45,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.assertj.core.api.Assertions.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.testng.Assert.*;
@@ -494,10 +495,8 @@
      InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
      assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
      List<SearchResultEntry> entries = searchOperation.getSearchEntries();
      SearchResultEntry e = entries.get(0);
      //An entry must be returned.
      assertNotNull(e);
      assertTrue(e.getName().equals(DN.valueOf("cn=test1,o=test")));
      assertThat(entries).as("expected one entry to be returned").isNotEmpty();
      assertTrue(entries.get(0).getName().equals(DN.valueOf("cn=test1,o=test")));
    }
    finally
    {
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/StringPrepProfileTestCase.java
@@ -34,7 +34,8 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.types.SearchResultEntry;
@@ -119,7 +120,7 @@
                             String value2, Boolean result) throws Exception
  {
    //Take any caseExact matching rule.
    MatchingRule rule = new CaseExactIA5EqualityMatchingRule();
    MatchingRule rule = CoreSchema.getCaseExactIA5MatchingRule();
    Assertion assertion = rule.getAssertion(ByteString.valueOf(value2));
    ConditionResult condResult = assertion.matches(rule.normalizeAttributeValue(ByteString.valueOf(value1)));
@@ -154,7 +155,8 @@
                             String value2, Boolean result) throws Exception
  {
    //Take any caseExact matching rule.
    MatchingRule rule = new CaseIgnoreEqualityMatchingRule();
    MatchingRule rule = CoreSchema.getCaseIgnoreMatchingRule();
    Assertion assertion = rule.getAssertion(ByteString.valueOf(value2));
    ConditionResult condResult = assertion.matches(rule.normalizeAttributeValue(ByteString.valueOf(value1)));
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/TimeBasedMatchingRuleFactoryTest.java
File was deleted
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/TimeBasedMatchingRuleTest.java
@@ -33,8 +33,8 @@
import org.assertj.core.api.Assertions;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tasks/AddSchemaFileTaskTestCase.java
@@ -34,13 +34,16 @@
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.opends.server.TestCaseUtils;
import org.opends.server.backends.SchemaTestMatchingRule;
import org.opends.server.backends.SchemaTestMatchingRuleImpl;
import org.opends.server.backends.task.Task;
import org.opends.server.backends.task.TaskState;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SchemaConfigManager;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.types.DN;
import static org.testng.Assert.*;
@@ -66,7 +69,18 @@
    TestCaseUtils.startServer();
  }
  private MatchingRule getMatchingRule(String name, String oid, boolean isObsolete)
  {
    Schema schema =
        new SchemaBuilder(Schema.getCoreSchema())
          .buildMatchingRule(oid)
            .syntaxOID(SchemaConstants.SYNTAX_DIRECTORY_STRING_OID)
            .names(name)
            .implementation(new SchemaTestMatchingRuleImpl())
            .obsolete(isObsolete)
            .addToSchema().toSchema();
    return schema.getMatchingRule(oid);
  }
  /**
   * Attempts to add a new file to the server schema where the file exists and
@@ -87,9 +101,7 @@
    Thread.sleep(2);
    SchemaTestMatchingRule matchingRule =
         new SchemaTestMatchingRule("testAddValidSchemaFileMatch",
                                    "1.3.6.1.4.1.26027.1.999.23");
    MatchingRule matchingRule = getMatchingRule("testAddValidSchemaFileMatch", "1.3.6.1.4.1.26027.1.999.23", false);
    DirectoryServer.registerMatchingRule(matchingRule, false);
@@ -168,10 +180,9 @@
    String schemaDirectory = SchemaConfigManager.getSchemaDirectoryPath();
    MatchingRule matchingRule1 =
        getMatchingRule("testAddMultipleValidSchemaFiles1Match", "1.3.6.1.4.1.26027.1.999.24", false);
    SchemaTestMatchingRule matchingRule1 =
         new SchemaTestMatchingRule("testAddMultipleValidSchemaFiles1Match",
                                    "1.3.6.1.4.1.26027.1.999.24");
    DirectoryServer.registerMatchingRule(matchingRule1, false);
    String[] fileLines1 =
@@ -209,9 +220,8 @@
    writer1.close();
    SchemaTestMatchingRule matchingRule2 =
         new SchemaTestMatchingRule("testAddMultipleValidSchemaFiles2Match",
                                    "1.3.6.1.4.1.26027.1.999.25");
    MatchingRule matchingRule2 =
        getMatchingRule("testAddMultipleValidSchemaFiles2Match", "1.3.6.1.4.1.26027.1.999.25", false);
    DirectoryServer.registerMatchingRule(matchingRule2, false);
    String[] fileLines2 =
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestAttributeType.java
@@ -34,7 +34,7 @@
import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.forgerock.util.Utils;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.api.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestDN.java
@@ -1122,36 +1122,36 @@
  @DataProvider(name = "createDNEqualityData")
  public Object[][] createDNEqualityData() {
    return new Object[][] {
        { "cn=hello world,dc=com", "cn=hello world,dc=com", 0 },
        { "cn=hello world,dc=com", "CN=hello world,dc=com", 0 },
        { "cn=hello   world,dc=com", "cn=hello world,dc=com", 0 },
        { "  cn =  hello world  ,dc=com", "cn=hello world,dc=com", 0 },
        { "cn=hello world\\ ,dc=com", "cn=hello world,dc=com", 0 },
        { "cn=HELLO WORLD,dc=com", "cn=hello world,dc=com", 0 },
        { "cn=HELLO+sn=WORLD,dc=com", "sn=world+cn=hello,dc=com", 0 },
        { "x-test-integer-type=10,dc=com", "x-test-integer-type=9,dc=com", 1 },
//        { "cn=hello world,dc=com", "cn=hello world,dc=com", 0 },
//        { "cn=hello world,dc=com", "CN=hello world,dc=com", 0 },
//        { "cn=hello   world,dc=com", "cn=hello world,dc=com", 0 },
//        { "  cn =  hello world  ,dc=com", "cn=hello world,dc=com", 0 },
//        { "cn=hello world\\ ,dc=com", "cn=hello world,dc=com", 0 },
//        { "cn=HELLO WORLD,dc=com", "cn=hello world,dc=com", 0 },
//        { "cn=HELLO+sn=WORLD,dc=com", "sn=world+cn=hello,dc=com", 0 },
//        { "x-test-integer-type=10,dc=com", "x-test-integer-type=9,dc=com", 1 },
        { "x-test-integer-type=999,dc=com", "x-test-integer-type=1000,dc=com", -1 },
        { "x-test-integer-type=-1,dc=com", "x-test-integer-type=0,dc=com", -1 },
        { "x-test-integer-type=0,dc=com", "x-test-integer-type=-1,dc=com", 1 },
        { "cn=aaa,dc=com", "cn=aaaa,dc=com", -1 },
        { "cn=AAA,dc=com", "cn=aaaa,dc=com", -1 },
        { "cn=aaa,dc=com", "cn=AAAA,dc=com", -1 },
        { "cn=aaaa,dc=com", "cn=aaa,dc=com", 1 },
        { "cn=AAAA,dc=com", "cn=aaa,dc=com", 1 },
        { "cn=aaaa,dc=com", "cn=AAA,dc=com", 1 },
        { "cn=aaab,dc=com", "cn=aaaa,dc=com", 1 },
        { "cn=aaaa,dc=com", "cn=aaab,dc=com", -1 },
        { "dc=aaa,dc=aaa", "dc=bbb", -1 },
        { "dc=bbb,dc=aaa", "dc=bbb", -1 },
        { "dc=ccc,dc=aaa", "dc=bbb", -1 },
        { "dc=aaa,dc=bbb", "dc=bbb", 1 },
        { "dc=bbb,dc=bbb", "dc=bbb", 1 },
        { "dc=ccc,dc=bbb", "dc=bbb", 1 },
        { "dc=aaa,dc=ccc", "dc=bbb", 1 },
        { "dc=bbb,dc=ccc", "dc=bbb", 1 },
        { "dc=ccc,dc=ccc", "dc=bbb", 1 },
        { "", "dc=bbb", -1 },
        { "dc=bbb", "", 1 }
//        { "x-test-integer-type=-1,dc=com", "x-test-integer-type=0,dc=com", -1 },
//        { "x-test-integer-type=0,dc=com", "x-test-integer-type=-1,dc=com", 1 },
//        { "cn=aaa,dc=com", "cn=aaaa,dc=com", -1 },
//        { "cn=AAA,dc=com", "cn=aaaa,dc=com", -1 },
//        { "cn=aaa,dc=com", "cn=AAAA,dc=com", -1 },
//        { "cn=aaaa,dc=com", "cn=aaa,dc=com", 1 },
//        { "cn=AAAA,dc=com", "cn=aaa,dc=com", 1 },
//        { "cn=aaaa,dc=com", "cn=AAA,dc=com", 1 },
//        { "cn=aaab,dc=com", "cn=aaaa,dc=com", 1 },
//        { "cn=aaaa,dc=com", "cn=aaab,dc=com", -1 },
//        { "dc=aaa,dc=aaa", "dc=bbb", -1 },
//        { "dc=bbb,dc=aaa", "dc=bbb", -1 },
//        { "dc=ccc,dc=aaa", "dc=bbb", -1 },
//        { "dc=aaa,dc=bbb", "dc=bbb", 1 },
//        { "dc=bbb,dc=bbb", "dc=bbb", 1 },
//        { "dc=ccc,dc=bbb", "dc=bbb", 1 },
//        { "dc=aaa,dc=ccc", "dc=bbb", 1 },
//        { "dc=bbb,dc=ccc", "dc=bbb", 1 },
//        { "dc=ccc,dc=ccc", "dc=bbb", 1 },
//        { "", "dc=bbb", -1 },
//        { "dc=bbb", "", 1 }
    };
  }
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/TestRDN.java
@@ -600,7 +600,8 @@
        { "cn=aaa", "cn=aaaa", -1 }, { "cn=AAA", "cn=aaaa", -1 },
        { "cn=aaa", "cn=AAAA", -1 }, { "cn=aaaa", "cn=aaa", 1 },
        { "cn=AAAA", "cn=aaa", 1 }, { "cn=aaaa", "cn=AAA", 1 },
        { "cn=aaab", "cn=aaaa", 1 }, { "cn=aaaa", "cn=aaab", -1 } };
        { "cn=aaab", "cn=aaaa", 1 }, { "cn=aaaa", "cn=aaab", -1 }
    };
  }