ServiceSchemaManager.java revision 462c13f3868602f960e6d27438972e565417734c
/**
* 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: ServiceSchemaManager.java,v 1.12 2009/07/25 05:11:55 qcheng Exp $
*
* Portions Copyrighted 2012-2015 ForgeRock AS.
*/
/**
* The class <code>ServiceSchemaManager</code> provides interfaces to manage
* the service's schema. It provides access to <code>ServiceSchema</code>,
* which represents a single "schema" in the service.
*
* @supported.api
*/
public class ServiceSchemaManager {
private String serviceName;
private ServiceSchemaManagerImpl ssm;
/**
* Constructor for service's schema manager to manage the attributes and
* sub configurations. Assumes service version number to be <class>1.0
* </class>.
*
* @throws SMSException
* if an error occurred while trying to perform the operation
* @throws SSOException
* if the single sign on token is invalid or expired
*/
throws SMSException, SSOException {
}
/**
* Creates an instance of
* <code>ServiceSchemaManager</code> for the given service and version
* pair. It requires an user identity, that will used to perform operations
* with. It is assumed that the application calling this constructor should
* authenticate the user.
*
* @param token
* single sign on token of the user identity on whose behalf the
* operations are performed.
* @param serviceName
* the name of the service.
* @param version
* the version of the service.
* @throws SMSException
* if an error occurred while trying to perform the operation
* @throws SSOException
* if the single sign on token is invalid or expired
*
* @supported.api
*/
}
this.serviceName = serviceName;
}
/**
* Returns the name of the service.
*
* @return the name of the service
*
* @supported.api
*/
return (serviceName);
}
/**
* Returns the version of the service.
*
* @return the version of the service
*
* @supported.api
*/
public String getVersion() {
return (version);
}
/**
* Returns the I18N properties file name for the
* service.
*
* @return the I18N properties file name for the service
*
* @supported.api
*/
public String getI18NFileName() {
validate();
return (ssm.getI18NFileName());
}
/**
* Sets the I18N properties file name for the service
*
* @param url
* properties file name
* @throws SMSException
* if an error occurred while trying to perform the operation
* @throws SSOException
* if the single sign on token is invalid or expired
*
* @supported.api
*/
try {
} catch (SMSException se) {
throw se;
}
}
/**
* Returns the URL of the JAR file that contains the
* I18N properties file. The method could return null, in which case the
* properties file should be in <code>CLASSPATH</code>.
*
* @return the URL of the JAR file containing the <code>I18N</code>
* properties file.
*
* @supported.api
*/
public String getI18NJarURL() {
validate();
return (ssm.getI18NJarURL());
}
/**
* Sets the URL of the JAR file that contains the I18N
* properties
*
* @param url
* URL
* @throws SMSException
* if an error occurred while trying to perform the operation
* @throws SSOException
* if the single sign on token is invalid or expired
*
* @supported.api
*/
try {
} catch (SMSException se) {
throw se;
}
}
/**
* Returns the service's hierarchy.
*
* @return service hierarchy in slash format.
*
* @supported.api
*/
public String getServiceHierarchy() {
validate();
return (ssm.getServiceHierarchy());
}
/**
* Sets the service's hierarchy
*
* @param newhierarchy
* service hierarchy
* @throws SMSException
* if an error occurred while trying to perform the operation
* @throws SSOException
* if the single sign on token is invalid or expired
*
* @supported.api
*/
try {
} catch (SMSException e) {
throw e;
}
}
/**
* Returns i18nKey of the schema.
*
* @return i18nKey of the schema.
*
* @supported.api
*/
public String getI18NKey() {
validate();
return (ssm.getI18NKey());
}
/**
* Sets the i18nKey of the schema.
*
* @param i18nKey
* <code>i18nKey</code> of the schema.
* @throws SMSException
* if an error occurred while trying to perform the operation.
* @throws SSOException
* if the single sign on token is invalid or expired.
*
* @supported.api
*/
try {
} catch (SMSException e) {
throw e;
}
}
/**
* Returns URL of the view bean for the service
*
* @return URL for view bean
*
* @supported.api
*/
public String getPropertiesViewBeanURL() {
validate();
return (ssm.getPropertiesViewBeanURL());
}
/**
* Sets the URL of the view bean for the service.
*
* @param url
* of the view bean for the service.
* @throws SMSException
* if an error occurred while trying to perform the operation.
* @throws SSOException
* if the single sign on token is invalid or expired.
*
* @supported.api
*/
try {
} catch (SMSException e) {
throw e;
}
}
/**
* iPlanet_PUBLIC-METHOD Returns the revision number of the service schema.
*
* @return the revision number of the service schema
*/
public int getRevisionNumber() {
validate();
return (ssm.getRevisionNumber());
}
/**
* iPlanet_PUBLIC-METHOD Sets the revision number for the service schema.
*
* @param revisionNumber
* revision number of the service schema.
* @throws SMSException
* if there is a problem setting the value in the data store.
* @throws SSOException
* If the user has an invalid SSO token.
*/
try {
} catch (SMSException e) {
throw (e);
}
}
/**
* Returns the schema types available with this
* service.
*
* @return set of <code>SchemaTypes</code> in this service.
* @throws SMSException
* if an error occurred while trying to perform the operation
*
* @supported.api
*/
validate();
return (ssm.getSchemaTypes());
}
/**
* Returns the configuration schema for the given
* schema type
*
* @param type
* schema type.
* @return service schema.
* @throws SMSException
* if an error occurred while trying to perform the operation
*
* @supported.api
*/
validate();
SchemaType t = null;
t = SchemaType.DYNAMIC;
t = SchemaType.USER;
} else {
t = new SchemaType(type);
}
return (getSchema(t));
}
/**
* Returns the configuration schema for the given
* schema type
*
* @param type
* schema type.
* @return service schema.
* @throws SMSException
* if an error occurred while trying to perform the operation
*
* @supported.api
*/
validate();
}
}
return (null);
}
/**
* Returns the organization creation configuration schema if present; else
* returns <code>null</code>
*
* @return service schema.
* @throws SMSException
* if an error occurred while trying to perform the operation
*/
validate();
this, true));
}
}
return (null);
}
/**
* Returns the attribute schemas for the given schema
* type excluding status and service identifier attributes.
*
* @param type
* schema type.
* @return service schema.
* @throws SMSException
* if an error occurred while trying to perform the operation
*
* @supported.api
*/
validate();
return (ss.getServiceAttributeNames());
}
/**
* Returns the global service configuration schema.
*
* @return the global service configuration schema
* @throws SMSException
* if an error occurred while trying to perform the operation
*
* @supported.api
*/
}
/**
* Returns the organization service configuration
* schema.
*
* @return the organization service configuration schema
* @throws SMSException
* if an error occurred while trying to perform the operation
*
* @supported.api
*/
}
/**
* Returns the dynamic service configuration schema.
*
* @return the dynamic service configuration schema
* @throws SMSException
* if an error occurred while trying to perform the operation
*
* @supported.api
*/
}
/**
* Returns the user service configuration schema.
*
* @return the user service configuration schema
* @throws SMSException
* if an error occurred while trying to perform the operation
*
* @supported.api
*/
}
/**
* Returns the policy service configuration schema.
*
* @return the policy service configuration schema
* @throws SMSException
* if an error occurred while trying to perform the operation
*
* @supported.api
*/
}
/**
* Returns the service schema in XML for this service.
*
* @return the service schema in XML for this service
* @throws SMSException
* if an error occurred while trying to perform the operation
*
* @supported.api
*/
validate();
}
/**
* Replaces the existing service schema with the given
* schema defined by the XML input stream that follows the SMS DTD.
*
* @param xmlServiceSchema
* the XML format of the service schema
* @throws SMSException
* if an error occurred while trying to perform the operation
* @throws SSOException
* if the single sign on token is invalid or expired
* @throws IOException
* if an error occurred with the <code> InputStream </code>
*
* @supported.api
*/
}
// @Override
public int hashCode() {
int hash = 7;
return hash;
}
/**
* Returns true if the given object equals this
* object.
*
* @param o
* object for comparison.
* @return true if the given object equals this object.
*
* @supported.api
*/
if (o instanceof ServiceSchemaManager) {
return (true);
}
}
return (false);
}
/**
* Returns the string representation of the Service
* Schema.
*
* @return the string representation of the Service Schema.
*
* @supported.api
*/
validate();
}
/**
* Registers for changes to service's schema. The
* object will be called when schema for this service and version is
* changed.
*
* @param listener
* callback object that will be invoked when schema changes.
* @return an ID of the registered listener.
*
* @supported.api
*/
validate();
}
/**
* Removes the listener from the service for the given
* listener ID. The ID was issued when the listener was registered.
*
* @param listenerID
* the listener ID issued when the listener was registered
*
* @supported.api
*/
}
}
/**
* Returns the last modified time stamp of this service schema. This method
* is expensive because it does not cache the modified time stamp but goes
* directly to the data store to obtain the value of this entry
*
* @return The last modified time stamp as a string with the format of
* <code>yyyyMMddhhmmss</code>
* @throws SMSException if there is an error trying to read from the
* datastore.
* @throws SSOException if the single sign-on token of the user is invalid.
*/
}
true);
}
return mTS;
}
// ================= Plugin Interface Methods ========
/**
* Returns the names of the plugin interfaces used by the service
*
* @return service's plugin interface names
*/
public Set getPluginInterfaceNames() {
validate();
return (ssm.getPluginInterfaceNames());
}
/**
* Returns the <code>PluginInterface</code> object of the service for the
* specified plugin interface name
*
* @param pluginInterfaceName
* name of the plugin interface
* @return plugin interface configured for the service; else
* <code>null</code>
*/
validate();
}
/**
* Adds a new plugin interface objct to service's schema.
*
* @param interfaceName
* name for the plugin interface
* @param interfaceClass
* fully qualified interface class name
* @param i18nKey
* I18N key that will by used by UI to get messages to display
* the interface name
*/
throw (new IllegalArgumentException());
}
}
// Construct XML document
// Added to XML document and write it
}
/**
* Removes the plugin interface object from the service schema.
*
* @param interfacename Name of the plugin class.
*/
throws SMSException, SSOException {
// Get the plugin interface node
if (pluginNode != null) {
}
}
// -----------------------------------------------------------
// Plugin Schema
// -----------------------------------------------------------
/**
* Returns the names of plugins configured for the plugin interface. If
* organization is <code>null</code>, returns the plugins configured for
* the "root" organization.
*/
throws SMSException {
validate();
// Construct the DN to get CachedSubEntries
.toString());
try {
} catch (SSOException s) {
+ "Plugin Schema Names", s);
}
return (Collections.EMPTY_SET);
}
/**
* Returns the PluginSchema object given the schema name and the interface
* name for the specified organization. If organization is
* <code>null</code>, returns the PluginSchema for the "root" organization.
*/
validate();
interfaceName, orgName));
}
/**
* Returns true if admin token cached within this class is valid
*
* @return true is admin token is valid
*/
public boolean isSSOTokenValid() {
try {
return true;
} catch (SMSException smse) {
}
return false;
}
// -----------------------------------------------------------
// Internal protected method
// -----------------------------------------------------------
SSOToken getSSOToken() {
return (token);
}
validate();
return (ssm.getDocumentCopy());
}
throws SSOException, SMSException {
validate();
}
private void validate() {
try {
} catch (SSOException e) {
// Since method signatures cannot be changed, a runtime
// exception is thrown. This conditions would happen only
// when SSOToken has become invalid or service has been
// removed.
serviceName, e);
throw (new RuntimeException(e.getMessage()));
} catch (SMSException e) {
// Ignore the exception
}
}
private void validateServiceSchemaManagerImpl()
throws SMSException, SSOException {
// Recreate the SSM
}
}
// -----------------------------------------------------------
// Static method to create a new service schema
// -----------------------------------------------------------
throws SMSException, SSOException {
// Service node
if (smsEntry.isNewEntry()) {
// create this entry
}
// Version node
}
.getServiceVersion())))) {
} else {
// Throw service already exists exception
}
if (smsEntry.isNewEntry()) {
// add object classes
}
}
throws SMSException {
validate();
}
}
private void getPlugSchemaXML(
) throws SMSException {
}
}
}
}