Examples of AgentConfigurationError


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

        if (portStr.length()==0) portStr=DefaultValues.PORT;
        final int port;
        try {
            port = Integer.parseInt(portStr);
        } catch (NumberFormatException x) {
            throw new AgentConfigurationError(INVALID_SNMP_PORT, x, portStr);
        }

        if (port < 0) {
            throw new AgentConfigurationError(INVALID_SNMP_PORT, portStr);
        }

        // Get trap port number
        final String trapPortStr =
            props.getProperty(PropertyNames.TRAP_PORT,
                              DefaultValues.TRAP_PORT);

        final int trapPort;
        try {
            trapPort = Integer.parseInt(trapPortStr);
        } catch (NumberFormatException x) {
            throw new AgentConfigurationError(INVALID_SNMP_TRAP_PORT, x, trapPortStr);
        }

        if (trapPort < 0) {
            throw new AgentConfigurationError(INVALID_SNMP_TRAP_PORT, trapPortStr);
        }

        // Get bind address
        final String addrStr =
            props.getProperty(PropertyNames.BIND_ADDRESS,
                              DefaultValues.BIND_ADDRESS);

        // Get ACL File
        final String defaultAclFileName   =
            getDefaultFileName(DefaultValues.ACL_FILE_NAME);
        final String aclFileName =
            props.getProperty(PropertyNames.ACL_FILE_NAME,
                               defaultAclFileName);
        final String  useAclStr =
            props.getProperty(PropertyNames.USE_ACL,DefaultValues.USE_ACL);
        final boolean useAcl =
            Boolean.valueOf(useAclStr).booleanValue();

        if (useAcl) checkAclFile(aclFileName);

        AdaptorBootstrap adaptor = null;
        try {
            adaptor = getAdaptorBootstrap(port, trapPort, addrStr,
                                          useAcl, aclFileName);
        } catch (Exception e) {
            throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.getMessage());
        }
        return adaptor;
    }
View Full Code Here

Examples of sun.management.AgentConfigurationError

        final InetAddress address;
        try {
            address = InetAddress.getByName(bindAddress);
        } catch (UnknownHostException e) {
            throw new AgentConfigurationError(UNKNOWN_SNMP_INTERFACE, e, bindAddress);
        }
        if (log.isDebugOn()) {
            log.debug("initialize",
                      Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.starting" +
                      "\n\t" + PropertyNames.PORT + "=" + port +
                      "\n\t" + PropertyNames.TRAP_PORT + "=" + trapPort +
                      "\n\t" + PropertyNames.BIND_ADDRESS + "=" + address +
                      (useAcl?("\n\t" + PropertyNames.ACL_FILE_NAME + "="
                               + aclFileName):"\n\tNo ACL")+
                      ""));
        }

        final InetAddressAcl acl;
        try {
            acl = useAcl ? new SnmpAcl(System.getProperty("user.name"),aclFileName)
                         : null;
        } catch (UnknownHostException e) {
            throw new AgentConfigurationError(UNKNOWN_SNMP_INTERFACE, e, e.getMessage());
        }

        // Create adaptor
        final SnmpAdaptorServer adaptor =
            new SnmpAdaptorServer(acl, port, address);
        adaptor.setUserDataFactory(new JvmContextFactory());
        adaptor.setTrapPort(trapPort);

        // Create MIB
        //
        final JVM_MANAGEMENT_MIB_IMPL mib = new JVM_MANAGEMENT_MIB_IMPL();
        try {
            mib.init();
        } catch (IllegalAccessException x) {
            throw new AgentConfigurationError(SNMP_MIB_INIT_FAILED, x, x.getMessage());
        }

        // Configure the trap destinations.
        //
        mib.addTargets(getTargetList(acl,trapPort));


        // Start Adaptor
        //
        try {
            // Will wait until the adaptor starts or fails to start.
            // If the adaptor fails to start, a CommunicationException or
            // an InterruptedException is thrown.
            //
            adaptor.start(Long.MAX_VALUE);
        } catch (Exception x) {
            Throwable t=x;
            if (x instanceof com.sun.jmx.snmp.daemon.CommunicationException) {
                final Throwable next = t.getCause();
                if (next != null) t = next;
            }
            throw new AgentConfigurationError(SNMP_ADAPTOR_START_FAILED, t,
                                              address + ":" + port,
                                              "(" + t.getMessage() + ")");
        }

        // double check that adaptor is actually started (should always
        // be active, so that exception should never be thrown from here)
        //
        if (!adaptor.isActive()) {
            throw new AgentConfigurationError(SNMP_ADAPTOR_START_FAILED,
                                              address + ":" + port);
        }

        try {
            // Add MIB to adaptor
View Full Code Here

Examples of sun.management.AgentConfigurationError

        return new AdaptorBootstrap(adaptor,mib);
    }

    private static void checkAclFile(String aclFileName) {
        if (aclFileName == null || aclFileName.length()==0) {
            throw new AgentConfigurationError(SNMP_ACL_FILE_NOT_SET);
        }
        final File file = new File(aclFileName);
        if (!file.exists()) {
            throw new AgentConfigurationError(SNMP_ACL_FILE_NOT_FOUND, aclFileName);
        }
        if (!file.canRead()) {
            throw new AgentConfigurationError(SNMP_ACL_FILE_NOT_READABLE, aclFileName);
        }

        FileSystem fs = FileSystem.open();
        try {
            if (fs.supportsFileSecurity(file)) {
                if (!fs.isAccessUserOnly(file)) {
                    throw new AgentConfigurationError(SNMP_ACL_FILE_ACCESS_NOT_RESTRICTED,
                        aclFileName);
                }
            }
        } catch (IOException e) {
            throw new AgentConfigurationError(SNMP_ACL_FILE_READ_FAILED, aclFileName);

        }
    }
