Package com.sun.identity.policy
Class Referrals
- java.lang.Object
-
- com.sun.identity.policy.Referrals
-
- All Implemented Interfaces:
Cloneable
public class Referrals extends Object implements Cloneable
The classReferralsprovides methods to maintain a collection ofReferralobjects that can be applied to a policy. This class provides methods to add, replace and removeReferralobjects from this referrals collection. ThePolicyobject provides methods to setReferrals, which identifies referrals to whom the the policy applies.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedReferrals()Constructor used by thePolicyobject to get a default instance of theReferralsprotectedReferrals(PolicyManager pm, Node referralsNode)Constructor used byPolicyto obtain an instance ofReferralsfrom the XML documentReferrals(String name, String description)Constructor to obtain an instance ofReferralsto hold collection of referrals represented asReferral
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddReferral(Referral referral)Adds aReferralobject to the this instance of user collection.voidaddReferral(String referralName, Referral referral)Adds aReferralobject to the this instance of user collection.Objectclone()Returns a new copy of this object with the identical set of user collections (referrals).booleanequals(Object o)Checks if twoReferralsare identical.StringgetDescription()Returns the description for the collection of referrals represented asReferralStringgetName()Returns the name for the collection of referrals represented asReferralReferralgetReferral(String referralName)Returns theReferralobject associated with the given referral name.StringgetReferralName(Referral referral)Returns the name associated with the given referral object.SetgetReferralNames()Returns the names ofReferralobjects contained in this object.ReferralremoveReferral(Referral referral)Removes theReferralobject identified by object'sequalsmethod.ReferralremoveReferral(String referralName)Removes theReferralobject identified by the referral name.voidreplaceReferral(String referralName, Referral referral)Replaces an existing referral object having the same name with the new one.voidsetDescription(String description)Sets the description for this instance of theReferralswhich contains a collection of referrals respresented asReferral.voidsetName(String name)Sets the name for this instance of theReferralswhich contains a collection of referrals respresented asReferral.StringtoString()Returns XML string representation of the referral (user collection) object.protected StringtoXML()Returns an XML representaion of thisReferralsobject
-
-
-
Constructor Detail
-
Referrals
protected Referrals()
Constructor used by thePolicyobject to get a default instance of theReferrals
-
Referrals
protected Referrals(PolicyManager pm, Node referralsNode) throws InvalidFormatException, InvalidNameException, NameNotFoundException, PolicyException
Constructor used byPolicyto obtain an instance ofReferralsfrom the XML document- Parameters:
pm-PolicyManagerto initialize theReferralswithreferralsNode- node that repersents the Referrals- Throws:
InvalidFormatException- if the node passed in does not conform to expected formatInvalidNameException- if the name specified in the Node forReferralsis invalidNameNotFoundException- need to add the situations that would cause thisPolicyException- if can not constructReferrals
-
-
Method Detail
-
getName
public String getName()
Returns the name for the collection of referrals represented asReferral- Returns:
- name of the collection of referrals
-
getDescription
public String getDescription()
Returns the description for the collection of referrals represented asReferral- Returns:
- description for the collection of referrals
-
setName
public void setName(String name)
Sets the name for this instance of theReferralswhich contains a collection of referrals respresented asReferral.- Parameters:
name- for the collection of referrals
-
setDescription
public void setDescription(String description)
Sets the description for this instance of theReferralswhich contains a collection of referrals respresented asReferral.- Parameters:
description- description for the collection referrals
-
getReferralNames
public Set getReferralNames()
Returns the names ofReferralobjects contained in this object.- Returns:
- names of
Referralcontained in this object
-
getReferral
public Referral getReferral(String referralName) throws NameNotFoundException
Returns theReferralobject associated with the given referral name.- Parameters:
referralName- name of the referral object- Returns:
Referralobject corresponding to referral name- Throws:
NameNotFoundException- if a referral with the given name is not present
-
addReferral
public void addReferral(Referral referral) throws NameAlreadyExistsException
Adds aReferralobject to the this instance of user collection. Since the name is not provided it will be dynamically assigned such that it is unique within this instance of the user collection. However if a referral entry with the same name already exists in the user collectionNameAlreadyExistsExceptionwill be thrown.- Parameters:
referral- instance of the referral object added to this collection- Throws:
NameAlreadyExistsException- if a referral object is present with the same name
-
addReferral
public void addReferral(String referralName, Referral referral) throws NameAlreadyExistsException
Adds aReferralobject to the this instance of user collection. If another referral with the same name already exists in the user collectionNameAlreadyExistsExceptionwill be thrown.- Parameters:
referralName- name for the referral instancereferral- instance of the referral object added to this collection- Throws:
NameAlreadyExistsException- if a referral object is present with the same name
-
replaceReferral
public void replaceReferral(String referralName, Referral referral) throws NameNotFoundException
Replaces an existing referral object having the same name with the new one. If aReferralwith the given name does not exist,NameNotFoundExceptionwill be thrown.- Parameters:
referralName- name for the referral instancereferral- instance of the referral object that will replace another referral object having the given name- Throws:
NameNotFoundException- if a referral instance with the given name is not present
-
removeReferral
public Referral removeReferral(String referralName)
Removes theReferralobject identified by the referral name. If a referral instance with the given name does not exist, the method will return silently.- Parameters:
referralName- name of the referral instance that will be removed from the user collection- Returns:
- the referral that was just removed
-
removeReferral
public Referral removeReferral(Referral referral)
Removes theReferralobject identified by object'sequalsmethod. If a referral instance does not exist, the method will return silently.- Parameters:
referral- referral object that will be removed from the user collection- Returns:
- the referral that was just removed
-
getReferralName
public String getReferralName(Referral referral)
Returns the name associated with the given referral object. It uses theequalsmethod on the referral to determine equality. If a referral instance that matches the given referral object is not present, the method returnsnull.- Parameters:
referral- referral object for which this method will return its associated name- Returns:
- user friendly name given to the referral object;
nullif not present
-
equals
public boolean equals(Object o)
Checks if twoReferralsare identical. Two referrals (or user collections) are identical only if both have the same set ofReferralobjects.
-
clone
public Object clone()
Returns a new copy of this object with the identical set of user collections (referrals).
-
toString
public String toString()
Returns XML string representation of the referral (user collection) object.
-
toXML
protected String toXML()
Returns an XML representaion of thisReferralsobject
-
-