org.objectweb.jonas.security.realm.factory
Class JResource

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.objectweb.jonas.management.ReconfigDispatcher
          extended by org.objectweb.jonas.security.realm.factory.JResource
All Implemented Interfaces:
java.io.Serializable, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, javax.naming.Referenceable, ReconfigDispatcherMBean, JResourceMBean
Direct Known Subclasses:
JResourceDS, JResourceLDAP, JResourceMemory

public abstract class JResource
extends ReconfigDispatcher
implements java.io.Serializable, javax.naming.Referenceable, JResourceMBean

This class implements JOnAS realm factory objects. It is build from an xml file by the security service of JOnAS.

Author:
Florent Benoit
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.objectweb.jonas.management.ReconfigDispatcher
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
JResource()
          Constructor
 
Method Summary
 void clearCache()
          Clear the cache
abstract  User findUser(java.lang.String name)
          Check if a user is found and return it
abstract  java.util.ArrayList getArrayListCombinedRoles(User user)
          Get all the roles (from the roles and from the groups) of the given user
static org.objectweb.util.monolog.api.Logger getLogger()
           
protected  javax.management.MBeanServer getMBeanServer()
          Get the MBean server
 java.lang.String getName()
          Get the name of this resource
abstract  javax.naming.Reference getReference()
          Retrieves the Reference of the object.
protected  long getSequenceNumber()
          Return a sequence number and increase this number
 java.util.Hashtable getUsers()
          Return users
abstract  boolean isValidUser(User user, java.lang.String credentials)
          Check if the given credential is the right credential for the given user
abstract  void removeMBeans()
          Remove all the Mbeans used by this resource
 void saveConfig()
          Update and save configuration
static void setLogger(org.objectweb.util.monolog.api.Logger logger)
           
 void setName(java.lang.String name)
          Set the name of this resource
 void setUsers(java.util.Hashtable users)
           
 
Methods inherited from class org.objectweb.jonas.management.ReconfigDispatcher
addNotificationListener, getFilter, getHandback, getListener, getNotificationInfo, initLogger, removeNotificationListener, sendReconfigNotification, sendSaveNotification
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
handleNotification, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JResource

public JResource()
          throws java.lang.Exception
Constructor

Throws:
java.lang.Exception - if a service can't be retrieved
Method Detail

setName

public void setName(java.lang.String name)
Set the name of this resource

Parameters:
name - Name of the resource

getName

public java.lang.String getName()
Get the name of this resource

Specified by:
getName in interface JResourceMBean
Returns:
the name of this resource

getMBeanServer

protected javax.management.MBeanServer getMBeanServer()
Get the MBean server

Returns:
the MBean server

getReference

public abstract javax.naming.Reference getReference()
                                             throws javax.naming.NamingException
Retrieves the Reference of the object. The Reference contains the factory used to create this object and the optional parameters used to configure the factory.

Specified by:
getReference in interface javax.naming.Referenceable
Returns:
the non-null Reference of the object.
Throws:
javax.naming.NamingException - if a naming exception was encountered while retrieving the reference.

removeMBeans

public abstract void removeMBeans()
                           throws JResourceException
Remove all the Mbeans used by this resource

Throws:
JResourceException - if the MBeans can not be removed

findUser

public abstract User findUser(java.lang.String name)
                       throws JResourceException
Check if a user is found and return it

Parameters:
name - the wanted user name
Returns:
the user found or null
Throws:
JResourceException - if there is an error during the search

isValidUser

public abstract boolean isValidUser(User user,
                                    java.lang.String credentials)
Check if the given credential is the right credential for the given user

Parameters:
user - user to check its credentials
credentials - the given credentials
Returns:
true if the credential is valid for this user

getArrayListCombinedRoles

public abstract java.util.ArrayList getArrayListCombinedRoles(User user)
                                                       throws JResourceException
Get all the roles (from the roles and from the groups) of the given user

Parameters:
user - the given user
Returns:
the array list of all the roles for a given user
Throws:
JResourceException - if it fails

getUsers

public java.util.Hashtable getUsers()
Return users

Returns:
Return users

getSequenceNumber

protected long getSequenceNumber()
Return a sequence number and increase this number

Returns:
a sequence number

saveConfig

public void saveConfig()
Update and save configuration

Specified by:
saveConfig in interface JResourceMBean

getLogger

public static org.objectweb.util.monolog.api.Logger getLogger()
Returns:
Returns the logger.

setLogger

public static void setLogger(org.objectweb.util.monolog.api.Logger logger)
Parameters:
logger - The logger to set.

setUsers

public void setUsers(java.util.Hashtable users)
Parameters:
users - The users to set.

clearCache

public void clearCache()
Clear the cache