Package com.sun.identity.policy
Class Policy
java.lang.Object
com.sun.identity.policy.Policy
- All Implemented Interfaces:
Cloneable
Deprecated.
The class
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 Summary
ConstructorDescriptionDeprecated.Constructs a policy given the policy name.Deprecated.Constructs a policy given the policy name and description.Deprecated.Constructs a policy given the policy name,description and a referralPolicy flag.Deprecated.Constructs a policy given the policy name , description, referralPolicy flag, and active flag -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
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.getCondition
(String condition) Deprecated.Gets the condition object identified by name.Deprecated.Get the set of condition names associated with the policy.Deprecated.Gets the description for the policy.getName()
Deprecated.Gets the name of the policy.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.getReferral
(String referralName) Deprecated.Gets the Referral object identified by name.Deprecated.Get theSet
of referral names associated with the policy.Deprecated.Gets the rule object identified by name.Deprecated.Gets the set of rule names associated with the policy.getSubject
(String subjectName) Deprecated.Gets the Subject object identified by name.Deprecated.Get theSet
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 realmboolean
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 theCondition
object identified by object'sequals
method.removeCondition
(String condition) Deprecated.Removes the condition with the given name.void
removeReferral
(Referral referral) Deprecated.Removes theReferral
object identified by object'sequals
method.removeReferral
(String referralName) Deprecated.Removes the referral with the given name.removeRule
(String ruleName) Deprecated.Removes theRule
with the given name.void
removeSubject
(Subject subject) Deprecated.Removes theSubject
object identified by object'sequals
method.removeSubject
(String subjectName) Deprecated.Removes the subject with the given name.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
Deprecated.Sets the name of the policy.void
Deprecated.Stores the policy object in a persistent data store under the organization, sub-organization or a container object, specified as a parameter.toString()
Deprecated.Gets string representation of the policy object.toXML()
Deprecated.Returns the serialized policy in XML
-
Constructor Details
-
Policy
Deprecated.Constructs a policy given the policy name.- Parameters:
policyName
- name of the policy- Throws:
InvalidNameException
- if policy name is not valid
-
Policy
Deprecated.Constructs a policy given the policy name and description.- Parameters:
policyName
- name of the policydescription
- description for the policy- Throws:
InvalidNameException
- if policy name is not valid
-
Policy
@Supported public Policy(String policyName, String description, boolean referralPolicy) throws InvalidNameException Deprecated.Constructs a policy given the policy name,description and a referralPolicy flag.- Parameters:
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 values- Throws:
InvalidNameException
- if policy name is not valid
-
Policy
@Supported public Policy(String policyName, String description, boolean referralPolicy, boolean active) throws InvalidNameException Deprecated.Constructs a policy given the policy name , description, referralPolicy flag, and active flag- Parameters:
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 values- Throws:
InvalidNameException
- if policy name is not valid
-
-
Method Details
-
getName
Deprecated.Gets the name of the policy.- Returns:
- name of the policy
-
setName
Deprecated.Sets the name of the policy.- Parameters:
policyName
- name of the policy.- Throws:
InvalidNameException
- ifpolicyName
is an invalid name.
-
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. Otherwise this would benull
- Returns:
- the organization name under which the policy is created
-
getDescription
Deprecated.Gets the description for the policy. If the description for the policy has not been set the method will return an empty string; notnull
.- Returns:
- description of the policy
-
setDescription
Deprecated.Sets the description for the policy.- Parameters:
description
- description for the policy- Throws:
InvalidNameException
- if the description is invalid
-
isReferralPolicy
Deprecated.Checks whether the policy is a referral 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 values- Returns:
true
if this is a referral policy. Otherwise returnsfalse
-
isActive
Deprecated.Checks whether the policy is active or inactive An inactive policy is not used to make policy evaluations.- Returns:
true
if this is an active policy. Otherwise returnsfalse
-
setActive
Deprecated.Set the active flag for policy. An inactive policy is not used to make policy evaluations.- Parameters:
active
-boolean
representing active or inactive.
-
getRuleNames
Deprecated.Gets the set of rule names associated with the policy.- Returns:
Set
of rule names
-
getRule
Deprecated.Gets the rule object identified by name.- Parameters:
ruleName
- name of rule.- Returns:
Rule
object.- Throws:
NameNotFoundException
- if aRule
with the given name does not exist
-
addRule
Deprecated.Adds a new policy rule.- Parameters:
rule
- rule object to be added to the policy- Throws:
NameAlreadyExistsException
- a rule with the given name already existsInvalidNameException
- if the rule name is invalid same service name as the policy
-
replaceRule
Deprecated.Replaces an existing rule with the same name by the current one. If aRule
with the same name does not exist, it will be added.- Parameters:
rule
-Rule
that will replace an existing rule with the same name- Throws:
InvalidNameException
- ifRule
name is invalid
-
removeRule
Deprecated.Removes theRule
with the given name.- Parameters:
ruleName
- name of the rule- Returns:
- returns the
Rule
object being removed; if not present returnsnull
-
getSubjectNames
Deprecated.Get theSet
of subject names associated with the policy.- Returns:
Set
of String objects representing subject names
-
getSubject
Deprecated.Gets the Subject object identified by name.- Parameters:
subjectName
- name of subject.- Returns:
Subject
object- Throws:
NameNotFoundException
- if a Subject with the given name does not exist
-
addSubject
@Supported public void addSubject(String name, Subject subject) throws NameAlreadyExistsException, InvalidNameException Deprecated.Adds a new policy subject. The subject is added as a normal (non exclusive) subject. So, policy will apply to members of the subject. The policy will apply to a user if he is a member of any normal (non exclusive) subject in the policy or not a member of any exclusive subject in the policy.- Parameters:
name
- name of the Subject instancesubject
- Subject object to be added to the policy- Throws:
NameAlreadyExistsException
- if a Subject with the given name already existsInvalidNameException
- if the subject name is invalid
-
addRealmSubject
@Supported public void addRealmSubject(SSOToken token, String subjectName, String realmName, boolean exclusive) throws NameAlreadyExistsException, InvalidNameException, PolicyException, SSOException Deprecated.Adds a reference in the policy to a Subject defined at the realm.- Parameters:
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 defined- Throws:
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 reason
-
addRealmSubject
@Supported public void addRealmSubject(String subjectName, SubjectTypeManager stm, boolean exclusive) throws NameAlreadyExistsException, InvalidNameException, PolicyException, SSOException Deprecated.Adds a reference in the policy to a Subject defined at the realm.- Parameters:
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.- Throws:
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 reason
-
addSubject
@Supported public void addSubject(String name, Subject subject, boolean exclusive) throws NameAlreadyExistsException, InvalidNameException Deprecated.Adds a new policy subject. The policy will apply to a user if he is a member of any normal (non exclusive) subject in the policy or not a member of any exclusive subject in the policy.- Parameters:
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.- Throws:
NameAlreadyExistsException
- if a Subject with the given name already existsInvalidNameException
- if the subject name is invalid
-
replaceSubject
Deprecated.Replaces an existing subject with the same name by the current one. If a subject with the same name does not exist, it will be added. The subject is replaced as a normal (non exclusive) subject. So, policy will apply to members of the subject. The policy will apply to a user if he is a member of any normal (non exclusive) subject subject in the policy or not a member of any exclusive subject subject in the policy.- Parameters:
name
- name of the Subject instancesubject
- Subject that will replace an existing Subject with the same name- Throws:
NameNotFoundException
- if a Subject instance with the given name is not present
-
replaceSubject
@Supported public void replaceSubject(String name, Subject subject, boolean exclusive) throws NameNotFoundException Deprecated.Replaces an existing subject with the same name by the current one. If a subject with the same name does not exist, it will be added. The policy will apply to a user if he is a member of any normal (non exclusive) subject in the policy or not a member of any exclusive subject in the policy.- Parameters:
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.- Throws:
NameNotFoundException
- if a Subject instance with the given name is not present
-
removeSubject
Deprecated.Removes the subject with the given name.- Parameters:
subjectName
- name of the Subject- Returns:
- returns the Subject object being removed.
if not present returns
null
-
removeSubject
Deprecated.Removes theSubject
object identified by object'sequals
method. If a Subject instance does not exist, the method will return silently.- Parameters:
subject
- Subject object that will be removed from the user collection
-
isSubjectExclusive
Deprecated.Checks if the subject is exclusive. If subject is exclusive, policy applies to users who are not members of the subject. Otherwise, policy applies to members of the subject. The policy will apply to a user if he is a member of any normal (non exclusive) subject in the policy or not a member of any exclusive subject in the policy.- Parameters:
subjectName
- name of the subject- Returns:
true
if the subject is exclusive,false
otherwise.- Throws:
NameNotFoundException
- if the subject with the givensubjectName
does not exist in the policy.
-
isRealmSubject
Deprecated.Checks if the subjectName is a reference to a Subject defined at the realm- Parameters:
subjectName
- name of the subject- Returns:
true
if the subject is a reference to a Subject defined at the realm,false
otherwise.- Throws:
NameNotFoundException
- if the subject with the givensubjectName
does not exist in the policy.
-
getReferralNames
Deprecated.Get theSet
of referral names associated with the policy.- Returns:
Set
of referral names
-
getReferral
Deprecated.Gets the Referral object identified by name.- Parameters:
referralName
- name of referral.- Returns:
Referral
object- Throws:
NameNotFoundException
- if a Referral with the given name does not exist
-
addReferral
@Supported public void addReferral(String name, Referral referral) throws NameAlreadyExistsException, InvalidNameException Deprecated.Adds a new policy referral.- Parameters:
name
- name of theReferral
instancereferral
-Referral
object to be added to the policy- Throws:
NameAlreadyExistsException
- if a Referral with the given name already existsInvalidNameException
- if the referral name is invalid
-
replaceReferral
Deprecated.Replaces an existing referral with the same name by the current one. If a referral with the same name does not exist, it will be added.- Parameters:
name
- name of theReferral
instancereferral
-Referral
that will replace an existing Referral with the same name- Throws:
NameNotFoundException
- if a Referral instance with the given name is not present
-
removeReferral
Deprecated.Removes the referral with the given name.- Parameters:
referralName
- name of theReferral
- Returns:
- returns the
Referral
object being removed; if not present returnsnull
-
removeReferral
Deprecated.Removes theReferral
object identified by object'sequals
method. If a Referral instance does not exist, the method will return silently.- Parameters:
referral
- Referral object that will be removed
-
getConditionNames
Deprecated.Get the set of condition names associated with the policy.- Returns:
Set
of condition names
-
getCondition
Deprecated.Gets the condition object identified by name.- Parameters:
condition
- name of condition.- Returns:
Condition
object.- Throws:
NameNotFoundException
- if a Condition with the given name does not exist.
-
addCondition
@Supported public void addCondition(String name, Condition condition) throws NameAlreadyExistsException, InvalidNameException Deprecated.Adds a new policy condition.- Parameters:
name
- name of the Condition instancecondition
- Condition object to be added to the policy- Throws:
NameAlreadyExistsException
- if a Condition with the given name already existsInvalidNameException
- if the condition name is invalid
-
replaceCondition
@Supported public void replaceCondition(String name, Condition condition) throws NameNotFoundException Deprecated.Replaces an existing condition with the same name by the current one. If a condition with the same name does not exist, it will be added.- Parameters:
name
- name of theCondition
instancecondition
-Condition
that will replace an existing Condition with the same name- Throws:
NameNotFoundException
- if a Condition instance with the given name is not present
-
removeCondition
Deprecated.Removes the condition with the given name.- Parameters:
condition
- name of theCondition
- Returns:
- returns the Condition object being removed;
if not present returns
null
-
removeCondition
Deprecated.Removes theCondition
object identified by object'sequals
method. If a condition instance does not exist, the method will return silently.- Parameters:
condition
- Condition object that will be removed
-
store
@Supported public void store(SSOToken token, String name) throws SSOException, NoPermissionException, NameAlreadyExistsException, NameNotFoundException, PolicyException Deprecated.Stores the policy object in a persistent data store under the organization, sub-organization or a container object, specified as a parameter. The organization, sub-organization, or the container can be either a LDAP distinguished name (dn
) or slash "/" separated as per SMS. This method uses theSSOToken
provided to perform the store operation, and hence if the single sign token has expiredSSOException
will be thrown, and if the user does not have the required privilegesNoPermissionException
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 throwNameNotFoundException
.- Parameters:
token
- SSO token of the user managing policyname
- name of the organization, sub-organization or a container in which the policy will be stored.- Throws:
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 condition
-
toXML
Deprecated.Returns the serialized policy in XML- Returns:
- serialized policy in XML
-
toString
Deprecated.Gets string representation of the policy object.
-
Entitlement
instead asEntitlement
has replacedPolicy
.