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

java.lang.Object
  extended byjavax.management.NotificationBroadcasterSupport
      extended byorg.objectweb.jonas.management.ReconfigDispatcher
          extended byorg.objectweb.jonas.security.realm.factory.JResource
All Implemented Interfaces:
JResourceMBean, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, ReconfigDispatcherMBean, javax.naming.Referenceable, java.io.Serializable
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
protected static org.objectweb.util.monolog.api.Logger logger
          The logger used in JOnAS
protected  java.util.Hashtable users
          Hashtable used to cache the users (speed up search)
 
Fields inherited from class org.objectweb.jonas.management.ReconfigDispatcher
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
JResource()
          Constructor
 
Method Summary
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
protected  byte[] getBytesFromObject(java.lang.Object obj)
          Return an array of byte from a given object
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
abstract  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
 void setName(java.lang.String name)
          Set the name of this resource
 
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
 

Field Detail

logger

protected static org.objectweb.util.monolog.api.Logger logger
The logger used in JOnAS


users

protected java.util.Hashtable users
Hashtable used to cache the users (speed up search)

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 abstract java.util.Hashtable getUsers()
Return users

Returns:
Return users

getBytesFromObject

protected byte[] getBytesFromObject(java.lang.Object obj)
Return an array of byte from a given object

Parameters:
obj - the object from which we must extract the bytes.
Returns:
the byte[] from an object

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