ServerConfiguration.java revision d97b7ab26c446ed6c58b71c45249970c62f876f8
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * The contents of this file are subject to the terms
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * of the Common Development and Distribution License
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * (the License). You may not use this file except in
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * compliance with the License.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * You can obtain a copy of the License at
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * See the License for the specific language governing
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * permission and limitations under the License.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * When distributing Covered Code, include this CDDL
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * Header Notice in each file and include the License file
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * If applicable, add the following below the CDDL Header,
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * with the fields enclosed by brackets [] replaced by
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * your own identifying information:
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * $Id: ServerConfiguration.java,v 1.16 2010/01/15 18:10:55 veiming Exp $
74dca04245920444925c2544c591c3da5dad607eAndrew Forrest * Portions Copyrighted 2011-2015 ForgeRock AS.
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterimport com.sun.identity.sm.RemoteServiceAttributeValidator;
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterimport com.sun.identity.sm.ServiceSchemaManager;
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterimport javax.xml.parsers.ParserConfigurationException;
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterimport org.forgerock.openam.upgrade.UpgradeUtils;
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * This manages server configuration information.
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterpublic class ServerConfiguration extends ConfigurationBase {
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster private static final String ATTR_PARENT_SITE_ID = "parentsiteid";
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster private static final String ATTR_SERVER_CONFIG = "serverconfig";
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster private static final String ATTR_SERVER_CONFIG_XML = "serverconfigxml";
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster public static final String SERVER_DEFAULTS = "serverdefaults";
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster public static final String DEFAULT_SERVER_ID = "00";
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * Default server configuration.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster public static final String DEFAULT_SERVER_CONFIG = "server-default";
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster // prevent instantiation of this class.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * Returns a set of server information where each entry in a set is
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * a string of this format
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * <code>server-instance-name|serverId|siteId1|siteId2|...|siteIdn</code>.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * @param ssoToken Single Sign-On Token which is used to query the service
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * management datastore.
74dca04245920444925c2544c591c3da5dad607eAndrew Forrest * @return a set of server information.
74dca04245920444925c2544c591c3da5dad607eAndrew Forrest * @throws SMSException if errors access in the service management
74dca04245920444925c2544c591c3da5dad607eAndrew Forrest * @throws SSOException if the <code>ssoToken</code> is not valid.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster public static Set getServerInfo(SSOToken ssoToken)
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster ServiceConfig sc = getRootServerConfig(ssoToken);
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster for (Iterator i = names.iterator(); i.hasNext(); ) {
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster String serverId = (String)setID.iterator().next();
d1b57e78cf72f41c7c6a52bd7c2a6d6aa4da6ba4Craig McDonnell Set setSiteId = (Set)attrs.get(ATTR_PARENT_SITE_ID);
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster if ((setSiteId != null) && !setSiteId.isEmpty()) {
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster for (Iterator it = ids.iterator(); it.hasNext(); ) {
d1b57e78cf72f41c7c6a52bd7c2a6d6aa4da6ba4Craig McDonnell * Returns a map of server name to its load balancer cookie value.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * @param ssoToken Single Sign-On Token which is used to query the service
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * management datastore.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * @return a map of server id to its load balancer cookie value.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * @throws SMSException if errors access in the service management
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * datastore.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * @throws SSOException if the <code>ssoToken</code> is not valid.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster public static Map getLBCookieValues(SSOToken ssoToken)
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster throws SMSException, SSOException, IOException {
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster ServiceConfig sc = getRootServerConfig(ssoToken);
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster for (Iterator i = names.iterator(); i.hasNext(); ) {
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster String serverId = (String)setID.iterator().next();
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster if ((cValue != null) && (cValue.length() > 0)) {
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * Returns a set of server instance name (String).
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * @param ssoToken Single Sign-On Token which is used to query the service
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * management datastore.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * @return a set of server instance name.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster * @throws SMSException if errors access in the service management
return servers;
public static void createServerInstance(
public static void createServerInstance(
public static void createDefaults(
boolean bCreated = false;
} catch (SMSException e) {
if (!bCreated) {
return null;
public static Map<String, String> getNewServerDefaults(SSOToken ssoToken) throws SMSException, SSOException {
boolean bCreated = false;
if (bCreated) {
return newValues;
return map;
return serverId;
return xml;
public static void setServerConfigXML(
return prop;
public static boolean isServerInstanceExist(
public static void setServerInstance(
} catch (UnknownPropertyNameException e) {
"com.sun.identity.common.configuration.ServerPropertyValidator",
throw new UnknownPropertyNameException(
} catch (SMSException e) {
null);
public static void removeServerConfiguration(
i.remove();
public static boolean deleteServerInstance(
boolean deleted = false;
deleted = true;
return deleted;
public static boolean createServerInstance(
boolean created = false;
param);
created = true;
return created;
public static void upgradeServerInstance(
return prop;
throws IOException {
} catch (IOException e) {
return prop;
throws IOException {
return prop;
throws IOException {
throws IOException {
return set;
throws IOException {
public static void addToSite(
param);
return site;
public static void setServerSite(
public static void removeFromSite(
public static boolean belongToSite(
boolean belong = false;
return belong;
public static void cloneServerInstance(
throws ConfigurationException {
return set;
return xml;
public static void importServerInstance(