com.iona.security.common
Class Realm

java.lang.Object
  |
  +--com.iona.security.common.Realm

public final class Realm
extends java.lang.Object

The object which represents a realm which is or will be persisted. This may or may not also represent any associations between realms and roles. In the lightweight usage, it does not refer to those roles, it is just a container for administration which only looks at the realm itself. In the heavyweight usage it refers to the associated roles and is used indirectly when populating an AuthenticatedPrincipal. Associations with other objects are not directly represented in this object.
Note: this class is not multi-thread safe. You must add synchronization around it if you wish to share an instance among multiple threads.


Constructor Summary
Realm(java.lang.String description)
          Special constructor used for the global realm.
Realm(java.lang.String name, java.lang.String description)
          Constructor used for newly-created (not-yet-persisted) realms.
 
Method Summary
 void addRole(Role r)
          add a role
 void copyFromOptionalID(Realm realm)
          Copies data from a Realm object where the ID is optional in the source object; this method should only be used in azmgr classes.
 void createDefaultRoles()
          Creates the default roles in this realm object.
 boolean equals(java.lang.Object obj)
          Standard equality comparison.
 java.lang.String getDescription()
          Returns the realm description.
 java.lang.String getID()
          Returns the realm ID; this method should only be used in azmgr classes.
 java.lang.String getName()
          Returns the realm name.
 java.util.HashMap getRoles()
          Returns the map of roles.
 int hashCode()
          Standard hash code generation.
 boolean isGlobalRealm()
          Determines whether this realm is the global realm.
 void setDescription(java.lang.String description)
          Sets the realm description.
 void setID(java.lang.String id)
          Sets the realm ID; this method should only be used in azmgr classes.
 void setName(java.lang.String name)
          Sets the realm name.
 void setReadOnly()
          Sets the object into a non-modifiable mode.
 void setRoles(java.util.HashMap roles)
          Sets the map of roles.
 java.lang.String toString()
          Returns the string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Realm

public Realm(java.lang.String name,
             java.lang.String description)
      throws java.lang.IllegalArgumentException
Constructor used for newly-created (not-yet-persisted) realms.
Parameters:
name - the name of the realm
description - the description of the realm
Throws:
java.lang.IllegalArgumentException - if the name is invalid

Realm

public Realm(java.lang.String description)
      throws java.lang.IllegalArgumentException
Special constructor used for the global realm.
Parameters:
description - the description of the realm
Throws:
java.lang.IllegalArgumentException - if the name is invalid
Method Detail

copyFromOptionalID

public void copyFromOptionalID(Realm realm)
                        throws java.lang.IllegalArgumentException
Copies data from a Realm object where the ID is optional in the source object; this method should only be used in azmgr classes. If the ID is supplied in the source object, then the IDs must match. Otherwise the ID must be non-null in this object.
Parameters:
realm - the realm to copy from
Throws:
java.lang.IllegalArgumentException - if the role is null or the IDs do not match (if the source ID is not null) or this ID is null

getName

public java.lang.String getName()
Returns the realm name.
Returns:
the realm name

setName

public void setName(java.lang.String name)
             throws java.lang.IllegalArgumentException
Sets the realm name.
Parameters:
name - the new realm name
Throws:
java.lang.IllegalArgumentException - if the name is invalid

getID

public java.lang.String getID()
Returns the realm ID; this method should only be used in azmgr classes. Note that this may be null if the constructor without the ID was used.
Returns:
the realm ID

setID

public void setID(java.lang.String id)
           throws java.lang.IllegalArgumentException
Sets the realm ID; this method should only be used in azmgr classes.
Parameters:
id - the new realm ID.
Throws:
java.lang.IllegalArgumentException - if the ID is invalid or the realm already has an ID

getDescription

public java.lang.String getDescription()
Returns the realm description.
Returns:
the realm description

setDescription

public void setDescription(java.lang.String description)
                    throws java.lang.IllegalArgumentException
Sets the realm description.
Parameters:
description - the new realm description

getRoles

public java.util.HashMap getRoles()
Returns the map of roles. The key is the name of the role and the value is the corresponding Role object (with the same name). This may be null if no map has been set into this object.
Returns:
the map of role.

setRoles

public void setRoles(java.util.HashMap roles)
              throws java.lang.IllegalArgumentException
Sets the map of roles. The key must be the name of the role and the value is the corresponding Role object (with the same name).
Parameters:
roles - the map of roles
Throws:
java.lang.IllegalArgumentException - if the map is null

addRole

public void addRole(Role r)
add a role

createDefaultRoles

public void createDefaultRoles()
Creates the default roles in this realm object.

setReadOnly

public void setReadOnly()
Sets the object into a non-modifiable mode. After this point, the object cannot be changed and cannot be set back into a modifiable state.

isGlobalRealm

public boolean isGlobalRealm()
Determines whether this realm is the global realm.
Returns:
true iff this is the global realm

toString

public java.lang.String toString()
Returns the string representation of this object.
Overrides:
toString in class java.lang.Object
Returns:
the object in human-readable form

equals

public boolean equals(java.lang.Object obj)
Standard equality comparison. This compares the name, description, and ID fields of the object.
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare to
Returns:
a boolean indicating whether the objects are equal or not

hashCode

public int hashCode()
Standard hash code generation.
Overrides:
hashCode in class java.lang.Object
Returns:
the hash code

Documentation built [Sat Dec 11 21:11:34 2004].