CreateServerConfigXML.java revision e70418658b6daa84fc8a1f13677d2cb616a66725
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * The contents of this file are subject to the terms
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * of the Common Development and Distribution License
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * (the License). You may not use this file except in
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * compliance with the License.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * You can obtain a copy of the License at
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * https://opensso.dev.java.net/public/CDDLv1.0.html or
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * See the License for the specific language governing
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * permission and limitations under the License.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * When distributing Covered Code, include this CDDL
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Header Notice in each file and include the License file
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * If applicable, add the following below the CDDL Header,
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * with the fields enclosed by brackets [] replaced by
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * your own identifying information:
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * "Portions Copyrighted [year] [name of copyright owner]"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * $Id: CreateServerConfigXML.java,v 1.7 2009/11/20 23:52:53 ww203982 Exp $
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Portions Copyrighted [2011] [ForgeRock AS]
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkimport com.iplanet.dpro.session.service.AMSessionRepository;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkimport com.sun.identity.cli.AccessManagerConstants;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkimport com.sun.identity.cli.AuthenticatedCommand;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkimport com.sun.identity.shared.configuration.SystemPropertiesManager;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkpublic class CreateServerConfigXML extends AuthenticatedCommand implements Constants {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk private static final String DS_PWD_FILE = "dspassword-file";
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Handles request.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @param rc Request Context.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @throws CLIException if request cannot be processed.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk String outputFile = getStringOptionValue(IArgument.OUTPUT_FILE);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk String dsPasswordFile = getStringOptionValue(DS_PWD_FILE);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk if ((dsHost == null) || (dsHost.length() == 0)) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk if ((dsPort == null) || (dsPort.length() == 0)) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk if ((dsAdmin == null) || (dsAdmin.length() == 0)) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk if ((dsPasswordFile == null) || (dsPasswordFile.length() == 0)) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk dsPassword = CLIUtil.getFileContent(getCommandManager(),
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk if ((basedn == null) || (basedn.length() == 0)) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk dsPassword = (String)AccessController.doPrivileged(
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk if ((outputFile != null) && (outputFile.length() > 0)) {
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk String template = getResource("serverconfig.xml");
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk "FAILED_CREATE_SERVERCONFIG_XML", paramException);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk //No handling requried
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk String amadminPwds = CLIUtil.getFileContent(getCommandManager(),
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk getStringOptionValue(AccessManagerConstants.ARGUMENT_PASSWORD_FILE),
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk amadminPwds = (String)AccessController.doPrivileged(
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk xml = xml.replaceAll("@DIRECTORY_SERVER@", dsHost);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk xml = xml.replaceAll("@DIRECTORY_PORT@", dsPort);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk xml = xml.replaceAll("@ENCADMINPASSWD@", dsPassword);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk xml = xml.replaceAll("@ENCADADMINPASSWD@", amadminPwds);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk xml = xml.replaceAll("@SM_CONFIG_BASEDN@", canRootSuffix);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk xml = xml.replaceAll("@ORG_BASE@", canRootSuffix);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk // Set up our Session SFHA Container.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk SystemPropertiesManager.get(AMSessionRepository.SYS_PROPERTY_SESSION_HA_REPOSITORY_ROOT_DN,
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk String rdn = SystemPropertiesManager.get(AMSessionRepository.SYS_PROPERTY_SESSION_HA_REPOSITORY_ROOT_DN,
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk for (Iterator iter = rdns.iterator(); iter.hasNext();) {