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: ConfigDirValidator.java,v 1.1 2009/01/21 18:43:53 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.LocalizedMessage;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeperpublic class ConfigDirValidator extends ValidatorBase implements IConstants,
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper public ConfigDirValidator() throws InstallException {
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * Method isConfigDirValid
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * @param props
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * @param IStateAccess
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper * @return ValidationResult
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper public ValidationResult isConfigDirValid(String configDir, Map props,
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper ValidationResultStatus validRes = ValidationResultStatus.STATUS_FAILED;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper if ((configDir != null) && (configDir.trim().length() >= 0)) {
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper // The config dir has been normalized to have "/" only
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper String serverXmlFile = configDir + STR_FORWARD_SLASH +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper "ConfigDirValidator.isConfigDirValid(): Server XML " +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper if (isValid(configDir) && isValid(serverXmlFile)) {
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper state.put(STR_KEY_JETTY_SERVER_XML_FILE, serverXmlFile);
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper validRes = ValidationResultStatus.STATUS_SUCCESS;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper if (validRes.getIntValue() == ValidationResultStatus.INT_STATUS_FAILED)
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper "ConfigDirValidator.isConfigDirValid(): Is Jetty Server " +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper return new ValidationResult(validRes, null, returnMessage);
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper boolean valid = false;
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper if (file.exists() && file.canRead() && file.canWrite()) {
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper "ConfigDirValidator.isValid(): " + fileName +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper " does not exist");
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper "ConfigDirValidator.isValid(): " + fileName +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper " does not have read and write permissions");
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper public void initializeValidatorMap() throws InstallException {
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper Class[] paramObjs = {String.class, Map.class, IStateAccess.class};
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper "VALID_JETTY_CONFIG_DIR",
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper "isConfigDirValid",
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper "ConfigDirValidator: NoSuchMethodException " +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper "thrown while loading method :",
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper LocalizedMessage.get(LOC_VA_ERR_VAL_METHOD_NOT_FOUND),
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper "ConfigDirValidator: SecurityException thrown " +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper "while loading method :",
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper LocalizedMessage.get(LOC_VA_ERR_VAL_METHOD_NOT_FOUND),
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper "ConfigDirValidator: Exception thrown while " +
2be3e935b5cdea10ddcaf8afff4790d7ce09e950Mark de Reeper "loading method :",