001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2008 Sun Microsystems, Inc. 015 * Portions Copyright 2014-2016 ForgeRock AS. 016 */ 017package org.opends.server.schema; 018 019import java.util.Collection; 020import java.util.Collections; 021 022import org.opends.server.api.MatchingRuleFactory; 023import org.forgerock.opendj.server.config.server.MatchingRuleCfg; 024import org.forgerock.opendj.config.server.ConfigException; 025import org.forgerock.opendj.ldap.schema.CoreSchema; 026import org.forgerock.opendj.ldap.schema.MatchingRule; 027import org.forgerock.opendj.ldap.schema.SchemaBuilder; 028import org.opends.server.types.InitializationException; 029 030import static org.opends.server.schema.SchemaConstants.*; 031 032/** 033 * This class is a factory class for UserPasswordExactEqualityMatchingRule. 034 */ 035public final class UserPasswordEqualityMatchingRuleFactory extends MatchingRuleFactory<MatchingRuleCfg> 036{ 037 private MatchingRule matchingRule; 038 039 /** {@inheritDoc} */ 040 @Override 041 public final void initializeMatchingRule(MatchingRuleCfg configuration) 042 throws ConfigException, InitializationException 043 { 044 matchingRule = new SchemaBuilder(CoreSchema.getInstance()) 045 .buildMatchingRule(EMR_USER_PASSWORD_OID) 046 .names(EMR_USER_PASSWORD_NAME) 047 .syntaxOID(SYNTAX_OCTET_STRING_OID).description(EMR_USER_PASSWORD_DESCRIPTION) 048 .implementation(new UserPasswordEqualityMatchingRule()) 049 .addToSchema() 050 .toSchema().getMatchingRule(EMR_USER_PASSWORD_OID); 051 } 052 053 /** {@inheritDoc} */ 054 @Override 055 public final Collection<MatchingRule> getMatchingRules() 056 { 057 return Collections.singleton(matchingRule); 058 } 059}