org.chwf.plugin
Class User

java.lang.Object
  |
  +--org.chwf.plugin.User
Direct Known Subclasses:
DefaultUser

public abstract class User
extends java.lang.Object

An abstract superclass for custom user information. This plugin class can be used to define custom authentication mechanisms for the Chrysalis framework. Unlike most plugins, the User plugin is a per-user singleton rather than a global singleton.

Author:
Paul Strack

Field Summary
static java.lang.String AUTHENTICATED
          Special role requiring only authentication.
static java.lang.String REDIRECT_PARAMETER
          Parameter that stores post-login redirects.
 
Constructor Summary
protected User()
          No-op constructor.
 
Method Summary
abstract  void check(java.lang.String[] roles)
          Method that checks roles user roles.
abstract  java.lang.String getAuthType()
          A string name for the authentication mechanism.
static User getInstance()
          Returns the current User object.
abstract  java.lang.String getUserID()
          Retrieve the user ID (if available) used to log in this user.
abstract  boolean isAuthenticated()
          True if the user has logged in.
abstract  boolean isInRole(java.lang.String role)
          True if the user is in the specified role.
abstract  void logout()
          Log the user out.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUTHENTICATED

public static final java.lang.String AUTHENTICATED
Special role requiring only authentication.

REDIRECT_PARAMETER

public static final java.lang.String REDIRECT_PARAMETER
Parameter that stores post-login redirects.
Constructor Detail

User

protected User()
No-op constructor.
Method Detail

getInstance

public static User getInstance()
                        throws RegistryException
Returns the current User object. This object will contain no information if no user is currently logged in. Any custom login operation should populate the User object with appropriate authentication data.

Returns:
The user.
Throws:
RegistryException - If the user class cannot be initialized.

getUserID

public abstract java.lang.String getUserID()
Retrieve the user ID (if available) used to log in this user.

Returns:
User id or null if not logged in.

isInRole

public abstract boolean isInRole(java.lang.String role)
True if the user is in the specified role.

Parameters:
role - The role.
Returns:
True if the user is in the specified role.

isAuthenticated

public abstract boolean isAuthenticated()
True if the user has logged in.

Returns:
True if the user has logged in.

getAuthType

public abstract java.lang.String getAuthType()
A string name for the authentication mechanism.

Returns:
The authentication mechanism or null if not logged in.

logout

public abstract void logout()
Log the user out. This method should also invalidate the user's session. This method may not completely log out the user, because some mechanisms (e.g. Basic HTTP authentication) will immediately log the user back in for the next request.


check

public abstract void check(java.lang.String[] roles)
                    throws AuthenticationException

Method that checks roles user roles. This method should throw a SecurityException if the user's role is invalid.

Parameters:
roles - The expected security roles.
Throws:
AuthenticationException - With error message for security failure.


Copyright © 2002-2004, Paul Strack. All Rights Reserved.