Search in sources :

Example 61 with LocalizedMessage

use of com.sun.identity.install.tools.util.LocalizedMessage in project OpenAM by OpenRock.

the class InstallDriver method getProductConfigFilePathMessage.

public LocalizedMessage getProductConfigFilePathMessage() {
    String productConfigFilePath = (String) getInstallState().getStateAccess().get(STR_CONFIG_FILE_PATH_TAG);
    Object[] args = { productConfigFilePath };
    LocalizedMessage message = LocalizedMessage.get(LOC_DR_MSG_PRODUCT_CONFIG_FILE_NAME, args);
    return message;
}
Also used : LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 62 with LocalizedMessage

use of com.sun.identity.install.tools.util.LocalizedMessage in project OpenAM by OpenRock.

the class NetworkValidator method isHostValid.

/**
     * Checks whether the given host is a valid host or not It allows IP
     * addresses &
     * 
     * @param host
     * @param props
     * @param state
     * 
     * @return ValidationResult
     * 
     */
public ValidationResult isHostValid(String host, Map props, IStateAccess state) {
    ValidationResultStatus validRes = ValidationResultStatus.STATUS_FAILED;
    LocalizedMessage returnMessage = null;
    boolean cont = false;
    if ((host != null) && (host.length() > 0)) {
        try {
            // For jdk bug, we check if hostname is a int or double
            int intHost = Integer.parseInt(host);
            double dobHost = Double.parseDouble(host);
        } catch (NumberFormatException exc) {
            cont = true;
        } catch (Exception ex) {
            cont = true;
        }
        try {
            if (cont) {
                String tempHost = InetAddress.getByName(host).getHostName();
                if (tempHost != null) {
                    returnMessage = LocalizedMessage.get(LOC_VA_MSG_VAL_HOST, new Object[] { host });
                    validRes = ValidationResultStatus.STATUS_SUCCESS;
                }
            }
        } catch (Exception ex) {
            Debug.log("NetworkVaidator.isHostValid(..) threw exception :", ex);
        }
    }
    if (validRes.getIntValue() == ValidationResultStatus.INT_STATUS_FAILED) {
        returnMessage = LocalizedMessage.get(LOC_VA_WRN_IN_VAL_HOST, new Object[] { host });
    }
    Debug.log("NetworkValidator : Is Host : " + host + " valid ? " + validRes.isSuccessful());
    return new ValidationResult(validRes, null, returnMessage);
}
Also used : LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 63 with LocalizedMessage

use of com.sun.identity.install.tools.util.LocalizedMessage in project OpenAM by OpenRock.

the class UserResponseHandler method getInvalidLineErrorMessage.

public LocalizedMessage getInvalidLineErrorMessage(int lineNumber) {
    Object[] args = { getFile(), new Integer(lineNumber), STR_KEY_VALUE_SEP };
    LocalizedMessage message = LocalizedMessage.get(LOC_DR_ERR_INVALID_LINE, args);
    return message;
}
Also used : LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 64 with LocalizedMessage

use of com.sun.identity.install.tools.util.LocalizedMessage in project OpenAM by OpenRock.

the class ValidateURL method isAgentURLValidInternal.

/*
     * Checks if agent URL is valid and agent container is stopped
     * 
     * @param url @param props @param state
     * 
     * @return ValidationResult
     */
