org.ow2.jonas.security.internal.realm.factory
Class JResourceMemory

java.lang.Object
  extended by org.ow2.jonas.lib.management.javaee.ManagedObject
      extended by org.ow2.jonas.security.internal.realm.factory.AbstractJResource
          extended by org.ow2.jonas.security.internal.realm.factory.JResourceMemory
All Implemented Interfaces:
Serializable, Referenceable, JResource

public class JResourceMemory
extends AbstractJResource

This class extends the JResource class for the Memory implementation.

Author:
Florent Benoit
See Also:
Serialized Form

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<String> getArrayListCombinedRoles(JUser user)
          Get all the roles (from the roles and from the groups) of the given user.
 Hashtable<String,Group> getGroups()
          Return all the groups.
 Reference getReference()
          Retrieves the Reference of the object.
 Hashtable<String,Role> 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<String,Group> groups)
          Set the groups.
 void setRoles(Hashtable<String,Role> 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.ow2.jonas.security.internal.realm.factory.AbstractJResource
clearCache, getLogger, getName, getSequenceNumber, getUsers, registerGroupMBean, registerRoleMBean, registerUserMBean, saveConfig, setDomainName, setJmxService, setLogger, setName, setSecurityService, setUsers, unregisterGroupMBean, unregisterRoleMBean, unregisterUserMBean
 
Methods inherited from class org.ow2.jonas.lib.management.javaee.ManagedObject
getModelMBean, sendNotification, sendReconfigNotification, sendSaveNotification, setModelMBean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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.

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.

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

getGroups

public Hashtable<String,Group> getGroups()
Return all the groups.

Returns:
the groups

getRoles

public Hashtable<String,Role> getRoles()
Return all the roles.

Returns:
the roles

getArrayListCombinedRoles

public ArrayList<String> getArrayListCombinedRoles(JUser 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

setGroups

public void setGroups(Hashtable<String,Group> groups)
Set the groups.

Parameters:
groups - the groups of this resource

setRoles

public void setRoles(Hashtable<String,Role> 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.

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?

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?

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?

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?

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.

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.

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.

Returns:
the array of the roles

listGroups

public String[] listGroups()
Get the groups.

Returns:
the array of the groups

removeMBeans

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

Throws:
JResourceException - if the MBeans can not be removed


Copyright © 2011 OW2 Consortium. All Rights Reserved.