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

Chris Ridd
16.12.2013 7fc458b7be71111b4c4a6e91f7b3ed6642b104a1
opends/src/server/org/opends/server/extensions/RC4PasswordStorageScheme.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -37,6 +38,8 @@
import org.opends.server.types.*;
import org.opends.server.util.Base64;
import java.util.Arrays;
import static org.opends.messages.ExtensionMessages.*;
import static org.opends.server.extensions.ExtensionsConstants.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
@@ -108,10 +111,11 @@
  public ByteString encodePassword(ByteSequence plaintext)
         throws DirectoryException
  {
    byte[] plaintextBytes = null;
    try
    {
      // TODO: Can we avoid this copy?
      byte[] plaintextBytes = plaintext.toByteArray();
      plaintextBytes = plaintext.toByteArray();
      byte[] encodedBytes = cryptoManager.encrypt(CIPHER_TRANSFORMATION_RC4,
                                                  KEY_SIZE_RC4,
                                                  plaintextBytes);
@@ -129,6 +133,11 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   m, e);
    }
    finally
    {
      if (plaintextBytes != null)
        Arrays.fill(plaintextBytes, (byte) 0);
    }
  }
@@ -144,11 +153,12 @@
    buffer.append('{');
    buffer.append(STORAGE_SCHEME_NAME_RC4);
    buffer.append('}');
    byte[] plaintextBytes = null;
    try
    {
      // TODO: Can we avoid this copy?
      byte[] plaintextBytes = plaintext.toByteArray();
      plaintextBytes = plaintext.toByteArray();
      byte[] encodedBytes = cryptoManager.encrypt(CIPHER_TRANSFORMATION_RC4,
                                                  KEY_SIZE_RC4,
                                                  plaintextBytes);
@@ -166,6 +176,11 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   m, e);
    }
    finally
    {
      if (plaintextBytes != null)
        Arrays.fill(plaintextBytes, (byte) 0);
    }
    return ByteString.valueOf(buffer.toString());
  }