private ValidationResult isAgentURLValidInternal(String url, Map props, IStateAccess state) {
    ValidationResultStatus validRes = ValidationResultStatus.STATUS_FAILED;
    LocalizedMessage returnMessage = null;
    boolean agentContainerRunning = false;
    boolean invalidDeploymentURI = false;
    try {
        URL agentUrl = new URL(url);
        returnMessage = LocalizedMessage.get(LOC_VA_MSG_VAL_AGENT_URL, new Object[] { url });
        String protocol = agentUrl.getProtocol();
        String hostName = agentUrl.getHost();
        int portNum = agentUrl.getPort();
        if (portNum == -1) {
            if (protocol.equals("http")) {
                portNum = 80;
            } else if (protocol.equals("https")) {
                portNum = 443;
            }
        }
        String sPortNum = new Integer(portNum).toString();
        Map tokens = state.getData();
        tokens.put("AGENT_PREF_PROTO", protocol);
        tokens.put("AGENT_HOST", hostName);
        tokens.put("AGENT_PREF_PORT", sPortNum);
        /* 
             * Construct the agent container URL and test if the 
             * container is running. If so, ask the user to shut it 
             * down before continuing with the agent installation.
             */
        StringBuffer bf = new StringBuffer();
        bf.append(protocol);
        bf.append("://");
        bf.append(hostName);
        bf.append(":");
        bf.append(sPortNum);
        String containerURL = bf.toString();
        URLConnection connection = null;
        try {
            connection = (new URL(containerURL)).openConnection();
            connection.connect();
            agentContainerRunning = true;
            returnMessage = LocalizedMessage.get(LOC_VA_MSG_AGENT_CONTAINER_RUNNING, new Object[] { containerURL });
            Debug.log("ValidateURL.isAgentURLValid: " + "The agent container is running.");
        } catch (IOException ex) {
            Debug.log("ValidateURL.isAgentURLValid: " + "The agent container is not running.");
        }
        if (!agentContainerRunning) {
            String agentType = (String) props.get(STR_AGENT_TYPE);
            if (agentType != null && agentType.equals("webagent")) {
                state.putData(tokens);
                validRes = ValidationResultStatus.STATUS_SUCCESS;
            } else {
                String deploymentURI = agentUrl.getPath();
                Debug.log("deploymentURI ==> " + deploymentURI);
                if (deploymentURI.length() > 1) {
                    tokens.put("AGENT_APP_URI", deploymentURI);
                    state.putData(tokens);
                    validRes = ValidationResultStatus.STATUS_SUCCESS;
                } else {
                    invalidDeploymentURI = true;
                    validRes = ValidationResultStatus.STATUS_FAILED;
                    returnMessage = LocalizedMessage.get(LOC_VA_MSG_IN_VAL_DEPLOYMENT_URI, new Object[] { url });
                }
            }
        }
    } catch (MalformedURLException mfe) {
        Debug.log("ValidateURL.isAgentURLValid threw exception :", mfe);
    }
    if (validRes.getIntValue() == ValidationResultStatus.INT_STATUS_FAILED) {
        if (!invalidDeploymentURI && !agentContainerRunning) {
            returnMessage = LocalizedMessage.get(LOC_VA_WRN_IN_VAL_AGENT_URL, new Object[] { url });
        }
    }
    return new ValidationResult(validRes, null, returnMessage);
}
Also used : MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) URL(java.net.URL) URLConnection(java.net.URLConnection) Map(java.util.Map) LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 65 with LocalizedMessage

use of com.sun.identity.install.tools.util.LocalizedMessage in project OpenAM by OpenRock.

the class ValidateURL method isServerURLValidInternal.

/*
     * Checks if server url is valid
     * 
     * @param url @param props @param state
     * 
     * @return ValidationResult
     */
