org.norther.tammi.core.realm
Class DefaultMemoryRealm

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.config.DefaultConfigurable
          extended by org.norther.tammi.core.realm.AbstractRealm
              extended by org.norther.tammi.core.realm.DefaultMemoryRealm
All Implemented Interfaces:
Serializable, EventListener, NotificationBroadcaster, NotificationEmitter, TraceListener, Manageable, MBeanDelegate, Configurable, MemoryRealm, Realm

public class DefaultMemoryRealm
extends AbstractRealm
implements MemoryRealm

A default implementation of MemoryRealm.

Based on MemoryRealm in the Apache Jakarta Tomcat project.

Author:
Craig R. McClanahan, Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.norther.tammi.core.config.DefaultConfigurable
MODIFIED, SYNCHRONIZED, UNMODIFIED
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.core.realm.MemoryRealm
LOCALE_PROPERTY, PASSWORD_PROPERTY, ROLES_PROPERTY
 
Fields inherited from interface org.norther.tammi.core.realm.Realm
ANONYMOUS_USER_PROPERTY, CACHED_PASSWORDS_PROPERTY, DEFAULT_ROLE_PROPERTY, DIGEST_ALGORITHM_PROPERTY, MEMBER_PROPERTY, PUBLIC_NAME_PROPERTY
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
DefaultMemoryRealm()
          Constructs a new realm.
 
Method Summary
 void addRole(String username, String role)
          Adds a role.
 void addUser(String username, String password)
          Adds a new user.
 void addUser(String username, String password, List roles)
          Adds a new user with roles.
 void changePassword(String username, String password)
          Changes the password.
protected  Principal getPrincipal(String domain, String username, String password)
          Gets the user principal representing the authenticated user.
 List getRoles(String username)
          Gets roles.
 void loadPasswordFile(String path, boolean shadow)
          Loads encrypted passwords from the Unix kind of passwd/shadow file.
 void removeRole(String username, String role)
          Removes a role.
 void removeUser(String username)
          Removes a user.
 void setRoles(String username, List roles)
          Sets roles.
protected  void updateProperties()
          Updates properties.
 
Methods inherited from class org.norther.tammi.core.realm.AbstractRealm
addRoles, authenticate, authenticate, authenticate, authenticate, authenticate, authenticate, authenticate, authenticate, checkProperties, createPrincipal, createPrincipal, digest, generateAuthenticate, getAnonymousUser, getAuthType, getDefaultRole, getDigestAlgorithm, getMemberMap, getMessageDigest, getPublicName, identify, identify, isAuthenticated, isAuthenticated, isCachedPasswords, isUserInRole, setAnonymousUser, setCachedPasswords, setDefaultRole, setDigestAlgorithm, setPublicName
 
Methods inherited from class org.norther.tammi.core.config.DefaultConfigurable
addProperty, addProperty, clearProperties, containsProperty, getConfigKey, getConfiguration, getModifiedState, getProperties, getProperty, getPropertyFilePath, indexOfProperty, loadConfiguration, loadConfiguration, loadConfiguration, modified, propertyMap, propertyMap, removeProperty, removeProperty, setConfigKey, setModifiedState, setProperties, setProperty, setPropertyFilePath, setPropertyFilePath, storeProperties
 
Methods inherited from class org.norther.tammi.core.base.Adaptee
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, postmanaged, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unmanaged, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.core.realm.Realm
authenticate, authenticate, authenticate, authenticate, authenticate, authenticate, authenticate, authenticate, digest, generateAuthenticate, getAnonymousUser, getAuthType, getDefaultRole, getDigestAlgorithm, getPublicName, identify, identify, isAuthenticated, isAuthenticated, isCachedPasswords, isUserInRole, setAnonymousUser, setCachedPasswords, setDefaultRole, setDigestAlgorithm, setPublicName
 
Methods inherited from interface org.norther.tammi.core.config.Configurable
addProperty, addProperty, clearProperties, containsProperty, getConfigKey, getProperties, getProperty, getPropertyFilePath, indexOfProperty, propertyMap, propertyMap, removeProperty, removeProperty, setConfigKey, setProperties, setProperty, setPropertyFilePath, setPropertyFilePath, storeProperties
 

Constructor Detail

DefaultMemoryRealm

public DefaultMemoryRealm()
Constructs a new realm.

Method Detail

addUser

public void addUser(String username,
                    String password)
             throws LogException
Description copied from interface: MemoryRealm
Adds a new user.

Specified by:
addUser in interface MemoryRealm
Parameters:
username - the username.
password - the password.
Throws:
LogException - if already exists.

addUser

public void addUser(String username,
                    String password,
                    List roles)
             throws LogException
Description copied from interface: MemoryRealm
Adds a new user with roles.

Specified by:
addUser in interface MemoryRealm
Parameters:
username - the username.
password - the password.
roles - a list of roles.
Throws:
LogException - if already exists.

changePassword

public void changePassword(String username,
                           String password)
                    throws LogException
Description copied from interface: MemoryRealm
Changes the password.

Specified by:
changePassword in interface MemoryRealm
Parameters:
username - the username.
password - the password.
Throws:
LogException - if not found.

addRole

public void addRole(String username,
                    String role)
             throws LogException
Description copied from interface: MemoryRealm
Adds a role.

Specified by:
addRole in interface MemoryRealm
Parameters:
username - the username.
role - the role to add.
Throws:
LogException - if not found.

removeRole

public void removeRole(String username,
                       String role)
                throws LogException
Description copied from interface: MemoryRealm
Removes a role.

Specified by:
removeRole in interface MemoryRealm
Parameters:
username - the username.
role - the role to remove.
Throws:
LogException - if not found.

getRoles

public List getRoles(String username)
              throws LogException
Description copied from interface: MemoryRealm
Gets roles.

Specified by:
getRoles in interface MemoryRealm
Parameters:
username - the username.
Returns:
a list of roles.
Throws:
LogException - if not found.

setRoles

public void setRoles(String username,
                     List roles)
              throws LogException
Description copied from interface: MemoryRealm
Sets roles.

Specified by:
setRoles in interface MemoryRealm
Parameters:
username - the username.
roles - a list of roles.
Throws:
LogException - if not found.

removeUser

public void removeUser(String username)
Description copied from interface: MemoryRealm
Removes a user.

Specified by:
removeUser in interface MemoryRealm
Parameters:
username - the username.

loadPasswordFile

public void loadPasswordFile(String path,
                             boolean shadow)
                      throws LogException
Loads encrypted passwords from the Unix kind of passwd/shadow file.

Parameters:
path - the pathname of the password file either relative to the config key folder or as an absolute path.
shadow - true, if the content is in the shadow format, otherwise passwd format.
Throws:
LogException - if problems in accessing the files.

getPrincipal

protected Principal getPrincipal(String domain,
                                 String username,
                                 String password)
Description copied from class: AbstractRealm
Gets the user principal representing the authenticated user. Subclasses may implement this method only and rely on authentication operations provided by this class.

Specified by:
getPrincipal in class AbstractRealm
Parameters:
domain - the domain.
username - the username.
password - the user password.
Returns:
the principal or null.

updateProperties

protected void updateProperties()
Description copied from class: AbstractRealm
Updates properties.

Overrides:
updateProperties in class AbstractRealm


Copyright © 2004 The Norther Organization. All rights reserved.