Examples of AgentConfigurationError


Examples of sun.management.AgentConfigurationError

            JMXServiceURL url = new JMXServiceURL("rmi", localhost, 0);
            JMXConnectorServer server = JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
            server.start();
            return server;
        } catch (Exception e) {
            throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.toString());
        }
    }
View Full Code Here

Examples of sun.management.AgentConfigurationError

        }
    }

    private static void checkPasswordFile(String passwordFileName) {
        if (passwordFileName == null || passwordFileName.length() == 0) {
            throw new AgentConfigurationError(PASSWORD_FILE_NOT_SET);
        }
        File file = new File(passwordFileName);
        if (!file.exists()) {
            throw new AgentConfigurationError(PASSWORD_FILE_NOT_FOUND,
                    passwordFileName);
        }

        if (!file.canRead()) {
            throw new AgentConfigurationError(
                    PASSWORD_FILE_NOT_READABLE, passwordFileName);
        }

        FileSystem fs = FileSystem.open();
        try {
            if (fs.supportsFileSecurity(file)) {
                if (!fs.isAccessUserOnly(file)) {
                    final String msg = Agent.getText(
                            "jmxremote.ConnectorBootstrap.initialize.password.readonly",
                            passwordFileName);
                    log.log(Level.FINE, "initialize", msg);
                    throw new AgentConfigurationError(
                            PASSWORD_FILE_ACCESS_NOT_RESTRICTED,
                            passwordFileName);
                }
            }
        } catch (IOException e) {
            throw new AgentConfigurationError(
                    PASSWORD_FILE_READ_FAILED, e, passwordFileName);
        }
    }
View Full Code Here

Examples of sun.management.AgentConfigurationError

        }
    }

    private static void checkAccessFile(String accessFileName) {
        if (accessFileName == null || accessFileName.length() == 0) {
            throw new AgentConfigurationError(ACCESS_FILE_NOT_SET);
        }
        File file = new File(accessFileName);
        if (!file.exists()) {
            throw new AgentConfigurationError(ACCESS_FILE_NOT_FOUND,
                    accessFileName);
        }

        if (!file.canRead()) {
            throw new AgentConfigurationError(ACCESS_FILE_NOT_READABLE,
                    accessFileName);
        }
    }
View Full Code Here

