コード例 #1
0
  /**
   * Tests the process of initializing the handler with invalid configurations.
   *
   * @param entry The configuration entry to use for the initialization.
   * @throws Exception If an unexpected problem occurs.
   */
  @Test(
      dataProvider = "invalidConfigs",
      expectedExceptions = {ConfigException.class, InitializationException.class})
  public void testInitializeWithInvalidConfigs(Entry e) throws Exception {
    CramMD5SASLMechanismHandlerCfg configuration =
        AdminTestCaseUtils.getConfiguration(CramMD5SASLMechanismHandlerCfgDefn.getInstance(), e);

    CRAMMD5SASLMechanismHandler handler = new CRAMMD5SASLMechanismHandler();
    handler.initializeSASLMechanismHandler(configuration);
  }
  private Object[] generateValues(String password) throws Exception {
    ByteString bytePassword = ByteString.valueOf(password);
    SaltedMD5PasswordStorageScheme scheme = new SaltedMD5PasswordStorageScheme();

    ConfigEntry configEntry =
        DirectoryServer.getConfigEntry(
            DN.decode("cn=Salted MD5,cn=Password Storage Schemes,cn=config"));

    SaltedMD5PasswordStorageSchemeCfg configuration =
        AdminTestCaseUtils.getConfiguration(
            SaltedMD5PasswordStorageSchemeCfgDefn.getInstance(), configEntry.getEntry());

    scheme.initializePasswordStorageScheme(configuration);

    ByteString encodedAuthPassword = scheme.encodePasswordWithScheme(bytePassword);

    return new Object[] {encodedAuthPassword.toString(), password, true};
  }