2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * The contents of this file are subject to the terms
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * of the Common Development and Distribution License
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * (the License). You may not use this file except in
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * compliance with the License.
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * You can obtain a copy of the License at
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * https://opensso.dev.java.net/public/CDDLv1.0.html or
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * See the License for the specific language governing
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * permission and limitations under the License.
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * When distributing Covered Code, include this CDDL
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * Header Notice in each file and include the License file
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * If applicable, add the following below the CDDL Header,
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * with the fields enclosed by brackets [] replaced by
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * your own identifying information:
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * "Portions Copyrighted [year] [name of copyright owner]"
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * $Id: HomeDirValidator.java,v 1.1 2009/01/21 18:43:55 kanduls Exp $
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeperpackage com.sun.identity.agents.tools.jetty.v61;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeperimport com.sun.identity.install.tools.configurator.IStateAccess;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeperimport com.sun.identity.install.tools.configurator.InstallException;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeperimport com.sun.identity.install.tools.configurator.ValidationResult;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeperimport com.sun.identity.install.tools.configurator.ValidationResultStatus;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeperimport com.sun.identity.install.tools.configurator.ValidatorBase;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeperimport com.sun.identity.install.tools.util.Debug;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeperimport com.sun.identity.install.tools.util.FileUtils;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeperimport com.sun.identity.install.tools.util.LocalizedMessage;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeperpublic class HomeDirValidator extends ValidatorBase implements IConstants,
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper public HomeDirValidator() throws InstallException {
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * Method isHomeDirValid
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * @param props
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * @param IStateAccess
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * @return ValidationResult
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper ValidationResultStatus validRes = ValidationResultStatus.STATUS_FAILED;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper if ((jettyHomeDir != null) && (jettyHomeDir.trim().length() >= 0)) {
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper // The config dir has been normalized to have "/" only
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper String jettyJarFile = jettyHomeDir + STR_FORWARD_SLASH +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper String webAppDir =jettyHomeDir + STR_FORWARD_SLASH +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper returnMessage = LocalizedMessage.get(VA_MSG_JETTY_VAL_HOME,
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper STR_JETTY_GROUP, new Object[] { jettyHomeDir });
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper validRes = ValidationResultStatus.STATUS_SUCCESS;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper state.put(STR_KEY_JETTY_START_JAR_PATH, jettyJarFile);
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper Debug.log("HomeDirValidator: Added Jetty home to state --> " +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper state.put(STR_KEY_JETTY_INST_DEPLOY_DIR, webAppDir);
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper Debug.log("HomeDirValidator: Added Jetty webapp dir to state " +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper if (validRes.getIntValue() == ValidationResultStatus.INT_STATUS_FAILED)
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper returnMessage = LocalizedMessage.get(VA_WRN_JETTY_IN_VAL_HOME,
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper STR_JETTY_GROUP, new Object[] { jettyHomeDir });
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper Debug.log("HomeDirValidator : Is Jetty Home directory " + jettyHomeDir +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper return new ValidationResult(validRes, null, returnMessage);
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper public void initializeValidatorMap() throws InstallException {
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper Class[] paramObjs = { String.class, Map.class, IStateAccess.class };
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper "VALID_JETTY_HOME_DIR",
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper "isHomeDirValid",
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper Debug.log("HomeDirValidator: NoSuchMethodException " +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper LocalizedMessage.get(LOC_VA_ERR_VAL_METHOD_NOT_FOUND),
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper Debug.log("HomeDirValidator: SecurityException thrown " +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper LocalizedMessage.get(LOC_VA_ERR_VAL_METHOD_NOT_FOUND),
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper Debug.log("HomeDirValidator: Exception thrown while "+
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper LocalizedMessage.get(LOC_VA_ERR_VAL_METHOD_NOT_FOUND), ex);
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper protected boolean canUpdateJettyConfigFile(String jettyHomeDir) {
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper boolean result = false;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper String jettyConfFile = jettyHomeDir + STR_FORWARD_SLASH +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper STR_ETC_DIRECTORY + STR_FORWARD_SLASH + STR_SERVER_XML;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper if (file.exists() && file.canWrite() && file.canRead()