8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * opensso/legal/CDDLv1.0.txt
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * at opensso/legal/CDDLv1.0.txt.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: ChoiceValues.java,v 1.3 2008/06/25 05:44:03 qcheng Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.sun.identity.sm;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Map;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.w3c.dom.Node;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The abstract class <code>ChoiceValues</code> provides a mechanism for
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * services to provide choice values for attributes dynamically instead of being
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * statically defined in the service XML file stored in the directory.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <p>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * An implementation of this class must be specified in the service
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * configuration XML file in the definition of the respective attribute schema.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Instead of providing the choice values in the XML configuration file, the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * class name must be specified within the XML node
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>ChoiceValuesClassName</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.all.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic abstract class ChoiceValues {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Abstract method that must be implemented by a class extending this class,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * and should return the choice values and their corresponding I18N key, for
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return choice values for the attribute as a <code>java.util.Map</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Key being the choice and the value being the I18N key
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public abstract Map getChoiceValues();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the choice values for attribute for the given environment
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * parameters. The default implementation calls the interface
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>getChoiceValues</code> without the parameter. A class extending
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * this class can override this method to return the choice values and their
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * corresponding I18N key, for the attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param envParams
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * environment parameters
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return choice values for the attribute as a <code>java.util.Map</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Key being the choice and the value being the I18N key
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Map getChoiceValues(Map envParams) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (getChoiceValues());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the name of the attribute for which the choice values will be
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * returned.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the name of attribute for which the choice values are returned
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final String getAttributeName() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (attributeSchema.getName());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the configured key-value pairs for the class in the service's
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * configuration file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return key-value pairs configured for this class in the service schema
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * XML file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final Map getConfiguredKeyValues() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (keyValues);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the XML <code>AttributeSchema</code> node associated with this
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return XML node of <code>AttributeSchema</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public final Node getAttributeSchemaNode() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (parentNode);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Set the <code>AttributeSchema</code> for which the choice values are
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * being obtained
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster final void setAttributeSchema(AttributeSchemaImpl as) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster attributeSchema = as;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the key-values pairs configured for this object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster final void setKeyValues(Node node) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster keyValues = CreateServiceConfig.getAttributeValuePairs(node);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the <code>AttributeSchema</code> node of the XML schema
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster final void setParentNode(Node n) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster parentNode = n;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Pointer to AttributeSchema, key-value pairs and parent node
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster AttributeSchemaImpl attributeSchema;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Map keyValues;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node parentNode;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}