org.apache.catalina.realm

Class GenericPrincipal

Implemented Interfaces:
Principal

public class GenericPrincipal
extends java.lang.Object
implements Principal

Generic implementation of java.security.Principal that is available for use by Realm implementations.

Version:
$Revision: 1.4 $ $Date: 2004/02/27 14:58:45 $

Author:
Craig R. McClanahan

Field Summary

protected String
name
The username of the user represented by this Principal.
protected String
password
The authentication credentials for the user represented by this Principal.
protected Realm
realm
The Realm with which this Principal is associated.
protected String[]
roles
The set of roles associated with this user.

Constructor Summary

GenericPrincipal(String name, String password, List roles)
GenericPrincipal(Realm realm, String name, String password)
Construct a new Principal, associated with the specified Realm, for the specified username and password.
GenericPrincipal(Realm realm, String name, String password, List roles)
Construct a new Principal, associated with the specified Realm, for the specified username and password, with the specified role names (as Strings).

Method Summary

String
getName()
String
getPassword()
Realm
getRealm()
String[]
getRoles()
boolean
hasRole(String role)
Does the user represented by this Principal possess the specified role?
String
toString()
Return a String representation of this object, which exposes only information that should be public.

Field Details

name

protected String name
The username of the user represented by this Principal.


password

protected String password
The authentication credentials for the user represented by this Principal.


realm

protected Realm realm
The Realm with which this Principal is associated.


roles

protected String[] roles
The set of roles associated with this user.

Constructor Details

GenericPrincipal

public GenericPrincipal(String name,
                        String password,
                        List roles)


GenericPrincipal

public GenericPrincipal(Realm realm,
                        String name,
                        String password)
Construct a new Principal, associated with the specified Realm, for the specified username and password.

Parameters:
realm - The Realm that owns this Principal
name - The username of the user represented by this Principal
password - Credentials used to authenticate this user


GenericPrincipal

public GenericPrincipal(Realm realm,
                        String name,
                        String password,
                        List roles)
Construct a new Principal, associated with the specified Realm, for the specified username and password, with the specified role names (as Strings).

Parameters:
realm - The Realm that owns this principal
name - The username of the user represented by this Principal
password - Credentials used to authenticate this user
roles - List of roles (must be Strings) possessed by this user

Method Details

getName

public String getName()


getPassword

public String getPassword()


getRealm

public Realm getRealm()


getRoles

public String[] getRoles()


hasRole

public boolean hasRole(String role)
Does the user represented by this Principal possess the specified role?

Parameters:
role - Role to be tested


toString

public String toString()
Return a String representation of this object, which exposes only information that should be public.


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.