public class Subjects extends Object
Subjects
provides methods to maintain
a collection of Subject
objects that can be
applied to a policy. This class provides methods to add, replace
and remove Subject
objects from this users collection.
The Policy
object provides methods to set
Subjects
, which identifies users to whom the
the policy applies.Modifier | Constructor and Description |
---|---|
protected |
Subjects()
Constructor used by the
Policy object
to get a default instance of the Subjects |
protected |
Subjects(PolicyManager pm,
Node usersNode)
Constructor used by
Policy to obtain
an instance of Subjects from the
XML document |
|
Subjects(String name,
String description)
Constructor to obtain an instance of
Subjects
to hold collection of users represented as
Subject |
Modifier and Type | Method and Description |
---|---|
void |
addSubject(String subjectName,
Subject subject)
Adds a
Subject object to the this instance
of user collection. |
void |
addSubject(String subjectName,
Subject subject,
boolean exclusive)
Adds a
Subject object to the this instance
of user collection. |
void |
addSubject(Subject subject)
Adds a
Subject object to the this instance
of user collection. |
Object |
clone()
Returns a new copy of this object with the identical
set of user collections (subjects).
|
boolean |
equals(Object o)
Checks if two
Subjects are identical. |
String |
getDescription()
Returns the description for the collection of users
represented as
Subject |
String |
getName()
Returns the name for the collection of users
represented as
Subject |
Subject |
getSubject(String subjectName)
Returns the
Subject object associated
with the given subject name. |
String |
getSubjectName(Subject subject)
Returns the name associated with the given subject object.
|
Set |
getSubjectNames()
Returns the names of
Subject objects
contained in this object. |
boolean |
isMember(SSOToken token)
Checks if the given user (using
SSOToken ) belongs
to any of the subjects contained in this user collection (subjects). |
boolean |
isRealmSubject(String subjectName)
Checks if the subject is a reference to a
Subject
defined at the realm. |
boolean |
isSubjectExclusive(String subjectName)
Checks if the subject is exclusive.
|
Subject |
removeSubject(String subjectName)
Removes the
Subject object identified by
the subject name. |
Subject |
removeSubject(Subject subject)
Removes the
Subject object identified by
object's equals method. |
void |
replaceSubject(String subjectName,
Subject subject)
Replaces an existing subject object having the same name
with the new one.
|
void |
replaceSubject(String subjectName,
Subject subject,
boolean exclusive)
Replaces an existing subject object having the same name
with the new one.
|
void |
setDescription(String description)
Sets the description for this instance of the
Subjects |
void |
setName(String name)
Sets the name for this instance of the
Subjects |
String |
toString()
Returns XML string representation of the subject
(user collection) object.
|
protected String |
toXML()
Returns XML string representation of the subject
(user collection) object.
|
protected Subjects()
Policy
object
to get a default instance of the Subjects
protected Subjects(PolicyManager pm, Node usersNode) throws InvalidFormatException, InvalidNameException, NameNotFoundException, PolicyException
Policy
to obtain
an instance of Subjects
from the
XML documentusersNode
- node that repersents the SubjectsInvalidFormatException
- if the node passed in does not
conform to expected formatInvalidNameException
NameNotFoundException
PolicyException
- if can not construct Subjects
public String getName()
Subject
public String getDescription()
Subject
public void setName(String name)
Subjects which contains a collection
of users respresented as Subject
.
name
- for the collection of subjectspublic void setDescription(String description)
Subjects which contains a collection
of users respresented as Subject
.
description
- description for the collection subjectspublic Set getSubjectNames()
Subject
objects
contained in this object.Subject
contained in
this objectpublic Subject getSubject(String subjectName) throws NameNotFoundException
Subject
object associated
with the given subject name.subjectName
- name of the subject objectNameNotFoundException
- if a subject
with the given name is not presentpublic void addSubject(Subject subject) throws NameAlreadyExistsException
Subject
object 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 subject
entry with the same name already exists in the user collection
NameAlreadyExistsException
will be thrown.
The subject is added as a normal (non exclusive) subject.
So, policy will apply to members of the subject.subject
- instance of the subject object added to this
collectionNameAlreadyExistsException
- throw if a
subject object is present with the same namepublic void addSubject(String subjectName, Subject subject) throws NameAlreadyExistsException
Subject
object to the this instance
of user collection. If another subject with the same name
already exists in the user collection
NameAlreadyExistsException
will be thrown.
The subject is added as a normal (non exclusive) subject.
So, policy will apply to members of the subject.subjectName
- name for the subject instancesubject
- instance of the subject object added to this
collectionNameAlreadyExistsException
- if a
subject object is present with the same namepublic void addSubject(String subjectName, Subject subject, boolean exclusive) throws NameAlreadyExistsException
Subject
object to the this instance
of user collection. If another subject with the same name
already exists in the user collection
NameAlreadyExistsException
will be thrown.subjectName
- name for the subject instancesubject
- instance of the subject object added to this
collectionexclusive
- 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 object is present with the same namepublic void replaceSubject(String subjectName, Subject subject) throws NameNotFoundException
Subject
with the given
name does not exist, NameNotFoundException
will be thrown.
The subject is replaced as a normal (non exclusive) subject.
So, policy will apply to members of the subject.subjectName
- name for the subject instancesubject
- instance of the subject object that will
replace another subject object having the given nameNameNotFoundException
- if a subject instance
with the given name is not presentpublic void replaceSubject(String subjectName, Subject subject, boolean exclusive) throws NameNotFoundException
Subject
with the given
name does not exist, NameNotFoundException
will be thrown.subjectName
- name for the subject instancesubject
- instance of the subject object that will
replace another subject object having the given 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)
Subject
object identified by
the subject name. If a subject instance with the given
name does not exist, the method will return silently.subjectName
- name of the subject instance that
will be removed from the user collectionpublic Subject 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
otherwiseNameNotFoundException
- if the subject with the given subjectName
does not exist in the policypublic boolean isRealmSubject(String subjectName) throws NameNotFoundException
Subject
defined at the realm.subjectName
- name of the subjecttrue
if the subject is a reference to
a Subject
definet at the realm, false
otherwiseNameNotFoundException
- if the subject with the given subjectName
does not exist in the policypublic String getSubjectName(Subject subject)
equals
method on the subject
to determine equality. If a subject instance that matches
the given subject object is not present, the method
returns null
.subject
- subject object for which this method will
return its associated namenull
if not presentpublic boolean equals(Object o)
Subjects
are identical.
Two subjects (or user collections) are identical only
if both have the same set of Subject
objects.public Object clone()
public boolean isMember(SSOToken token) throws SSOException, PolicyException
SSOToken
) belongs
to any of the subjects contained in this user collection (subjects).
In the current implementation it is sufficient if the user
belongs to one of the subject objects, however in the future it
can be extended to have complex logical operations.token
- single-sign-on token of the usertrue
if the user is memeber of one
of the subjects; false
otherwise.SSOException
- if SSO token is not validPolicyException
- if an error occured while
checking if the user is a member of one of subjectspublic String toString()
protected String toXML()
Copyright © 2010–2025 Open Identity Platform Community. All rights reserved.