@Deprecated public class Policy extends Object implements Cloneable
Policy
represents a policy definition.
A policy contains a set of rules associated with a collection of
users and conditions. The policy object is saved in the data store
only when the store
method of the Policy
is
called, or if the methods addPolicy
or replacePolicy
of PolicyManager
instance is invoked with this policy.
The Policy
object is accessible to policy evaluation and
enforcement points only after it is saved in data store.Constructor and Description |
---|
Policy(String policyName)
Deprecated.
Constructs a policy given the policy name.
|
Policy(String policyName,
String description)
Deprecated.
Constructs a policy given the policy name and description.
|
Policy(String policyName,
String description,
boolean referralPolicy)
Deprecated.
Constructs a policy given the policy name,description and a
referralPolicy flag.
|
Policy(String policyName,
String description,
boolean referralPolicy,
boolean active)
Deprecated.
Constructs a policy given the policy name , description,
referralPolicy flag, and active flag
|
Modifier and Type | Method and Description |
---|---|
void |
addCondition(String name,
Condition condition)
Deprecated.
Adds a new policy condition.
|
void |
addRealmSubject(SSOToken token,
String subjectName,
String realmName,
boolean exclusive)
Deprecated.
Adds a reference in the policy to a Subject defined at the realm.
|
void |
addRealmSubject(String subjectName,
SubjectTypeManager stm,
boolean exclusive)
Deprecated.
Adds a reference in the policy to a Subject defined at the realm.
|
void |
addReferral(String name,
Referral referral)
Deprecated.
Adds a new policy referral.
|
void |
addRule(Rule rule)
Deprecated.
Adds a new policy rule.
|
void |
addSubject(String name,
Subject subject)
Deprecated.
Adds a new policy subject.
|
void |
addSubject(String name,
Subject subject,
boolean exclusive)
Deprecated.
Adds a new policy subject.
|
Condition |
getCondition(String condition)
Deprecated.
Gets the condition object identified by name.
|
Set |
getConditionNames()
Deprecated.
Get the set of condition names associated with the policy.
|
String |
getDescription()
Deprecated.
Gets the description for the policy.
|
String |
getName()
Deprecated.
Gets the name of the policy.
|
String |
getOrganizationName()
Deprecated.
Gets the organization name under which the policy is created
This would be set only for policies that have been read from data store.
|
Referral |
getReferral(String referralName)
Deprecated.
Gets the Referral object identified by name.
|
Set |
getReferralNames()
Deprecated.
Get the
Set of referral names associated with the policy. |
Rule |
getRule(String ruleName)
Deprecated.
Gets the rule object identified by name.
|
Set |
getRuleNames()
Deprecated.
Gets the set of rule names associated with the policy.
|
Subject |
getSubject(String subjectName)
Deprecated.
Gets the Subject object identified by name.
|
Set |
getSubjectNames()
Deprecated.
Get the
Set of subject names associated with the policy. |
boolean |
isActive()
Deprecated.
Checks whether the policy is active or inactive
An inactive policy is not used to make policy evaluations.
|
boolean |
isRealmSubject(String subjectName)
Deprecated.
Checks if the subjectName is a reference to a Subject
defined at the realm
|
boolean |
isReferralPolicy()
Deprecated.
Checks whether the policy is a referral policy.
|
boolean |
isSubjectExclusive(String subjectName)
Deprecated.
Checks if the subject is exclusive.
|
void |
removeCondition(Condition condition)
Deprecated.
Removes the
Condition object identified by
object's equals method. |
Condition |
removeCondition(String condition)
Deprecated.
Removes the condition with the given name.
|
void |
removeReferral(Referral referral)
Deprecated.
Removes the
Referral object identified by
object's equals method. |
Referral |
removeReferral(String referralName)
Deprecated.
Removes the referral with the given name.
|
Rule |
removeRule(String ruleName)
Deprecated.
Removes the
Rule with the given name. |
Subject |
removeSubject(String subjectName)
Deprecated.
Removes the subject with the given name.
|
void |
removeSubject(Subject subject)
Deprecated.
Removes the
Subject object identified by
object's equals method. |
void |
replaceCondition(String name,
Condition condition)
Deprecated.
Replaces an existing condition with the same name by the
current one.
|
void |
replaceReferral(String name,
Referral referral)
Deprecated.
Replaces an existing referral with the same name by the
current one.
|
void |
replaceRule(Rule rule)
Deprecated.
Replaces an existing rule with the same name by the
current one.
|
void |
replaceSubject(String name,
Subject subject)
Deprecated.
Replaces an existing subject with the same name by the
current one.
|
void |
replaceSubject(String name,
Subject subject,
boolean exclusive)
Deprecated.
Replaces an existing subject with the same name by the
current one.
|
void |
setActive(boolean active)
Deprecated.
Set the active flag for policy.
|
void |
setDescription(String description)
Deprecated.
Sets the description for the policy.
|
void |
setName(String policyName)
Deprecated.
Sets the name of the policy.
|
void |
store(SSOToken token,
String name)
Deprecated.
Stores the policy object in a persistent data store
under the organization, sub-organization or a container
object, specified as a parameter.
|
String |
toString()
Deprecated.
Gets string representation of the policy object.
|
String |
toXML()
Deprecated.
Returns the serialized policy in XML
|
public Policy(String policyName) throws InvalidNameException
policyName
- name of the policyInvalidNameException
- if policy name is not validpublic Policy(String policyName, String description) throws InvalidNameException
policyName
- name of the policydescription
- description for the policyInvalidNameException
- if policy name is not validpublic Policy(String policyName, String description, boolean referralPolicy) throws InvalidNameException
policyName
- name of the policydescription
- description for the policyreferralPolicy
- indicates whether the policy is a
referral policy or a standard policy.
A referral policy is used only to delegate policy definitions to
sub/peer organizations. A referral policy does not make use of any
action valuesInvalidNameException
- if policy name is not validpublic Policy(String policyName, String description, boolean referralPolicy, boolean active) throws InvalidNameException
policyName
- name of the policydescription
- description for the policyreferralPolicy
- indicates whether the policy is a
referral policy or a standard policy.active
- indicates if the policy is active or not.
A referral policy is used only to delegate policy definitions to
sub/peer organizations. A referral policy does not make use of any
action valuesInvalidNameException
- if policy name is not validpublic String getName()
public void setName(String policyName) throws InvalidNameException
policyName
- name of the policy.InvalidNameException
- if policyName
is an invalid
name.public String getOrganizationName()
null
public String getDescription()
null
.public void setDescription(String description) throws InvalidNameException
description
- description for the policyInvalidNameException
- if the description is invalidpublic boolean isReferralPolicy()
true
if this is a referral policy.
Otherwise returns false
public boolean isActive()
true
if this is an active policy.
Otherwise returns false
public void setActive(boolean active)
active
- boolean
representing active or inactive.public Set getRuleNames()
Set
of rule namespublic Rule getRule(String ruleName) throws NameNotFoundException
ruleName
- name of rule.Rule
object.NameNotFoundException
- if a Rule
with the given
name does not existpublic void addRule(Rule rule) throws NameAlreadyExistsException, InvalidNameException
rule
- rule object to be added to the policyNameAlreadyExistsException
- a rule with the given name
already existsInvalidNameException
- if the rule name is invalid
same service name as the policypublic void replaceRule(Rule rule) throws InvalidNameException
Rule
with the same name does not exist,
it will be added.rule
- Rule
that will replace an existing rule
with the same nameInvalidNameException
- if Rule
name is invalidpublic Rule removeRule(String ruleName)
Rule
with the given name.ruleName
- name of the ruleRule
object being removed;
if not present returns null
public Set getSubjectNames()
Set
of subject names associated with the policy.Set
of String objects representing subject namespublic Subject getSubject(String subjectName) throws NameNotFoundException
subjectName
- name of subject.Subject
objectNameNotFoundException
- if a Subject with the given name
does not existpublic void addSubject(String name, Subject subject) throws NameAlreadyExistsException, InvalidNameException
name
- name of the Subject instancesubject
- Subject object to be added to the policyNameAlreadyExistsException
- if a Subject with the given name
already existsInvalidNameException
- if the subject name is invalidpublic void addRealmSubject(SSOToken token, String subjectName, String realmName, boolean exclusive) throws NameAlreadyExistsException, InvalidNameException, PolicyException, SSOException
token
- SSOToken of the user adding the subjectsubjectName
- name of the Subject as defined at the realmrealmName
- name of the realm in which the subject is definedNameAlreadyExistsException
- if a Subject with the given name
already exists in the policyInvalidNameException
- if the subject name is invalid
or the subject is not found at the realmSSOException
- if the SSO token is invalidPolicyException
- if the subject could not be added
for any other reasonpublic void addRealmSubject(String subjectName, SubjectTypeManager stm, boolean exclusive) throws NameAlreadyExistsException, InvalidNameException, PolicyException, SSOException
subjectName
- name of the Subject as defined at the realmstm
- SubjectTypeManager
of the realm.
You have to pass the SubjectTypeManager of realm in which
you would save the policy. Trying to save the policy at
a different realm would throw PolicyException.NameAlreadyExistsException
- if a Subject with the given name
already exists in the policyInvalidNameException
- if the subject name is invalid
or the subject is not found at the realmSSOException
- if the SSO token is invalidPolicyException
- if the subject could not be added
for any other reasonpublic void addSubject(String name, Subject subject, boolean exclusive) throws NameAlreadyExistsException, InvalidNameException
name
- name of the Subject instancesubject
- Subject object to be added to the policyexclusive
- boolean flag indicating whether the subject
is to be exclusive subject. If subject is exclusive,
policy applies to users who are not members of the
subject. Otherwise, policy applies to members of the subject.NameAlreadyExistsException
- if a Subject with the given name
already existsInvalidNameException
- if the subject name is invalidpublic void replaceSubject(String name, Subject subject) throws NameNotFoundException
name
- name of the Subject instancesubject
- Subject that will replace an existing Subject
with the same nameNameNotFoundException
- if a Subject instance
with the given name is not presentpublic void replaceSubject(String name, Subject subject, boolean exclusive) throws NameNotFoundException
name
- name of the Subject instancesubject
- Subject that will replace an existing Subject
with the same nameexclusive
- boolean flag indicating whether the subject
is to be exclusive subject. If subject is exclusive,
policy applies to users who are not members of the
subject. Otherwise, policy applies to members of the subject.NameNotFoundException
- if a Subject instance
with the given name is not presentpublic Subject removeSubject(String subjectName)
subjectName
- name of the Subjectnull
public void removeSubject(Subject subject)
Subject
object identified by
object's equals
method. If a Subject instance
does not exist, the method will return silently.subject
- Subject object that
will be removed from the user collectionpublic boolean isSubjectExclusive(String subjectName) throws NameNotFoundException
subjectName
- name of the subjecttrue
if the subject is exclusive, false
otherwise.NameNotFoundException
- if the subject with the given
subjectName
does not exist in the policy.public boolean isRealmSubject(String subjectName) throws NameNotFoundException
subjectName
- name of the subjecttrue
if the subject is a reference to a
Subject defined at the realm, false
otherwise.NameNotFoundException
- if the subject with the given
subjectName
does not exist in the policy.public Set getReferralNames()
Set
of referral names associated with the policy.Set
of referral namespublic Referral getReferral(String referralName) throws NameNotFoundException
referralName
- name of referral.Referral
objectNameNotFoundException
- if a Referral with the given name
does not existpublic void addReferral(String name, Referral referral) throws NameAlreadyExistsException, InvalidNameException
name
- name of the Referral
instancereferral
- Referral
object to be added to the policyNameAlreadyExistsException
- if a Referral with the given name
already existsInvalidNameException
- if the referral name is invalidpublic void replaceReferral(String name, Referral referral) throws NameNotFoundException
name
- name of the Referral
instancereferral
- Referral
that will replace an existing
Referral with the same nameNameNotFoundException
- if a Referral instance
with the given name is not presentpublic Referral removeReferral(String referralName)
referralName
- name of the Referral
Referral
object being removed;
if not present returns null
public void removeReferral(Referral referral)
Referral
object identified by
object's equals
method. If a Referral instance
does not exist, the method will return silently.referral
- Referral object that will be removedpublic Set getConditionNames()
Set
of condition namespublic Condition getCondition(String condition) throws NameNotFoundException
condition
- name of condition.Condition
object.NameNotFoundException
- if a Condition with the given name
does not exist.public void addCondition(String name, Condition condition) throws NameAlreadyExistsException, InvalidNameException
name
- name of the Condition instancecondition
- Condition object to be added to the policyNameAlreadyExistsException
- if a Condition with the given name
already existsInvalidNameException
- if the condition name is invalidpublic void replaceCondition(String name, Condition condition) throws NameNotFoundException
name
- name of the Condition
instancecondition
- Condition
that will replace an
existing Condition with the same nameNameNotFoundException
- if a Condition instance
with the given name is not presentpublic Condition removeCondition(String condition)
condition
- name of the Condition
null
public void removeCondition(Condition condition)
Condition
object identified by
object's equals
method. If a condition instance
does not exist, the method will return silently.condition
- Condition object that will be removedpublic void store(SSOToken token, String name) throws SSOException, NoPermissionException, NameAlreadyExistsException, NameNotFoundException, PolicyException
dn
) or slash "/" separated
as per SMS. This method
uses the SSOToken
provided to perform the store
operation, and hence if the single sign token has expired
SSOException
will be thrown, and if the
user does not have the required privileges
NoPermissionException
exception will be thrown.
If a policy with the same name exists for the organization
the method will throw NameAlreadyExistsException
.
And if the organization name does not exist, the method
will throw NameNotFoundException
.
token
- SSO token of the user managing policyname
- name of the organization, sub-organization or
a container in which the policy will be stored.SSOException
- invalid or expired single-sign-on tokenNoPermissionException
- user does not have sufficient
privileges to add policyNameAlreadyExistsException
- a policy with the same
name already existsNameNotFoundException
- the given organization name
does not existPolicyException
- for any other abnormal conditionpublic String toXML()
Copyright © 2010-2018, ForgeRock All Rights Reserved.