Examples of sun.management.AgentConfigurationError

        try {
            connServer = JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
            connServer.start();
        } catch (IOException e) {
            if (connServer == null) {
                throw new AgentConfigurationError(
                        CONNECTOR_SERVER_IO_ERROR, e, url.toString());
            } else {
                throw new AgentConfigurationError(
                        CONNECTOR_SERVER_IO_ERROR, e, connServer.getAddress().toString());
            }
        }

        if (useRegistrySsl) {
            if (registry == null) {
                try {
                    registry = LocateRegistry.createRegistry(serverPort, csf, ssf);
                    registry.bind("jmxrmi", exporter.firstExported);
                } catch (RemoteException ex) {
                   throw new AgentConfigurationError(
                           CONNECTOR_SERVER_IO_ERROR, ex, ex.getMessage());
                } catch (AlreadyBoundException ex) {
                   throw new AgentConfigurationError(
                           CONNECTOR_SERVER_IO_ERROR, ex, ex.getMessage());
                }
            } else {
                registry.rebind("jmxrmi", exporter.firstExported);
            }
        } else {
            if (registry == null) {
                try {
                    registry = LocateRegistry.createRegistry(serverPort);
                    registry.bind("jmxrmi", exporter.firstExported);
                } catch (RemoteException ex) {
                   throw new AgentConfigurationError(
                           CONNECTOR_SERVER_IO_ERROR, ex, ex.getMessage());
                } catch (AlreadyBoundException ex) {
                   throw new AgentConfigurationError(
                           CONNECTOR_SERVER_IO_ERROR, ex, ex.getMessage());
                }
            } else {
                registry.rebind("jmxrmi", exporter.firstExported);
            }
View Full Code Here

Examples of sun.management.AgentConfigurationError

    public static void resetRegistry() {
        try {
            exporter.unexportObject(exporter.firstExported, true);
            ConnectorBootstrap.registry.unbind("jmxrmi");
        } catch (RemoteException ex) {
            throw new AgentConfigurationError(
                           CONNECTOR_SERVER_IO_ERROR, ex, ex.getMessage());
        } catch (NotBoundException ex) {
            throw new AgentConfigurationError(
                           CONNECTOR_SERVER_IO_ERROR, ex, ex.getMessage());
        }
    }
View Full Code Here

Examples of sun.management.AgentConfigurationError

        // Get serverPort number
        final int serverPort;
        try {
            serverPort = Integer.parseInt(portStr);
        } catch (NumberFormatException x) {
            throw new AgentConfigurationError(INVALID_JMXREMOTE_PORT,
                    x, portStr);
        }
        if (serverPort < 0) {
            throw new AgentConfigurationError(INVALID_JMXREMOTE_PORT,
                    portStr);
        }

        // Do we use authentication?
        final String useAuthenticationStr = props.getProperty(
                PropertyNames.USE_AUTHENTICATION,
                DefaultValues.USE_AUTHENTICATION);
        final boolean useAuthentication = Boolean.valueOf(
                useAuthenticationStr).booleanValue();

        // Do we use SSL?
        final String useSslStr = props.getProperty(
                PropertyNames.USE_SSL, DefaultValues.USE_SSL);
        final boolean useSsl = Boolean.valueOf(useSslStr).booleanValue();

        // Do we use RMI Registry SSL?
        final String useRegistrySslStr = props.getProperty(
                PropertyNames.USE_REGISTRY_SSL,
                DefaultValues.USE_REGISTRY_SSL);
        final boolean useRegistrySsl = Boolean.valueOf(
                useRegistrySslStr).booleanValue();

        final String enabledCipherSuites = props.getProperty(PropertyNames.SSL_ENABLED_CIPHER_SUITES);
        String enabledCipherSuitesList[] = null;
        if (enabledCipherSuites != null) {
            StringTokenizer st = new StringTokenizer(
                    enabledCipherSuites, ",");
            int tokens = st.countTokens();
            enabledCipherSuitesList = new String[tokens];
            for (int i = 0; i < tokens; i++) {
                enabledCipherSuitesList[i] = st.nextToken();
            }
        }

        final String enabledProtocols = props.getProperty(PropertyNames.SSL_ENABLED_PROTOCOLS);
        String enabledProtocolsList[] = null;
        if (enabledProtocols != null) {
            StringTokenizer st = new StringTokenizer(enabledProtocols,
                    ",");
            int tokens = st.countTokens();
            enabledProtocolsList = new String[tokens];
            for (int i = 0; i < tokens; i++) {
                enabledProtocolsList[i] = st.nextToken();
            }
        }

        final String sslNeedClientAuthStr = props.getProperty(
                PropertyNames.SSL_NEED_CLIENT_AUTH,
                DefaultValues.SSL_NEED_CLIENT_AUTH);
        final boolean sslNeedClientAuth = Boolean.valueOf(
                sslNeedClientAuthStr).booleanValue();
        String serverKeystorePassword = null;
        String loginConfigName = null;
        String passwordFileName = null;
        String keystorePasswordFileName = null;
        String accessFileName = null;

        // Initialize settings when authentication is active
        if (useAuthentication) {

            // Get non-default login configuration
            loginConfigName = props.getProperty(PropertyNames.LOGIN_CONFIG_NAME);

            if (loginConfigName == null) {
                // Get password file
                passwordFileName = props.getProperty(
                        PropertyNames.PASSWORD_FILE_NAME,
                        getDefaultFileName(DefaultValues.PASSWORD_FILE_NAME));
                checkPasswordFile(passwordFileName);
            }

            // Get access file
            accessFileName = props.getProperty(
                    PropertyNames.ACCESS_FILE_NAME,
                    getDefaultFileName(DefaultValues.ACCESS_FILE_NAME));
            checkAccessFile(accessFileName);
        }

        if (useSsl) {

            // Get keystore password file
            keystorePasswordFileName = props.getProperty(PropertyNames.SSL_SERVER_KEYSTORE_PASSWORD_FILE);

            // get the keystore password from the keystore password file
            // (/var/sgeCA/portNNNN/sge_cell/private/keystore.password)
            // workaround for euid problem of libjvm under Linux otherwise jmxremote.password
            // could have been used
            try {
                serverKeystorePassword = propertiesFromFile(keystorePasswordFileName).getProperty(PropertyNames.SSL_SERVER_KEYSTORE_PASSWORD);
            } catch (IOException ex) {
                throw new AgentConfigurationError(AGENT_EXCEPTION, ex, ex.getMessage());
            }

            // setup SSLContext to use different TrustManager and KeyManager
            final String serverKeystore = props.getProperty(PropertyNames.SSL_SERVER_KEYSTORE);

            File serverKeystoreFile = new File(serverKeystore);
            File caTop = JGDIAgent.getCaTop();
            String serverHost = "";
            try {
                serverHost = InetAddress.getLocalHost().getHostName();
            } catch (UnknownHostException ex) {
                throw new AgentConfigurationError(AGENT_EXCEPTION, ex, "Can't resolve local host");
            }
            char[] pw = (serverKeystorePassword != null) ? serverKeystorePassword.toCharArray() : "".toCharArray();
            log.log(Level.FINE, "SSLHelper.init: caTop = {0} serverKeystore = {1} serverKeystorePW = {2}",
                    new Object[]{caTop, serverKeystore, (serverKeystorePassword != null) ? serverKeystorePassword : "-empty pw-"});
            SSLHelper.getInstanceByKey(serverHost, serverPort, caTop).setKeystore(serverKeystoreFile, pw);
        }

        if (log.isLoggable(Level.FINE)) {
            log.log(Level.FINE,
                    "initialize",
                    Agent.getText("jmxremote.ConnectorBootstrap.initialize") + "\n\t" + PropertyNames.PORT + "=" + serverPort + "\n\t" + PropertyNames.USE_SSL + "=" + useSsl + "\n\t" + PropertyNames.USE_REGISTRY_SSL + "=" + useRegistrySsl + "\n\t" + PropertyNames.SSL_ENABLED_CIPHER_SUITES + "=" + enabledCipherSuites + "\n\t" + PropertyNames.SSL_ENABLED_PROTOCOLS + "=" + enabledProtocols + "\n\t" + PropertyNames.SSL_NEED_CLIENT_AUTH + "=" + sslNeedClientAuth + "\n\t" + PropertyNames.USE_AUTHENTICATION + "=" + useAuthentication + (useAuthentication ? (loginConfigName == null ? ("\n\t" + PropertyNames.PASSWORD_FILE_NAME + "=" + passwordFileName)
                    : ("\n\t" + PropertyNames.LOGIN_CONFIG_NAME + "=" + loginConfigName))
                    : "\n\t" + Agent.getText("jmxremote.ConnectorBootstrap.initialize.noAuthentication")) + (useAuthentication ? ("\n\t" + PropertyNames.ACCESS_FILE_NAME + "=" + accessFileName)
                    : "") + "");
        }

        final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        JMXConnectorServer cs = null;
        try {
            cs = exportMBeanServer(mbs, serverPort, useSsl, useRegistrySsl,
                    enabledCipherSuitesList, enabledProtocolsList,
                    sslNeedClientAuth, useAuthentication,
                    loginConfigName, passwordFileName, accessFileName);

            final JMXServiceURL url = cs.getAddress();
            if (log.isLoggable(Level.FINE)) {
                log.log(Level.FINE, "initialize", Agent.getText(
                        "jmxremote.ConnectorBootstrap.initialize.ready",
                        new JMXServiceURL(url.getProtocol(), url.getHost(),
                        url.getPort(), "/jndi/rmi://" + url.getHost() + ":" + serverPort + "/" + "jmxrmi").toString()));
            }
        } catch (Exception e) {
            throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.toString());
        }
        return cs;
    }