View Full Code Here

Examples of sun.management.AgentConfigurationError

        if (portStr.length()==0) portStr=DefaultValues.PORT;
        final int port;
        try {
            port = Integer.parseInt(portStr);
        } catch (NumberFormatException x) {
            throw new AgentConfigurationError(INVALID_SNMP_PORT, x, portStr);
        }

        if (port < 0) {
            throw new AgentConfigurationError(INVALID_SNMP_PORT, portStr);
        }

        // Get trap port number
        final String trapPortStr =
            props.getProperty(PropertyNames.TRAP_PORT,
                              DefaultValues.TRAP_PORT);

        final int trapPort;
        try {
            trapPort = Integer.parseInt(trapPortStr);
        } catch (NumberFormatException x) {
            throw new AgentConfigurationError(INVALID_SNMP_TRAP_PORT, x, trapPortStr);
        }

        if (trapPort < 0) {
            throw new AgentConfigurationError(INVALID_SNMP_TRAP_PORT, trapPortStr);
        }

        // Get bind address
        final String addrStr =
            props.getProperty(PropertyNames.BIND_ADDRESS,
                              DefaultValues.BIND_ADDRESS);

        // Get ACL File
        final String defaultAclFileName   =
            getDefaultFileName(DefaultValues.ACL_FILE_NAME);
        final String aclFileName =
            props.getProperty(PropertyNames.ACL_FILE_NAME,
                               defaultAclFileName);
        final String  useAclStr =
            props.getProperty(PropertyNames.USE_ACL,DefaultValues.USE_ACL);
        final boolean useAcl =
            Boolean.valueOf(useAclStr).booleanValue();

        if (useAcl) checkAclFile(aclFileName);

        AdaptorBootstrap adaptor = null;
        try {
            adaptor = getAdaptorBootstrap(port, trapPort, addrStr,
                                          useAcl, aclFileName);
        } catch (Exception e) {
            throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.getMessage());
        }
        return adaptor;
    }
View Full Code Here

