SK.gnome.dwarf.auth.login
Class MD5PasswordEncoder

java.lang.Object
  extended bySK.gnome.dwarf.auth.login.MD5PasswordEncoder
All Implemented Interfaces:
PasswordEncoder

public final class MD5PasswordEncoder
extends java.lang.Object
implements PasswordEncoder

Password encoder based on the MD5 digest.

This class encodes the user password by creating a MD5 digest of it. The digest is then returned as a BASE64-encoded string.

This class may be used to encrypt ASCII passwords only.


Constructor Summary
MD5PasswordEncoder()
           
 
Method Summary
 boolean compare(java.lang.String encoded, char[] plain)
          Compares two passwords.
 java.lang.String encode(char[] password)
          Encodes a single password.
static java.lang.String encodePassword(char[] password)
          Encodes a single password.
static void main(java.lang.String[] args)
          Encodes an array of passwords.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MD5PasswordEncoder

public MD5PasswordEncoder()
Method Detail

encodePassword

public static java.lang.String encodePassword(char[] password)
Encodes a single password.

Parameters:
password - the password
Returns:
BASE64-encoded MD5 digest of the password

main

public static void main(java.lang.String[] args)
Encodes an array of passwords.

The original/encoded pairs are printed to System.out on a separate lines.

Parameters:
args - the passwords to encode

encode

public java.lang.String encode(char[] password)
Description copied from interface: PasswordEncoder
Encodes a single password.

Note that two subsequent calls to this method with the same argument may result in two different strings returned. Use the compare method therefore for comparing the encoded password with its plain format.

Specified by:
encode in interface PasswordEncoder
Parameters:
password - the password
Returns:
the encoded password

compare

public boolean compare(java.lang.String encoded,
                       char[] plain)
Description copied from interface: PasswordEncoder
Compares two passwords.

Specified by:
compare in interface PasswordEncoder
Parameters:
encoded - the encoded password
plain - the plain (non-encoded) password
Returns:
true if the passwords are equal


Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.