| | |
| | | * 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 static org.opends.server.loggers.Error.*; |
| | | 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.*; |
| | |
| | | extends PasswordStorageScheme |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | * The fully-qualified name of this class. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.extensions.SaltedSHA512PasswordStorageScheme"; |
| | |
| | | { |
| | | super(); |
| | | |
| | | assert debugConstructor(CLASS_NAME); |
| | | } |
| | | |
| | | |
| | |
| | | public void initializePasswordStorageScheme(ConfigEntry configEntry) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "initializePasswordStorageScheme", |
| | | String.valueOf(configEntry)); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "initializePasswordStorageScheme", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_PWSCHEME_CANNOT_INITIALIZE_MESSAGE_DIGEST; |
| | | String message = getMessage(msgID, MESSAGE_DIGEST_ALGORITHM_SHA_512, |
| | |
| | | @Override() |
| | | public String getStorageSchemeName() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getStorageSchemeName"); |
| | | |
| | | return STORAGE_SCHEME_NAME_SALTED_SHA_512; |
| | | } |
| | |
| | | public ByteString encodePassword(ByteString plaintext) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "encodePassword", "ByteString"); |
| | | |
| | | byte[] plainBytes = plaintext.value(); |
| | | byte[] saltBytes = new byte[NUM_SALT_BYTES]; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "encodePassword", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_PWSCHEME_CANNOT_ENCODE_PASSWORD; |
| | | String message = getMessage(msgID, CLASS_NAME, |
| | |
| | | public ByteString encodePasswordWithScheme(ByteString plaintext) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "encodePasswordWithScheme", |
| | | "ByteString"); |
| | | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | buffer.append('{'); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "encodePassword", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_PWSCHEME_CANNOT_ENCODE_PASSWORD; |
| | | String message = getMessage(msgID, CLASS_NAME, |
| | |
| | | public boolean passwordMatches(ByteString plaintextPassword, |
| | | ByteString storedPassword) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "passwordMatches", |
| | | String.valueOf(plaintextPassword), |
| | | String.valueOf(storedPassword)); |
| | | |
| | | |
| | | // Base64-decode the stored value and take the last 8 bytes as the salt. |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "passwordMatches", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_PWSCHEME_CANNOT_BASE64_DECODE_STORED_PASSWORD; |
| | | String message = getMessage(msgID, storedPassword.stringValue(), |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "passwordMatches", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | |
| | | @Override() |
| | | public boolean supportsAuthPasswordSyntax() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "supportsAuthPasswordSyntax"); |
| | | |
| | | // This storage scheme does support the authentication password syntax. |
| | | return true; |
| | |
| | | @Override() |
| | | public String getAuthPasswordSchemeName() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getAuthPasswordSchemeName"); |
| | | |
| | | return AUTH_PASSWORD_SCHEME_NAME_SALTED_SHA_512; |
| | | } |
| | |
| | | public ByteString encodeAuthPassword(ByteString plaintext) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "encodeAuthPassword", |
| | | String.valueOf(plaintext)); |
| | | |
| | | |
| | | byte[] plainBytes = plaintext.value(); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "encodePassword", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_PWSCHEME_CANNOT_ENCODE_PASSWORD; |
| | | String message = getMessage(msgID, CLASS_NAME, |
| | |
| | | public boolean authPasswordMatches(ByteString plaintextPassword, |
| | | String authInfo, String authValue) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "authPasswordMatches", |
| | | String.valueOf(plaintextPassword), |
| | | String.valueOf(authInfo), String.valueOf(authValue)); |
| | | |
| | | |
| | | byte[] saltBytes; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "authPasswordMatches", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | |
| | | @Override() |
| | | public boolean isReversible() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "isReversible"); |
| | | |
| | | return false; |
| | | } |
| | |
| | | public ByteString getPlaintextValue(ByteString storedPassword) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getPlaintextValue", |
| | | String.valueOf(storedPassword)); |
| | | |
| | | int msgID = MSGID_PWSCHEME_NOT_REVERSIBLE; |
| | | String message = getMessage(msgID, STORAGE_SCHEME_NAME_SALTED_SHA_512); |
| | |
| | | String authValue) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getAuthPasswordPlaintextValue", |
| | | String.valueOf(authInfo), String.valueOf(authValue)); |
| | | |
| | | int msgID = MSGID_PWSCHEME_NOT_REVERSIBLE; |
| | | String message = getMessage(msgID, |
| | |
| | | @Override() |
| | | public boolean isStorageSchemeSecure() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "isStorageSchemeSecure"); |
| | | |
| | | // SHA-2 should be considered secure. |
| | | return true; |