org.norther.tammi.root.realm
Class DefaultRepositoryRealm

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.root.realm.DefaultRepositoryRealm
All Implemented Interfaces:
Serializable, EventListener, NotificationBroadcaster, NotificationEmitter, TraceListener, Manageable, MBeanDelegate, Configurable, Realm, MultiRepositoryClient, RepositoryClient, RepositoryRealm

public class DefaultRepositoryRealm
extends AbstractRealm
implements RepositoryRealm

A default implementation of RepositoryRealm.

Author:
Marketta Priha
See Also:
Serialized Form

Field Summary
static String DEFAULT_ACCOUNT_ID_ATTIBUTE
          The default account id attribute.
 
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.root.realm.RepositoryRealm
ACCOUNT_CLASS_NAME_PROPERTY, CASE_INSENSITIVE_PROPERTY, USER_CLASS_NAME_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
DefaultRepositoryRealm()
          The default constructor.
 
Method Summary
 Persister acquirePersister()
          Acquires a persister through the default connection.
 Persister acquirePersister(Principal principal)
          Acquires an authenticated persister through the default connection.
 Persister acquirePersister(String key)
          Acquires a persister through the specified connection.
 Persister acquirePersister(String key, Principal principal)
          Acquires an authenticated persister through the specified connection.
 Persister acquirePersister(String user, String pswd)
          Acquires an authenticated persister through the default connection.
 Persister acquirePersister(String key, String user, String pswd)
          Acquires an authenticated persister through the specified connection.
 void clearConnections()
          Clears all connections.
 Set connectionKeySet()
          Returns a read-only set of available connection aliases.
 boolean containsConnection(String key)
          Checks the specified connection.
 String getAccountClassName()
          Gets the account class name.
 String getAccountClassName(String domain)
          Gets the account class name in the specified domain.
 String getAuthenticatedPasswordKey()
          Gets the authenticated password key.
 String getAuthenticatedPasswordKey(String key)
          Gets the authenticated password key of the specified connection.
 String getAuthenticatedUsernameKey()
          Gets the authenticated username key.
 String getAuthenticatedUsernameKey(String key)
          Gets the authenticated username key of the specified connection.
 String getAuthenticationConnectionKey()
          Gets the authentication connection key.
 String getAuthenticationConnectionKey(String key)
          Gets the authentication connection key of the specified connection.
 String getConnectionAlias(String key)
          Gets the alias of the specified connection.
 String getConnectionKey()
          Gets the default connection key of the repository this client uses.
 String getConnectionUsername()
          Gets the user's login name for the default connection.
 String getConnectionUsername(String key)
          Gets the user's login name of the specified connection.
 String getPersisterClassName()
          Gets the class name of the persister implemention for the default connection.
 String getPersisterClassName(String key)
          Gets the class name of the persister implementation of the specified connection.
protected  Principal getPrincipal(String domain, String username, String password)
          Gets the user principal representing the authenticated user.
 String getResourceKey()
          Gets the resource connection key of the repository this client uses.
 String getUserClassName()
          Gets the user class name.
 boolean isCaseInsensitive()
          Checks whether usernames and role names are case-insensitive.
 boolean isConnectionAuthenticated()
          Checks whether authentication is configured for the default connection.
 boolean isConnectionAuthenticated(String key)
          Checks whether authentication is configured for the specified connection.
 void removeConnection(String key)
          Removes the specified connection.
 void setAccountClassName(String className)
          Sets the account class name.
 void setAccountClassName(String domain, String className)
          Sets the account class name in the specified domain.
 void setAuthenticationConnection(String alias, String userKey, String pswdKey)
          Sets authentication connection.
 void setAuthenticationConnection(String key, String alias, String userKey, String pswdKey)
          Sets authentication connection of the specified connection.
 void setCaseInsensitive(boolean flag)
          Sets whether usernames and role names are case-insensitive.
 void setConnectionAlias(String key, String alias)
          Sets the alias of the specified connection.
 void setConnectionAuthenticated(boolean authenticated)
          Sets whether authentication is configured for the default connection.
 void setConnectionAuthenticated(String key, boolean authenticated)
          Sets whether authentication is configured for the specified connection.
 void setConnectionKey(String key)
          Sets the default connection key of the repository this client uses.
 void setConnectionPassword(String password)
          Sets the user's credentials for the default connection.
 void setConnectionPassword(String key, String password)
          Sets the user's credentials of the specified connection.
 void setConnectionUsername(String username)
          Sets the user's login name for the default connection.
 void setConnectionUsername(String key, String username)
          Sets the user's login name of the specified connection.
 void setPersisterClassName(String className)
          Sets the class name of the persister implementation for the default connection.
 void setPersisterClassName(String key, String className)
          Sets the class name of the persister implementation of the specified connection.
 void setResourceKey(String key)
          Sets the resource connection key of the repository this client uses.
 void setUserClassName(String className)
          Sets the user class name.
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
 

