com.bea.ales.management
Class PolicyQuery

java.lang.Object
  |
  +--com.bea.ales.management.PolicyQuery

public class PolicyQuery
extends java.lang.Object

This class represents a policy query. It contains all query criteria for querying policies. The query criteria include effect type, result type, action, resource, role, subject and delegator. Notice policy constraints can not be a query criterion. A PolicyQuery instance can be saved persistently and deleted by PoliciesManager.


Inner Class Summary
static class PolicyQuery.OrderType
          This class represents the order type of a policy query.
static class PolicyQuery.ResultType
          This class represents the result type of a policy query.
 
Constructor Summary
PolicyQuery(java.lang.String name, java.lang.String owner, PolicyType policyType)
          Construct the PolicyQuery instance.
 
Method Summary
 void addAction(Action action)
          Add the action to the policy query.
 void addDelegator(User delegator)
          Add the delegator to the policy query.
 void addResource(Resource resource)
          Add the resource to the policy query.
 void addRole(Role role)
          Add the role to the policy query.
 void addSubject(java.lang.Object subject)
          Add the subject to the policy query.
 java.util.List getActions()
          Get all actions of the policy query.
 AuthorizationPolicyQueryResult getAuthorizationPolicies(PoliciesManager policiesManager)
          Find all authorization policies which match this policyQuery.
 java.util.List getDelegators()
          Get all delegators of the policy query.
 PolicyEffectType getEffectType()
          Get the effect type of the policy query.
 MembershipRuleQueryResult getMembershipRules(PoliciesManager policiesManager)
          Find all membership rules which match this policyQuery.
 java.lang.String getName()
          Gets the name of the policy query.
 PolicyQuery.OrderType getOrderType()
          Get the order type of the policy query.
 java.lang.String getOwner()
          Get the owner name of the policy query.
 PolicyType getPolicyType()
          Get the policy type of the policy query.
 java.util.List getResources()
          Get all resources of the policy query.
 PolicyQuery.ResultType getResultType()
          Get the result type of the policy query.
 java.util.List getRoles()
          Get the roles of the policy query.
 java.util.List getSubjects()
          Get all subjects of the policy query.
 void removeAction(Action action)
          Remove the action from the policy query.
 void removeDelegator(User delegator)
          Remove the delegator from the policy query.
 void removeResource(Resource resource)
          Remove a resource from the policy query.
 void removeRole(Role role)
          Remove the role from the policy query.
 void removeSubject(java.lang.Object subject)
          Remove the subject from the policy query.
 void setActions(java.util.List actions)
          Set actions to the policy query.
 void setDelegators(java.util.List delegators)
          Set delegators to the policy query.
 void setEffectType(PolicyEffectType effectType)
          Set the effect type of the policy query.
 void setName(java.lang.String name)
          Set the name of the policy query.
 void setOrderType(PolicyQuery.OrderType orderType)
          Set the order type to the policy query.
 void setOwner(java.lang.String owner)
          Set the owner name to the policy query.
 void setPolicyType(PolicyType policyType)
          Set the policy type to the policy query.
 void setResources(java.util.List resources)
          Set resources to the policy query.
 void setResultType(PolicyQuery.ResultType resultType)
          Set the result type to the policy query.
 void setRoles(java.util.List roles)
          Sets role to the policy query.
 void setSubjects(java.util.List subjects)
          Set subjects to the policy query.
 java.lang.String toString()
          Convert the policy query to a text value
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PolicyQuery

public PolicyQuery(java.lang.String name,
                   java.lang.String owner,
                   PolicyType policyType)
            throws java.lang.IllegalArgumentException
Construct the PolicyQuery instance.

Parameters:
name - the name of policy query. It can not be a null or empty string, otherwise an IllegalArgumentException will be thrown.
owner - the owner name of policy query. It must be a qualified name. And it can not be a null or empty string, otherwise an IllegalArgumentException will be thrown.
policyType - the policy type which is either PolicyType.AUTHORIZATION_POLICY or PolicyType.MEMBERSHIP_RULE. It can not be null, otherwise an IllegalArgumentException will be thrown.
Throws:
java.lang.IllegalArgumentException - if one of name, owner and policyType is invalid.
Method Detail

getName

public java.lang.String getName()
Gets the name of the policy query.

Returns:
the name of the policy query.

setName

public void setName(java.lang.String name)
             throws java.lang.IllegalArgumentException
Set the name of the policy query.

Parameters:
name - the name to be set.
Throws:
java.lang.IllegalArgumentException - if name is null or empty string.

getOwner

public java.lang.String getOwner()
Get the owner name of the policy query.

Returns:
the owner name of the policy query. The name is a qualified user name.

