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 $
cfba646ddfa9d543f0c40e4c7788c65b4a24b34dPhill Cunnington * Portions Copyrighted 2010-2015 ForgeRock AS.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.config.SessionAttributeNames;
532e14cdd83d81cef3bb65d5c2c3748fb61914f7Mark de Reeperimport com.sun.identity.config.util.ProtectedPage;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.setup.ConfiguratorException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.setup.HttpServletRequestWrapper;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.setup.HttpServletResponseWrapper;
532e14cdd83d81cef3bb65d5c2c3748fb61914f7Mark de Reeperpublic class Wizard extends ProtectedPage implements Constants {
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";
4bbe3c444008393d516e54018387a5833694dc8ejeff.schenk public static String defaultRootSuffix = DEFAULT_ROOT_SUFFIX;
cfba646ddfa9d543f0c40e4c7788c65b4a24b34dPhill Cunnington AMSetupUtils.getFirstUnusedPort(hostName, 50389, 1000));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String defaultAdminPort = Integer.toString(
cfba646ddfa9d543f0c40e4c7788c65b4a24b34dPhill Cunnington AMSetupUtils.getFirstUnusedPort(hostName, 4444, 1000));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String defaultJmxPort = Integer.toString(
cfba646ddfa9d543f0c40e4c7788c65b4a24b34dPhill Cunnington AMSetupUtils.getFirstUnusedPort(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 HttpServletRequest req = getContext().getRequest();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new HttpServletRequestWrapper(getContext().getRequest());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new HttpServletResponseWrapper(getContext().getResponse());
74354cd390b85c5421c375b4d70fab7b58d40ffaNeil Madden // User must have accepted license terms to reach this point
74354cd390b85c5421c375b4d70fab7b58d40ffaNeil Madden request.addParameter(SetupConstants.ACCEPT_LICENSE_PARAM, "true");
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);
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(
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk // Assume no Session HA Failover.
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk if (getContext().getSessionAttribute(SessionAttributeNames.LB_SESSION_HA_SFO) != null)
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk { isSessionHASFOEnabled = Boolean.valueOf( (Boolean)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster siteConfig.put(SetupConstants.LB_SITE_NAME, loadBalancerHost);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster siteConfig.put(SetupConstants.LB_PRIMARY_URL, primaryURL);
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk siteConfig.put(SetupConstants.LB_SESSION_HA_SFO, isSessionHASFOEnabled.toString());
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;