Field Detail

DEFAULT_ACCOUNT_ID_ATTIBUTE

public static final String DEFAULT_ACCOUNT_ID_ATTIBUTE
The default account id attribute.

See Also:
Constant Field Values
Constructor Detail

DefaultRepositoryRealm

public DefaultRepositoryRealm()
The default constructor.

Method Detail

getConnectionKey

public String getConnectionKey()
Description copied from interface: RepositoryClient
Gets the default connection key of the repository this client uses.

Specified by:
getConnectionKey in interface RepositoryClient
Returns:
the connection key.

setConnectionKey

public void setConnectionKey(String key)
Description copied from interface: RepositoryClient
Sets the default connection key of the repository this client uses.

Specified by:
setConnectionKey in interface RepositoryClient
Parameters:
key - the connection key.

getPersisterClassName

public String getPersisterClassName()
Description copied from interface: RepositoryClient
Gets the class name of the persister implemention for the default connection.

Specified by:
getPersisterClassName in interface RepositoryClient
Returns:
the persister class name.

setPersisterClassName

public void setPersisterClassName(String className)
Description copied from interface: RepositoryClient
Sets the class name of the persister implementation for the default connection.

Specified by:
setPersisterClassName in interface RepositoryClient
Parameters:
className - the persister class name.

getConnectionUsername

public String getConnectionUsername()
Description copied from interface: RepositoryClient
Gets the user's login name for the default connection.

Specified by:
getConnectionUsername in interface RepositoryClient
Returns:
the user's repository connection login name.

setConnectionUsername

public void setConnectionUsername(String username)
Description copied from interface: RepositoryClient
Sets the user's login name for the default connection.

Specified by:
setConnectionUsername in interface RepositoryClient
Parameters:
username - the user's repository connection login name.

setConnectionPassword

public void setConnectionPassword(String password)
Description copied from interface: RepositoryClient
Sets the user's credentials for the default connection.

Specified by:
setConnectionPassword in interface RepositoryClient
Parameters:
password - the user's repository connection credentials.

isConnectionAuthenticated

public boolean isConnectionAuthenticated()
Description copied from interface: RepositoryClient
Checks whether authentication is configured for the default connection. If username and password are not configured separately, the values passed to the client are used for the connection.

Specified by:
isConnectionAuthenticated in interface RepositoryClient
Returns:
true for an authenticated connection, false otherwise.

setConnectionAuthenticated

public void setConnectionAuthenticated(boolean authenticated)
Description copied from interface: RepositoryClient
Sets whether authentication is configured for the default connection. If username and password are not configured separately, the values passed to the client are used for the connection.

Specified by:
setConnectionAuthenticated in interface RepositoryClient
Parameters:
authenticated - true for an authenticated connection, false otherwise.

getAuthenticationConnectionKey

public String getAuthenticationConnectionKey()
Description copied from interface: RepositoryClient
Gets the authentication connection key.

