SK.gnome.dwarf.auth.login
Class CryptPasswordEncoder

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

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

Password encoder based on the Unix crypt command.

This class encodes the user password with algorithm compatible with the standard Unix crypt hashing function.

This class may be used to encrypt the ASCII passwords only.


Constructor Summary
CryptPasswordEncoder()
           
 
Method Summary
 boolean compare(java.lang.String encoded, char[] plain)
          Compares two passwords.
static java.lang.String crypt(java.lang.String salt, char[] password)
          Encrypts a single password.
 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

CryptPasswordEncoder

public CryptPasswordEncoder()
Method Detail

encodePassword

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

Encodes a single password by calling the crypt(String, char[]) method with the salt argument generated from the current system time.

Parameters:
password - the password
Returns:
the encrypted password

main

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

The original/encoded pairs are printed to the System.out on 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

crypt

public static java.lang.String crypt(java.lang.String salt,
                                     char[] password)
Encrypts a single password.

Parameters:
salt - the salt
password - the password
Returns:
the encrypted password


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