org.apache.catalina.realm

Class UserDatabaseRealm

public class UserDatabaseRealm extends RealmBase

Implementation of Realm that is based on an implementation of UserDatabase made available through the global JNDI resources configured for this instance of Catalina. Set the resourceName parameter to the global JNDI resources name for the configured instance of UserDatabase that we should consult.

Since: 4.1

Version: $Revision: 543691 $ $Date: 2007-06-02 03:37:08 +0200 (Sat, 02 Jun 2007) $

Author: Craig R. McClanahan

Field Summary
protected UserDatabasedatabase
The UserDatabase we will use to authenticate users and identify associated roles.
protected Stringinfo
Descriptive information about this Realm implementation.
protected static Stringname
Descriptive information about this Realm implementation.
protected StringresourceName
The global JNDI name of the UserDatabase resource we will be utilizing.
Method Summary
StringgetInfo()
Return descriptive information about this Realm implementation and the corresponding version number, in the format <description>/<version>.
protected StringgetName()
Return a short name for this Realm implementation.
protected StringgetPassword(String username)
Return the password associated with the given principal's user name.
protected PrincipalgetPrincipal(String username)
Return the Principal associated with the given user name.
StringgetResourceName()
Return the global JNDI name of the UserDatabase resource we will be using.
booleanhasRole(Principal principal, String role)
Return true if the specified Principal has the specified security role, within the context of this Realm; otherwise return false.
voidsetResourceName(String resourceName)
Set the global JNDI name of the UserDatabase resource we will be using.
voidstart()
Prepare for active use of the public methods of this Component.
voidstop()
Gracefully shut down active use of the public methods of this Component.

Field Detail

database

protected UserDatabase database
The UserDatabase we will use to authenticate users and identify associated roles.

info

protected final String info
Descriptive information about this Realm implementation.

name

protected static final String name
Descriptive information about this Realm implementation.

resourceName

protected String resourceName
The global JNDI name of the UserDatabase resource we will be utilizing.

Method Detail

getInfo

public String getInfo()
Return descriptive information about this Realm implementation and the corresponding version number, in the format <description>/<version>.

getName

protected String getName()
Return a short name for this Realm implementation.

getPassword

protected String getPassword(String username)
Return the password associated with the given principal's user name.

getPrincipal

protected Principal getPrincipal(String username)
Return the Principal associated with the given user name.

getResourceName

public String getResourceName()
Return the global JNDI name of the UserDatabase resource we will be using.

hasRole

public boolean hasRole(Principal principal, String role)
Return true if the specified Principal has the specified security role, within the context of this Realm; otherwise return false. This implementation returns true if the User has the role, or if any Group that the User is a member of has the role.

Parameters: principal Principal for whom the role is to be checked role Security role to be checked

setResourceName

public void setResourceName(String resourceName)
Set the global JNDI name of the UserDatabase resource we will be using.

Parameters: resourceName The new global JNDI name

start

public void start()
Prepare for active use of the public methods of this Component.

Throws: LifecycleException if this component detects a fatal error that prevents it from being started

stop

public void stop()
Gracefully shut down active use of the public methods of this Component.

Throws: LifecycleException if this component detects a fatal error that needs to be reported

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.