Specified by:
getAuthenticationConnectionKey in interface RepositoryClient
Returns:
the authentication connection key or null.

getAuthenticatedUsernameKey

public String getAuthenticatedUsernameKey()
Description copied from interface: RepositoryClient
Gets the authenticated username key.

Specified by:
getAuthenticatedUsernameKey in interface RepositoryClient
Returns:
the authenticated username key or null.

getAuthenticatedPasswordKey

public String getAuthenticatedPasswordKey()
Description copied from interface: RepositoryClient
Gets the authenticated password key.

Specified by:
getAuthenticatedPasswordKey in interface RepositoryClient
Returns:
the authenticated password key or null.

setAuthenticationConnection

public void setAuthenticationConnection(String alias,
                                        String userKey,
                                        String pswdKey)
Description copied from interface: RepositoryClient
Sets authentication connection.

Specified by:
setAuthenticationConnection in interface RepositoryClient
Parameters:
alias - the authentication key.
userKey - the username key.
pswdKey - the password key.

acquirePersister

public Persister acquirePersister()
                           throws ConstructionException
Description copied from interface: RepositoryClient
Acquires a persister through the default connection. If the connection is defined to be an authenticated one, the username and password specified for the connection are applied to authentication.

Specified by:
acquirePersister in interface RepositoryClient
Returns:
the default persister.
Throws:
ConstructionException - if construction fails.

acquirePersister

public Persister acquirePersister(String user,
                                  String pswd)
                           throws ConstructionException
Description copied from interface: RepositoryClient
Acquires an authenticated persister through the default connection. If the connection is not defined to be an authenticated one or a connection specific identity is defined, the username and password are ignored.

Specified by:
acquirePersister in interface RepositoryClient
Parameters:
user - the username of the connection.
pswd - the password of the connection.
Returns:
the authenticated persister.
Throws:
ConstructionException - if construction fails.

acquirePersister

public Persister acquirePersister(Principal principal)
                           throws ConstructionException
Description copied from interface: RepositoryClient
Acquires an authenticated persister through the default connection. If the connection is not defined to be an authenticated one or a connection specific identity is defined, the principal is ignored.

Specified by:
acquirePersister in interface RepositoryClient
Parameters:
principal - an authenticated principal.
Returns:
the authenticated persister.
Throws:
ConstructionException - if construction fails.

getResourceKey

public String getResourceKey()
Description copied from interface: MultiRepositoryClient
Gets the resource connection key of the repository this client uses.

Specified by:
getResourceKey in interface MultiRepositoryClient
Returns:
the resource key.

setResourceKey

public void setResourceKey(String key)
Description copied from interface: MultiRepositoryClient
Sets the resource connection key of the repository this client uses.

Specified by:
setResourceKey in interface MultiRepositoryClient
Parameters:
key - the resource key.

getConnectionAlias

public String getConnectionAlias(String key)
Description copied from interface: MultiRepositoryClient
Gets the alias of the specified connection. The key is applied if not specified.

Specified by:
getConnectionAlias in interface MultiRepositoryClient
Parameters:
key - the connection key.
Returns:
the connection alias.

setConnectionAlias

public void setConnectionAlias(String key,
                               String alias)
Description copied from interface: MultiRepositoryClient
Sets the alias of the specified connection. The key is applied if not specified.

Specified by:
setConnectionAlias in interface MultiRepositoryClient
Parameters:
key - the connection key.
alias - the connection alias.

getPersisterClassName

public String getPersisterClassName(String key)
Description copied from interface: MultiRepositoryClient
Gets the class name of the persister implementation of the specified connection.

Specified by:
getPersisterClassName in interface MultiRepositoryClient
Parameters:
key - the connection key.
Returns:
the class name.

setPersisterClassName

public void setPersisterClassName(String key,
                                  String className)
Description copied from interface: MultiRepositoryClient
Sets the class name of the persister implementation of the specified connection.

