    All Examples  Security Examples  This Package

## Class examples.security.rdbmsrealm.RDBMSUser

    java.lang.Object
        |
        +----java.security.Identity
                |
                +----weblogic.security.acl.User
                        |
                        +----examples.security.rdbmsrealm.RDBMSUser

class RDBMSUser
extends weblogic.security.acl.User

This is the in-memory representation of a user from the database. The user has a name and password. The password may be one-way hashed; hashed passwords are stored in the database in the form `{HASH}gobbledygook`, where `HASH` is the name of the hashing algorithm, and `gobbledygook` is the hashed password.

You can store passwords either in hashed or plaintext form, and if you wish, you cvan vary this on a per-user basis (for example, use MD5 for one user, SHA for another, and a plaintext password for another user). However, for security and manageability reasons, we recommend using a single hashing algorithm for all passwords, and not storing any plaintext passwords in the database.

This class has a `main` method, which you can use to generate hashed passwords from plaintext passwords. The hashed passwords can then be stored in your database.

Author:
  Copyright (c) 1998-2000 by BEA Systems, Inc. All Rights Reserved.

##

ALGORITHM
  The default password-generation algorithm.
md
  The digest algorithm used to one-way hash this user's password.
passwd
  This user's password.
realm
  The realm that created this user object.

##

RDBMSUser(String, String, RDBMSRealm)
  Create a user with the given name and (maybe hashed) password, from the given realm.

##

authenticate(String)
  Check a plaintext password against this user's password.
getRealm()
  Return the realm that created this object.
hash(MessageDigest, String)
  Hash the given plaintext with the given digest algorithm, and base64-encode the result.
main(String[])
  Hash passwords according to the given algorithm.

##

ALGORITHM

    protected static final java.lang.String ALGORITHM

The default password-generation algorithm.

realm

    private transient RDBMSRealm realm

The realm that created this user object.

passwd

    private transient java.lang.String passwd

This user's password. If this is hashed, the md field will contain an instance of an object that performs the hashing algorithm.

md

    private transient java.security.MessageDigest md

The digest algorithm used to one-way hash this user's password. If the password is not hashed with a known algorithm, or is in plain form, this will be null.

##

RDBMSUser

    RDBMSUser(java.lang.String name,
              java.lang.String passwd,
              RDBMSRealm realm)

Create a user with the given name and (maybe hashed) password, from the given realm.

##

getRealm

    public weblogic.security.acl.BasicRealm getRealm()

Return the realm that created this object.
  Overrides:
    getRealm in class weblogic.security.acl.User

hash

    protected static java.lang.String hash(java.security.MessageDigest md,
                                 java.lang.String plaintext)

Hash the given plaintext with the given digest algorithm, and base64-encode the result.
  Parameters:
    `md` - message digest algorithm to hash with
    `plaintext` - text to hash
  Returns:
    base64-encoded hashed text

authenticate

    boolean authenticate(java.lang.String plaintext)

Check a plaintext password against this user's password. If the object containing the password is not known, authentication will fail.
  Parameters:
    `plaintext` - the plaintext password to check
  Returns:
    true if matched, false otherwise

main

    public static void main(java.lang.String args[]) throws java.io.IOException

Hash passwords according to the given algorithm. Plaintext passwords are read from stdin, and the encrypted passwords are printed to stdout. If no algorithm is specified on the command line, the one specified in ALGORITHM is used.
  See Also:
    ALGORITHM

    All Examples  Security Examples  This Package