setOwner

public void setOwner(java.lang.String owner)
              throws java.lang.IllegalArgumentException
Set the owner name to the policy query.

Parameters:
owner - the owner name to be set. The name must be a qualified user name.
Throws:
java.lang.IllegalArgumentException - if owner is null or empty string.

getPolicyType

public PolicyType getPolicyType()
                         throws ManagementException
Get the policy type of the policy query.

Returns:
the policy type of the policy query.
Throws:
ManagementException - if failed to get policy type

setPolicyType

public void setPolicyType(PolicyType policyType)
                   throws java.lang.IllegalArgumentException,
                          ManagementException
Set the policy type to the policy query.

Parameters:
policyType - the policy type to the policy query.
Throws:
java.lang.IllegalArgumentException - if the policyType is null
ManagementException - if failed to set policy type

getEffectType

public PolicyEffectType getEffectType()
                               throws ManagementException
Get the effect type of the policy query.

Returns:
the effect type of the policy query.
Throws:
ManagementException - if failed to get effect type

setEffectType

public void setEffectType(PolicyEffectType effectType)
                   throws ManagementException
Set the effect type of the policy query.

Parameters:
effectType - the effect type of the policy query.
Throws:
ManagementException - if failed to set effect type

getActions

public java.util.List getActions()
                          throws ManagementException
Get all actions of the policy query.

Returns:
list of actions as Action.
Throws:
ManagementException - if failed to get actions

setActions

public void setActions(java.util.List actions)
                throws ManagementException
Set actions to the policy query.

Parameters:
actions - list of actions as Action. The null or empty list indicate any action.
Throws:
ManagementException - if failed to set actions.

addAction

public void addAction(Action action)
               throws java.lang.IllegalArgumentException,
                      ManagementException
Add the action to the policy query.

Parameters:
action - the action to be added.
Throws:
java.lang.IllegalArgumentException - if action is null.
ManagementException - if failed to add action

removeAction

public void removeAction(Action action)
                  throws java.lang.IllegalArgumentException,
                         ManagementException
Remove the action from the policy query.

Parameters:
action - the action to be removed.
Throws:
java.lang.IllegalArgumentException - if action is null or this policy query doesn't contain the action.
ManagementException - if failed to remove action

getRoles

public java.util.List getRoles()
                        throws ManagementException
Get the roles of the policy query.

Returns:
list of roles as Role.
Throws:
ManagementException - if failed to get roles

setRoles

public void setRoles(java.util.List roles)
              throws ManagementException
Sets role to the policy query.

Parameters:
roles - list of roles as Role.
Throws:
ManagementException - if failed to set roles

addRole

public void addRole(Role role)
             throws java.lang.IllegalArgumentException,
                    ManagementException
Add the role to the policy query.

Parameters:
role - the role to be added.
Throws:
java.lang.IllegalArgumentException - if role is null.
ManagementException - if failed to add role

removeRole

public void removeRole(Role role)
                throws java.lang.IllegalArgumentException,
                       ManagementException
Remove the role from the policy query.

Parameters:
role - the role to be removed.
Throws:
java.lang.IllegalArgumentException - if role is null or this policy query doesn't contain the role.
ManagementException - if failed to remove role

getResources

public java.util.List getResources()
                            throws ManagementException
Get all resources of the policy query.

Returns:
list of resources as Resource.
Throws:
ManagementException - if failed to get resources

setResources

public void setResources(java.util.List resources)
                  throws ManagementException
Set resources to the policy query.

Parameters:
resources - list of resources as Resource.
Throws:
ManagementException - if failed to set resources

addResource

public void addResource(Resource resource)
                 throws java.lang.IllegalArgumentException,
                        ManagementException
Add the resource to the policy query.

Parameters:
resource - the resource to be added.
Throws:
java.lang.IllegalArgumentException - if resource is null.
ManagementException - if failed to add resource

removeResource

public void removeResource(Resource resource)
                    throws java.lang.IllegalArgumentException,
                           ManagementException
Remove a resource from the policy query.

Parameters:
resource - the resource to be removed.
Throws:
java.lang.IllegalArgumentException - if resource is null or this policy query doesn't contain the resource.
ManagementException - if failed to remove resource

getSubjects

public java.util.List getSubjects()
                           throws ManagementException
Get all subjects of the policy query.

Returns:
list of subjects. If the policy type is PolicyType.AUTHORIZATION_POLICY, the possilbe type of subject is User, Group or Role. If the policy type is PolicyType.MEMBERSHIP_RULE, the possible type of subject is User or Group.
Throws:
ManagementException - if failed to get subjects

setSubjects

public void setSubjects(java.util.List subjects)
                 throws ManagementException
