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

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

public class JResourceMemory
extends JResource
implements JResourceMemoryMBean

This class extends the JResource class for the Memory implementation.

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
JResourceMemory()
          Constructor .
 
Method Summary
 void addGroup(Group group)
          Add a group to this resource.
 void addGroup(java.lang.String groupname)
          Add a group with a given name
 void addRole(Role role)
          Add a role to this resource.
 void addRole(java.lang.String rolename)
          Add a role with a given name
 void addUser(java.lang.String username, java.lang.String password)
          Add a user with a given principal and credential
 void addUser(User user)
          Add a user to this resource.
 User findUser(java.lang.String name)
          Check if a user is found and return it
 java.util.ArrayList getArrayListCombinedRoles(User user)
          Get all the roles (from the roles and from the groups) of the given user
 java.util.Hashtable getGroups()
          Return all the groups
 javax.naming.Reference getReference()
          Retrieves the Reference of the object.
 java.util.Hashtable getRoles()
          Return all the roles
 boolean isValidUser(User user, java.lang.String credentials)
          Check if the given credential is the right credential for the given user
 java.lang.String[] listGroups()
          Get the groups
 java.lang.String[] listRoles()
          Get the roles
 void removeGroup(java.lang.String groupname)
          Remove a group with a given name
 void removeMBeans()
          Remove all the Mbeans used by this resource
 void removeRole(java.lang.String rolename)
          Remove a role with a given name
 void removeUser(java.lang.String username)
          Remove a user with a given principal
 void setGroups(java.util.Hashtable groups)
          Set the groups
 void setRoles(java.util.Hashtable roles)
          Set the roles
 java.lang.String toString()
          The string representation of this realm is the XML
 java.lang.String toXML()
          String representation of the MemoryRealm
 
Methods inherited from class org.objectweb.jonas.security.realm.factory.JResource
clearCache, getLogger, getMBeanServer, getName, getSequenceNumber, getUsers, saveConfig, setLogger, setName, setUsers
 
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, wait, wait, wait
 
Methods inherited from interface org.objectweb.jonas.security.realm.factory.JResourceMBean
getName, saveConfig
 

Constructor Detail

JResourceMemory

public JResourceMemory()
                throws java.lang.Exception
Constructor . Use the super constructor

Throws:
java.lang.Exception - if super constructor fail
Method Detail

addUser

public void addUser(User user)
             throws java.lang.Exception
Add a user to this resource.

Parameters:
user - the user which need to be added.
Throws:
java.lang.Exception - if the user already exists

addGroup

public void addGroup(Group group)
              throws java.lang.Exception
Add a group to this resource.

Parameters:
group - the group which need to be added.
Throws:
java.lang.Exception - if the group already exists

addRole

public void addRole(Role role)
             throws java.lang.Exception
Add a role to this resource.

Parameters:
role - the role which need to be added.
Throws:
java.lang.Exception - if the role already exists

findUser

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

Specified by:
findUser in class JResource
Parameters:
name - the wanted user name
Returns:
the user found or null
Throws:
JResourceException - if there is an error during the search

isValidUser

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

Specified by:
isValidUser in class JResource
Parameters:
user - user to check its credentials
credentials - the given credentials
Returns:
true if the credential is valid for this user

getGroups

public java.util.Hashtable getGroups()
Return all the groups

Returns:
the groups

getRoles

public java.util.Hashtable getRoles()
Return all the roles

Returns:
the roles

getArrayListCombinedRoles

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

Specified by:
getArrayListCombinedRoles in class JResource
Parameters:
user - the given user
Returns:
the array list of all the roles for a given user
Throws:
JResourceException - if it fails

setGroups

public void setGroups(java.util.Hashtable groups)
Set the groups

Parameters:
groups - the groups of this resource

setRoles

public void setRoles(java.util.Hashtable roles)
Set the roles

Parameters:
roles - the roles of this resource

addUser

public void addUser(java.lang.String username,
                    java.lang.String password)
             throws java.lang.Exception
Add a user with a given principal and credential

Specified by:
addUser in interface JResourceMemoryMBean
Parameters:
username - the name of the user
password - password of the user
Throws:
java.lang.Exception - if the user already exists

addGroup

public void addGroup(java.lang.String groupname)
              throws java.lang.Exception
Add a group with a given name

Specified by:
addGroup in interface JResourceMemoryMBean
Parameters:
groupname - the name of the group
Throws:
java.lang.Exception - if the group already exists

addRole

public void addRole(java.lang.String rolename)
             throws java.lang.Exception
Add a role with a given name

Specified by:
addRole in interface JResourceMemoryMBean
Parameters:
rolename - the name of the role
Throws:
java.lang.Exception - if the role already exists

removeUser

public void removeUser(java.lang.String username)
                throws java.lang.Exception
Remove a user with a given principal

Specified by:
removeUser in interface JResourceMemoryMBean
Parameters:
username - the name of the user
Throws:
java.lang.Exception - if the user was not found

removeGroup

public void removeGroup(java.lang.String groupname)
                 throws java.lang.Exception
Remove a group with a given name

Specified by:
removeGroup in interface JResourceMemoryMBean
Parameters:
groupname - the name of the group
Throws:
java.lang.Exception - if the group was not found

removeRole

public void removeRole(java.lang.String rolename)
                throws java.lang.Exception
Remove a role with a given name

Specified by:
removeRole in interface JResourceMemoryMBean
Parameters:
rolename - the name of the role
Throws:
java.lang.Exception - if the role was not found

toXML

public java.lang.String toXML()
String representation of the MemoryRealm

Returns:
the xml representation of the MemoryRealm

toString

public java.lang.String toString()
The string representation of this realm is the XML

Overrides:
toString in class java.lang.Object
Returns:
XML representation

getReference

public 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
Specified by:
getReference in class JResource
Returns:
the non-null Reference of the object.
Throws:
javax.naming.NamingException - if a naming exception was encountered while retrieving the reference.

listRoles

public java.lang.String[] listRoles()
Get the roles

Specified by:
listRoles in interface JResourceMemoryMBean
Returns:
the array of the roles

listGroups

public java.lang.String[] listGroups()
Get the groups

Specified by:
listGroups in interface JResourceMemoryMBean
Returns:
the array of the groups

removeMBeans

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

Specified by:
removeMBeans in class JResource
Throws:
JResourceException - if the MBeans can not be removed