Wizard.java revision 848c79d6050902d469405a8b17adc81a97ea4f29
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
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 * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
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 * $Id: Wizard.java,v 1.27 2009/01/17 02:05:35 kevinserwin Exp $
848c79d6050902d469405a8b17adc81a97ea4f29jeff.schenk * Portions Copyrighted 2010-2012 ForgeRock AS
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.config.SessionAttributeNames;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.setup.ConfiguratorException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.setup.HttpServletRequestWrapper;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.setup.HttpServletResponseWrapper;
8bb3e4cda81612f01c0254c263155f65506a018cjeff.schenkimport org.forgerock.openam.common.OpenAMCommonConstants;
8bb3e4cda81612f01c0254c263155f65506a018cjeff.schenkpublic class Wizard extends AjaxPage implements OpenAMCommonConstants {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new ActionLink("createConfig", this, "createConfig" );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new ActionLink("testNewInstanceUrl", this, "testNewInstanceUrl" );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new ActionLink("pushConfig", this, "pushConfig" );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String dataStore = SetupConstants.SMS_EMBED_DATASTORE;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static String defaultUserName = "cn=Directory Manager";
8bb3e4cda81612f01c0254c263155f65506a018cjeff.schenk public static String defaultRootSuffix = OpenAMCommonConstants.DEFAULT_ROOT_SUFFIX;
8bb3e4cda81612f01c0254c263155f65506a018cjeff.schenk public static String defaultSessionRootSuffix = OpenAMCommonConstants.DEFAULT_SESSION_ROOT_SUFFIX;
848c79d6050902d469405a8b17adc81a97ea4f29jeff.schenk public static String defaultSessionStoreType = OpenAMCommonConstants.DEFAULT_SESSION_STORE_TYPE;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster AMSetupServlet.getUnusedPort(hostName, 50389, 1000));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String defaultAdminPort = Integer.toString(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster AMSetupServlet.getUnusedPort(hostName, 4444, 1000));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String defaultJmxPort = Integer.toString(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster AMSetupServlet.getUnusedPort(hostName, 1689, 1000));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This is the 'execute' operation for the entire wizard. This method
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * aggregates all data submitted across the wizard pages here in one lump
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * and hands it off to the back-end for processing.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean createConfig() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster HttpServletRequest req = getContext().getRequest();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new HttpServletRequestWrapper(getContext().getRequest());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new HttpServletResponseWrapper(getContext().getResponse());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Get the admin password. use the same value for password and confirm
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * value because they were validated in the input screen
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String adminPassword = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_ADMIN_PWD, adminPassword);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_CONFIRM_ADMIN_PWD, adminPassword);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Get the agent password. same value used for password and confirm
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * because they were validated in the input screen.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String agentPassword = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.CONFIG_VAR_AMLDAPUSERPASSWD);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_AMLDAPUSERPASSWD, agentPassword);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_AMLDAPUSERPASSWD_CONFIRM, agentPassword);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Set the data store information
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.CONFIG_VAR_DATA_STORE, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean isEmbedded = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (tmp.equals(SetupConstants.SMS_EMBED_DATASTORE)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("configStoreHost", hostName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_HOST, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_SSL, "SIMPLE");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute(SetupConstants.DS_EMB_REPL_FLAG, "false");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * set the embedded replication information for local host port
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * and remote host port
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster isEmbedded = tmp.equals(SetupConstants.DS_EMP_REPL_FLAG_VAL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.DS_EMB_REPL_REPLPORT1, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.DS_EMB_REPL_HOST2, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.DS_EMB_REPL_ADMINPORT2, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.DS_EMB_REPL_REPLPORT2, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.DS_EMB_EXISTING_SERVERID,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("configStorePort", defaultPort);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_PORT, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("configStoreAdminPort", defaultAdminPort);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DIRECTORY_ADMIN_SERVER_PORT, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("configStoreJmxPort", defaultJmxPort);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DIRECTORY_JMX_SERVER_PORT, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("rootSuffix", defaultRootSuffix);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.CONFIG_VAR_ROOT_SUFFIX, tmp);
8bb3e4cda81612f01c0254c263155f65506a018cjeff.schenk tmp = getAttribute("sessionRootSuffix", defaultSessionRootSuffix);
8bb3e4cda81612f01c0254c263155f65506a018cjeff.schenk request.addParameter(SetupConstants.CONFIG_VAR_SESSION_ROOT_SUFFIX, tmp);
8bb3e4cda81612f01c0254c263155f65506a018cjeff.schenk tmp = getAttribute("sessionStoreType", defaultSessionStoreType);
8bb3e4cda81612f01c0254c263155f65506a018cjeff.schenk request.addParameter(SetupConstants.CONFIG_VAR_SESSION_STORE_TYPE, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("configStoreHost", hostName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_HOST, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("configStoreSSL", "SIMPLE");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_SSL, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("configStoreLoginId", defaultUserName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // user store repository
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster store.put(SetupConstants.USER_STORE_HOST, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster store.put(SetupConstants.USER_STORE_PORT, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster store.put(SetupConstants.USER_STORE_ROOT_SUFFIX, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster store.put(SetupConstants.USER_STORE_LOGIN_ID, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster store.put(SetupConstants.USER_STORE_LOGIN_PWD, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster store.put(SetupConstants.USER_STORE_TYPE, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // site configuration is passed as a map of the site information
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String loadBalancerHost = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String primaryURL = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster siteConfig.put(SetupConstants.LB_SITE_NAME, loadBalancerHost);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster siteConfig.put(SetupConstants.LB_PRIMARY_URL, primaryURL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_SITE_CONFIGURATION, siteConfig);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // server properties
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String serverUrl = (String) getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster serverHost = getHostName(serverUrl, getHostName());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster serverPort = getServerPort(serverUrl, req.getServerPort());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_SERVER_HOST, serverHost);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_SERVER_PORT, serverPort);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_SERVER_URI, req.getRequestURL().toString());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_ENCRYPTION_KEY, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String cookie = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.CONFIG_VAR_COOKIE_DOMAIN, cookie);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String locale = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster locale = SetupConstants.DEFAULT_PLATFORM_LOCALE;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.CONFIG_VAR_PLATFORM_LOCALE, locale);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String base = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.CONFIG_VAR_BASE_DIR, base);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter("locale", configLocale.toString());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (AMSetupServlet.processRequest(request, response)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster writeToResponse(AMSetupServlet.getErrorMessage());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return false;