ServiceSchemaImpl.java revision 590e03a0114f53c994d970cfb356dadaaa57e39d
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: ServiceSchemaImpl.java,v 1.7 2008/06/25 05:44:05 qcheng Exp $
*
* Portions Copyrighted 2012-2016 ForgeRock AS.
*/
/**
* The class <code>ServiceSchema</code> 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.
*/
class ServiceSchemaImpl {
// ServiceSchema XML node
// Instance variables
// Attribute & sub-schema variables
boolean isOrgAttrSchema;
private volatile boolean valid = false;
// Debug class
// do nothing
}
// Protected Constructor
}
// Protected constructor
}
/**
* Returns the name of the schema.
*/
return (name);
}
/**
* Returns the name of the schema for CREST representation.
*/
return resourceName;
}
/**
* Should this service schema be hidden in the Configuration UI.
* @return True if it should be hidden.
*/
boolean isHiddenInConfigUI() {
}
/**
* 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 set {@code realmCloneable} to {@code no} to
* avoid being copied.
*
* @return {@code true} if the config is cloneable between realms.
*/
boolean isRealmCloneable() {
// value is null in some schemas and we want to default to true, so check for "no" rather than "yes"
}
/**
* Returns the I18N key that points to the description of the service.
*/
String getI18NKey() {
: i18nKey;
}
/**
* Returns statusAttribute name
*
*/
return (statusAttribute);
}
/**
*/
String getValidate() {
return (validate);
}
/**
* Returns <code>true</code> if service schema supports multiple
* configurations; <code>false</code> otherwise.
*/
boolean supportsMultipleConfigurations() {
return (inheritance != null)
}
/**
* 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 the schema attributes defined for the service which
* are searchable. It does not return the schema attributes defined for the
* sub-schema.
*/
protected Set getSearchableAttributeNames() {
if (searchableAttributeNames != null
&& !searchableAttributeNames.isEmpty()) {
if ((isOrgAttrSchema)
serviceName.toLowerCase()))) {
} else {
}
}
}
return (searchableAttributeNames);
}
return (new HashSet(serviceAttributes));
}
/**
* 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.
*/
}
}
/**
* Get a map of all the attribute and their default values in this schema
*/
}
/**
* Get a read only map (Unmodifiable map) of all the attribute and their
* default values in this schema
*/
return attrReadOnlyDefaults;
}
/**
* Returns the names of sub-schemas for the service.
*/
Set getSubSchemaNames() {
}
/**
* Returns <code>ServiceSchema</code> object given the name of the
* service's sub-schema.
*/
}
/**
* Returns <code>ServiceSchema</code> for creating Organizations if
* present; else <code>null</code>.
*/
return (orgAttrSchema);
}
/**
* 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.
*/
throws SMSException {
}
/**
* Determines whether each attribute in the attribute set is valid. This
* method additionally takes the organization name that would be passed to
* the validation. Iterates though the set checking each element to see if
* there is a validator that needs to execute.
*/
}
/**
* Determines whether each attribute in the attribute set is valid. This
* method additionally takes the organization name and SSOToken that would
* be passed to the validation. Iterates though the set checking each element
* to see if there is a validator that needs to execute.
*/
// Do not validate attributes in this subschema
return (true);
}
// to check for duplicates (case insensitive)
// For each attribute, validate its values
{
"sms-attributeschema-duplicates", args);
} else {
}
}
}
return (true);
}
}
if (getResourceName() != null) {
}
// Attributes
}
}
// Sub-schemas
}
}
}
Node getSchemaNode() {
return (schemaNode);
}
// -----------------------------------------------------------
// Protected methods
// -----------------------------------------------------------
schemaNode = sNode;
if (schemaNode == null) {
if (debug.warningEnabled()) {
}
name = "";
i18nFileName = null;
serviceAttributes = new HashSet();
searchableAttributeNames = new HashSet();
subSchemas = new CaseInsensitiveHashMap();
}
// Get the name and i18nKey
// Update sub-schema's, organization schema and attributes
if (attrSchemas != null) {
}
} else {
// Get the instance of attribute schema and update it
}
}
if (asi.isSearchable()) {
}
if (subSchemas != null) {
}
} else {
}
}
{
}
}
valid = true;
}
synchronized void clear() {
// org attr-schema
if (orgAttrSchema != null) {
}
// Sub-schemas
}
}
//important to clean all reference to ServiceSchemaManagerImpl
//finally clear all subschemas
subSchemas.clear();
//when clear is called, this object is no longer valid.
valid = false;
}
return null;
}
}
return (av);
}
// Validates the values for the attribute, for the
// given organization name
// Do not validate attributes in this subschema
return;
}
// Invalid attribute name
if (debug.messageEnabled()) {
}
throw (new InvalidAttributeNameException(
"sms-validation_failed_invalid_name", args));
}
// Check if required attributes have values
// %%% Due to comms issue, where they define AttributeSchema
// %%% without default values, this check should not be done
// %%% if orgName is null
// OrgName should be null only during loading of schema
// and when ServiceSchema.validateAttributes(...) is called
// with no orgName param or if orgName == null
"sms-required-attribute-delete", args);
"ServiceSchemaImpl.validateAttrValues: " + attrName
+ " is a required attribute and cannot"
+ " be deleted", smse);
throw smse;
}
}
// If orgName is not null, pass it as an environment map
}
} else {
}
}
/**
* Validates the attribute with the validation plugin if a plugin has been
* registered for this attribute in the service schema.
*
* @param token
* Single Sign On token.
* @param attrName
* the name of the attribute to validate
* @param values
* the <code>Set</code> of string values to validate
* @return true if the values are valid or there is no validation plugin
* registered to the attribute; false otherwise
* @throws SMSException
* error during instantiating the Java class
* @throws InvalidAttributeNameException
* the attribute does not appear in the schema
*/
) throws SMSException, InvalidAttributeNameException {
throw new InvalidAttributeNameException(
"sms-validation_failed_invalid_name", args);
}
if (validatorName == null) {
// no validator registered for this service attribute
return true;
}
if (validatorAttrSchema != null) {
try {
} catch (SMSException e) {
if (!isServerMode) {
} else {
throw e;
}
}
}
}
return true;
}
private void clientEndAttrValidation(
) throws SMSException {
) {
}
}
private void serverEndAttrValidation(
) throws SMSException {
try {
clazz.newInstance();
}
} catch (InstantiationException ex) {
args);
} catch (IllegalAccessException ex) {
args);
} catch (ClassNotFoundException ex) {
args);
}
}
private void validatePlugin(
) throws InvalidAttributeValueException {
(validator instanceof RequiredValueValidator),
}
}
private void throwInvalidAttributeValuesException(
boolean isRequiredValue,
throws InvalidAttributeValueException {
? "sms-attribute-values-missing"
: "sms-attribute-values-does-not-match-schema";
if (i18nFileName != null) {
throw new InvalidAttributeValueException(
} else {
throw new InvalidAttributeValueException(
}
}
boolean isValid() {
return valid;
}
/**
* Returns the I18N properties file name for the service schema.
*
* @return the I18N properties file name for the service schema
*/
return i18nFileName;
}
}