| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | 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.*; |
| | |
| | | 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); |
| | |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | m, e); |
| | | } |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | 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); |
| | |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | m, e); |
| | | } |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | |
| | | return ByteString.valueOf(buffer.toString()); |
| | | } |