Package com.sun.identity.sm
Class ServiceSchema
- java.lang.Object
-
- com.sun.identity.sm.ServiceSchema
-
- All Implemented Interfaces:
org.forgerock.openam.core.sms.AttributeSchemaProvider
@SupportedAll public class ServiceSchema extends Object implements org.forgerock.openam.core.sms.AttributeSchemaProvider
The classServiceSchema
provides interfaces to manage the schema information of a service. The schema for a service can be one of the following types: GLOBAL, ORGANIZATION, DYNAMIC, USER, and POLICY.
-
-
Field Summary
Fields Modifier and Type Field Description static String
INHERITANCE_MULTIPLE
This is the schema inheritance of "multiple", i.e.static String
INHERITANCE_SINGLE
This is the schema inheritance of "single", i.e.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ServiceSchema(com.sun.identity.sm.ServiceSchemaImpl ssi, String compName, SchemaType type, ServiceSchemaManager ssm)
protected
ServiceSchema(com.sun.identity.sm.ServiceSchemaImpl ssi, String compName, SchemaType type, ServiceSchemaManager ssm, boolean isOrgAttrSchema)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttributeSchema(InputStream xmlAttrSchema)
Adds the attribute schema to this service.void
addSubSchema(InputStream xmlSubSchema)
Adds the service's sub-schema given the XML input stream that follows the SMS DTD.void
addSubSchema(Document xmlSubSchema)
Adds the service's sub-schema given the XML document that follows the SMS DTD.Set<org.forgerock.openam.core.sms.AttributeSchemaProvider.Schema>
getAllAttributeSchema()
org.forgerock.openam.sm.ConfigurationAttributes
getAttributeDefaults()
Returns a map of all the attribute and their default values in this schema.Map<String,Set<String>>
getAttributeExamples()
Returns a map of all the attribute and their example values in this schema.AttributeSchema
getAttributeSchema(String attributeName)
Returns the schema for an attribute given the name of the attribute, defined for this service.Set<String>
getAttributeSchemaNames()
Returns the names of the schema attributes defined for the service.Set<AttributeSchema>
getAttributeSchemas()
Returns the attribute schemas defined for the service.String
getI18NFileName()
Returns the I18N properties file name for the service schema.String
getI18NKey()
Returns the I18N key that points to the description of the service.String
getI18NKeyWithoutDefault()
Returns the I18N key that points to the description of the schema, ornull
if not present.String
getInheritance()
Get the inheritance of this schema.org.forgerock.openam.core.sms.AttributeSchemaProvider.Schema
getInternalAttributeSchema(String attributeName)
String
getName()
Returns the name of the schema.String
getPropertiesViewBeanURL()
Returns the view bean URL for this serviceMap
getReadOnlyAttributeDefaults()
Returns an unmodifiable map of all the attribute and their default values in this schema.String
getResourceName()
Returns the name for the service schema when used in a CREST representation.Node
getSchemaNode()
Returns the Node of this schema element.protected Set<String>
getSearchableAttributeNames()
Returns the names of the schema attributes defined for the service which are searchable.Set<String>
getServiceAttributeNames()
Returns the attribute schemas defined for the service that is not a status attribute and is not a service attribute.String
getServiceName()
Returns the name of the service.SchemaType
getServiceType()
Returns the schema type.String
getStatusAttribute()
Returns the name of the status attribute, as defined in the Service schemaServiceSchema
getSubSchema(String subSchemaName)
ReturnsServiceSchema
object given the name of the service's sub-schema.Set<String>
getSubSchemaNames()
Returns the names of sub-schemas for the service.String
getVersion()
Returns the version of the service.boolean
isExportable()
Returnstrue
if the service configuration created can be exported to other organizations.boolean
isHiddenInConfigUI()
Should this service schema be hidden in the Configuration UI.boolean
isRealmCloneable()
During the creation of a new organisation/realm the services assigned to the parent realm are copied to the child realm.void
removeAttributeDefaults(Set<String> attrs)
Removes the default values of attributes in the schema.void
removeAttributeSchema(String attrName)
Removes the attribute schema from this service.void
removeSubSchema(String subSchemaName)
Removes the service's sub-schema from the service.void
replaceAttributeSchema(String attrName, Node attributeSchemaNode)
Removes the attribute schema from this service.void
replaceSubSchema(String subSchemaName, Document xmlSubSchema)
Replaces the service's sub-schema given the XML document that follows the SMS DTD.void
setExportable(boolean exportable)
Sets the exportable nature of the service configurations created for this schema.void
setI18NFileName(String url)
Sets the I18N properties file name for the service schemavoid
setI18Nkey(String key)
Sets the value of the I18N key in the service schema.void
setInheritance(String value)
Set the value of inheritance attribute in service schema.void
setResourceName(String name)
Sets the CREST resource name for the service schema.boolean
supportsMultipleConfigurations()
Returnstrue
if service schema supports multiple configurations;false
otherwiseString
toString()
Returns string representation of the schema.org.forgerock.openam.sm.ConfigurationAttributes
validateAndInheritDefaults(org.forgerock.openam.sm.ConfigurationAttributes attrMap, boolean inherit, org.forgerock.openam.sm.ConfigurationAttributes defaults)
Validates theattrMap
against the attributes defined in this schema of the service.org.forgerock.openam.sm.ConfigurationAttributes
validateAndInheritDefaults(org.forgerock.openam.sm.ConfigurationAttributes attrMap, String orgName, boolean inherit, org.forgerock.openam.sm.ConfigurationAttributes defaults)
Validates theattrMap
against the attributes defined in this schema of the service for the given organization.boolean
validateAttributes(List<String> configPath, Map<String,Set<String>> attributeSet)
Determines whether each attribute in the attribute set is valid.boolean
validateAttributes(List<String> configPath, Map<String,Set<String>> attributeSet, String orgName)
Determines whether each attribute in the attribute set is valid for the given organization.boolean
validateAttributes(Map<String,Set<String>> attributeSet)
Determines whether each attribute in the attribute set is valid.boolean
validateAttributes(Map<String,Set<String>> attributeSet, String orgName)
Determines whether each attribute in the attribute set is valid for the given organization.
-
-
-
Field Detail
-
INHERITANCE_SINGLE
public static final String INHERITANCE_SINGLE
This is the schema inheritance of "single", i.e. there is only one instance, this is the default value- See Also:
- Constant Field Values
-
INHERITANCE_MULTIPLE
public static final String INHERITANCE_MULTIPLE
This is the schema inheritance of "multiple", i.e. the service can have multiple instances- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ServiceSchema
protected ServiceSchema(com.sun.identity.sm.ServiceSchemaImpl ssi, String compName, SchemaType type, ServiceSchemaManager ssm)
-
ServiceSchema
protected ServiceSchema(com.sun.identity.sm.ServiceSchemaImpl ssi, String compName, SchemaType type, ServiceSchemaManager ssm, boolean isOrgAttrSchema)
-
-
Method Detail
-
getServiceName
public String getServiceName()
Returns the name of the service.- Returns:
- the name of the schema
-
getVersion
public String getVersion()
Returns the version of the service.- Returns:
- version of the service schema
-
getName
public String getName()
Returns the name of the schema.- Returns:
- the name of the schema
-
getServiceType
public SchemaType getServiceType()
Returns the schema type.- Returns:
- the schema type.
-
getI18NKey
public String getI18NKey()
Returns the I18N key that points to the description of the service. If this schema is a sub schema and does not contain an i18nKey, then the value defaults to the i18nKey of the service.- Returns:
- the I18N key that points to the description of this schema or the description of the service
-
getI18NKeyWithoutDefault
public String getI18NKeyWithoutDefault()
Returns the I18N key that points to the description of the schema, ornull
if not present.- Returns:
- the I18N key that points to the description of this schema
-
supportsMultipleConfigurations
public boolean supportsMultipleConfigurations()
Returnstrue
if service schema supports multiple configurations;false
otherwise- Returns:
true
if service schema supports multiple configurations;false
otherwise
-
getInheritance
public String getInheritance()
Get the inheritance of this schema.The inheritance of a schema relate to that instance having a single instance or multiple instances.
See:
INHERITANCE_SINGLE
andINHERITANCE_MULTIPLE
.- Returns:
- the inheritance
-
setI18Nkey
public void setI18Nkey(String key) throws SMSException, SSOException
Sets the value of the I18N key in the service schema.- Parameters:
key
- Value to be set for the I18N key of the service schema.- Throws:
SMSException
- if there is a problem setting the value in the data store.SSOException
- If the user has an invalid SSO token.
-
setInheritance
public void setInheritance(String value) throws SMSException, SSOException
Set the value of inheritance attribute in service schema.- Parameters:
value
- New value of inheritance attribute.- Throws:
SMSException
- if there is a problem setting the value in the data store.SSOException
- if the user has an invalid single sign on token.
-
getPropertiesViewBeanURL
public String getPropertiesViewBeanURL()
Returns the view bean URL for this service- Returns:
- file name that contains I18N messages
-
getStatusAttribute
public String getStatusAttribute()
Returns the name of the status attribute, as defined in the Service schema- Returns:
- String name of status attribute
-
isExportable
public boolean isExportable()
Returnstrue
if the service configuration created can be exported to other organizations.- Returns:
true
if service configurations for this schema can be exported to other organizations;false
otherwise.
-
setExportable
public void setExportable(boolean exportable)
Sets the exportable nature of the service configurations created for this schema. Setting it totrue
allows the configurations to be exported to other organizations and a value offalse
disables exporting of configuration data.- Parameters:
exportable
-true
if service configurations for this schema can be exported to other organizations;false
otherwise.
-
getI18NFileName
public String getI18NFileName()
Returns the I18N properties file name for the service schema.- Returns:
- the I18N properties file name for the service schema
-
setI18NFileName
public void setI18NFileName(String url) throws SMSException, SSOException
Sets the I18N properties file name for the service schema- Parameters:
url
- properties file name- Throws:
SMSException
- if an error occurred while trying to perform the operationSSOException
- if the single sign on token is invalid or expired
-
getResourceName
public String getResourceName()
Returns the name for the service schema when used in a CREST representation.
-
isHiddenInConfigUI
public boolean isHiddenInConfigUI()
Should this service schema be hidden in the Configuration UI.- Returns:
- True if it should be hidden.
-
isRealmCloneable
public boolean isRealmCloneable()
During the creation of a new organisation/realm the services assigned to the parent realm are copied to the child realm. This will include the sub configs for that service, which in some cases are realm specific and will fail validation if copied. The schemas of these sub configs should setrealmCloneable
tono
to avoid being copied.- Returns:
true
if the config is cloneable between realms.
-
setResourceName
public void setResourceName(String name) throws SMSException, SSOException
Sets the CREST resource name for the service schema.- Parameters:
name
- resource name.- Throws:
SMSException
- if an error occurred while trying to perform the operationSSOException
- if the single sign on token is invalid or expired
-
getAttributeSchemaNames
public Set<String> getAttributeSchemaNames()
Returns the names of the schema attributes defined for the service. It does not return the schema attributes defined for the sub-schema.- Returns:
- the names of schema attributes defined for the service
-
getSearchableAttributeNames
protected Set<String> getSearchableAttributeNames()
Returns the names of the schema attributes defined for the service which are searchable. It does not return the schema attributes defined for the sub-schema.- Returns:
- the names of schema attributes defined for the service which are searchable attributes.
-
getAttributeSchema
public AttributeSchema getAttributeSchema(String attributeName)
Returns the schema for an attribute given the name of the attribute, defined for this service. It returns only the attribute schema defined at the top level for the service and not from the sub-schema.- Parameters:
attributeName
- the name of the schema attribute- Returns:
- the schema for the attribute
-
getInternalAttributeSchema
public org.forgerock.openam.core.sms.AttributeSchemaProvider.Schema getInternalAttributeSchema(String attributeName)
- Parameters:
attributeName
- The name of the attribute to return, maybe null.- Returns:
- A representation of the attribute
AttributeSchemaProvider.Schema
.
-
getAllAttributeSchema
public Set<org.forgerock.openam.core.sms.AttributeSchemaProvider.Schema> getAllAttributeSchema()
-
getAttributeSchemas
public Set<AttributeSchema> getAttributeSchemas()
Returns the attribute schemas defined for the service. It does not return the schema attributes defined for the sub-schema.- Returns:
- attribute schemas defined for the service
-
getServiceAttributeNames
public Set<String> getServiceAttributeNames()
Returns the attribute schemas defined for the service that is not a status attribute and is not a service attribute. It does not return the schema attributes defined for the sub-schema.- Returns:
- attribute schemas defined for the service
-
validateAndInheritDefaults
public org.forgerock.openam.sm.ConfigurationAttributes validateAndInheritDefaults(org.forgerock.openam.sm.ConfigurationAttributes attrMap, boolean inherit, org.forgerock.openam.sm.ConfigurationAttributes defaults) throws SMSException
Validates theattrMap
against the attributes defined in this schema of the service. It will throw an exception if the map contains any attribute not listed in the schema. It will also pick up default values for any attributes not in the map but which are listed in the schema, if the booleaninherit
is set to true.- Parameters:
attrMap
- map of attributesinherit
- if true, then inherit the default values- Returns:
- Map of validated attributes with default values
- Throws:
SMSException
- if invalid attribute names are present in theattrMap
.
-
validateAndInheritDefaults
public org.forgerock.openam.sm.ConfigurationAttributes validateAndInheritDefaults(org.forgerock.openam.sm.ConfigurationAttributes attrMap, String orgName, boolean inherit, org.forgerock.openam.sm.ConfigurationAttributes defaults) throws SMSException
Validates theattrMap
against the attributes defined in this schema of the service for the given organization. It will throw an exception if the map contains any attribute not listed in the schema. It will also pick up default values for any attributes not in the map but which are listed in the schema, if the booleaninherit
is set to true.- Parameters:
attrMap
- map of attributesinherit
- if true, then inherit the default values- Returns:
- Map of validated attributes with default values
- Throws:
SMSException
- if invalid attribute names are present in theattrMap
.
-
addAttributeSchema
public void addAttributeSchema(InputStream xmlAttrSchema) throws SSOException, SMSException
Adds the attribute schema to this service. The schema is defined in XML input stream that follows the SMS DTD.- Parameters:
xmlAttrSchema
- the XML format of the attribute schema- Throws:
SMSException
- if an error occurred while performing the operationSSOException
- if the single sign on token is invalid or expired
-
removeAttributeSchema
public void removeAttributeSchema(String attrName) throws SSOException, SMSException
Removes the attribute schema from this service.- Parameters:
attrName
- the name of the attribute schema- Throws:
SMSException
- if an error occurred while performing the operationSSOException
- if the single sign on token is invalid or expired
-
getAttributeDefaults
public org.forgerock.openam.sm.ConfigurationAttributes getAttributeDefaults()
Returns a map of all the attribute and their default values in this schema.- Returns:
- Map of Attribute Names and Sets of their default values as defined in the Schema
-
getAttributeExamples
public Map<String,Set<String>> getAttributeExamples()
Returns a map of all the attribute and their example values in this schema.- Returns:
- Map of Attribute Names and Sets of their example values as defined in the Schema
-
getReadOnlyAttributeDefaults
public Map getReadOnlyAttributeDefaults()
Returns an unmodifiable map of all the attribute and their default values in this schema.- Returns:
- Map of Attribute Names and Sets of their default values as defined in the Schema
-
removeAttributeDefaults
public void removeAttributeDefaults(Set<String> attrs) throws SMSException, SSOException
Removes the default values of attributes in the schema.- Parameters:
attrs
- A set of the names ofAttributeSchema
.- Throws:
SMSException
- if an error occurred while performing the operationSSOException
- if the single sign on token is invalid or expired
-
getSubSchemaNames
public Set<String> getSubSchemaNames()
Returns the names of sub-schemas for the service.- Returns:
- the names of service's sub-schemas
-
getSubSchema
public ServiceSchema getSubSchema(String subSchemaName) throws SMSException
ReturnsServiceSchema
object given the name of the service's sub-schema.- Parameters:
subSchemaName
- the name of the service's sub-schema- Returns:
ServiceSchema
object- Throws:
SMSException
- if an error occurred while performing the operation
-
addSubSchema
public void addSubSchema(InputStream xmlSubSchema) throws SSOException, SMSException
Adds the service's sub-schema given the XML input stream that follows the SMS DTD.- Parameters:
xmlSubSchema
- the XML format of the sub-schema- Throws:
SMSException
- if an error occurred while performing the operationSSOException
- if the single sign on token is invalid or expired
-
addSubSchema
public void addSubSchema(Document xmlSubSchema) throws SSOException, SMSException
Adds the service's sub-schema given the XML document that follows the SMS DTD.- Parameters:
xmlSubSchema
- the XML format of the sub-schema.- Throws:
SMSException
- if an error occurred while performing the operation.SSOException
- if the single sign on token is invalid or expired.
-
replaceSubSchema
public void replaceSubSchema(String subSchemaName, Document xmlSubSchema) throws SSOException, SMSException
Replaces the service's sub-schema given the XML document that follows the SMS DTD.- Parameters:
subSchemaName
- the name of the service's sub-schemaxmlSubSchema
- the XML format of the sub-schema.- Throws:
SMSException
- if an error occurred while performing the operation.SSOException
- if the single sign on token is invalid or expired.
-
removeSubSchema
public void removeSubSchema(String subSchemaName) throws SSOException, SMSException
Removes the service's sub-schema from the service.- Parameters:
subSchemaName
- the name of the service's sub-schema- Throws:
SMSException
- if an error occurred while performing the operationSSOException
- if the single sign on token is invalid or expired
-
validateAttributes
public boolean validateAttributes(Map<String,Set<String>> attributeSet) throws SMSException
Determines whether each attribute in the attribute set is valid. Iterates though the set checking each element to see if there is a validator that needs to execute.- Parameters:
attributeSet
- theMap
where key is the attribute name and value is theSet
of attribute values- Returns:
- true if all attributes are valid
- Throws:
SMSException
- if an error occurred while performing the operation
-
validateAttributes
public boolean validateAttributes(Map<String,Set<String>> attributeSet, String orgName) throws SMSException
Determines whether each attribute in the attribute set is valid for the given organization. Iterates though the set checking each element to see if there is a validator that needs to execute.- Parameters:
attributeSet
- theMap
where key is the attribute name and value is theSet
of attribute valuesorgName
- organization name- Returns:
- true if all attributes are valid
- Throws:
SMSException
- if an error occurred while performing the operation
-
validateAttributes
public boolean validateAttributes(List<String> configPath, Map<String,Set<String>> attributeSet) throws SMSException
Determines whether each attribute in the attribute set is valid. Iterates though the set checking each element to see if there is a validator that needs to execute.- Parameters:
configPath
- The path of config names to the config instance - the ID of the instance should be the last entry in the list.attributeSet
- theMap
where key is the attribute name and value is theSet
of attribute values- Returns:
- true if all attributes are valid
- Throws:
SMSException
- if an error occurred while performing the operation
-
validateAttributes
public boolean validateAttributes(List<String> configPath, Map<String,Set<String>> attributeSet, String orgName) throws SMSException
Determines whether each attribute in the attribute set is valid for the given organization. Iterates though the set checking each element to see if there is a validator that needs to execute.- Parameters:
configPath
- The path of config names to the config instance - the ID of the instance should be the last entry in the list.attributeSet
- theMap
where key is the attribute name and value is theSet
of attribute valuesorgName
- organization name- Returns:
- true if all attributes are valid
- Throws:
SMSException
- if an error occurred while performing the operation
-
toString
public String toString()
Returns string representation of the schema.
-
getSchemaNode
public Node getSchemaNode()
Returns the Node of this schema element. Used by Policy component'sServiceType
to getActionSchema
.- Returns:
- the Node of this schema element. Used by Policy component's
ServiceType
to getActionSchema
.
-
replaceAttributeSchema
public void replaceAttributeSchema(String attrName, Node attributeSchemaNode) throws SSOException, SMSException
Removes the attribute schema from this service.- Parameters:
attrName
- the name of the attribute schema- Throws:
SMSException
- if an error occurred while performing the operationSSOException
- if the single sign on token is invalid or expired
-
-