| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006 Sun Microsystems, Inc. |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | | import static org.opends.server.loggers.Debug.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCought; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.messages.ExtensionsMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | public class Base64PasswordStorageScheme |
| | | extends PasswordStorageScheme |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.extensions.Base64PasswordStorageScheme"; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | super(); |
| | | |
| | | assert debugConstructor(CLASS_NAME); |
| | | } |
| | | |
| | | |
| | |
| | | public void initializePasswordStorageScheme(ConfigEntry configEntry) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "initializePasswordStorageScheme", |
| | | String.valueOf(configEntry)); |
| | | |
| | | // No initialization is required. |
| | | } |
| | |
| | | @Override() |
| | | public String getStorageSchemeName() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getStorageSchemeName"); |
| | | |
| | | return STORAGE_SCHEME_NAME_BASE64; |
| | | } |
| | |
| | | public ByteString encodePassword(ByteString plaintext) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "encodePassword", "ByteString"); |
| | | |
| | | return ByteStringFactory.create(Base64.encode(plaintext.value())); |
| | | } |
| | |
| | | public ByteString encodePasswordWithScheme(ByteString plaintext) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "encodePasswordWithScheme", |
| | | "ByteString"); |
| | | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | buffer.append('{'); |
| | |
| | | public boolean passwordMatches(ByteString plaintextPassword, |
| | | ByteString storedPassword) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "passwordMatches", |
| | | String.valueOf(plaintextPassword), |
| | | String.valueOf(storedPassword)); |
| | | |
| | | |
| | | String userString = Base64.encode(plaintextPassword.value()); |
| | |
| | | @Override() |
| | | public boolean isReversible() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "isReversible"); |
| | | |
| | | return true; |
| | | } |
| | |
| | | public ByteString getPlaintextValue(ByteString storedPassword) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getPlaintextValue", |
| | | String.valueOf(storedPassword)); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "getPlaintextValue", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_PWSCHEME_CANNOT_BASE64_DECODE_STORED_PASSWORD; |
| | | String message = getMessage(msgID, storedPassword.stringValue(), |
| | |
| | | @Override() |
| | | public boolean supportsAuthPasswordSyntax() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "supportsAuthPasswordSyntax"); |
| | | |
| | | // This storage scheme does not support the authentication password syntax. |
| | | return false; |
| | |
| | | public ByteString encodeAuthPassword(ByteString plaintext) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "encodeAuthPassword", |
| | | String.valueOf(plaintext)); |
| | | |
| | | |
| | | int msgID = MSGID_PWSCHEME_DOES_NOT_SUPPORT_AUTH_PASSWORD; |
| | |
| | | public boolean authPasswordMatches(ByteString plaintextPassword, |
| | | String authInfo, String authValue) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "authPasswordMatches", |
| | | String.valueOf(plaintextPassword), |
| | | String.valueOf(authInfo), String.valueOf(authValue)); |
| | | |
| | | |
| | | // This storage scheme does not support the authentication password syntax. |
| | |
| | | String authValue) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getAuthPasswordPlaintextValue", |
| | | String.valueOf(authInfo), String.valueOf(authValue)); |
| | | |
| | | int msgID = MSGID_PWSCHEME_DOES_NOT_SUPPORT_AUTH_PASSWORD; |
| | | String message = getMessage(msgID, getStorageSchemeName()); |
| | |
| | | @Override() |
| | | public boolean isStorageSchemeSecure() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "isStorageSchemeSecure"); |
| | | |
| | | // Base64-encoded values may be easily decoded with no key or special |
| | | // knowledge. |