Package com.sun.identity.sm
Class OrganizationConfigManager
- java.lang.Object
-
- com.sun.identity.sm.OrganizationConfigManager
-
public class OrganizationConfigManager extends Object
The classOrganizationConfigManagerprovides interfaces to manage an organization's configuration data. It provides interfaces to create and delete organizations, service attributes for organizations and service configuration parameters.The organization configuration can be managed in a hierarchical manner, and a forward slash "/" will be used to separate the name hierarchy. Hence the root of the organization hierarchy will be represented by a single forward slash "/", and sub-organizations will be separated by "/". For example "/a/b/c" would represent a "c" sub-organization within "b" which would be a sub-organization of "a".
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringSERVICES_NODEstatic StringSUNORG_ALIAS
-
Constructor Summary
Constructors Constructor Description OrganizationConfigManager(SSOToken token, String orgName)Constructor to obtain an instance ofOrganizationConfigManagerfor an organization by providing an authenticated identity of the user.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddAttributeValues(String serviceName, String attrName, Set values)Adds organization attributes for the service.StringaddListener(ServiceListener listener)Registers for changes to organization's configuration.ServiceConfigaddServiceConfig(String serviceName, Map attributes)Adds a service configuration object for the given service name for this organization.voidassignService(String serviceName, Map attributes)Assigns the given service to the orgnization with the respective attributes.OrganizationConfigManagercreateSubOrganization(String subOrgName, Map attributes)Creates a sub-organization under the current organization and sets the specified attributes.voiddeleteSubOrganization(String subOrgName, boolean recursive)Deletes the given sub-organization.Set<String>getAssignableServices()Returns a set of service names that can be assigned to a realm.Set<String>getAssignedServices()Returns a set of service names that are assigned to a realm.Set<String>getAssignedServices(boolean includeMandatory)Returns a set of service names that are assigned to a realm.MapgetAttributes(String serviceName)Returns the organization creation attributes for the service.SetgetConfiguredServices()Deprecated.This method has been deprecated, usegetAssignedServices()instead.StringgetNamingAttrForOrg()StringgetOrganizationName()Returns the fully qualified name of the organization from the rootOrganizationConfigManagergetParentOrgConfigManager()Returns theOrganizationConfigManagerof the parent for the given organization name.SetgetPeerOrganizationNames()Returns the names of all peer-organizations.MapgetServiceAttributes(String serviceName)Returns attributes configured for the service.ServiceConfiggetServiceConfig(String serviceName)Returns the service configuration object for the given service name.SetgetServiceSchemas()Returns a set of service schemas to be used for creation of an organization.SetgetSubOrganizationNames()Returns the names of all sub-organizations.SetgetSubOrganizationNames(String pattern, boolean recursive)Returns names of sub-organizations matching the given pattern.OrganizationConfigManagergetSubOrgConfigManager(String subOrgName)Returns theOrganizationConfigManagerfor the given organization name.protected booleanisCopyOrgEnabled()Determines whether an organization ought to be created for each realm in realm only mode of installation based on the boolean flag in amSDK plugin.static voidloadDefaultServices(SSOToken token, OrganizationConfigManager ocm)Loads default services to a newly created realmvoidmodifyService(String serviceName, Map attributes)Sets the attributes related to provided service.voidremoveAttribute(String serviceName, String attrName)Removes the given organization creation attribute for the service.voidremoveAttributeValues(String serviceName, String attrName, Set values)Removes the given organization creation attribute values for the service.voidremoveListener(String listenerID)Removes the listener from the organization for the given listener ID.voidremoveServiceConfig(String serviceName)Removes the service configuration object for the given service name for this organization.voidsetAttributes(String serviceName, Map attributes)Sets/Creates organization attributes for the service.voidunassignService(String serviceName)Unassigns the service from the organization.
-
-
-
Field Detail
-
SERVICES_NODE
protected static final String SERVICES_NODE
-
SUNORG_ALIAS
public static final String SUNORG_ALIAS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OrganizationConfigManager
@Inject public OrganizationConfigManager(SSOToken token, String orgName) throws SMSException
Constructor to obtain an instance ofOrganizationConfigManagerfor an organization by providing an authenticated identity of the user. The organization name would be "/" seperated to represent organization hierarchy.- Parameters:
token- single sign on token of authenticated user identity.orgName- name of the organization. The value ofnullor "/" would represent the root organization.- Throws:
SMSException- if an error has occurred while getting the instance ofOrganizationConfigManager.
-
-
Method Detail
-
getOrganizationName
public String getOrganizationName()
Returns the fully qualified name of the organization from the root- Returns:
- the name of the organization
-
getConfiguredServices
public Set getConfiguredServices() throws SMSException
Deprecated.This method has been deprecated, usegetAssignedServices()instead.Returns the services configured for the organization.- Returns:
- service names configured for the organization.
- Throws:
SMSException- if there is an error accessing the data store to read the configured services.
-
getServiceSchemas
public Set getServiceSchemas() throws SMSException
Returns a set of service schemas to be used for creation of an organization. The service schemas contain a list of attributes and their schema, and will be provided asServiceSchema.- Returns:
- Set of
ServiceSchemato be used for creation of an organization. - Throws:
SMSException- if there is an error accessing the data store to read the service schemas.
-
createSubOrganization
public OrganizationConfigManager createSubOrganization(String subOrgName, Map attributes) throws SMSException
Creates a sub-organization under the current organization and sets the specified attributes. The sub-organization created can be only one level below the current organization. For multiple levels this method must be called recursively with the correspondingOrganizationConfigManager. The organization name must not have forward slash ("/"). For eg., the actual organization name 'iplanet' cannot be 'iplan/et' because we are using '/' as the seperator here. The attributes for the organization can benull; else would contain service name as the key and anotherMapas the value that would contain the key-values pair for the services.- Parameters:
subOrgName- the name of the sub-organization.attributes- Map of attributes for the organization per service. The parameter Map attributes contains another Map as its value, which then has attribute names and values. The way it is arranged is: Map::attributes --> Key: String::ServiceName Value: Map::svcAttributes Map::svcAttributes --> Key: String::AttributeName Value: Set::AttributeValues- Returns:
- organization config manager of the newly created sub-organization.
- Throws:
SMSException- if creation of sub-organization failed, or if creation of sub-organization is attempted when configuration is not migrated to realms.
-
getSubOrganizationNames
public Set getSubOrganizationNames() throws SMSException
Returns the names of all sub-organizations.- Returns:
- set of names of all sub-organizations.
- Throws:
SMSException- if there is an error accessing the data store to read the sub-organization names.
-
getPeerOrganizationNames
public Set getPeerOrganizationNames() throws SMSException
Returns the names of all peer-organizations.- Returns:
- set of names of all peer-organizations.
- Throws:
SMSException- if there is an error accessing the data store to read the peer-organization names.
-
getSubOrganizationNames
public Set getSubOrganizationNames(String pattern, boolean recursive) throws SMSException
Returns names of sub-organizations matching the given pattern. If the parameterrecursiveis set totrue, search will be performed for the entire sub-tree. The pattern can contain "*" as the wildcard to represent zero or more characters.- Parameters:
pattern- pattern that will be used for searching, where "*" will be the wildcard.recursive- if set totruethe entire sub-tree will be searched for the organization names.- Returns:
- names of sub-organizations matching the pattern.
- Throws:
SMSException- if there is an error accessing the data store to read the sub-organization names.
-
deleteSubOrganization
public void deleteSubOrganization(String subOrgName, boolean recursive) throws SMSException
Deletes the given sub-organization. If the parameterrecursiveis set totrue, then the suborganization and the sub-tree will be deleted. If the parameterrecursiveis set tofalsethen the sub-organization shall be deleted provided it is the leaf node. If there are entries beneath the sub-organization and if the parameterrecursiveis set tofalse, then an exception is thrown that this sub-organization cannot be deleted.- Parameters:
subOrgName- sub-organization name to be deleted.recursive- if set totruethe entire sub-tree will be deleted.- Throws:
SMSException- if the sub-organization name cannot be found, or if there are entries beneath the sub-organization and if the parameterrecursiveis set tofalse.
-
getSubOrgConfigManager
public OrganizationConfigManager getSubOrgConfigManager(String subOrgName) throws SMSException
Returns theOrganizationConfigManagerfor the given organization name.- Parameters:
subOrgName- the name of the organization.- Returns:
- the configuration manager for the given organization.
- Throws:
SMSException- if the organization name cannot be found or user doesn't have access to that organization.
-
getAttributes
public Map getAttributes(String serviceName) throws SMSException
Returns the organization creation attributes for the service.- Parameters:
serviceName- name of the service.- Returns:
- map of organization creation attribute values for service
- Throws:
SMSException- if there is an error accessing the data store to read the attributes of the service.
-
addAttributeValues
public void addAttributeValues(String serviceName, String attrName, Set values) throws SMSException
Adds organization attributes for the service. If the attribute already exists, the values will be appended to it, provided it is a multi-valued attribute. It will throw exception if we try to add a value to an attribute which has the same value already.- Parameters:
serviceName- name of the service.attrName- name of the attribute.values- values for the attribute.- Throws:
SMSException- if we try to add a value to an attribute which has the same value already.
-
setAttributes
public void setAttributes(String serviceName, Map attributes) throws SMSException
Sets/Creates organization attributes for the service. If the attributes already exists, the given attribute values will replace them.- Parameters:
serviceName- name of the service.attributes- attribute-values pairs.- Throws:
SMSException- if the serviceName cannot be found.
-
removeAttribute
public void removeAttribute(String serviceName, String attrName) throws SMSException
Removes the given organization creation attribute for the service.- Parameters:
serviceName- name of service.attrName- name of attribute.- Throws:
SMSException- if the organization attribute for the service to be removed cannot be found, or if the service name cannot be found.
-
removeAttributeValues
public void removeAttributeValues(String serviceName, String attrName, Set values) throws SMSException
Removes the given organization creation attribute values for the service.- Parameters:
serviceName- name of service.attrName- name of attribute.values- attribute values to be removed.- Throws:
SMSException- if the organization attribute for the service to be removed cannot be found, or if the service name cannot be found, or if the value cannot be removed.
-
getServiceConfig
public ServiceConfig getServiceConfig(String serviceName) throws SMSException
Returns the service configuration object for the given service name.- Parameters:
serviceName- name of a service.- Returns:
- service configuration object for the service.
- Throws:
SMSException- if there is an error accessing the data store to read the service configuration, or if the service name cannot be found.
-
addServiceConfig
public ServiceConfig addServiceConfig(String serviceName, Map attributes) throws SMSException
Adds a service configuration object for the given service name for this organization. If the service has been already added aSMSExceptionwill be thrown.- Parameters:
serviceName- name of the service.attributes- service configuration attributes.- Returns:
- service configuration object.
- Throws:
SMSException- if the service configuration has been added already.
-
removeServiceConfig
public void removeServiceConfig(String serviceName) throws SMSException
Removes the service configuration object for the given service name for this organization.- Parameters:
serviceName- name of the service.- Throws:
SMSException- if the service name cannot be found, or not added to the organization.
-
addListener
public String addListener(ServiceListener listener)
Registers for changes to organization's configuration. The object will be called when configuration for this organization is changed.- Parameters:
listener- callback object that will be invoked when organization configuration has changed- Returns:
- an ID of the registered listener.
-
removeListener
public void removeListener(String listenerID)
Removes the listener from the organization for the given listener ID. The ID was issued when the listener was registered.- Parameters:
listenerID- the listener ID issued when the listener was registered
-
getAssignableServices
public Set<String> getAssignableServices() throws SMSException
Returns a set of service names that can be assigned to a realm. This set excludes name of services that are already assigned to the realm and services that are required for the existence of a realm.- Returns:
- a set of service names that can be assigned to a realm.
- Throws:
SMSException- if there is an error accessing the data store to read the service configuration
-
getAssignedServices
public Set<String> getAssignedServices() throws SMSException
Returns a set of service names that are assigned to a realm.- Returns:
- a set of service names that are assigned to a realm.
- Throws:
SMSException- if there is an error accessing the data store to read the service configuration
-
getAssignedServices
public Set<String> getAssignedServices(boolean includeMandatory) throws SMSException
Returns a set of service names that are assigned to a realm.- Parameters:
includeMandatory-trueto include mandatory service names.- Returns:
- a set of service names that are assigned to a realm.
- Throws:
SMSException- if there is an error accessing the data store to read the service configuration
-
assignService
public void assignService(String serviceName, Map attributes) throws SMSException
Assigns the given service to the orgnization with the respective attributes. If the service has been already added aSMSExceptionwill be thrown.- Parameters:
serviceName- name of the serviceattributes- service configuration attributes- Throws:
SMSException- if the service configuration has been added already.
-
getServiceAttributes
public Map getServiceAttributes(String serviceName) throws SMSException
Returns attributes configured for the service.- Parameters:
serviceName- name of the service- Returns:
- a map of attributes for the service
- Throws:
SMSException- if there is an error accessing the data store to read the service configuration, or if the service name cannot be found.
-
unassignService
public void unassignService(String serviceName) throws SMSException
Unassigns the service from the organization.- Parameters:
serviceName- name of the service- Throws:
SMSException- if the service name cannot be found or assigned, or if the service is a mandatory service.
-
modifyService
public void modifyService(String serviceName, Map attributes) throws SMSException
Sets the attributes related to provided service. The assumption is that the service is already assigned to the organization. The attributes for the service are validated against the service schema.- Parameters:
serviceName- name of the serviceattributes- attributes of the service- Throws:
SMSException- if the service name cannot be found or not assigned to the organization.
-
getNamingAttrForOrg
public String getNamingAttrForOrg()
-
getParentOrgConfigManager
public OrganizationConfigManager getParentOrgConfigManager() throws SMSException
Returns theOrganizationConfigManagerof the parent for the given organization name.- Returns:
- the configuration manager of the parent for the given organization.
- Throws:
SMSException- if user doesn't have access to that organization.
-
loadDefaultServices
public static void loadDefaultServices(SSOToken token, OrganizationConfigManager ocm) throws SMSException
Loads default services to a newly created realm- Throws:
SMSException
-
isCopyOrgEnabled
protected boolean isCopyOrgEnabled()
Determines whether an organization ought to be created for each realm in realm only mode of installation based on the boolean flag in amSDK plugin. This requirement is for portal customers.
-
-