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

matthew_swift
05.42.2009 22094368c2865dcfb6daf8366425212b721a4657
opends/src/server/org/opends/server/extensions/RC4PasswordStorageScheme.java
@@ -28,8 +28,6 @@
import java.util.Arrays;
import org.opends.messages.Message;
import org.opends.server.admin.std.server.RC4PasswordStorageSchemeCfg;
import org.opends.server.api.PasswordStorageScheme;
@@ -107,15 +105,17 @@
   * {@inheritDoc}
   */
  @Override()
  public ByteString encodePassword(ByteString plaintext)
  public ByteString encodePassword(ByteSequence plaintext)
         throws DirectoryException
  {
    try
    {
      // TODO: Can we avoid this copy?
      byte[] plaintextBytes = plaintext.toByteArray();
      byte[] encodedBytes = cryptoManager.encrypt(CIPHER_TRANSFORMATION_RC4,
                                                  KEY_SIZE_RC4,
                                                  plaintext.value());
      return ByteStringFactory.create(Base64.encode(encodedBytes));
                                                  plaintextBytes);
      return ByteString.valueOf(Base64.encode(encodedBytes));
    }
    catch (Exception e)
    {
@@ -137,7 +137,7 @@
   * {@inheritDoc}
   */
  @Override()
  public ByteString encodePasswordWithScheme(ByteString plaintext)
  public ByteString encodePasswordWithScheme(ByteSequence plaintext)
         throws DirectoryException
  {
    StringBuilder buffer = new StringBuilder();
@@ -147,9 +147,11 @@
    try
    {
      // TODO: Can we avoid this copy?
      byte[] plaintextBytes = plaintext.toByteArray();
      byte[] encodedBytes = cryptoManager.encrypt(CIPHER_TRANSFORMATION_RC4,
                                                  KEY_SIZE_RC4,
                                                  plaintext.value());
                                                  plaintextBytes);
      buffer.append(Base64.encode(encodedBytes));
    }
    catch (Exception e)
@@ -165,7 +167,7 @@
                                   m, e);
    }
    return ByteStringFactory.create(buffer.toString());
    return ByteString.valueOf(buffer.toString());
  }
@@ -174,14 +176,15 @@
   * {@inheritDoc}
   */
  @Override()
  public boolean passwordMatches(ByteString plaintextPassword,
                                 ByteString storedPassword)
  public boolean passwordMatches(ByteSequence plaintextPassword,
                                 ByteSequence storedPassword)
  {
    try
    {
      byte[] decryptedPassword =
           cryptoManager.decrypt(Base64.decode(storedPassword.stringValue()));
      return Arrays.equals(plaintextPassword.value(), decryptedPassword);
      ByteString decryptedPassword =
          ByteString.wrap(cryptoManager.decrypt(
               Base64.decode(storedPassword.toString())));
      return plaintextPassword.equals(decryptedPassword);
    }
    catch (Exception e)
    {
@@ -211,14 +214,14 @@
   * {@inheritDoc}
   */
  @Override()
  public ByteString getPlaintextValue(ByteString storedPassword)
  public ByteString getPlaintextValue(ByteSequence storedPassword)
         throws DirectoryException
  {
    try
    {
      byte[] decryptedPassword =
           cryptoManager.decrypt(Base64.decode(storedPassword.stringValue()));
      return ByteStringFactory.create(decryptedPassword);
           cryptoManager.decrypt(Base64.decode(storedPassword.toString()));
      return ByteString.wrap(decryptedPassword);
    }
    catch (Exception e)
    {
@@ -252,7 +255,7 @@
   * {@inheritDoc}
   */
  @Override()
  public ByteString encodeAuthPassword(ByteString plaintext)
  public ByteString encodeAuthPassword(ByteSequence plaintext)
         throws DirectoryException
  {
    Message message =
@@ -266,7 +269,7 @@
   * {@inheritDoc}
   */
  @Override()
  public boolean authPasswordMatches(ByteString plaintextPassword,
  public boolean authPasswordMatches(ByteSequence plaintextPassword,
                                     String authInfo, String authValue)
  {
    // This storage scheme does not support the authentication password syntax.