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

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.objectweb.jonas.management.reconfig.emitter.ReconfigEmitter
          extended by org.objectweb.jonas.security.realm.factory.AbstractJResource
              extended by org.objectweb.jonas.security.realm.factory.JResourceMemory
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Referenceable, JResource, JResourceMBean, JResourceMemoryMBean

public class JResourceMemory
extends AbstractJResource
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.reconfig.emitter.ReconfigEmitter
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
JResourceMemory()
          Constructor .
 
Method Summary
 void addGroup(Group group)
          Add a group to this resource.
 void addGroup(String groupname)
          Add a group with a given name
 void addRole(Role role)
          Add a role to this resource.
 void addRole(String rolename)
          Add a role with a given name
 void addUser(String username, String password)
          Add a user with a given principal and credential
 void addUser(User user)
          Add a user to this resource.
 JUser findUser(String name)
          Check if a user is found and return it
 ArrayList getArrayListCombinedRoles(JUser user)
          Get all the roles (from the roles and from the groups) of the given user
 Hashtable getGroups()
          Return all the groups
 Reference getReference()
          Retrieves the Reference of the object.
 Hashtable getRoles()
          Return all the roles
 boolean isValidUser(JUser user, String credentials)
          Check if the given credential is the right credential for the given user
 String[] listGroups()
          Get the groups
 String[] listRoles()
          Get the roles
 void removeGroup(String groupname)
          Remove a group with a given name
 void removeMBeans()
          Remove all the MBeans used by this resource
 void removeRole(String rolename)
          Remove a role with a given name
 void removeUser(String username)
          Remove a user with a given principal
 void setGroups(Hashtable groups)
          Set the groups
 void setRoles(Hashtable roles)
          Set the roles
 String toString()
          The string representation of this realm is the XML
 String toXML()
          String representation of the MemoryRealm
 
Methods inherited from class org.objectweb.jonas.security.realm.factory.AbstractJResource
addNotificationListener, clearCache, getLogger, getName, getSequenceNumber, getUsers, registerGroupMBean, registerMBean, registerRoleMBean, registerUserMBean, saveConfig, setLogger, setName, setUsers, unregisterGroupMBean, unregisterMBean, unregisterRoleMBean, unregisterUserMBean
 
Methods inherited from class org.objectweb.jonas.management.reconfig.emitter.ReconfigEmitter
initLogger, sendReconfigNotification, sendSaveNotification
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
getNotificationInfo, handleNotification, removeNotificationListener, 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 Exception
Constructor . Use the super constructor

Throws:
Exception - if super constructor fail
Method Detail

addUser

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

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

addGroup

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

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

addRole

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

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

findUser

public JUser findUser(String name)
               throws JResourceException
Check if a user is found and return it

Specified by:
findUser in interface 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(JUser user,
                           String credentials)
Check if the given credential is the right credential for the given user

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

getGroups

public Hashtable getGroups()
Return all the groups

Returns:
the groups

getRoles

public Hashtable getRoles()
Return all the roles

Returns:
the roles

getArrayListCombinedRoles

public ArrayList getArrayListCombinedRoles(JUser user)
                                    throws JResourceException
Get all the roles (from the roles and from the groups) of the given user

Specified by:
getArrayListCombinedRoles in interface 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(Hashtable groups)
Set the groups

Parameters:
groups - the groups of this resource

setRoles

public void setRoles(Hashtable roles)
Set the roles

Parameters:
roles - the roles of this resource

addUser

public void addUser(String username,
                    String password)
             throws 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:
Exception - if the user already exists

addGroup

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

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

addRole

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

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

removeUser

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

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

removeGroup

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

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

removeRole

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

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

toXML

public String toXML()
String representation of the MemoryRealm

Returns:
the xml representation of the MemoryRealm

toString

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

Overrides:
toString in class Object
Returns:
XML representation

getReference

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

listRoles

public String[] listRoles()
Get the roles

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

listGroups

public 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 interface JResource
Throws:
JResourceException - if the MBeans can not be removed


Copyright © 2007 OW2 Consortium. All Rights Reserved.