Examples of sun.management.AgentConfigurationError

        final InetAddress address;
        try {
            address = InetAddress.getByName(bindAddress);
        } catch (UnknownHostException e) {
            throw new AgentConfigurationError(UNKNOWN_SNMP_INTERFACE, e, bindAddress);
        }
        if (log.isDebugOn()) {
            log.debug("initialize",
                      Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.starting" +
                      "\n\t" + PropertyNames.PORT + "=" + port +
                      "\n\t" + PropertyNames.TRAP_PORT + "=" + trapPort +
                      "\n\t" + PropertyNames.BIND_ADDRESS + "=" + address +
                      (useAcl?("\n\t" + PropertyNames.ACL_FILE_NAME + "="
                               + aclFileName):"\n\tNo ACL")+
                      ""));
        }

        final InetAddressAcl acl;
        try {
            acl = useAcl ? new SnmpAcl(System.getProperty("user.name"),aclFileName)
                         : null;
        } catch (UnknownHostException e) {
            throw new AgentConfigurationError(UNKNOWN_SNMP_INTERFACE, e, e.getMessage());
        }

        // Create adaptor
        final SnmpAdaptorServer adaptor =
            new SnmpAdaptorServer(acl, port, address);
        adaptor.setUserDataFactory(new JvmContextFactory());
        adaptor.setTrapPort(trapPort);

        // Create MIB
        //
        final JVM_MANAGEMENT_MIB_IMPL mib = new JVM_MANAGEMENT_MIB_IMPL();
        try {
            mib.init();
        } catch (IllegalAccessException x) {
            throw new AgentConfigurationError(SNMP_MIB_INIT_FAILED, x, x.getMessage());
        }

        // Configure the trap destinations.
        //
        mib.addTargets(getTargetList(acl,trapPort));


        // Start Adaptor
        //
        try {
            // Will wait until the adaptor starts or fails to start.
            // If the adaptor fails to start, a CommunicationException or
            // an InterruptedException is thrown.
            //
            adaptor.start(Long.MAX_VALUE);
        } catch (Exception x) {
            Throwable t=x;
            if (x instanceof com.sun.jmx.snmp.daemon.CommunicationException) {
                final Throwable next = t.getCause();
                if (next != null) t = next;
            }
            throw new AgentConfigurationError(SNMP_ADAPTOR_START_FAILED, t,
                                              address + ":" + port,
                                              "(" + t.getMessage() + ")");
        }

        // double check that adaptor is actually started (should always
        // be active, so that exception should never be thrown from here)
        //
        if (!adaptor.isActive()) {
            throw new AgentConfigurationError(SNMP_ADAPTOR_START_FAILED,
                                              address + ":" + port);
        }

        try {
            // Add MIB to adaptor
View Full Code Here

Examples of sun.management.AgentConfigurationError

        return new AdaptorBootstrap(adaptor,mib);
    }

    private static void checkAclFile(String aclFileName) {
        if (aclFileName == null || aclFileName.length()==0) {
            throw new AgentConfigurationError(SNMP_ACL_FILE_NOT_SET);
        }
        final File file = new File(aclFileName);
        if (!file.exists()) {
            throw new AgentConfigurationError(SNMP_ACL_FILE_NOT_FOUND, aclFileName);
        }
        if (!file.canRead()) {
            throw new AgentConfigurationError(SNMP_ACL_FILE_NOT_READABLE, aclFileName);
        }

        FileSystem fs = FileSystem.open();
        try {
            if (fs.supportsFileSecurity(file)) {
                if (!fs.isAccessUserOnly(file)) {
                    throw new AgentConfigurationError(SNMP_ACL_FILE_ACCESS_NOT_RESTRICTED,
                        aclFileName);
                }
            }
        } catch (IOException e) {
            throw new AgentConfigurationError(SNMP_ACL_FILE_READ_FAILED, aclFileName);

        }
    }
View Full Code Here

Examples of sun.management.AgentConfigurationError

        // Get port number
        final int port;
        try {
            port = Integer.parseInt(portStr);
        } catch (NumberFormatException x) {
            throw new AgentConfigurationError(INVALID_JMXREMOTE_PORT, x, portStr);
        }
        if (port < 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();

        // Read SSL config file name
        final String sslConfigFileName =
                props.getProperty(PropertyNames.SSL_CONFIG_FILE_NAME);

        String loginConfigName = null;
        String passwordFileName = 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 (log.debugOn()) {
            log.debug("initialize",
                    Agent.getText("jmxremote.ConnectorBootstrap.initialize") +
                    "\n\t" + PropertyNames.PORT + "=" + port +
                    "\n\t" + PropertyNames.USE_SSL + "=" + useSsl +
                    "\n\t" + PropertyNames.USE_REGISTRY_SSL + "=" + useRegistrySsl +
                    "\n\t" + PropertyNames.SSL_CONFIG_FILE_NAME + "=" + sslConfigFileName +
                    "\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, port, useSsl, useRegistrySsl,
                    sslConfigFileName, enabledCipherSuitesList,
                    enabledProtocolsList, sslNeedClientAuth,
                    useAuthentication, loginConfigName,
                    passwordFileName, accessFileName);

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

Examples of sun.management.AgentConfigurationError

            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.config("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
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.