Set subjects to the policy query.

Parameters:
subjects - list of subjects to be set. If the policy type is PolicyType.AUTHORIZATION_POLICY, the possible type of subject is User, Group or Role. If the policy type is PolicyType.MEMBERSHIP_RULE, the possible type of subject is User or Group.
Throws:
ManagementException - if failed to set subjects

addSubject

public void addSubject(java.lang.Object subject)
                throws java.lang.IllegalArgumentException,
                       ManagementException
Add the subject to the policy query.

Parameters:
subject - the subject to be added. If the policy type is PolicyType.AUTHORIZATION_POLICY, the possible type of subject is User, Group or Role. If the policy type is PolicyType.MEMBERSHIP_RULE, the possible type of subject is User or Group.
Throws:
java.lang.IllegalArgumentException - if subject is null or its type is invalid.
ManagementException - if failed to add subject

removeSubject

public void removeSubject(java.lang.Object subject)
                   throws java.lang.IllegalArgumentException,
                          ManagementException
Remove the subject from the policy query.

Parameters:
subject - the subject to be removed. If the policy type is PolicyType.AUTHORIZATION_POLICY, the possible type of subject is User, Group or Role. If the policy type is PolicyType.MEMBERSHIP_RULE, the possible type of subject is User or Group.
Throws:
java.lang.IllegalArgumentException - if subject is null or its type is invalid or this policy query doesn't contain the subject.
ManagementException - if failed to remove subject

getDelegators

public java.util.List getDelegators()
                             throws ManagementException
Get all delegators of the policy query.

Returns:
list of delegators as User.
Throws:
ManagementException - if failed to get delegators

setDelegators

public void setDelegators(java.util.List delegators)
                   throws ManagementException
Set delegators to the policy query.

Parameters:
delegators - list of delegators as User.
Throws:
ManagementException - if failed to set delegators

addDelegator

public void addDelegator(User delegator)
                  throws java.lang.IllegalArgumentException,
                         ManagementException
Add the delegator to the policy query.

Parameters:
delegator - a delegator to be added.
Throws:
java.lang.IllegalArgumentException - if delegator is null.
ManagementException - if failed to add delegator

removeDelegator

public void removeDelegator(User delegator)
                     throws java.lang.IllegalArgumentException,
                            ManagementException
Remove the delegator from the policy query.

Parameters:
delegator - the delegator to be removed.
Throws:
java.lang.IllegalArgumentException - if delegator is null or this policy query doesn't contain the delegator.
ManagementException - if failed to remove delegator

getResultType

public PolicyQuery.ResultType getResultType()
                                     throws ManagementException
Get the result type of the policy query.

Returns:
the result type of the policy query.
Throws:
ManagementException - if failed to get ResultType

setResultType

public void setResultType(PolicyQuery.ResultType resultType)
                   throws ManagementException
Set the result type to the policy query.

Parameters:
resultType - the result type to be set.
Throws:
ManagementException - if failed to set ResultType

getOrderType

public PolicyQuery.OrderType getOrderType()
                                   throws ManagementException
Get the order type of the policy query.

Returns:
the order type of the policy query.
Throws:
ManagementException - if failed to getOrderType

setOrderType

public void setOrderType(PolicyQuery.OrderType orderType)
                  throws ManagementException
Set the order type to the policy query.

Parameters:
orderType - the order type to the policy query.
Throws:
ManagementException - if failed to set OrderType

toString

public java.lang.String toString()
Convert the policy query to a text value

Returns:
the text value of the policy query
Throws:
java.lang.IllegalStateException - if failed to convert this policy query to a string
Overrides:
toString in class java.lang.Object

getAuthorizationPolicies

public AuthorizationPolicyQueryResult getAuthorizationPolicies(PoliciesManager policiesManager)
                                                        throws ManagementException
Find all authorization policies which match this policyQuery.

Parameters:
policiesManager - by which policy query to be executed.
Returns:
authorization policies which match the policyQuery.
Throws:
java.lang.IllegalStateException - if this policy type is not PolicyType.AUTHORIZATION_POLICY
ManagementException - if failed to retrieve authorization policy.

getMembershipRules

public MembershipRuleQueryResult getMembershipRules(PoliciesManager policiesManager)
                                             throws java.lang.IllegalStateException,
                                                    ManagementException
Find all membership rules which match this policyQuery.

Parameters:
policiesManager - by which policy query to be executed.
Returns:
membership rules which match policyQuery
Throws:
java.lang.IllegalStateException - if this policy type is not PolicyType.MEMBERSHIP_RULE
ManagementException - if failed to retrieve membership rules


Copyright © 2004-2008, Oracle and/or its affiliates. All rights reserved.