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:
java.io.Serializable, javax.naming.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(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.
 JUser findUser(java.lang.String name)
          Check if a user is found and return it.
 java.util.ArrayList<java.lang.String> getArrayListCombinedRoles(JUser user)
          Get all the roles (from the roles and from the groups) of the given user.
 java.util.Hashtable<java.lang.String,Group> getGroups()
          Return all the groups.
 javax.naming.Reference getReference()
          Retrieves the Reference of the object.
 java.util.Hashtable<java.lang.String,Role> getRoles()
          Return all the roles.
 boolean isValidUser(JUser 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<java.lang.String,Group> groups)
          Set the groups.
 void setRoles(java.util.Hashtable<java.lang.String,Role> 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.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 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 JUser 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 boolean isValidUser(JUser 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

getGroups

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

Returns:
the groups

getRoles

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

Returns:
the roles

getArrayListCombinedRoles

public java.util.ArrayList<java.lang.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(java.util.Hashtable<java.lang.String,Group> groups)
Set the groups.

Parameters:
groups - the groups of this resource

setRoles

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

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?

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?

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?

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?

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.

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.

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.

Returns:
the array of the roles

listGroups

public java.lang.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 © 2010 OW2 Consortium. All Rights Reserved.