Search in sources :

Example 21 with MBeanContainer

use of org.eclipse.jetty.jmx.MBeanContainer in project gocd by gocd.

the class Jetty9Server method mbeans.

private MBeanContainer mbeans() {
    MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
    MBeanContainer mbeans = new MBeanContainer(platformMBeanServer);
    return mbeans;
}
Also used : MBeanContainer(org.eclipse.jetty.jmx.MBeanContainer) MBeanServer(javax.management.MBeanServer)

Example 22 with MBeanContainer

use of org.eclipse.jetty.jmx.MBeanContainer in project Openfire by igniterealtime.

the class JMXManager method start.

private void start() {
    setContainer(new MBeanContainer(ManagementFactory.getPlatformMBeanServer()));
    int jmxPort = JMXManager.getPort();
    String jmxUrl = "/jndi/rmi://localhost:" + jmxPort + "/jmxrmi";
    Map<String, Object> env = new HashMap<>();
    if (JMXManager.isSecure()) {
        env.put("jmx.remote.authenticator", new JMXAuthenticator() {

            @Override
            public Subject authenticate(Object credentials) {
                if (!(credentials instanceof String[])) {
                    if (credentials == null) {
                        throw new SecurityException("Credentials required");
                    }
                    throw new SecurityException("Credentials should be String[]");
                }
                final String[] aCredentials = (String[]) credentials;
                if (aCredentials.length < 2) {
                    throw new SecurityException("Credentials should have at least two elements");
                }
                String username = aCredentials[0];
                String password = aCredentials[1];
                try {
                    AuthFactory.authenticate(username, password);
                } catch (Exception ex) {
                    Log.error("Authentication failed for " + username);
                    throw new SecurityException();
                }
                if (AdminManager.getInstance().isUserAdmin(username, true)) {
                    return new Subject(true, Collections.singleton(new JMXPrincipal(username)), Collections.EMPTY_SET, Collections.EMPTY_SET);
                } else {
                    Log.error("Authorization failed for " + username);
                    throw new SecurityException();
                }
            }
        });
    }
    try {
        jmxServer = new ConnectorServer(new JMXServiceURL("rmi", null, jmxPort, jmxUrl), env, "org.eclipse.jetty.jmx:name=rmiconnectorserver");
        jmxServer.start();
    } catch (Exception e) {
        Log.error("Failed to start JMX connector", e);
    }
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) HashMap(java.util.HashMap) JMXAuthenticator(javax.management.remote.JMXAuthenticator) JMXPrincipal(javax.management.remote.JMXPrincipal) Subject(javax.security.auth.Subject) MBeanContainer(org.eclipse.jetty.jmx.MBeanContainer) ConnectorServer(org.eclipse.jetty.jmx.ConnectorServer)

Example 23 with MBeanContainer

use of org.eclipse.jetty.jmx.MBeanContainer in project killbill by killbill.

the class HttpServer method configureJMX.

private void configureJMX(final MBeanServer mbeanServer) {
    // Setup JMX
    final MBeanContainer mbContainer = new MBeanContainer(mbeanServer);
    server.addBean(mbContainer);
    // Add loggers MBean to server (will be picked up by MBeanContainer above)
    server.addBean(Log.getLogger(HttpServer.class));
}
Also used : MBeanContainer(org.eclipse.jetty.jmx.MBeanContainer)

Example 24 with MBeanContainer

use of org.eclipse.jetty.jmx.MBeanContainer in project camel by apache.

the class JettyHttpComponent method getMbContainer.

public synchronized MBeanContainer getMbContainer() {
    // If null, provide the default implementation.
    if (mbContainer == null) {
        MBeanServer mbs = null;
        final ManagementStrategy mStrategy = this.getCamelContext().getManagementStrategy();
        final ManagementAgent mAgent = mStrategy.getManagementAgent();
        if (mAgent != null) {
            mbs = mAgent.getMBeanServer();
        }
        if (mbs != null) {
            mbContainer = new MBeanContainer(mbs);
            startMbContainer();
        } else {
            LOG.warn("JMX disabled in CamelContext. Jetty JMX extensions will remain disabled.");
        }
    }
    return this.mbContainer;
}
Also used : ManagementAgent(org.apache.camel.spi.ManagementAgent) ManagementStrategy(org.apache.camel.spi.ManagementStrategy) MBeanContainer(org.eclipse.jetty.jmx.MBeanContainer) MBeanServer(javax.management.MBeanServer)

Aggregations

MBeanContainer (org.eclipse.jetty.jmx.MBeanContainer)24 Server (org.eclipse.jetty.server.Server)15 ServerConnector (org.eclipse.jetty.server.ServerConnector)8 File (java.io.File)7 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)7 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)6 MBeanServer (javax.management.MBeanServer)5 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)5 SecureRequestCustomizer (org.eclipse.jetty.server.SecureRequestCustomizer)5 ContextHandlerCollection (org.eclipse.jetty.server.handler.ContextHandlerCollection)5 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)5 SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)4 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)4 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)4 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)4 JMXServiceURL (javax.management.remote.JMXServiceURL)3 HashLoginService (org.eclipse.jetty.security.HashLoginService)3 DefaultHandler (org.eclipse.jetty.server.handler.DefaultHandler)3 HandlerCollection (org.eclipse.jetty.server.handler.HandlerCollection)3 FilterHolder (org.eclipse.jetty.servlet.FilterHolder)3