/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007 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: ServerConfiguration.java,v 1.16 2010/01/15 18:10:55 veiming Exp $
*
* Portions Copyrighted 2011-2016 ForgeRock AS.
*/
/**
* This manages server configuration information.
*/
/**
* Default server configuration.
*/
// prevent instantiation of this class.
private ServerConfiguration() {
}
/**
* Returns a set of server information where each entry in a set is
* a string of this format
* <code>server-instance-name|serverId|siteId1|siteId2|...|siteIdn</code>.
*
* @param ssoToken Single Sign-On Token which is used to query the service
* management datastore.
* @return a set of server information.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
*/
throws SMSException, SSOException {
}
} else {
}
}
}
}
return serverInfo;
}
/**
* Returns a map of server name to its load balancer cookie value.
* @param ssoToken Single Sign-On Token which is used to query the service
* management datastore.
* @return a map of server id to its load balancer cookie value.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
*/
}
}
}
}
return results;
}
/**
* Returns a set of server instance name (String).
*
* @param ssoToken Single Sign-On Token which is used to query the service
* management datastore.
* @return a set of server instance name.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
*/
throws SMSException, SSOException {
}
return servers;
}
/**
* Creates a server instance.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @param values Map of string to set of (String) values.
* @param serverConfigXML Server configuration XML.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
* @throws IOException if IO operation fails.
* @throws UnknownPropertyNameException if property names are unknown.
* @throws ConfigurationException if property names or values are not
* valid.
*/
public static void createServerInstance(
}
/**
* Creates a server instance.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @param values Set of string with this format <code>key=value</code>.
* @param serverConfigXML Server configuration XML.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
* @throws UnknownPropertyNameException if property names are unknown.
* @throws ConfigurationException if property names or values are not
* valid.
*/
public static void createServerInstance(
}
}
public static void createDefaults(
boolean bCreated = false;
try {
} catch (SMSException e) {
// ignore, default is not created.
}
}
if (!bCreated) {
) {
}
}
try {
} catch (ConfigurationException ex) {
//ignore, this should not happen because default values
//are all valid.
}
}
}
} else {
return null;
}
}
public static Map<String, String> getNewServerDefaults(SSOToken ssoToken) throws SMSException, SSOException {
boolean bCreated = false;
try {
} catch (SMSException smse) {
// ignore, default is not created.
}
}
if (bCreated) {
}
}
return newValues;
} else {
return Collections.EMPTY_MAP;
}
}
}
return map;
}
/**
* Returns server Identifier.
*
* @return server Identifier. Returns null if server Id is not stored in
* centralized datastore.
*/
) throws SMSException, SSOException {
}
return serverId;
}
/**
* Returns server configuration XML.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @return server configuration XML.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
*/
) throws SMSException, SSOException {
}
return xml;
}
/**
* Sets server configuration XML.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @param xml Server configuration XML.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
*/
public static void setServerConfigXML(
}
}
/**
* Returns the configuration of a server instance.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @return the configuration of the server Instance.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
* @throws IOException if IO operation fails.
*/
}
return prop;
}
/**
* Returns <code>true</code> if server instance exists.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @return <code>true</code> if server instance exists.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
*/
public static boolean isServerInstanceExist(
) throws SMSException, SSOException {
}
/**
* Returns <code>true</code> if server or site id exists.
*
* @param ssoToken Single Sign-On Token which is used to access to the service management datastore.
* @param serverId Id of the server instance.
*
* @return <code>true</code> if server id exists.
*
* @throws SMSException if errors access in the service management datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
*/
public static boolean hasServerOrSiteId(SSOToken ssoToken, String serverId) throws SMSException, SSOException {
}
/**
* Sets configuration to a server instance.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @param newValues Map of string to Set of string.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
* @throws UnknownPropertyNameException if property names are unknown.
* @throws ConfigurationException if property names or values are not
* valid.
*/
public static void setServerInstance(
try {
} catch (UnknownPropertyNameException e) {
//save the values even if property name is unknown
throw e;
}
}
}
if (SystemProperties.isServerMode()) {
} else {
try {
"com.sun.identity.common.configuration.ServerPropertyValidator",
) {
throw new UnknownPropertyNameException(
"invalid.properties", null);
}
} catch (SMSException e) {
throw new ConfigurationException("unable.to.connect.to.server",
null);
}
}
}
/**
* Removes server configuration. This will result in inheriting from
* default server configuration.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @param propertyNames Collection of property names to be removed.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
*/
public static void removeServerConfiguration(
) {
i.remove();
}
}
}
}
/**
* Deletes a server instance.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
*/
public static boolean deleteServerInstance(
) throws SMSException, SSOException {
boolean deleted = false;
deleted = true;
}
}
return deleted;
}
/**
* Creates a server instance.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @param instanceId Identifier of the server instance.
* @param values Set of string with this format <code>key=value</code>.
* @param serverConfigXML Service configuration XML.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
* @throws UnknownPropertyNameException if property names are unknown.
* @throws ConfigurationException if the property name and values are not
* valid.
*/
public static boolean createServerInstance(
boolean created = false;
}
try {
new URL(instanceName);
} catch (MalformedURLException ex) {
throw new ConfigurationException("invalid.server.name",
param);
}
}
}
}
created = true;
}
}
return created;
}
/**
* Upgrades a server instance.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @param instanceId Identifier of the server instance.
* @param upgradedValues Map of new values for the default server config
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
* @throws UnknownPropertyNameException if property names are unknown.
* @throws ConfigurationException if the property name and values are not
* valid.
*/
public static void upgradeServerInstance(
// remove ATTR_PARENT_SITE_ID as this should be excluded from server-default
} else {
throw new ConfigurationException("Unable to upgrade server " +
"default properties: no properties found!");
}
}
/**
* Returns the default server properties.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @return the default server properties.
*/
try {
} catch (SSOException ex) {
} catch (IOException ex) {
} catch (UnknownPropertyNameException ex) {
// ignore Default values should not have unknown property names.
} catch (SMSException ex) {
// amPlatform does not exist
prop = new Properties();
}
}
return prop;
}
/**
* Returns properties object.
*
* @param str String of this format key1=value1\nkey2=value2\n...keyN=valueN
* @return properties object.
* @throws IOException if <code>str</code> contains incorrect format.
*/
throws IOException {
try {
} finally {
try {
} catch (IOException e) {
//ignore
}
}
}
return prop;
}
/**
* Returns properties object.
*
* @param set Set of string of this format key=value.
* @return properties object.
* @throws IOException if <code>str</code> contains incorrect format.
*/
throws IOException {
if (idx != -1) {
}
}
return prop;
}
/**
* Returns set of string with this format, key=value.
*
* @param str String of this format key1=value1\nkey2=value2\n...keyN=valueN
* @return set of formated string.
* @throws IOException if <code>str</code> contains incorrect format.
*/
throws IOException {
}
throws IOException {
}
return set;
}
throws IOException {
return getPropertiesSet(map);
}
/**
* Adds server to a site.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @param siteId Identifier of the site.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
* @throws ConfigurationException if server instance is not found.
*/
public static void addToSite(
}
} else {
throw new ConfigurationException("invalid.server.instance",
param);
}
}
/**
* Returns a site name of which server belongs to.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @return a site name.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
*/
throws SMSException, SSOException {
}
}
return site;
}
/**
* Sets site name of which server belongs to.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @param siteName Site name.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
*/
public static void setServerSite(
) throws SMSException, SSOException {
}
}
/**
* Removes server from a site.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @param siteId Identifier of the site.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
*/
public static void removeFromSite(
) throws SMSException, SSOException {
}
}
}
/**
* Returns <code>true</code> if a server belongs to a site.
*
* @param ssoToken Single Sign-On Token which is used to access to the
* service management datastore.
* @param instanceName Name of the server instance.
* @param siteId Identifier of the site.
* @throws SMSException if errors access in the service management
* datastore.
* @throws SSOException if the <code>ssoToken</code> is not valid.
*/
public static boolean belongToSite(
) throws SMSException, SSOException {
boolean belong = false;
return belong;
}
/**
* Clones a server instance.
*
* @param serverName Server name to clone.
* @param cloneName server name.
* @param cloneId new server id
*/
public static void cloneServerInstance(
try {
} catch (MalformedURLException ex) {
}
}
}
}
/**
* Clones an existing server using the new cloned server name.
*
* @param token
* SSO token
* @param serverName
* name of existing server
* @param cloneName
* name of new cloned server
*
* @throws SSOException
* should there be some issue with the passed token
* @throws SMSException
* should some SMS error occur
* @throws ConfigurationException
* should some issue occur within configuration handling
*/
}
throws ConfigurationException {
try {
} catch (MalformedURLException ex) {
} catch (IOException ie) {
// ignore because the values should be well formated.
}
}
return set;
}
/**
* Exports a server instance.
*
* @param serverName Server name to clone.
* @return a XML representation of server instance.
*/
) throws SMSException, SSOException {
.append("\" />");
) {
.append("</Value>\n");
}
}
}
return xml;
}
/**
* Imports a server instance.
*
* @param serverName Server name to clone.
* @param xmlFile File that contains XML representation of server instance.
*/
public static void importServerInstance(
try {
new URL(serverName);
} catch (MalformedURLException ex) {
}
(Node)topElement);
}
}
}
}