Specified by:
setPersisterClassName in interface MultiRepositoryClient
Parameters:
key - the connection key.
className - the class name.

getConnectionUsername

public String getConnectionUsername(String key)
Description copied from interface: MultiRepositoryClient
Gets the user's login name of the specified connection.

Specified by:
getConnectionUsername in interface MultiRepositoryClient
Parameters:
key - the connection key.
Returns:
the user's repository connection login name.

setConnectionUsername

public void setConnectionUsername(String key,
                                  String username)
Description copied from interface: MultiRepositoryClient
Sets the user's login name of the specified connection.

Specified by:
setConnectionUsername in interface MultiRepositoryClient
Parameters:
key - the connection key.
username - the user's repository connection login name.

setConnectionPassword

public void setConnectionPassword(String key,
                                  String password)
Description copied from interface: MultiRepositoryClient
Sets the user's credentials of the specified connection.

Specified by:
setConnectionPassword in interface MultiRepositoryClient
Parameters:
key - the connection key.
password - the user's repository connection credentials.

isConnectionAuthenticated

public boolean isConnectionAuthenticated(String key)
Description copied from interface: MultiRepositoryClient
Checks whether authentication is configured for the specified connection. If username and password are not configured separately, the values passed to the client are used for the connection.

Specified by:
isConnectionAuthenticated in interface MultiRepositoryClient
Parameters:
key - the connection key.
Returns:
the class name.

setConnectionAuthenticated

public void setConnectionAuthenticated(String key,
                                       boolean authenticated)
Description copied from interface: MultiRepositoryClient
Sets whether authentication is configured for the specified connection. If username and password are not configured separately, the values passed to the client are used for the connection.

Specified by:
setConnectionAuthenticated in interface MultiRepositoryClient
Parameters:
key - the connection key.
authenticated - true if the connection is to be authenticated.

getAuthenticationConnectionKey

public String getAuthenticationConnectionKey(String key)
Description copied from interface: MultiRepositoryClient
Gets the authentication connection key of the specified connection.

Specified by:
getAuthenticationConnectionKey in interface MultiRepositoryClient
Parameters:
key - the connection key.
Returns:
the authentication connection key or null.

getAuthenticatedUsernameKey

public String getAuthenticatedUsernameKey(String key)
Description copied from interface: MultiRepositoryClient
Gets the authenticated username key of the specified connection.

Specified by:
getAuthenticatedUsernameKey in interface MultiRepositoryClient
Parameters:
key - the connection key.
Returns:
the authenticated username key or null.

getAuthenticatedPasswordKey

public String getAuthenticatedPasswordKey(String key)
Description copied from interface: MultiRepositoryClient
Gets the authenticated password key of the specified connection.

Specified by:
getAuthenticatedPasswordKey in interface MultiRepositoryClient
Parameters:
key - the connection key.
Returns:
the authenticated password key or null.

setAuthenticationConnection

public void setAuthenticationConnection(String key,
                                        String alias,
                                        String userKey,
                                        String pswdKey)
Description copied from interface: MultiRepositoryClient
Sets authentication connection of the specified connection.

Specified by:
setAuthenticationConnection in interface MultiRepositoryClient
Parameters:
key - the connection key.
alias - the authentication key.
userKey - the username key.
pswdKey - the password key.

containsConnection

public boolean containsConnection(String key)
Description copied from interface: MultiRepositoryClient
Checks the specified connection.

Specified by:
containsConnection in interface MultiRepositoryClient
Parameters:
key - the connection key.
Returns:
true if available, false otherwise.

removeConnection

public void removeConnection(String key)
Description copied from interface: MultiRepositoryClient
Removes the specified connection.

Specified by:
removeConnection in interface MultiRepositoryClient
Parameters:
key - the connection key.

clearConnections

public void clearConnections()
Description copied from interface: MultiRepositoryClient
Clears all connections.

Specified by:
clearConnections in interface MultiRepositoryClient

connectionKeySet