View Full Code Here

Examples of sun.management.AgentConfigurationError

            JMXServiceURL url = new JMXServiceURL("rmi", localhost, 0);
            JMXConnectorServer server = JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
            server.start();
            return server;
        } catch (Exception e) {
            throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.toString());
        }
    }
View Full Code Here

Examples of sun.management.AgentConfigurationError

        }
    }

    private static void checkPasswordFile(String passwordFileName) {
        if (passwordFileName == null || passwordFileName.length() == 0) {
            throw new AgentConfigurationError(PASSWORD_FILE_NOT_SET);
        }
        File file = new File(passwordFileName);
        if (!file.exists()) {
            throw new AgentConfigurationError(PASSWORD_FILE_NOT_FOUND,
                    passwordFileName);
        }

        if (!file.canRead()) {
            throw new AgentConfigurationError(
                    PASSWORD_FILE_NOT_READABLE, passwordFileName);
        }

        FileSystem fs = FileSystem.open();
        try {
            if (fs.supportsFileSecurity(file)) {
                if (!fs.isAccessUserOnly(file)) {
                    final String msg = Agent.getText(
                            "jmxremote.ConnectorBootstrap.initialize.password.readonly",
                            passwordFileName);
                    log.log(Level.FINE, "initialize", msg);
                    throw new AgentConfigurationError(
                            PASSWORD_FILE_ACCESS_NOT_RESTRICTED,
                            passwordFileName);
                }
            }
        } catch (IOException e) {
            throw new AgentConfigurationError(
                    PASSWORD_FILE_READ_FAILED, e, passwordFileName);
        }
    }
