com.sun.identity.policy
Class SubjectTypeManager

java.lang.Object
  extended by com.sun.identity.policy.SubjectTypeManager

public class SubjectTypeManager
extends Object

The class SubjectTypeManager provides methods to get a list of configured Subject objects, and to obtain a factory object for it.


Constructor Summary
protected SubjectTypeManager()
          Constructs a SubjectTypeManager object
protected SubjectTypeManager(PolicyManager pm)
          Constructs a SubjectTypeManager object
 
Method Summary
 void addSubject(String subjectName, Subject subject)
          Adds a policy subject at realm.
 String getDisplayName(String subjectType)
          Returns the display name for the subject type
 String getI18NKey(String subjectType)
          Returns the I18N key to be used to localize the display name for the subject type name.
protected  String getI18NPropertiesFileName(String subjectType)
          Returns the I18N properties file name that should be used to localize display names for the given subject type.
 Set getSelectedSubjectTypeNames()
          Returns a set of valid subject type names configured for the organization.
 Subject getSubject(String subjectType)
          Returns an instance of the Subject given the subject type name.
 Subject getSubjectByName(String subjectName)
          Returns the Subject object identified by subjectName defined at the realm
 Set getSubjectNames()
          Get the set of names of Subject(s) defined at the realm
 String getSubjectTypeName(Subject subject)
          Returns the type of the Subject implementation.
 Set getSubjectTypeNames()
          Returns a set of all valid subject type names defined by the policy service.
 String getViewBeanURL(Subject subject)
          Returns the view bean URL given the Subject
 Subject removeSubject(String subjectName)
          Removes the subject with the given name from the realm.
 Subject removeSubject(String subjectName, boolean forcedRemove)
          Removes the subject with the given name from the realm.
 void replaceSubject(String subjectName, Subject subject)
          Replaces an existing subject with the same name by the current one at the realm.
 

Constructor Detail

SubjectTypeManager

protected SubjectTypeManager()
                      throws SSOException
Constructs a SubjectTypeManager object

Throws:
SSOException

SubjectTypeManager

protected SubjectTypeManager(PolicyManager pm)
Constructs a SubjectTypeManager object

Parameters:
pm - PolicyManager to initialize SubjectTypeManager with
Method Detail

getSubjectTypeNames

public Set getSubjectTypeNames()
                        throws SSOException,
                               PolicyException
Returns a set of all valid subject type names defined by the policy service. Examples are LDAPRole, LDAPGroup, etc.

Returns:
a set of all valid subject type names defined by the policy service.
Throws:
SSOException - if the SSOToken used to create the PolicyManager has become invalid
PolicyException - for any other abnormal condition

getSelectedSubjectTypeNames

public Set getSelectedSubjectTypeNames()
                                throws SSOException,
                                       PolicyException
Returns a set of valid subject type names configured for the organization. Examples are LDAPRole, LDAPGroup, etc.

Returns:
a set of valid subject type names configured for the organization.
Throws:
SSOException - if the SSOToken used to create the PolicyManager has become invalid
PolicyException - for any other abnormal condition

getSubjectTypeName

public String getSubjectTypeName(Subject subject)
Returns the type of the Subject implementation. For example LDAPRoles, LDAPGroups etc.

Parameters:
subject - Subject for which this method will return its associated type
Returns:
type of the Subject, e.g., LDAPRoles, LDAPGroups, etc. Returns null if not present.

getI18NPropertiesFileName

protected String getI18NPropertiesFileName(String subjectType)
Returns the I18N properties file name that should be used to localize display names for the given subject type.

Parameters:
subjectType - subject type name
Returns:
i18n properties file name

getI18NKey

public String getI18NKey(String subjectType)
Returns the I18N key to be used to localize the display name for the subject type name.

Parameters:
subjectType - subject type name
Returns:
i18n key to obtain the display name

getDisplayName

public String getDisplayName(String subjectType)
Returns the display name for the subject type

Parameters:
subjectType - subject type
Returns:
display name for the subject type

getSubject

public Subject getSubject(String subjectType)
                   throws NameNotFoundException,
                          PolicyException
Returns an instance of the Subject given the subject type name.

Parameters:
subjectType - subject type.
Returns:
an instance of the Subject given the subject type name.
Throws:
NameNotFoundException - if the Subject for the subjectType name is not found
PolicyException - for any other abnormal condition

addSubject

public void addSubject(String subjectName,
                       Subject subject)
                throws NameAlreadyExistsException,
                       InvalidNameException,
                       PolicyException,
                       SSOException
Adds a policy subject at realm.

Parameters:
subjectName - name of the Subject instance
subject - Subject object to be added
Throws:
NameAlreadyExistsException - if a Subject with the given name already exists at the realm
InvalidNameException - if the subject name is invalid
PolicyException - if can not add the Subject
SSOException

removeSubject

public Subject removeSubject(String subjectName)
                      throws ObjectInUseException,
                             PolicyException,
                             SSOException
Removes the subject with the given name from the realm. This method would throw PolicyException if the subject is being used by any policy.

Parameters:
subjectName - name of the Subject
Returns:
returns the Subject object being removed, returns null if Subject with the given subjectName is not present
Throws:
PolicyException - if can not remove the Subject
ObjectInUseException
SSOException

removeSubject

public Subject removeSubject(String subjectName,
                             boolean forcedRemove)
                      throws ObjectInUseException,
                             PolicyException,
                             SSOException
Removes the subject with the given name from the realm. This method would throw PolicyException if the subject is being used by any policy unless forcedRemove argument is set to true. If the forcedRemove argument is set to true policies that are using the subject would be modified to remove the references to the subject

Parameters:
subjectName - name of the Subject
forcedRemove - if set to true, policies that use the subject would be modifed to remove the references to the subject. Otherwise, ObjectInUseException would be thrown if there is any policy using the subject
Returns:
returns the Subject object being removed, returns null if Subject with the given subjectName is not present
Throws:
PolicyException - if can not remove the Subject
ObjectInUseException
SSOException

replaceSubject

public void replaceSubject(String subjectName,
                           Subject subject)
                    throws NameNotFoundException,
                           PolicyException,
                           SSOException
Replaces an existing subject with the same name by the current one at the realm. If a subject with the same name does not exist, it will be added.

Parameters:
subjectName - name of the Subject instance
subject - Subject that will replace an existing Subject with the same name
Throws:
NameNotFoundException - if a Subject instance with the given name is not present
PolicyException - if can not replace the Subject
SSOException

getSubjectNames

public Set getSubjectNames()
                    throws PolicyException,
                           SSOException
Get the set of names of Subject(s) defined at the realm

Returns:
set of subject names
Throws:
PolicyException
SSOException

getSubjectByName

public Subject getSubjectByName(String subjectName)
                         throws NameNotFoundException,
                                PolicyException
Returns the Subject object identified by subjectName defined at the realm

Parameters:
subjectName - name of subject.
Returns:
Subject object
Throws:
NameNotFoundException - if a Subject with the given name does not exist
PolicyException - if can not get the Subject

getViewBeanURL

public String getViewBeanURL(Subject subject)
Returns the view bean URL given the Subject

Parameters:
subject - subject for which to get the view bean URL
Returns:
view bean URL defined for the subject plugin in the policy service PluginSchema.