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

neil_a_wilson
12.33.2006 85e5ea2b9fb0d035912d74f57be54b31b88884e1
Add test cases for a number of classes in the extensions package, including the
password storage schemes, some of the simple key/trust manager providers, the
random password generator, and the certificate validation policy.
16 files added
1 files modified
1530 ■■■■■ changed files
opends/ext/testng/testng.xml 1 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/Base64PasswordStorageSchemeTestCase.java 69 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/BlindTrustManagerProviderTestCase.java 86 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/CertificateValidationPolicyTestCase.java 132 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/ClearPasswordStorageSchemeTestCase.java 69 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/ExtensionsTestCase.java 46 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/MD5PasswordStorageSchemeTestCase.java 69 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/NullKeyManagerProviderTestCase.java 78 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/NullTrustManagerProviderTestCase.java 78 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/PasswordStorageSchemeTestCase.java 233 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/RandomPasswordGeneratorTestCase.java 219 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SHA1PasswordStorageSchemeTestCase.java 69 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SaltedMD5PasswordStorageSchemeTestCase.java 70 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SaltedSHA1PasswordStorageSchemeTestCase.java 101 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SaltedSHA256PasswordStorageSchemeTestCase.java 70 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SaltedSHA384PasswordStorageSchemeTestCase.java 70 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SaltedSHA512PasswordStorageSchemeTestCase.java 70 ●●●●● patch | view | raw | blame | history
opends/ext/testng/testng.xml
@@ -11,6 +11,7 @@
            <package name="org.opends.server.util"/>
            <package name="org.opends.server.schema"/>
            <package name="org.opends.server.monitors"/>
            <package name="org.opends.server.extensions"/>
        </packages>
    </test>
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/Base64PasswordStorageSchemeTestCase.java
New file
@@ -0,0 +1,69 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import org.opends.server.api.PasswordStorageScheme;
/**
 * A set of test cases for the base64 password storage scheme.
 */
