From 22094368c2865dcfb6daf8366425212b721a4657 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Thu, 05 Feb 2009 17:42:14 +0000
Subject: [PATCH] Merge ASN1 branch to trunk
---
opends/src/server/org/opends/server/extensions/RC4PasswordStorageScheme.java | 39 +++++++++++++++++++++------------------
1 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/opends/src/server/org/opends/server/extensions/RC4PasswordStorageScheme.java b/opends/src/server/org/opends/server/extensions/RC4PasswordStorageScheme.java
index f60450b..06f963c 100644
--- a/opends/src/server/org/opends/server/extensions/RC4PasswordStorageScheme.java
+++ b/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.
--
Gitblit v1.10.0