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

boli
01.27.2007 455897cc245b67d929f409a93cfa7106e835cc1f
opends/src/server/org/opends/server/extensions/SaltedSHA512PasswordStorageScheme.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 */
package org.opends.server.extensions;
@@ -47,8 +47,10 @@
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.*;
@@ -70,7 +72,7 @@
       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";
@@ -106,7 +108,6 @@
  {
    super();
    assert debugConstructor(CLASS_NAME);
  }
@@ -118,8 +119,6 @@
  public void initializePasswordStorageScheme(ConfigEntry configEntry)
         throws ConfigException, InitializationException
  {
    assert debugEnter(CLASS_NAME, "initializePasswordStorageScheme",
                      String.valueOf(configEntry));
    try
    {
@@ -128,7 +127,10 @@
    }
    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,
@@ -148,7 +150,6 @@
  @Override()
  public String getStorageSchemeName()
  {
    assert debugEnter(CLASS_NAME, "getStorageSchemeName");
    return STORAGE_SCHEME_NAME_SALTED_SHA_512;
  }
@@ -162,7 +163,6 @@
  public ByteString encodePassword(ByteString plaintext)
         throws DirectoryException
  {
    assert debugEnter(CLASS_NAME, "encodePassword", "ByteString");
    byte[] plainBytes    = plaintext.value();
    byte[] saltBytes     = new byte[NUM_SALT_BYTES];
@@ -186,7 +186,10 @@
    }
    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,
@@ -219,8 +222,6 @@
  public ByteString encodePasswordWithScheme(ByteString plaintext)
         throws DirectoryException
  {
    assert debugEnter(CLASS_NAME, "encodePasswordWithScheme",
                      "ByteString");
    StringBuilder buffer = new StringBuilder();
    buffer.append('{');
@@ -249,7 +250,10 @@
    }
    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,
@@ -283,9 +287,6 @@
  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.
@@ -303,7 +304,10 @@
    }
    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(),
@@ -331,7 +335,10 @@
    }
    catch (Exception e)
    {
      assert debugException(CLASS_NAME, "passwordMatches", e);
      if (debugEnabled())
      {
        debugCought(DebugLogLevel.ERROR, e);
      }
      return false;
    }
@@ -351,7 +358,6 @@
  @Override()
  public boolean supportsAuthPasswordSyntax()
  {
    assert debugEnter(CLASS_NAME, "supportsAuthPasswordSyntax");
    // This storage scheme does support the authentication password syntax.
    return true;
@@ -365,7 +371,6 @@
  @Override()
  public String getAuthPasswordSchemeName()
  {
    assert debugEnter(CLASS_NAME, "getAuthPasswordSchemeName");
    return AUTH_PASSWORD_SCHEME_NAME_SALTED_SHA_512;
  }
@@ -379,8 +384,6 @@
  public ByteString encodeAuthPassword(ByteString plaintext)
         throws DirectoryException
  {
    assert debugEnter(CLASS_NAME, "encodeAuthPassword",
                      String.valueOf(plaintext));
    byte[] plainBytes    = plaintext.value();
@@ -405,7 +408,10 @@
    }
    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,
@@ -440,9 +446,6 @@
  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;
@@ -454,7 +457,10 @@
    }
    catch (Exception e)
    {
      assert debugException(CLASS_NAME, "authPasswordMatches", e);
      if (debugEnabled())
      {
        debugCought(DebugLogLevel.ERROR, e);
      }
      return false;
    }
@@ -487,7 +493,6 @@
  @Override()
  public boolean isReversible()
  {
    assert debugEnter(CLASS_NAME, "isReversible");
    return false;
  }
@@ -501,8 +506,6 @@
  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);
@@ -520,8 +523,6 @@
                                                  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,
@@ -538,7 +539,6 @@
  @Override()
  public boolean isStorageSchemeSecure()
  {
    assert debugEnter(CLASS_NAME, "isStorageSchemeSecure");
    // SHA-2 should be considered secure.
    return true;