com.metamatrix.platform.security.api
Class AuthorizationRealm

java.lang.Object
  extended by com.metamatrix.platform.security.api.AuthorizationRealm
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class AuthorizationRealm
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

This class contains the realm and sub realm for an AuthorizationPermission.
It may be composed of two divisions - a super realm and a sub realm. The super realm is required and is a major grouping for AuthorizationPermissions. The sub realm is an optional and arbitrary tag that subdivides the super realm.
This object will not change during the life of an AuthorizationPermission.

See Also:
Serialized Form

Field Summary
static int MAX_DESCRIPTION_LEN
          Largest allowable description.
 
Constructor Summary
AuthorizationRealm(java.lang.String realmName)
          ctor Meant to be used only by JDBCAuthorizationTransaction to populate AuthorizationPermissions with their realm when retrieving them from the database.
AuthorizationRealm(java.lang.String superRealmName, java.lang.String subRealmName)
          ctor Must have at least a superRealmName and may have a subRealmName.
AuthorizationRealm(java.lang.String superRealmName, java.lang.String subRealmName, java.lang.String description)
          ctor Must have at least a superRealmName and may have a subRealmName.
 
Method Summary
static int compare(AuthorizationRealm obj1, AuthorizationRealm obj2)
          Utility method to compare two AuthorizationRealm instances.
 int compareTo(java.lang.Object o)
          Compares this AuthorizationRealm to another Object.
 boolean equals(java.lang.Object obj)
          Returns true if the specified object is semantically equal to this instance.
 java.lang.String getDescription()
          Get the realm description.
 java.lang.String getRealmName()
          Get the full realm name.
 java.lang.String getSubRealmName()
          Get the sub realm name.
 java.lang.String getSuperRealmName()
          Get the super realm name.
 int hashCode()
          Overrides Object hashCode method.
 void setDescription(java.lang.String description)
          Set the realm description.
 java.lang.String toString()
          Override Object method.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_DESCRIPTION_LEN

public static final int MAX_DESCRIPTION_LEN
Largest allowable description. Descriptions longer will be truncated.

See Also:
Constant Field Values
Constructor Detail

AuthorizationRealm

public AuthorizationRealm(java.lang.String realmName)
ctor Meant to be used only by JDBCAuthorizationTransaction to populate AuthorizationPermissions with their realm when retrieving them from the database.

Parameters:
realmName - The name of the realm to which an AuthorizationPermission belongs - May not be null. May be the combined super and sub realm names, in which case it will be parsed correctly. Must contain no more than 2 realm components.
Throws:
java.lang.IllegalArgumentException - if realmName contains too many components.

AuthorizationRealm

public AuthorizationRealm(java.lang.String superRealmName,
                          java.lang.String subRealmName)
ctor Must have at least a superRealmName and may have a subRealmName.

Parameters:
superRealmName - The name of the realm to which an AuthorizationPermission belongs - May not be null.
subRealmName - An arbitrary subdivision of the given realm - May be null.
Throws:
java.lang.IllegalArgumentException - if realmName contains too many components.

AuthorizationRealm

public AuthorizationRealm(java.lang.String superRealmName,
                          java.lang.String subRealmName,
                          java.lang.String description)
ctor Must have at least a superRealmName and may have a subRealmName.

Parameters:
superRealmName - The name of the realm to which an AuthorizationPermission belongs - May not be null.
subRealmName - An arbitrary subdivision of the given realm - May be null.
description - May be null.
Throws:
java.lang.IllegalArgumentException - if superRelamName is null or empty or if either superRealmName or subRealmName contain a realm delimeter char '.'.
Method Detail

getRealmName

public java.lang.String getRealmName()
Get the full realm name.

Returns:
The full realm name.

getSuperRealmName

public java.lang.String getSuperRealmName()
Get the super realm name.

Returns:
The realm name.

getSubRealmName

public java.lang.String getSubRealmName()
Get the sub realm name.

Returns:
The sub realm name - May be null.

getDescription

public java.lang.String getDescription()
Get the realm description.

Returns:
The realm description.

setDescription

public void setDescription(java.lang.String description)
Set the realm description. The description argument will be ignored if it's null or empty.

Parameters:
description - The realm description.

toString

public java.lang.String toString()
Override Object method.

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides Object hashCode method.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.
See Also:
Object.hashCode(), Object.equals(Object)

equals

public boolean equals(java.lang.Object obj)
Returns true if the specified object is semantically equal to this instance. Note: this method is consistent with compareTo().

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object that this instance is to be compared to.
Returns:
whether the object is equal to this object.

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Compares this AuthorizationRealm to another Object. If the Object is an AuthorizationRealm, this function compares the name. Otherwise, it throws a ClassCastException (as AuthorizationRealm instances are comparable only to other AuthorizationRealm instances). Note: this method is consistent with equals().

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the object that this instance is to be compared to.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object, respectively.
Throws:
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this AuthorizationRealm.

compare

public static final int compare(AuthorizationRealm obj1,
                                AuthorizationRealm obj2)
Utility method to compare two AuthorizationRealm instances. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Subclasses may not override this method because it is designed to enforce a constraint placed on all AuthorizationRealms.

This method assumes that all type-checking has already been performed.

Parameters:
obj1 - the first policyID to be compared
obj2 - the second policyID to be compared
Returns:
-1, 0, +1 based on whether obj1 is less than, equal to, or greater than obj2


Copyright © 2009. All Rights Reserved.