org.apache.catalina.realm

Class MemoryRealm

public class MemoryRealm extends RealmBase

Simple implementation of Realm that reads an XML file to configure the valid users, passwords, and roles. The file format (and default file location) are identical to those currently supported by Tomcat 3.X.

IMPLEMENTATION NOTE: It is assumed that the in-memory collection representing our defined users (and their roles) is initialized at application startup and never modified again. Therefore, no thread synchronization is performed around accesses to the principals collection.

Version: $Revision: 777556 $ $Date: 2009-05-22 16:59:34 +0200 (Fri, 22 May 2009) $

Author: Craig R. McClanahan

Field Summary
protected Stringinfo
Descriptive information about this Realm implementation.
protected static Stringname
Descriptive information about this Realm implementation.
Method Summary
Principalauthenticate(String username, String credentials)
Return the Principal associated with the specified username and credentials, if there is one; otherwise return null.
protected DigestergetDigester()
Return a configured Digester to use for processing the XML input file, creating a new one if necessary.
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.
StringgetPathname()
Return the pathname of our XML file containing user definitions.
protected PrincipalgetPrincipal(String username)
Return the Principal associated with the given user name.
protected MapgetPrincipals()
Returns the principals for this realm.
voidsetPathname(String pathname)
Set the pathname of our XML file containing user definitions.
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

info

protected final String info
Descriptive information about this Realm implementation.

name

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

Method Detail

authenticate

public Principal authenticate(String username, String credentials)
Return the Principal associated with the specified username and credentials, if there is one; otherwise return null.

Parameters: username Username of the Principal to look up credentials Password or other credentials to use in authenticating this username

getDigester

protected Digester getDigester()
Return a configured Digester to use for processing the XML input file, creating a new one if necessary.

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.

getPathname

public String getPathname()
Return the pathname of our XML file containing user definitions.

getPrincipal

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

getPrincipals

protected Map getPrincipals()
Returns the principals for this realm.

Returns: The principals, keyed by user name (a String)

setPathname

public void setPathname(String pathname)
Set the pathname of our XML file containing user definitions. If a relative pathname is specified, it is resolved against "catalina.base".

Parameters: pathname The new pathname

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.