private ValidationResult isServerURLValidInternal(String url, Map props, IStateAccess state) {
    LocalizedMessage returnMessage = null;
    ValidationResultStatus validRes = ValidationResultStatus.STATUS_FAILED;
    boolean invalidDeploymentURI = false;
    try {
        URL serverUrl = new URL(url);
        String protocol = serverUrl.getProtocol();
        String hostName = serverUrl.getHost();
        int portNum = serverUrl.getPort();
        if (portNum == -1) {
            if (protocol.equals("http")) {
                portNum = 80;
            } else if (protocol.equals("https")) {
                portNum = 443;
            }
        }
        String sPortNum = new Integer(portNum).toString();
        String deploymentURI = serverUrl.getPath();
        if (deploymentURI.length() > 0) {
            Map tokens = state.getData();
            tokens.put("AM_SERVICES_PROTO", protocol);
            tokens.put("AM_SERVICES_HOST", hostName);
            tokens.put("AM_SERVICES_PORT", sPortNum);
            tokens.put("AM_SERVICES_DEPLOY_URI", deploymentURI);
            state.putData(tokens);
            // Establish the connection
            URLConnection urlConnect = serverUrl.openConnection();
            urlConnect.connect();
            returnMessage = LocalizedMessage.get(LOC_VA_MSG_VAL_SERVER_URL, new Object[] { url });
            state.put("isServerURLValid", "true");
            validRes = ValidationResultStatus.STATUS_SUCCESS;
        } else {
            invalidDeploymentURI = true;
            validRes = ValidationResultStatus.STATUS_FAILED;
            returnMessage = LocalizedMessage.get(LOC_VA_MSG_IN_VAL_DEPLOYMENT_URI, new Object[] { url });
        }
    } catch (UnknownHostException uhe) {
        Debug.log("ValidateURL.isServerUrlValid threw exception :", uhe);
        returnMessage = LocalizedMessage.get(LOC_VA_WRN_UN_REACHABLE_SERVER_URL, new Object[] { url });
        state.put("isServerURLValid", "false");
        validRes = ValidationResultStatus.STATUS_WARNING;
    } catch (ConnectException ce) {
        Debug.log("ValidateURL.isServerUrlValid threw exception :", ce);
        returnMessage = LocalizedMessage.get(LOC_VA_WRN_UN_REACHABLE_SERVER_URL, new Object[] { url });
        state.put("isServerURLValid", "false");
        validRes = ValidationResultStatus.STATUS_WARNING;
    } catch (Exception e) {
        if (url.toLowerCase().startsWith("https")) {
            Debug.log("ValidateURL.isServerUrlValid threw exception :", e);
            returnMessage = LocalizedMessage.get(LOC_VA_WRN_UN_REACHABLE_SSL_SERVER_URL, new Object[] { url });
            state.put("isServerURLValid", "false");
            validRes = ValidationResultStatus.STATUS_WARNING;
        } else {
            Debug.log("ValidateURL.isServerUrlValid threw exception :", e);
        }
    }
    if (validRes.getIntValue() == ValidationResultStatus.INT_STATUS_FAILED) {
        if (!invalidDeploymentURI) {
            returnMessage = LocalizedMessage.get(LOC_VA_WRN_IN_VAL_SERVER_URL, new Object[] { url });
        }
    }
    return new ValidationResult(validRes, null, returnMessage);
}
Also used : UnknownHostException(java.net.UnknownHostException) URL(java.net.URL) URLConnection(java.net.URLConnection) MalformedURLException(java.net.MalformedURLException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) Exception(java.lang.Exception) Map(java.util.Map) LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage) ConnectException(java.net.ConnectException)

Aggregations

LocalizedMessage (com.sun.identity.install.tools.util.LocalizedMessage)73 Map (java.util.Map)9 File (java.io.File)8 ArrayList (java.util.ArrayList)8 IOException (java.io.IOException)6 HashMap (java.util.HashMap)5 Iterator (java.util.Iterator)5 ConnectException (java.net.ConnectException)4 UnknownHostException (java.net.UnknownHostException)4 StringTokenizer (java.util.StringTokenizer)4 FileNotFoundException (java.io.FileNotFoundException)3 RESTUtils (com.sun.identity.install.tools.util.RESTUtils)2 BufferedReader (java.io.BufferedReader)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 URLConnection (java.net.URLConnection)2 TreeMap (java.util.TreeMap)2 Audit (com.sun.identity.install.tools.util.Audit)1 FileReader (java.io.FileReader)1 InputStream (java.io.InputStream)1