com.sun.identity.policy
Class Rule

java.lang.Object
  |
  +--com.sun.identity.policy.Rule
All Implemented Interfaces:
java.lang.Cloneable

public class Rule
extends java.lang.Object
implements java.lang.Cloneable

The class Rule provides interfaces to manage a rule that can be added to a policy. A rule constains the rule name, service type, a resource and a map containing action names and action values.


Constructor Summary
Rule(java.lang.String serviceName, java.util.Map actions)
          Constructor to create a rule object with the service name and actions.
Rule(java.lang.String serviceName, java.lang.String resourceName, java.util.Map actions)
          Constructor to create a rule object with the service name, resource name and actions.
Rule(java.lang.String ruleName, java.lang.String serviceName, java.lang.String resourceName, java.util.Map actions)
          Constructor to create a rule object with rule name, service name, resource name and actions.
 
Method Summary
 java.util.Set getActionNames()
          Returns the action names that have been set for the rule.
 java.util.Map getActionValues()
          Returns a Map of all action names and their corresponding action values that have been set in the rule.
 java.util.Set getActionValues(java.lang.String actionName)
          Returns a set of action values that have been set for the specified action name.
 java.lang.String getName()
          Returns the name assigned to the rule.
 java.lang.String getResourceName()
          Returns the resource name for which the rule has been created.
 java.lang.String getServiceTypeName()
          Returns the service name for which the rule has been created.
 void setActionValues(java.util.Map actionValues)
          Sets the action names and their corresponding actions values (or permissions) for the resource or the service.
 void setName(java.lang.String ruleName)
          Sets the name for the rule.
 java.lang.String toXML()
          Returns an XML string representing the rule.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rule

public Rule(java.lang.String serviceName,
            java.lang.String resourceName,
            java.util.Map actions)
     throws NameNotFoundException,
            InvalidNameException
Constructor to create a rule object with the service name, resource name and actions. The actions provided as a Map must have the action name as it key and a Set containing strings as its value. The action names and action values must match the privileges defined by the service via its SMS XML file. If they do not match, InvalidNameException is thrown. Also the parameters ruleName and resourceName can be null.
Parameters:
serviceName - name of the service type as defined by the service's SMS XML
resourceName - name of the resource for the service type
actions - map of action and action values for the resource
Throws:
NameNotFoundException - the service name provided does not exist
InvalidNameException - the resource name, action name, or values is not valid

Rule

public Rule(java.lang.String serviceName,
            java.util.Map actions)
     throws NameNotFoundException,
            InvalidNameException
Constructor to create a rule object with the service name and actions. This is useful for services (and possibly action names) that do not have resource names. The actions provided as a Map must have the action name as it key and a Set containing strings as its value. The action names and action values must match the privileges defined by the service via its SMS XML file. If they do not match, InvalidNameException is thrown. Also the parameters ruleName and resourceName can be null.
Parameters:
serviceName - name of the service type as defined by the service's SMS XML
actions - map of action and action values for the resource
Throws:
NameNotFoundException - the service name provided does not exist
InvalidNameException - the resource name, action name, or values is not valid

Rule

public Rule(java.lang.String ruleName,
            java.lang.String serviceName,
            java.lang.String resourceName,
            java.util.Map actions)
     throws NameNotFoundException,
            InvalidNameException
Constructor to create a rule object with rule name, service name, resource name and actions. The actions provided as a Map must have the action name as it key and a Set containing strings as its value. The action names and action values must match the privileges defined by the service via its SMS XML file. If they do not match, InvalidNameException is thrown. Also the parameters ruleName and resourceName can be null.
Parameters:
ruleName - name of the rule
serviceName - name of the service type as defined by the service's SMS XML
resourceName - name of the resource for the service type
actions - map of action and action values for the resource
Throws:
NameNotFoundException - the service name provided does not exist
InvalidNameException - the resource name, action name, or values is not valid
Method Detail

getName

public java.lang.String getName()
Returns the name assigned to the rule. It could be null if it was not constructed with a name.
Returns:
rule name

setName

public void setName(java.lang.String ruleName)
             throws InvalidNameException
Sets the name for the rule. If a name has already been assigned, it will be replaced with the given name.
Parameters:
ruleName - rule name.
Throws:
InvalidNameException - if rule name is invalid.

getServiceTypeName

public java.lang.String getServiceTypeName()
Returns the service name for which the rule has been created. The service name of the rule cannot be changed.
Returns:
service name

getResourceName

public java.lang.String getResourceName()
Returns the resource name for which the rule has been created. If the service does not support resource names, the method will return null. However the resource name of the rule cannot be changed.
Returns:
resource name

getActionNames

public java.util.Set getActionNames()
Returns the action names that have been set for the rule. The action names returned could be the same as the service's action names or a subset of it.
Returns:
action names defined in this rule for the service

getActionValues

public java.util.Set getActionValues(java.lang.String actionName)
                              throws NameNotFoundException
Returns a set of action values that have been set for the specified action name.
Parameters:
actionName - action name for which to compute values.
Returns:
action names defined in this rule for the service
Throws:
NameNotFoundException - if actions name is not found in the rule

getActionValues

public java.util.Map getActionValues()
Returns a Map of all action names and their corresponding action values that have been set in the rule. The "key" of the Map will be the action name as a string, and its "value" will be a Set which contains the action values as strings.
Returns:
all action names and corresponding action values

setActionValues

public void setActionValues(java.util.Map actionValues)
                     throws InvalidNameException
Sets the action names and their corresponding actions values (or permissions) for the resource or the service.
Parameters:
actionValues - action names and their corresponding values
Throws:
InvalidNameException - if action name is invalid.

toXML

public java.lang.String toXML()
Returns an XML string representing the rule.
Returns:
an XML string representing the rule.


Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.