public class Base64PasswordStorageSchemeTestCase
       extends PasswordStorageSchemeTestCase
{
  /**
   * Creates a new instance of this storage scheme test case.
   */
  public Base64PasswordStorageSchemeTestCase()
  {
    super("cn=Base64,cn=Password Storage Schemes,cn=config");
  }
  /**
   * Retrieves an initialized instance of this password storage scheme.
   *
   * @param  configEntry  The configuration entry for the password storage
   *                      scheme, or <CODE>null</CODE> if none is available.
   *
   * @return  An initialized instance of this password storage scheme.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  public PasswordStorageScheme getScheme()
         throws Exception
  {
    Base64PasswordStorageScheme scheme = new Base64PasswordStorageScheme();
    scheme.initializePasswordStorageScheme(configEntry);
    return scheme;
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/BlindTrustManagerProviderTestCase.java
New file
@@ -0,0 +1,86 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import java.security.cert.X509Certificate;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.opends.server.TestCaseUtils;
import static org.testng.Assert.*;
/**
 * A set of test cases for the blind trust manager provider.
 */
public class BlindTrustManagerProviderTestCase
       extends ExtensionsTestCase
{
  /**
   * Ensures that the Directory Server is running.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @BeforeClass()
  public void startServer()
         throws Exception
  {
    TestCaseUtils.startServer();
  }
  /**
   * Tests the blind trust manager provider by creating a new instance,
   * initializing it, and getting the trust managers and issuers.  In this case,
   * since we know that all certificates will always be trusted then we can also
   * invoke the checkClientTrusted and checkServerTrusted methods with empty
   * certificate chains.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testBlindTrustManagerProvider()
         throws Exception
  {
    BlindTrustManagerProvider provider = new BlindTrustManagerProvider();
    provider.initializeTrustManagerProvider(null);
    assertNotNull(provider.getTrustManagers());
    assertNotNull(provider.getAcceptedIssuers());
    provider.checkClientTrusted(new X509Certificate[0], "");
    provider.checkServerTrusted(new X509Certificate[0], "");
    provider.finalizeTrustManagerProvider();
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/CertificateValidationPolicyTestCase.java
New file
@@ -0,0 +1,132 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
/**
 * A set of test cases for the certificate validation policy enumeration.
 */
public class CertificateValidationPolicyTestCase
       extends ExtensionsTestCase
{
  /**
   * Retrieves the names of the certificate validation policies.
   *
   * @return  The names of the certificate validation policies.
   */
  @DataProvider(name= "policyNames")
  public Object[][] getPolicyNames()
  {
    return new Object[][]
    {
      new Object[] { "ALWAYS" },
      new Object[] { "NEVER" },
      new Object[] { "IFPRESENT" },
    };
  }
  /**
   * Tests the <CODE>policyForName</CODE> method with a valid policy name.
   *
   * @param  name  The name for the policy to retrieve.
   */
  @Test(dataProvider = "policyNames")
  public void testPolicyForValidName(String name)
  {
    assertNotNull(CertificateValidationPolicy.policyForName(name));
  }
  /**
   * Tests the <CODE>policyForName</CODE> method with an invalid policy name.
   */
  @Test()
  public void testPolicyForInvalidName()
  {
    assertNull(CertificateValidationPolicy.policyForName("invalid"));
  }
  /**
   * Tests the <CODE>valueOf</CODE> method with a valid policy name.
   *
   * @param  name  The name for the policy to retrieve.
   */
  @Test(dataProvider = "policyNames")
  public void testValueOfValid(String name)
  {
    assertNotNull(CertificateValidationPolicy.valueOf(name));
  }
  /**
   * Tests the <CODE>valueOf</CODE> method with an invalid policy name.
   */
  @Test(expectedExceptions = { IllegalArgumentException.class })
  public void testValueOfInvalid()
  {
    CertificateValidationPolicy.valueOf("invalid");
  }
  /**
   * Tests the <CODE>values</CODE> method.
   */
  @Test()
  public void testValues()
  {
    assertNotNull(CertificateValidationPolicy.values());
  }
  /**
   * Tests the <CODE>toString</CODE> method.
   *
   * @param  name  The name for the policy to retrieve.
   */
  @Test(dataProvider = "policyNames")
  public void testToString(String name)
  {
    CertificateValidationPolicy.policyForName(name).toString();
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/ClearPasswordStorageSchemeTestCase.java
New file
@@ -0,0 +1,69 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import org.opends.server.api.PasswordStorageScheme;
/**
 * A set of test cases for the clear password storage scheme.
 */
public class ClearPasswordStorageSchemeTestCase
       extends PasswordStorageSchemeTestCase
{
  /**
   * Creates a new instance of this storage scheme test case.
   */
  public ClearPasswordStorageSchemeTestCase()
  {
    super("cn=Clear,cn=Password Storage Schemes,cn=config");
  }
  /**
   * Retrieves an initialized instance of this password storage scheme.
   *
   * @param  configEntry  The configuration entry for the password storage
   *                      scheme, or <CODE>null</CODE> if none is available.
   *
   * @return  An initialized instance of this password storage scheme.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  public PasswordStorageScheme getScheme()
         throws Exception
  {
    ClearPasswordStorageScheme scheme = new ClearPasswordStorageScheme();
    scheme.initializePasswordStorageScheme(configEntry);
    return scheme;
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/ExtensionsTestCase.java
New file
@@ -0,0 +1,46 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import org.testng.annotations.Test;
import org.opends.server.DirectoryServerTestCase;
/**
 * An abstract base class for all extensions test cases.
 */
@Test(groups = { "precommit", "extensions" })
public abstract class ExtensionsTestCase
       extends DirectoryServerTestCase
{
  // No implementation required.
}
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/MD5PasswordStorageSchemeTestCase.java
New file
@@ -0,0 +1,69 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import org.opends.server.api.PasswordStorageScheme;
/**
 * A set of test cases for the MD5 password storage scheme.
 */
public class MD5PasswordStorageSchemeTestCase
       extends PasswordStorageSchemeTestCase
{
  /**
   * Creates a new instance of this storage scheme test case.
   */
  public MD5PasswordStorageSchemeTestCase()
  {
    super("cn=MD5,cn=Password Storage Schemes,cn=config");
  }
  /**
   * Retrieves an initialized instance of this password storage scheme.
   *
   * @param  configEntry  The configuration entry for the password storage
   *                      scheme, or <CODE>null</CODE> if none is available.
   *
   * @return  An initialized instance of this password storage scheme.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  public PasswordStorageScheme getScheme()
         throws Exception
  {
    MD5PasswordStorageScheme scheme = new MD5PasswordStorageScheme();
    scheme.initializePasswordStorageScheme(configEntry);
    return scheme;
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/NullKeyManagerProviderTestCase.java
New file
@@ -0,0 +1,78 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import java.security.cert.X509Certificate;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.opends.server.TestCaseUtils;
import static org.testng.Assert.*;
/**
 * A set of test cases for the null key manager provider.
 */
public class NullKeyManagerProviderTestCase
       extends ExtensionsTestCase
{
  /**
   * Ensures that the Directory Server is running.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @BeforeClass()
  public void startServer()
         throws Exception
  {
    TestCaseUtils.startServer();
  }
  /**
   * Tests the null key manager provider by creating a new instance,
   * initializing it, and getting the key managers.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testNullKeyManagerProvider()
         throws Exception
  {
    NullKeyManagerProvider provider = new NullKeyManagerProvider();
    provider.initializeKeyManagerProvider(null);
    assertNotNull(provider.getKeyManagers());
    provider.finalizeKeyManagerProvider();
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/NullTrustManagerProviderTestCase.java
New file
@@ -0,0 +1,78 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import java.security.cert.X509Certificate;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.opends.server.TestCaseUtils;
import static org.testng.Assert.*;
/**
 * A set of test cases for the null trust manager provider.
 */
public class NullTrustManagerProviderTestCase
       extends ExtensionsTestCase
{
  /**
   * Ensures that the Directory Server is running.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @BeforeClass()
  public void startServer()
         throws Exception
  {
    TestCaseUtils.startServer();
  }
  /**
   * Tests the null trust manager provider by creating a new instance,
   * initializing it, and getting the trust managers.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testNullTrustManagerProvider()
         throws Exception
  {
    NullTrustManagerProvider provider = new NullTrustManagerProvider();
    provider.initializeTrustManagerProvider(null);
    assertNotNull(provider.getTrustManagers());
    provider.finalizeTrustManagerProvider();
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/PasswordStorageSchemeTestCase.java
New file
@@ -0,0 +1,233 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.config.ConfigEntry;
import org.opends.server.core.DirectoryException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.schema.AuthPasswordSyntax;
import org.opends.server.schema.UserPasswordSyntax;
import org.opends.server.types.ByteString;
import org.opends.server.types.DN;
import static org.testng.Assert.*;
/**
 * A set of generic test cases for password storage schemes.
 */
public abstract class PasswordStorageSchemeTestCase
       extends ExtensionsTestCase
{
  // The configuration entry for this password storage scheme.
  protected ConfigEntry configEntry;
  // The string representation of the DN of the configuration entry for this
  // password storage scheme.
  private String configDNString;
  /**
   * Creates a new instance of this password storage scheme test case with the
   * provided information.
   *
   * @param  configDNString  The string representation of the DN of the
   *                         configuration entry, or <CODE>null</CODE> if there
   *                         is none.
   */
  protected PasswordStorageSchemeTestCase(String configDNString)
  {
    super();
    this.configDNString = configDNString;
    this.configEntry    = null;
  }
  /**
   * Ensures that the Directory Server is started before running any of these
   * tests.
   */
  @BeforeClass()
  public void startServer()
         throws Exception
  {
    TestCaseUtils.startServer();
    if (configDNString != null)
    {
      configEntry = DirectoryServer.getConfigEntry(DN.decode(configDNString));
    }
  }
  /**
   * Retrieves a set of passwords that may be used to test the password storage
   * scheme.
   *
   * @return  A set of passwords that may be used to test the password storage
   *          scheme.
   */
  @DataProvider(name = "testPasswords")
  public Object[][] getTestPasswords()
  {
    return new Object[][]
    {
      new Object[] { new ASN1OctetString() },
      new Object[] { new ASN1OctetString("") },
      new Object[] { new ASN1OctetString("\u0000") },
      new Object[] { new ASN1OctetString("\t") },
      new Object[] { new ASN1OctetString("\n") },
      new Object[] { new ASN1OctetString("\r\n") },
      new Object[] { new ASN1OctetString(" ") },
      new Object[] { new ASN1OctetString("Test1\tTest2\tTest3") },
      new Object[] { new ASN1OctetString("Test1\nTest2\nTest3") },
      new Object[] { new ASN1OctetString("Test1\r\nTest2\r\nTest3") },
      new Object[] { new ASN1OctetString("a") },
      new Object[] { new ASN1OctetString("ab") },
      new Object[] { new ASN1OctetString("abc") },
      new Object[] { new ASN1OctetString("abcd") },
      new Object[] { new ASN1OctetString("abcde") },
      new Object[] { new ASN1OctetString("abcdef") },
      new Object[] { new ASN1OctetString("abcdefg") },
      new Object[] { new ASN1OctetString("abcdefgh") },
      new Object[] { new ASN1OctetString("The Quick Brown Fox Jumps Over " +
                                         "The Lazy Dog") },
      new Object[] { new ASN1OctetString("\u00BFD\u00F3nde est\u00E1 el " +
                                         "ba\u00F1o?") }
    };
  }
  /**
   * Creates an instance of the password storage scheme, uses it to encode the
   * provided password, and ensures that the encoded value is correct.
   *
   * @param  plaintext  The plain-text version of the password to encode.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(dataProvider = "testPasswords")
  public void testStorageScheme(ByteString plaintext)
         throws Exception
  {
    PasswordStorageScheme scheme = getScheme();
    assertNotNull(scheme);
    assertNotNull(scheme.getStorageSchemeName());
    ByteString encodedPassword = scheme.encodePassword(plaintext);
    assertNotNull(encodedPassword);
    assertTrue(scheme.passwordMatches(plaintext, encodedPassword));
    ByteString schemeEncodedPassword =
         scheme.encodePasswordWithScheme(plaintext);
    String[] pwComponents = UserPasswordSyntax.decodeUserPassword(
                                 schemeEncodedPassword.stringValue());
    assertNotNull(pwComponents);
    if (scheme.supportsAuthPasswordSyntax())
    {
      assertNotNull(scheme.getAuthPasswordSchemeName());
      ByteString encodedAuthPassword = scheme.encodeAuthPassword(plaintext);
      StringBuilder[] authPWComponents =
           AuthPasswordSyntax.decodeAuthPassword(
                encodedAuthPassword.stringValue());
      assertTrue(scheme.authPasswordMatches(plaintext,
                                            authPWComponents[1].toString(),
                                            authPWComponents[2].toString()));
    }
    else
    {
      try
      {
        scheme.encodeAuthPassword(plaintext);
        throw new Exception("Expected encodedAuthPassword to fail for scheme " +
                            scheme.getStorageSchemeName() +
                            " because it doesn't support auth passwords.");
      }
      catch (DirectoryException de)
      {
        // This was expected.
      }
      assertFalse(scheme.authPasswordMatches(plaintext, "foo", "bar"));
    }
    if (scheme.isReversible())
    {
      assertEquals(plaintext, scheme.getPlaintextValue(encodedPassword));
    }
    else
    {
      try
      {
        scheme.getPlaintextValue(encodedPassword);
        throw new Exception("Expected getPlaintextValue to fail for scheme " +
                            scheme.getStorageSchemeName() +
                            " because it is not reversible.");
      }
      catch (DirectoryException de)
      {
        // This was expected.
      }
    }
    scheme.isStorageSchemeSecure();
  }
  /**
   * Retrieves an initialized instance of this password storage scheme.
   *
   * @param  configEntry  The configuration entry for the password storage
   *                      scheme, or <CODE>null</CODE> if none is available.
   *
   * @return  An initialized instance of this password storage scheme.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  public abstract PasswordStorageScheme getScheme()
         throws Exception;
}
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/RandomPasswordGeneratorTestCase.java
New file
@@ -0,0 +1,219 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.opends.server.TestCaseUtils;
import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.InitializationException;
import org.opends.server.types.DN;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.util.LDIFReader;
import static org.testng.Assert.*;
/**
 * A set of test cases for the random password generator.
 */
public class RandomPasswordGeneratorTestCase
       extends ExtensionsTestCase
{
  /**
   * Ensures that the Directory Server is running.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @BeforeClass()
  public void startServer()
         throws Exception
  {
    TestCaseUtils.startServer();
  }
  /**
   * Tests the password generator with the default configuration.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testDefaultConfiguration()
         throws Exception
  {
    DN dn = DN.decode("cn=Random Password Generator,cn=Password Generators," +
                      "cn=config");
    ConfigEntry configEntry = DirectoryServer.getConfigEntry(dn);
    assertNotNull(configEntry);
    RandomPasswordGenerator generator = new RandomPasswordGenerator();
    generator.initializePasswordGenerator(configEntry);
    assertNotNull(generator.generatePassword(null));
    generator.finalizePasswordGenerator();
  }
  /**
   * Retrieves a set of LDIF representations for invalid configuration entries.
   *
   * @return  A set of LDIF representations for invalid configuration entries.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @DataProvider(name = "invalidConfigEntries")
  public Object[][] getInvalidConfigEntries()
         throws Exception
  {
    String[] entryStrings =
    {
      "dn: cn=Random Password Generator,cn=Password Generators,cn=config\n" +
      "objectClass: top\n" +
      "objectClass: ds-cfg-password-generator\n" +
      "cn: Random Password Generator\n" +
      "ds-cfg-password-generator-class: " +
           "org.opends.server.extensions.RandomPasswordGenerator\n" +
      "ds-cfg-password-generator-enabled: true\n",
      "dn: cn=Random Password Generator,cn=Password Generators,cn=config\n" +
      "objectClass: top\n" +
      "objectClass: ds-cfg-password-generator\n" +
      "objectClass: ds-cfg-random-password-generator\n" +
      "cn: Random Password Generator\n" +
      "ds-cfg-password-generator-class: " +
           "org.opends.server.extensions.RandomPasswordGenerator\n" +
      "ds-cfg-password-generator-enabled: true\n" +
      "ds-cfg-password-character-set:\n",
      "dn: cn=Random Password Generator,cn=Password Generators,cn=config\n" +
      "objectClass: top\n" +
      "objectClass: ds-cfg-password-generator\n" +
      "objectClass: ds-cfg-random-password-generator\n" +
      "cn: Random Password Generator\n" +
      "ds-cfg-password-generator-class: " +
           "org.opends.server.extensions.RandomPasswordGenerator\n" +
      "ds-cfg-password-generator-enabled: true\n" +
      "ds-cfg-password-character-set: foo:\n" +
      "ds-cfg-password-format: foo:8\n",
      "dn: cn=Random Password Generator,cn=Password Generators,cn=config\n" +
      "objectClass: top\n" +
      "objectClass: ds-cfg-password-generator\n" +
      "objectClass: ds-cfg-random-password-generator\n" +
      "cn: Random Password Generator\n" +
      "ds-cfg-password-generator-class: " +
           "org.opends.server.extensions.RandomPasswordGenerator\n" +
      "ds-cfg-password-generator-enabled: true\n" +
      "ds-cfg-password-character-set: foo:abcd\n" +
      "ds-cfg-password-character-set: foo:efgh\n" +
      "ds-cfg-password-format: foo:8\n",
      "dn: cn=Random Password Generator,cn=Password Generators,cn=config\n" +
      "objectClass: top\n" +
      "objectClass: ds-cfg-password-generator\n" +
      "objectClass: ds-cfg-random-password-generator\n" +
      "cn: Random Password Generator\n" +
      "ds-cfg-password-generator-class: " +
           "org.opends.server.extensions.RandomPasswordGenerator\n" +
      "ds-cfg-password-generator-enabled: true\n" +
      "ds-cfg-password-character-set: foo:abcd\n",
      "dn: cn=Random Password Generator,cn=Password Generators,cn=config\n" +
      "objectClass: top\n" +
      "objectClass: ds-cfg-password-generator\n" +
      "objectClass: ds-cfg-random-password-generator\n" +
      "cn: Random Password Generator\n" +
      "ds-cfg-password-generator-class: " +
           "org.opends.server.extensions.RandomPasswordGenerator\n" +
      "ds-cfg-password-generator-enabled: true\n" +
      "ds-cfg-password-character-set: foo:abcd\n" +
      "ds-cfg-password-format: bar:8\n",
      "dn: cn=Random Password Generator,cn=Password Generators,cn=config\n" +
      "objectClass: top\n" +
      "objectClass: ds-cfg-password-generator\n" +
      "objectClass: ds-cfg-random-password-generator\n" +
      "cn: Random Password Generator\n" +
      "ds-cfg-password-generator-class: " +
           "org.opends.server.extensions.RandomPasswordGenerator\n" +
      "ds-cfg-password-generator-enabled: true\n" +
      "ds-cfg-password-character-set: foo:abcd\n" +
      "ds-cfg-password-format: foo:abcd\n",
    };
    Object[][] entryObjects = new Object[entryStrings.length][1];
    for (int i=0; i < entryStrings.length; i++)
    {
      entryObjects[i] = new Object[] { entryStrings[i] };
    }
    return entryObjects;
  }
  /**
   * Tests with an invalid configuration entry.
   *
   * @param  ldifString  The LDIF representation of the configuration entry.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(dataProvider = "invalidConfigEntries",
        expectedExceptions = { ConfigException.class,
                               InitializationException.class })
  public void testInvalidConfigurations(String ldifString)
         throws Exception
  {
    ByteArrayInputStream bais =
         new ByteArrayInputStream(ldifString.getBytes("UTF-8"));
    LDIFImportConfig importConfig = new LDIFImportConfig(bais);
    importConfig.setValidateSchema(false);
    LDIFReader reader = new LDIFReader(new LDIFImportConfig(bais));
    String parentDNStr = "cn=Password Generators,cn=config";
    ConfigEntry parentEntry =
         DirectoryServer.getConfigEntry(DN.decode(parentDNStr));
    ConfigEntry configEntry = new ConfigEntry(reader.readEntry(), parentEntry);
    RandomPasswordGenerator generator = new RandomPasswordGenerator();
    generator.initializePasswordGenerator(configEntry);
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SHA1PasswordStorageSchemeTestCase.java
New file
@@ -0,0 +1,69 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import org.opends.server.api.PasswordStorageScheme;
/**
 * A set of test cases for the SHA-1 password storage scheme.
 */
public class SHA1PasswordStorageSchemeTestCase
       extends PasswordStorageSchemeTestCase
{
  /**
   * Creates a new instance of this storage scheme test case.
   */
  public SHA1PasswordStorageSchemeTestCase()
  {
    super("cn=SHA-1,cn=Password Storage Schemes,cn=config");
  }
  /**
   * Retrieves an initialized instance of this password storage scheme.
   *
   * @param  configEntry  The configuration entry for the password storage
   *                      scheme, or <CODE>null</CODE> if none is available.
   *
   * @return  An initialized instance of this password storage scheme.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  public PasswordStorageScheme getScheme()
         throws Exception
  {
    SHA1PasswordStorageScheme scheme = new SHA1PasswordStorageScheme();
    scheme.initializePasswordStorageScheme(configEntry);
    return scheme;
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SaltedMD5PasswordStorageSchemeTestCase.java
New file
@@ -0,0 +1,70 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import org.opends.server.api.PasswordStorageScheme;
/**
 * A set of test cases for the salted MD5 password storage scheme.
 */
public class SaltedMD5PasswordStorageSchemeTestCase
       extends PasswordStorageSchemeTestCase
{
  /**
   * Creates a new instance of this storage scheme test case.
   */
  public SaltedMD5PasswordStorageSchemeTestCase()
  {
    super("cn=Salted MD5,cn=Password Storage Schemes,cn=config");
  }
  /**
   * Retrieves an initialized instance of this password storage scheme.
   *
   * @param  configEntry  The configuration entry for the password storage
   *                      scheme, or <CODE>null</CODE> if none is available.
   *
   * @return  An initialized instance of this password storage scheme.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  public PasswordStorageScheme getScheme()
         throws Exception
  {
    SaltedMD5PasswordStorageScheme scheme =
         new SaltedMD5PasswordStorageScheme();
    scheme.initializePasswordStorageScheme(configEntry);
    return scheme;
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SaltedSHA1PasswordStorageSchemeTestCase.java
New file
@@ -0,0 +1,101 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import org.testng.annotations.Test;
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.schema.UserPasswordSyntax;
import org.opends.server.types.ByteString;
import static org.testng.Assert.*;
/**
 * A set of test cases for the salted SHA-1 password storage scheme.
 */
public class SaltedSHA1PasswordStorageSchemeTestCase
       extends PasswordStorageSchemeTestCase
{
  /**
   * Creates a new instance of this storage scheme test case.
   */
  public SaltedSHA1PasswordStorageSchemeTestCase()
  {
    super("cn=Salted SHA-1,cn=Password Storage Schemes,cn=config");
  }
  /**
   * Retrieves an initialized instance of this password storage scheme.
   *
   * @param  configEntry  The configuration entry for the password storage
   *                      scheme, or <CODE>null</CODE> if none is available.
   *
   * @return  An initialized instance of this password storage scheme.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  public PasswordStorageScheme getScheme()
         throws Exception
  {
    SaltedSHA1PasswordStorageScheme scheme =
         new SaltedSHA1PasswordStorageScheme();
    scheme.initializePasswordStorageScheme(configEntry);
    return scheme;
  }
  /**
   * Tests the <CODE>encodeOffline</CODE> method.
   *
   * @param  plaintext  The plaintext password to use for the test.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(dataProvider = "testPasswords")
  public void testEncodeOffline(ByteString plaintext)
         throws Exception
  {
    SaltedSHA1PasswordStorageScheme scheme =
         new SaltedSHA1PasswordStorageScheme();
    scheme.initializePasswordStorageScheme(configEntry);
    String passwordString = scheme.encodeOffline(plaintext.value());
    String[] pwComps = UserPasswordSyntax.decodeUserPassword(passwordString);
    ASN1OctetString encodedPassword = new ASN1OctetString(pwComps[1]);
    assertTrue(scheme.passwordMatches(plaintext, encodedPassword));
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SaltedSHA256PasswordStorageSchemeTestCase.java
New file
@@ -0,0 +1,70 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import org.opends.server.api.PasswordStorageScheme;
/**
 * A set of test cases for the salted SHA-256 password storage scheme.
 */
public class SaltedSHA256PasswordStorageSchemeTestCase
       extends PasswordStorageSchemeTestCase
{
  /**
   * Creates a new instance of this storage scheme test case.
   */
  public SaltedSHA256PasswordStorageSchemeTestCase()
  {
    super("cn=Salted SHA-256,cn=Password Storage Schemes,cn=config");
  }
  /**
   * Retrieves an initialized instance of this password storage scheme.
   *
   * @param  configEntry  The configuration entry for the password storage
   *                      scheme, or <CODE>null</CODE> if none is available.
   *
   * @return  An initialized instance of this password storage scheme.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  public PasswordStorageScheme getScheme()
         throws Exception
  {
    SaltedSHA256PasswordStorageScheme scheme =
         new SaltedSHA256PasswordStorageScheme();
    scheme.initializePasswordStorageScheme(configEntry);
    return scheme;
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SaltedSHA384PasswordStorageSchemeTestCase.java
New file
@@ -0,0 +1,70 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import org.opends.server.api.PasswordStorageScheme;
/**
 * A set of test cases for the salted SHA-384 password storage scheme.
 */
public class SaltedSHA384PasswordStorageSchemeTestCase
       extends PasswordStorageSchemeTestCase
{
  /**
   * Creates a new instance of this storage scheme test case.
   */
  public SaltedSHA384PasswordStorageSchemeTestCase()
  {
    super("cn=Salted SHA-384,cn=Password Storage Schemes,cn=config");
  }
  /**
   * Retrieves an initialized instance of this password storage scheme.
   *
   * @param  configEntry  The configuration entry for the password storage
   *                      scheme, or <CODE>null</CODE> if none is available.
   *
   * @return  An initialized instance of this password storage scheme.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  public PasswordStorageScheme getScheme()
         throws Exception
  {
    SaltedSHA384PasswordStorageScheme scheme =
         new SaltedSHA384PasswordStorageScheme();
    scheme.initializePasswordStorageScheme(configEntry);
    return scheme;
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SaltedSHA512PasswordStorageSchemeTestCase.java
New file
@@ -0,0 +1,70 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
import org.opends.server.api.PasswordStorageScheme;
/**
 * A set of test cases for the salted SHA-512 password storage scheme.
 */
public class SaltedSHA512PasswordStorageSchemeTestCase
       extends PasswordStorageSchemeTestCase
{
  /**
   * Creates a new instance of this storage scheme test case.
   */
  public SaltedSHA512PasswordStorageSchemeTestCase()
  {
    super("cn=Salted SHA-512,cn=Password Storage Schemes,cn=config");
  }
  /**
   * Retrieves an initialized instance of this password storage scheme.
   *
   * @param  configEntry  The configuration entry for the password storage
   *                      scheme, or <CODE>null</CODE> if none is available.
   *
   * @return  An initialized instance of this password storage scheme.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  public PasswordStorageScheme getScheme()
         throws Exception
  {
    SaltedSHA512PasswordStorageScheme scheme =
         new SaltedSHA512PasswordStorageScheme();
    scheme.initializePasswordStorageScheme(configEntry);
    return scheme;
  }
}