org.securityfilter.realm
Class SimpleSecurityRealmBase

java.lang.Object
  extended byorg.securityfilter.realm.SimpleSecurityRealmBase
All Implemented Interfaces:
SecurityRealmInterface

public class SimpleSecurityRealmBase
extends Object
implements SecurityRealmInterface

Security realm base class. This class insulates you from having to create or process Principal objects. You can implement a realm by overriding the two methods that neither take or return a Principal object and this class does the conversions for you.

Version:
$Revision: 1.1 $ $Date: 2004/07/03 20:53:44 $
Author:
Max Cooper (max@maxcooper.com)

Constructor Summary
SimpleSecurityRealmBase()
           
 
Method Summary
 Principal authenticate(String username, String password)
          Authenticate a user.
 boolean booleanAuthenticate(String username, String password)
          Authenticate a user.
 boolean isUserInRole(Principal principal, String rolename)
          Test for role membership.
 boolean isUserInRole(String username, String rolename)
          Test for role membership.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSecurityRealmBase

public SimpleSecurityRealmBase()
Method Detail

booleanAuthenticate

public boolean booleanAuthenticate(String username,
                                   String password)
Authenticate a user. Override this method in a subclass to avoid dealing with Principal objects.

Parameters:
username - a username
password - a plain text password, as entered by the user
Returns:
true if the username/password combination is valid, false otherwise

isUserInRole

public boolean isUserInRole(String username,
                            String rolename)
Test for role membership. Override this method in a subclass to avoid dealing with Principal objects.

Parameters:
username - a username
rolename - name of a role to test for membership
Returns:
true if the user is in the role, false otherwise

authenticate

public Principal authenticate(String username,
                              String password)
Authenticate a user.

Specified by:
authenticate in interface SecurityRealmInterface
Parameters:
username - a username
password - a plain text password, as entered by the user
Returns:
a Principal object representing the user if successful, false otherwise

isUserInRole

public boolean isUserInRole(Principal principal,
                            String rolename)
Test for role membership. Use Principal.getName() to get the username from the principal object.

Specified by:
isUserInRole in interface SecurityRealmInterface
Parameters:
principal - Principal object representing a user
rolename - name of a role to test for membership
Returns:
true if the user is in the role, false otherwise