SessionHAFailoverSetupSubConfig.java revision 89503929c8983c48e2049c77284b52e79ad37c32
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2012 ForgeRock AS 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]"
*
* Portions Copyrighted [2010] [ForgeRock AS]
*
*/
/**
* SessionHAFailoverSetupSubConfig
* <p/>
* This utility helper class provides the necessary
* process methods to perform the simple construction
* and persistence of the configuration entry
* to set the proper sub-configuration element
* for Site and Session HA Failover.
* <p/>
*
* This utility is only called a single time and should only be called
* once within the lifetime of an OpenAM instance install.
*
* @author jeff.schenk@forgerock.com
*/
public class SessionHAFailoverSetupSubConfig implements Constants {
/**
* Define usage constants after install.
* As soon as this class' method createServiceSubConfig is
* used and successful, it will no longer be allowed to be called by any
* component or layer. Safety Measure.
*
* then this class will never be loaded.
*
*/
private static boolean thisCreateServiceSubConfigHasBeenUsed = false;
/**
* Global Constants
*/
/**
* Instantiate Singleton Static Interface.
*/
private static SessionHAFailoverSetupSubConfig instance =
/**
* Define Session DN Constants
*/
private static final String SM_CONFIG_ROOT_DN =
private static final String SERVICES_BASE_ROOT_DN =
// Example of Depicted DN:
//dn: ou=default,ou=GlobalConfig,ou=1.0,ou=iPlanetAMSessionService,
// ou=services,dc=openam,dc=forgerock,dc=org
private static final String SITE_SESSION_FAILOVER_HA_SERVICES_BASE_DN_TEMPLATE =
/**
* Default locked down constructor.
*/
private SessionHAFailoverSetupSubConfig() {
}
/**
* Provide a Singleton Static instance.
*
* @return SessionHAFailoverSetupSubConfig Instance.
*/
public static SessionHAFailoverSetupSubConfig getInstance() {
return instance;
}
/**
* Creates a new Site Sub configuration specifically for Session HA FO.
*
* @param siteName Name of sub configuration, in our case the Site Name.
* @param serviceName Name of the Specific Service.
* @param values Map of attribute name to its values.
* @return boolean Indicates True, if method was successful or not.
* @throws IllegalStateException - when this method was already run successfully.
* @throws StoreException - when down stream Persistent store exception occurs.
*/
public static synchronized boolean createSessionHAFOSubConfigEntry(SSOToken adminToken, String siteName,
throws StoreException, IllegalStateException {
{ throw new IllegalStateException("Illegal State Exception encountered, unable to allow Creation."); }
}
/**
* Private Helper Method to perform the convoluted instantiation steps
* to simple persist a single configuration element sub-entry.
* Yikes. Someday we will need to revisit how we abstract out a property based
* configuration persistent store.
*
*/
private static synchronized boolean createServiceSubConfig(SSOToken adminToken, String siteName, String serviceID,
boolean successful;
try {
// Construct ServiceConfigManagerImpl
// Obtain reference to Service Schema Manager.
// Obtain reference to Service Schema.
// Obtain the Service Configuration Implementation.
// Now Finally access the service Config where we can add the Sub-Configuration Element.
// Create the Session HA Failover Indicator Setting for the Specified Site and
// Add the Sub Configuration Entry.
// Tell our view Cache to update with the new Value!
// TODO This attempt above of poking cache should work, but does not. Fix!!!
// Assume Success, if we hit here.
successful = true;
} catch (ServiceAlreadyExistsException smsException) {
// Does Entry Already Exists?
// Yes, in which case, assume we were successful.
successful = true;
} catch (SMSException smsException) {
throw new StoreException("Unable to Dynamically Add the Session HA SF Property for DN:["
} catch (SSOException ssoException) {
throw new StoreException("Unable to Dynamically Add the Session HA SF Property for DN:["
}
// Set if we can allow this to be used again or not.
// return our indicator.
return successful;
}
}