public Set connectionKeySet()
Description copied from interface: MultiRepositoryClient
Returns a read-only set of available connection aliases.

Specified by:
connectionKeySet in interface MultiRepositoryClient
Returns:
a set of connections aliases.

acquirePersister

public Persister acquirePersister(String key)
                           throws ConstructionException
Description copied from interface: MultiRepositoryClient
Acquires a persister through the specified connection. If the connection is defined to be an authenticated one, the username and password specified for the connection are applied to authentication.

Specified by:
acquirePersister in interface MultiRepositoryClient
Parameters:
key - the connection key.
Returns:
the default persister.
Throws:
ConstructionException - if construction fails.

acquirePersister

public Persister acquirePersister(String key,
                                  String user,
                                  String pswd)
                           throws ConstructionException
Description copied from interface: MultiRepositoryClient
Acquires an authenticated persister through the specified connection. If the connection is not defined to be an authenticated one or a connection specific identity is defined, the username and password are ignored.

Specified by:
acquirePersister in interface MultiRepositoryClient
Parameters:
key - the connection key.
user - the username of the connection.
pswd - the password of the connection.
Returns:
the authenticated persister.
Throws:
ConstructionException - if construction fails.

acquirePersister

public Persister acquirePersister(String key,
                                  Principal principal)
                           throws ConstructionException
Description copied from interface: MultiRepositoryClient
Acquires an authenticated persister through the specified connection. If the connection is not defined to be an authenticated one or a connection specific identity is defined, the principal is ignored.

Specified by:
acquirePersister in interface MultiRepositoryClient
Parameters:
key - the connection key.
principal - an authenticated principal.
Returns:
the authenticated persister.
Throws:
ConstructionException - if construction fails.

isCaseInsensitive

public boolean isCaseInsensitive()
Description copied from interface: RepositoryRealm
Checks whether usernames and role names are case-insensitive.

Specified by:
isCaseInsensitive in interface RepositoryRealm
Returns:
true if case-insensitive, false otherwise.

setCaseInsensitive

public void setCaseInsensitive(boolean flag)
Description copied from interface: RepositoryRealm
Sets whether usernames and role names are case-insensitive.

Specified by:
setCaseInsensitive in interface RepositoryRealm
Parameters:
flag - true if case-insensitive, false otherwise.

getUserClassName

public String getUserClassName()
Description copied from interface: RepositoryRealm
Gets the user class name.

Specified by:
getUserClassName in interface RepositoryRealm
Returns:
the user class name or null.

setUserClassName

public void setUserClassName(String className)
Description copied from interface: RepositoryRealm
Sets the user class name.

Specified by:
setUserClassName in interface RepositoryRealm
Parameters:
className - the user class name.

getAccountClassName

public String getAccountClassName()
Description copied from interface: RepositoryRealm
Gets the account class name.

Specified by:
getAccountClassName in interface RepositoryRealm
Returns:
the account class name or null.

setAccountClassName

public void setAccountClassName(String className)
Description copied from interface: RepositoryRealm
Sets the account class name.

The primary key field of the account class should be UserId and it should contain the FirstName and LastName fields to provide the real name for authenticated principals.

Specified by:
setAccountClassName in interface RepositoryRealm
Parameters:
className - the account class name.

getAccountClassName

public String getAccountClassName(String domain)
Description copied from interface: RepositoryRealm
Gets the account class name in the specified domain.

Specified by:
getAccountClassName in interface RepositoryRealm
Parameters:
domain - the user domain.
Returns:
the account class name or null.

setAccountClassName

public void setAccountClassName(String domain,
                                String className)
Description copied from interface: RepositoryRealm
Sets the account class name in the specified domain.

The primary key field of the account class should be UserId and it should contain the FirstName and LastName fields to provide the real name for authenticated principals.

Specified by:
setAccountClassName in interface RepositoryRealm
Parameters:
domain - the user domain.
className - the account class name.

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