cfba646ddfa9d543f0c40e4c7788c65b4a24b34dPhill Cunnington/*
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
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 *
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 * opensso/legal/CDDLv1.0.txt
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * at opensso/legal/CDDLv1.0.txt.
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 *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: Wizard.java,v 1.27 2009/01/17 02:05:35 kevinserwin Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
cfba646ddfa9d543f0c40e4c7788c65b4a24b34dPhill Cunnington * Portions Copyrighted 2010-2015 ForgeRock AS.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.sun.identity.config.wizard;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.config.SessionAttributeNames;
532e14cdd83d81cef3bb65d5c2c3748fb61914f7Mark de Reeperimport com.sun.identity.config.util.ProtectedPage;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.setup.AMSetupServlet;
cfba646ddfa9d543f0c40e4c7788c65b4a24b34dPhill Cunningtonimport com.sun.identity.setup.AMSetupUtils;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.setup.ConfiguratorException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.setup.HttpServletRequestWrapper;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.setup.HttpServletResponseWrapper;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.setup.SetupConstants;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.HashMap;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Map;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport javax.servlet.http.HttpServletRequest;
4bbe3c444008393d516e54018387a5833694dc8ejeff.schenk
4bbe3c444008393d516e54018387a5833694dc8ejeff.schenkimport com.sun.identity.shared.Constants;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.apache.click.control.ActionLink;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
532e14cdd83d81cef3bb65d5c2c3748fb61914f7Mark de Reeperpublic class Wizard extends ProtectedPage implements Constants {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public int startingTab = 1;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ActionLink createConfigLink =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new ActionLink("createConfig", this, "createConfig" );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ActionLink testUrlLink =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new ActionLink("testNewInstanceUrl", this, "testNewInstanceUrl" );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ActionLink pushConfigLink =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new ActionLink("pushConfig", this, "pushConfig" );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String cookieDomain = null;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String hostName = getHostName();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String dataStore = SetupConstants.SMS_EMBED_DATASTORE;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static String defaultUserName = "cn=Directory Manager";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static String defaultPassword = "";
4bbe3c444008393d516e54018387a5833694dc8ejeff.schenk public static String defaultRootSuffix = DEFAULT_ROOT_SUFFIX;
8bb3e4cda81612f01c0254c263155f65506a018cjeff.schenk
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String defaultPort = Integer.toString(
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
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
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 */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean createConfig() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster HttpServletRequest req = getContext().getRequest();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster HttpServletRequestWrapper request =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new HttpServletRequestWrapper(getContext().getRequest());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster HttpServletResponseWrapper response =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new HttpServletResponseWrapper(getContext().getResponse());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster initializeResourceBundle();
74354cd390b85c5421c375b4d70fab7b58d40ffaNeil Madden
74354cd390b85c5421c375b4d70fab7b58d40ffaNeil Madden // User must have accepted license terms to reach this point
74354cd390b85c5421c375b4d70fab7b58d40ffaNeil Madden request.addParameter(SetupConstants.ACCEPT_LICENSE_PARAM, "true");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*
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 */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String adminPassword = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.CONFIG_VAR_ADMIN_PWD);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_ADMIN_PWD, adminPassword);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_CONFIRM_ADMIN_PWD, adminPassword);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*
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 */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String agentPassword = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.CONFIG_VAR_AMLDAPUSERPASSWD);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_AMLDAPUSERPASSWD, agentPassword);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_AMLDAPUSERPASSWD_CONFIRM, agentPassword);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Set the data store information
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String tmp = getAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DATA_STORE,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.SMS_EMBED_DATASTORE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.CONFIG_VAR_DATA_STORE, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean isEmbedded = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (tmp.equals(SetupConstants.SMS_EMBED_DATASTORE)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("configStoreHost", hostName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_HOST, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_SSL, "SIMPLE");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute(SetupConstants.DS_EMB_REPL_FLAG, "false");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * set the embedded replication information for local host port
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * and remote host port
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster isEmbedded = tmp.equals(SetupConstants.DS_EMP_REPL_FLAG_VAL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (isEmbedded) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.DS_EMB_REPL_FLAG,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.DS_EMP_REPL_FLAG_VAL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("localRepPort", "");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.DS_EMB_REPL_REPLPORT1, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("existingHost", "");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.DS_EMB_REPL_HOST2, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("existingPort", "");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.DS_EMB_REPL_ADMINPORT2, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("existingRepPort", "");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.DS_EMB_REPL_REPLPORT2, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("existingserverid", "");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.DS_EMB_EXISTING_SERVERID,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("configStorePort", defaultPort);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_PORT, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("configStoreAdminPort", defaultAdminPort);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DIRECTORY_ADMIN_SERVER_PORT, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("configStoreJmxPort", defaultJmxPort);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DIRECTORY_JMX_SERVER_PORT, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("rootSuffix", defaultRootSuffix);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.CONFIG_VAR_ROOT_SUFFIX, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (!isEmbedded) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("configStoreHost", hostName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_HOST, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("configStoreSSL", "SIMPLE");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_SSL, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("configStoreLoginId", defaultUserName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DS_MGR_DN, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = getAttribute("configStorePassword", "");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_DS_MGR_PWD, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // user store repository
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.EXT_DATA_STORE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((tmp != null) && tmp.equals("true")) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Map store = new HashMap(12);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.USER_STORE_HOST);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster store.put(SetupConstants.USER_STORE_HOST, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.USER_STORE_SSL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster store.put(SetupConstants.USER_STORE_SSL, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.USER_STORE_PORT);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster store.put(SetupConstants.USER_STORE_PORT, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.USER_STORE_ROOT_SUFFIX);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster store.put(SetupConstants.USER_STORE_ROOT_SUFFIX, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.USER_STORE_LOGIN_ID);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster store.put(SetupConstants.USER_STORE_LOGIN_ID, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.USER_STORE_LOGIN_PWD);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster store.put(SetupConstants.USER_STORE_LOGIN_PWD, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.USER_STORE_TYPE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster store.put(SetupConstants.USER_STORE_TYPE, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter("UserStore", store);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // site configuration is passed as a map of the site information
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk Map siteConfig = new HashMap(3);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String loadBalancerHost = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.LB_SITE_NAME);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String primaryURL = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.LB_PRIMARY_URL);
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk // Assume no Session HA Failover.
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk Boolean isSessionHASFOEnabled = false;
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk if (getContext().getSessionAttribute(SessionAttributeNames.LB_SESSION_HA_SFO) != null)
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk { isSessionHASFOEnabled = Boolean.valueOf( (Boolean)getContext().getSessionAttribute(
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk SessionAttributeNames.LB_SESSION_HA_SFO));
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (loadBalancerHost != null) {
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 request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_SITE_CONFIGURATION, siteConfig);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // server properties
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String serverUrl = (String) getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.SERVER_URL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String serverHost;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int serverPort;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (serverUrl == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster serverUrl = req.getRequestURL().toString();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster serverHost = getHostName();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster serverPort = req.getServerPort();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster serverHost = getHostName(serverUrl, getHostName());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster serverPort = getServerPort(serverUrl, req.getServerPort());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_SERVER_HOST, serverHost);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_SERVER_PORT, serverPort);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_SERVER_URI, req.getRequestURL().toString());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_SERVER_URL,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster getAttribute("serverURL", serverUrl));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.ENCRYPTION_KEY);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (tmp == null) {
cfba646ddfa9d543f0c40e4c7788c65b4a24b34dPhill Cunnington tmp = AMSetupUtils.getRandomString();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.CONFIG_VAR_ENCRYPTION_KEY, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster tmp = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.ENCLDAPUSERPASSWD);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (tmp != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SetupConstants.ENCRYPTED_LDAP_USER_PWD, tmp);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String cookie = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.COOKIE_DOMAIN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (cookie == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster cookie = getCookieDomain();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.CONFIG_VAR_COOKIE_DOMAIN, cookie);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String locale = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.PLATFORM_LOCALE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (locale == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster locale = SetupConstants.DEFAULT_PLATFORM_LOCALE;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.CONFIG_VAR_PLATFORM_LOCALE, locale);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String base = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.CONFIG_DIR);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (base == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster base = getBaseDir(getContext().getRequest());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter(SetupConstants.CONFIG_VAR_BASE_DIR, base);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster request.addParameter("locale", configLocale.toString());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (AMSetupServlet.processRequest(request, response)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster writeToResponse("true");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster writeToResponse(AMSetupServlet.getErrorMessage());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (ConfiguratorException cfe) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster writeToResponse(cfe.getMessage());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setPath(null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}