View Full Code Here

Examples of sun.management.AgentConfigurationError

        }
    }

    private static void checkAccessFile(String accessFileName) {
        if (accessFileName == null || accessFileName.length() == 0) {
            throw new AgentConfigurationError(ACCESS_FILE_NOT_SET);
        }
        File file = new File(accessFileName);
        if (!file.exists()) {
            throw new AgentConfigurationError(ACCESS_FILE_NOT_FOUND,
                    accessFileName);
        }

        if (!file.canRead()) {
            throw new AgentConfigurationError(ACCESS_FILE_NOT_READABLE,
                    accessFileName);
        }
    }
View Full Code Here

Examples of sun.management.AgentConfigurationError

        try {
            connServer = JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
            connServer.start();
        } catch (IOException e) {
            if (connServer == null) {
                throw new AgentConfigurationError(
                        CONNECTOR_SERVER_IO_ERROR, e, url.toString());
            } else {
                throw new AgentConfigurationError(
                        CONNECTOR_SERVER_IO_ERROR, e, connServer.getAddress().toString());
            }
        }

        if (useRegistrySsl) {
            if (registry == null) {
                try {
                    registry = LocateRegistry.createRegistry(serverPort, csf, ssf);
                    registry.bind("jmxrmi", exporter.firstExported);
                } catch (RemoteException ex) {
                   throw new AgentConfigurationError(
                           CONNECTOR_SERVER_IO_ERROR, ex, ex.getMessage());
                } catch (AlreadyBoundException ex) {
                   throw new AgentConfigurationError(
                           CONNECTOR_SERVER_IO_ERROR, ex, ex.getMessage());
                }
            } else {
                registry.rebind("jmxrmi", exporter.firstExported);
            }
        } else {
            if (registry == null) {
                try {
                    registry = LocateRegistry.createRegistry(serverPort);
                    registry.bind("jmxrmi", exporter.firstExported);
                } catch (RemoteException ex) {
                   throw new AgentConfigurationError(
                           CONNECTOR_SERVER_IO_ERROR, ex, ex.getMessage());
                } catch (AlreadyBoundException ex) {
                   throw new AgentConfigurationError(
                           CONNECTOR_SERVER_IO_ERROR, ex, ex.getMessage());
                }
            } else {
                registry.rebind("jmxrmi", exporter.firstExported);
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.