AttributeSchema.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: AttributeSchema.java,v 1.13 2009/01/13 06:56:08 mahesh_prasad_r Exp $
*
* Portions Copyrighted 2014-2016 ForgeRock AS.
*/
/**
* The class <code>AttributeSchema</code> provides methods to access the
* schema of a configuration parameter. Also, it provides methods to set default
* and choice values.
*
* @supported.all.api
*/
public class AttributeSchema {
// Debug
// Instance variable
/**
* Constructor. Makes it private so that it cannot be instantiated.
*/
private AttributeSchema() {
}
/**
* Constructor used by ServiceSchema to instantiate
* <code>AttributeSchema</code> objects.
*/
ServiceSchema ss) {
}
}
}
/**
* Returns the name of the attribute.
*
* @return the name of the attribute
*/
}
/**
* Returns the type of the attribute.
*
* @return the type of the attribute
*/
}
/**
* Returns Service Schema.
*
* @return Service Schema.
*/
public ServiceSchema getServiceSchema() {
return ss;
}
/**
* Sets the type.
*
* @param type
* to be changed to
* @throws SMSException
* if an error is encountered when trying to set
* @throws SSOException
* if the single sign on token is invalid or expired
*/
}
/**
* Returns the list order of the attribute.
*
* @return The list order of the attribute, or {@code null} if the list order is not defined.
*/
return as.getListOrder();
}
/**
* Returns the UI type of the attribute.
*
* @return the UI type of the attribute; or null if the UI Type is not
* defined
*/
}
/**
* Sets the <code>UIType</code> attribute.
*
* @param uiType
* user interface type.
* @throws SMSException
* if an error is encountered when trying to set
* <code>UIType</code> to the attribute schema.
* @throws SSOException
* if the single sign on token is invalid or expired
*/
}
/**
* Returns the syntax of the attribute.
*
* @return the syntax of the attribute
*/
}
/**
* Sets the Syntax attribute.
*
* @param synt
* syntax
* @throws SMSException
* if an error is encountered when trying to set the attribute
* syntax
* @throws SSOException
* if the single sign on token is invalid or expired
*/
}
/**
* Returns the I18N key to describe the configuration attribute.
*
* @return the I18N key to describe the configuration attribute
*/
public String getI18NKey() {
return (as.getI18NKey());
}
/**
* Sets the I18N key to describe the configuration attribute.
*
* @param i18nKey
* the I18N key to describe the attribute
* @throws SMSException
* if an error is encountered when trying to set I18N key to the
* attribute schema
* @throws SSOException
* if the single sign on token is invalid or expired
*/
}
/**
* Returns the value of the <code>cosQualifier</code> for this attribute
* that is <code>default, override, operational or merge-cos</code>.
*
* @return the value of the <code>cosQualifier</code>.
*/
public String getCosQualifier() {
return (as.getCosQualifier());
}
/**
* Sets the <code>cosQualifier</code> attribute
*
* @param cosq
* value of <code>cosQualifier</code>.
* @throws SMSException
* if an error is encountered when trying to set.
* @throws SSOException
* if the single sign on token is invalid or expired
*/
}
/**
* Returns the default values of the attribute. If there are no default
* values defined for this attribute in the schema then this method returns
* a Collections.EMPTY_SET
*
* @return set of default values of the attribute
*/
public Set getDefaultValues() {
return (as.getDefaultValues());
}
/**
* Returns the default values of the attribute for the given environment
* parameters. If there are no default values defined for this attribute in
* the schema then this method returns a Collections.EMPTY_SET
*
* @param envParams
* Map of environment parameter to a set of values
* @return set of default values of the attribute
*/
}
/**
* Sets the default values of the attribute.
*
* @param values
* the set of default values
* @throws SMSException
* if an error is encountered when trying to set.
* @throws SSOException
* if the single sign on token is invalid or expired
*/
}
/**
* Protected method to set the default values in the given XML document.
*
* @throws SMSException
* if an error is encountered when trying to set.
* @throws SSOException
* if the single sign on token is invalid or expired
*/
}
/**
* Adds a default value to the existing set of default values.
*
* @param value
* the default value to add
* @throws SMSException
* if an error is encountered when trying to set.
* @throws SSOException
* if the single sign on token is invalid or expired
*/
{
} else {
defaultValues = new HashSet();
}
}
/**
* Removes the all the default values for the attribute.
*
* @throws SMSException
* if an error is encountered when trying to set.
* @throws SSOException
* if the single sign on token is invalid or expired
*
*/
updateDefaultValues(new HashSet());
}
/**
* Removes the given value from the set of default values.
*
* @param value
* the default value to remove
* @throws SMSException
* if an error is encountered when trying to set.
* @throws SSOException
* if the single sign on token is invalid or expired
*/
}
}
/**
* Returns the possible choice values for the attribute if the attribute
* type is either <code>SINGLE_CHOICE</code> or
* <code>MULTIPLE_CHOICE</code>.
*
* @return set of possible choice values
*/
public String[] getChoiceValues() {
return (as.getChoiceValues());
}
/**
* Returns the possible choice values for the attribute if the attribute
* type is either <code>SINGLE_CHOICE</code> or
* <code>MULTIPLE_CHOICE</code>, for the given environment parameters.
*
* @param envParams
* Map of environment parameter to a set of values
* @return set of possible choice values
*/
}
/**
* Returns the possible choice values for the attribute if the attribute
* type is either <code>SINGLE_CHOICE</code> or
* <code>MULTIPLE_CHOICE</code>, for the given environment parameters,
* along with the values' i18n keys.
*
* @param envParams
* Map of environment parameter to a set of values
* @return Map of value to i18n key.
*/
}
/**
* Indicates whether this AttributeSchema has choice values defined.
*/
public boolean hasChoiceValues() {
return as.hasChoiceValues();
}
/**
* Returns the I18N key for the given choice value.
*
* @param cValue
* choice value.
* @return the I18N key for the given choice value
*/
}
/**
* Adds a choice value and its i18n key to the existing set of choice
* values.
*
* @param value
* the choice value to add
* @param i18nKey
* the I18N key for the choice value
* @throws SMSException
* if an error is encountered when trying to set.
* @throws SSOException
* if the single sign on token is invalid or expired
*/
throws SMSException, SSOException {
}
/**
* Removes the given value from the set of choice values.
*
* @param value
* the choice value to remove
* @throws SMSException
* if an error is encountered when trying to set.
* @throws SSOException
* if the single sign on token is invalid or expired
*/
}
}
/**
* Returns the start range if the attribute syntax is either
* <code>NUMBER_RANGE</code> or <code>DECIMAL_RANGE</code>.
*
* @return the start range for the attribute value
*/
public String getStartRange() {
return (as.getStartRange());
}
/**
* Sets the start range attribute.
*
* @param stRange
* start range.
* @throws SMSException
* if an error is encountered when trying to set
* @throws SSOException
* if the single sign on token is invalid or expired
*/
{
}
/**
* Returns the end range if the attribute syntax is either
* <code>NUMBER_RANGE</code> or <code>DECIMAL_RANGE</code>.
*
* @return the end range for the attribute value
*/
public String getEndRange() {
return (as.getEndRange());
}
/**
* Sets the end range Attribute.
*
* @param edRange
* end range.
* @throws SMSException
* if an error is encountered when trying to set
* @throws SSOException
* if the single sign on token is invalid or expired
*/
}
/**
* Method to get the validator name for using to validate this service
* attribute
*
* @return the validator name
*/
public String getValidator() {
return (as.getValidator());
}
/**
* Sets the Validator attribute
*
* @param valid
* validator
* @throws SMSException
* if an error is encountered when trying to set
* @throws SSOException
* if the single sign on token is invalid or expired
*/
}
/**
* Returns the minimum number of values for the attribute if the attribute
* is of type <code>MULTIPLE_CHOICE</code>.
*
* @return the minimum number of values
*/
public int getMinValue() {
return (as.getMinValue());
}
/**
* Sets the minimum value attribute.
*
* @param minV
* minimum value.
* @throws SMSException
* if an error is encountered when trying to set
* @throws SSOException
* if the single sign on token is invalid or expired
*/
}
/**
* Returns the maximum number of values for the attribute if the attribute
* is of type <code>MULTIPLE_CHOICE</code>.
*
* @return the maximum number of values
*/
public int getMaxValue() {
return (as.getMaxValue());
}
/**
* Sets the maximum value attribute.
*
* @param maxV
* maximum value.
* @throws SMSException
* if an error is encountered when trying to set
* @throws SSOException
* if the single sign on token is invalid or expired
*/
}
/**
* Sets the boolean values of the attribute.
*
* @param trueValue string value for <code>BooleanTrueValue</code>.
* @param trueValueI18nKey <code>I18N</code> key for
* <code>BooleanTrueValue</code>.
* @param falseValue string value for <code>BooleanFalseValue</code>.
* @param falseValueI18nKey <code>I18N</code> Key for
* <code>BooleanFalseValue</code>.
* @throws SMSException if an error is encountered when trying to set.
* @throws SSOException if the single sign on token is invalid or expired
*/
public void setBooleanValues(
) throws SSOException, SMSException {
}
/**
* Returns the string value for <code>BooleanTrueValue</code>.
*
* @return the string value for <code>BooleanTrueValue</code>.
*/
public String getTrueValue() {
return (as.getTrueValue());
}
/**
* Returns the <code>I18N</code> key for <code>BooleanTrueValue</code>.
*
* @return the <code>I18N</code> key for <code>BooleanTrueValue</code>.
*/
public String getTrueValueI18NKey() {
return (as.getTrueValueI18NKey());
}
/**
* Returns the string value for <code>BooleanFalseValue</code>.
*
* @return the string value for <code>BooleanFalseValue</code>.
*/
public String getFalseValue() {
return (as.getFalseValue());
}
/**
* Returns the <code>I18N</code> Key for <code>BooleanFalseValue</code>.
*
* @return the <code>I18N</code> Key for <code>BooleanFalseValue</code>.
*/
public String getFalseValueI18NKey() {
return (as.getFalseValueI18NKey());
}
/**
* Returns true if the attribute is an optional attribute.
*
* @return true if the attribute is an optional attribute.
*/
public boolean isOptional() {
return (as.isOptional());
}
/**
* Returns true if the attribute is a service identifier (i.e., in the case
* of LDAP it would be the COS Specifier attribute).
*
* @return true if the attribute is service identifier attribute.
*/
public boolean isServiceIdentifier() {
return (as.isServiceIdentifier());
}
/**
* Checks if the attribute allows to have resource name.
*
* @return true if the attribute allows to have resource name; false
* otherwise
*/
public boolean isResourceNameAllowed() {
return (as.isResourceNameAllowed());
}
/**
* Returns true if the attribute is a service's status attribute.
*
* @return true if the attribute is a status attribute.
*/
public boolean isStatusAttribute() {
return (as.isStatusAttribute());
}
/**
* Method to get service specific attributes. It return the value of the
* "any" attribute, if set in the XML schema for the service
*
* @return value of "any" attribute
*/
}
/**
* Sets the any attribute.
*
* @param a
* value for any attribute.
* @throws SMSException
* if an error is encountered when trying to set.
* @throws SSOException
* if the single sign on token is invalid or expired.
*/
}
/**
* Returns URL of the view bean for the attribute.
*
* @return URL for view bean
*/
public String getPropertiesViewBeanURL() {
return (as.getPropertiesViewBeanURL());
}
/**
* Sets the URL of the view bean for the attribute.
*
* @param prop
* properties view bean URL.
* @throws SMSException
* if an error is encountered when trying to set.
* @throws SSOException
* if the single sign on token is invalid or expired.
*/
}
/**
* Returns <code>true</code> if the attribute is searchable;
* <code>false</code> otherwise
*
* @return <code>true</code> if the attribute is an optional attribute;
* <code>false</code> otherwise
*/
public boolean isSearchable() {
return (as.isSearchable());
}
/**
* Sets the attribute isSearchable, if value is set to <code>true
* </code>,
* or <code>false</code>.
*
* @param value
* if set to <code>true</code> the attribute will be
* searchable; else searches cannot be performed on this
* attribute.
* @throws SMSException
* if an error is encountered when trying to set
* @throws SSOException
* if the single sign on token is invalid or expired
*/
.getString("sms-invalid-searchable-value")
}
}
/**
* Returns the name of this attribute when used in a CREST representation.
*/
public String getResourceName() {
}
/**
* Sets the CREST representation name for the attribute.
*
* @param name
* the name of the CREST property.
* @throws SMSException
* if an error is encountered when trying to set.
* @throws SSOException
* if the single sign on token is invalid or expired.
*/
}
/**
* Returns a string representation of this <code> AttributeSchema </code>
* object.
*
* @return String representation of this object
*/
}
/**
* Method for modifying default values
*/
}
/**
* Method for modifying default values given the XML document
*/
throws SMSException, SSOException {
// Check if the values are valid
}
// Check if the attributes have to be encoded
boolean encode = false;
encode = true;
}
// Construct DefaultValues node
if (encode) {
try {
} catch (Throwable e) {
}
} else {
.next()));
}
}
}
}
throws SMSException, SSOException {
// Construct ChoiceValues
.next());
} else {
}
}
}
protected void updateBooleanValues(
) throws SMSException, SSOException {
// Construct BooleanValues
} else {
}
} else {
}
}
// Update the default element in XML
try {
// Construct the XML document
// Convert to Schema's document
} else {
}
// Traverse the document to get this attribute element
} else {
}
// Try getting OrganizationAttributeSchema if AttributeSchema
// node is not there within Organization node.
// This will be a special case for idrepo service.
if (attrSchemaNode == null) {
}
} else {
}
// Update the schema in the directory
// do nothing
} else {
}
} catch (Exception e) {
throw (new SMSException(e.getMessage(), e,
"sms-cannot-update-xml-document"));
}
}
/**
* update attribute value in attribute schema element
*/
throws SMSException, SSOException {
// Update the default element in XML
try {
// Construct the XML document
} else {
}
// Traverse the document to get this attribute element
} else {
}
// Update the schema in the directory
} else {
}
} catch (Exception e) {
throw (new SMSException(e.getMessage(), e,
"sms-cannot-update-xml-document"));
}
}
/**
* The class <code>Type</code> defines the types of schema attributes and
* provides static constants for these types. This could also be viewed as a
* higher level structured data types like Set, List, etc. The primitive
* data types are defined by <code>Syntax</code>. Currently defined
* schema attribute types are <code>SINGLE</code>, <code>LIST</code>,
* <code>SINGLE_CHOICE</code>, <code>MULTIPLE_CHOICE</code>,
* <code>SIGNATURE</code> and <code>VALIDATOR</code>.
*/
/**
* The <code>SINGLE</code> attribute type specifies that the attribute
* can have only a single value.
*/
/**
* The <code>LIST</code> attribute type specifies that the attribute
* can have multiple values, i.e., multi-valued attribute.
*/
/**
* The <code>SINGLE_CHOICE</code> attribute type specifies that the
* attribute can have value defined by the <code>getChoiceValues</code>
* method of <code>AttributeSchema</code>.
*/
/**
* The <code>MULTIPLE_CHOICE</code> attribute type specifies that the
* attribute can have multiple values defined by the
* <code>getChoiceValues</code> method of <code>AttributeSchema</code>.
*/
/**
* The <code>SIGNATURE</code> attribute type specifies that the
* attribute is a signing attribute.
*/
/**
* The <code>VALIDATOR</code> attribute type specifies that the
* attribute defines a attribute validator plugin.
*/
private Type() {
}
}
/**
* The method returns the string representation of the schema attribute
* type.
*
* @return String string representation of schema attribute type
*/
return attrType;
}
/**
* Method to check if two schema attribute types are equal.
*
* @param schemaAttrType
* the reference object with which to compare
*
* @return <code>true</code> if the objects are same; <code>
* false</code>
* otherwise
*/
if (schemaAttrType instanceof Type) {
}
return (false);
}
/**
* Returns a hash code value for the object.
*
* @return a hash code value for the object
*/
public int hashCode() {
}
}
/**
* This enum {@code ListOrder} defines the list orders of schema attributes and provides constants for these list
* orders. These types will mainly be used by the GUI to determine how to display the schema attributes.
*/
public enum ListOrder {
/** Orders lists naturally. */
/** Orders lists in the order they are entered in LDAP. */
}
/**
* The class <code>UIType</code> defines the UI types of schema attributes
* and provides static constants for these types. These types mainly will be
* used by the GUI to determine how to display the schema attributes.
* Currently defined schema attribute UI types are <code>RADIO</code>,
* <code>LINK</code>, <code>BUTTON</code> and
* <code>NAME_VALUE_LIST</code>
*/
/**
* The <code>RADIO</code> attribute type specifies that the attribute
* should be display as radio button.
*/
/**
* The <code>LINK</code> attribute type specifies that the attribute
* should be display as a link.
*/
/**
* The <code>BUTTON</code> attribute type specifies that the attribute
* should be display as a button.
*/
/**
* The <code>NAME_VALUE_LIST</code> attribute type specifies that the
* attribute should be display as a name value list widget.
*/
"name_value_list");
/**
* The <code>UNORDERED_LIST</code> attribute type specifies that the
* attribute should be display as an unordered list widget.
*/
/**
* The <code>ORDERED_LIST</code> attribute type specifies that the
* attribute should be display as an ordered list widget.
*/
/**
* The <code>MAP_LIST</code> attribute type specifies that the
* attribute should be display as an map list widget.
*/
/**
* The <code>GLOBALMAP_LIST</code> attribute type specifies that the
* attribute should be display as a global map list widget.
*/
/**
* The <code>ADDREMOVELIST</code> attribute type specifies that the
* multiple choice attribute should be display as add remove list
* widget.
*/
/**
* The <code>SCRIPTSELECT</code> attribute type specifies that the
* attribute should be display as drop down widget.
*/
/**
* The <code>GLOBALSCRIPTSELECT</code> attribute type specifies that the
* attribute should be display as drop down widget with only global scripts.
*/
private UIType() {
}
}
/**
* The method returns the string representation of the schema attribute
* UI type.
*
* @return String string representation of schema attribute UI type
*/
return attrType;
}
/**
* Method to check if two schema attribute UI types are equal.
*
* @param schemaAttrType
* the reference object with which to compare
*
* @return <code>true</code> if the objects are same; <code>
* false</code>
* otherwise
*/
if (schemaAttrType instanceof UIType) {
}
return (false);
}
/**
* Returns a hash code value for the object.
*
* @return a hash code value for the object
*/
public int hashCode() {
}
}
/**
* The class <code>Syntax</code> defines the syntax of the schema
* attributes and provides static constants for these types. In other words,
* this class defines the primitive data types for the schema attributes.
*/
public static class Syntax {
/**
* The <code>BOOLEAN</code> attribute syntax specifies that the
* attribute is of boolean type, i.e., can have a value of either
* <code>true</code> or <code>
* false</code>
*/
/**
* The <code>EMAIL</code> attribute syntax specifies that the
* attribute is a email address.
*/
/**
* The <code>URL</code> attribute syntax specifies that the attribute
* is a URL.
*/
/**
* The <code>STRING</code> attribute syntax specifies that the
* attribute is of text type, i.e., can have any unicode characters.
*/
/**
* The <code>PARAGRAPH</code> attribute syntax specifies that the
* attribute is of multi-lined text type.
*/
/**
* The <code>XML</code> attribute syntax specifies that the attribute
* is of XML type, i.e., can have any unicode characters.
*/
/**
* The <code>SCRIPT</code> attribute syntax specifies that the
* attribute is of multi-lined text type and more specifically a script.
*/
/**
* The <code>PASSWORD</code> attribute syntax specifies that the
* attribute is of password type, will be used by UI to mask the
* password typed.
*/
/**
* The <code>ENCRYPTED PASSWORD</code> attribute syntax specifies that
* the attribute is of password type, will be used by UI to mask the
* password typed.
*/
"encrypted_password");
/**
* The <code>DATE</code> attribute syntax specifies that the attribute
* is of date type.
*/
/**
* The <code>NUMERIC</code> attribute syntax specifies that the
* attribute is numeric, i.e., can have numbers only.
*/
/**
* The <code>NUMBER</code> attribute syntax specifies that the
* attribute is a number.
*/
/**
* The <code>DECIMAL</code> attribute syntax specifies that the
* attribute is a decimal value.
*/
/**
* The <code>PERCENT</code> attribute syntax specifies that the
* attribute is a percentage.
*/
/**
* The <code>NUMBER_RANGE</code> attribute syntax specifies that the
* attribute is a number within a range.
*/
/**
* The <code>DECIMAL_RANGE</code> attribute syntax specifies that the
* attribute is a decimal number within a range.
*/
/**
* The <code>DECIMAL_NUMBER</code> attribute syntax specifies that the
* attribute is a floating point number, e.g., 1.5, 3.56, etc.
*/
public static final Syntax DECIMAL_NUMBER =
new Syntax("decimal_number");
/**
* The <code>DN</code> attribute syntax specifies that the attribute
* should be an LDAP distinguished name (DN).
*/
private String attrSyntax;
private Syntax() {
}
attrSyntax = syntax;
}
/**
* The method returns the string representation of the schema attribute
* syntax.
*
* @return String string representation of schema attribute syntax
*/
return (attrSyntax);
}
/**
* Method to check if two schema attribute syntax are equal.
*
* @param schemaAttrSyntax
* the reference object with which to compare
*
* @return <code>true</code> if the objects are same; <code>
* false</code>
* otherwise
*/
if (schemaAttrSyntax instanceof Syntax) {
}
return (false);
}
/**
* Returns a hash code value for the object.
*
* @return a hash code value for the object
*/
public int hashCode() {
return attrSyntax.hashCode();
}
}
private static final String XML_PREFIX =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
private static final String BOOLEAN_VALUES_BEGIN =
private static final String BOOLEAN_VALUES_END =
private static final String TRUE_BOOLEAN_KEY =
private static final String FALSE_BOOLEAN_KEY =
}