org.chwf.plugin.defaults
Class DefaultUser

java.lang.Object
  |
  +--org.chwf.plugin.User
        |
        +--org.chwf.plugin.defaults.DefaultUser

public class DefaultUser
extends User

A default user plugin implementation that uses the Servlet API to retrieve user data. It assumes that the J2EE Web Authentication mechanism is used to log the user in.

Author:
Paul Strack

Fields inherited from class org.chwf.plugin.User
AUTHENTICATED, REDIRECT_PARAMETER
 
Constructor Summary
DefaultUser()
           
 
Method Summary
 void check(java.lang.String[] roles)
          Method called for security check failure.
 java.lang.String getAuthType()
          A string name for the authentication mechanism.
 java.lang.String getUserID()
          Retrieve the user ID (if available) used to log in this user.
 boolean isAuthenticated()
          True if the user has logged in.
 boolean isInRole(java.lang.String role)
          True if the user is in the specified role.
 void logout()
          Log the user out.
 
Methods inherited from class org.chwf.plugin.User
getInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultUser

public DefaultUser()
Method Detail

getUserID

public java.lang.String getUserID()
Retrieve the user ID (if available) used to log in this user. Delegates to the request.getRemoteUser() method.

Overrides:
getUserID in class User
Returns:
User id or null if not logged in.

isInRole

public boolean isInRole(java.lang.String role)
True if the user is in the specified role. Delegates to the request.isUserInRole() method.

Overrides:
isInRole in class User
Parameters:
role - The role.
Returns:
True if the user is in the specified role.

isAuthenticated

public boolean isAuthenticated()
True if the user has logged in. Checks to see if the request.getAuthType() method is null.

Overrides:
isAuthenticated in class User
Returns:
True if the user has logged in.

getAuthType

public java.lang.String getAuthType()
A string name for the authentication mechanism. Delegates to the request.getAuthType() method.

Overrides:
getAuthType in class User
Returns:
The authentication mechanism or null if not logged in.

logout

public void logout()
Log the user out. This method invalidates the user's session.

Overrides:
logout in class User

check

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

Method called for security check failure. This method should either return the URL of a redirect page (e.g. to login the user) or throw a SecurityException.

Overrides:
check in class User
Parameters:
roles - The expected security roles.
Throws:
AuthenticationException - With error message for security failure.


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