use of org.eclipse.jetty.jmx.MBeanContainer in project vespa by vespa-engine.
the class JettyHttpServer method setupJmx.
private static void setupJmx(Server server, ServerConfig serverConfig) {
if (serverConfig.jmx().enabled()) {
System.setProperty("java.rmi.server.hostname", "localhost");
server.addBean(new MBeanContainer(ManagementFactory.getPlatformMBeanServer()));
server.addBean(new ConnectorServer(createJmxLoopbackOnlyServiceUrl(serverConfig.jmx().listenPort()), "org.eclipse.jetty.jmx:name=rmiconnectorserver"));
}
}
use of org.eclipse.jetty.jmx.MBeanContainer in project cia by Hack23.
the class CitizenIntelligenceAgencyServer method init.
/**
* Inits the.
*
* @throws Exception
* the exception
*/
public final void init() throws Exception {
initialised = true;
server = new Server();
Security.addProvider(new BouncyCastleProvider());
// Setup JMX
final MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
server.addBean(mbContainer);
// Enable parsing of jndi-related parts of web.xml and jetty-env.xml
final org.eclipse.jetty.webapp.Configuration.ClassList classlist = org.eclipse.jetty.webapp.Configuration.ClassList.setServerDefault(server);
classlist.addAfter("org.eclipse.jetty.webapp.FragmentConfiguration", "org.eclipse.jetty.plus.webapp.EnvConfiguration", "org.eclipse.jetty.plus.webapp.PlusConfiguration");
classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");
final HttpConfiguration http_config = new HttpConfiguration();
http_config.setSecureScheme("https");
http_config.setSecurePort(28443);
final HttpConfiguration https_config = new HttpConfiguration(http_config);
https_config.addCustomizer(new SecureRequestCustomizer());
final SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStoreType("JKS");
sslContextFactory.setKeyStorePath("target/keystore.jks");
sslContextFactory.setTrustStorePath("target/keystore.jks");
sslContextFactory.setKeyStorePassword("changeit");
sslContextFactory.setTrustStorePassword("changeit");
sslContextFactory.setKeyManagerPassword("changeit");
sslContextFactory.setCertAlias("jetty");
sslContextFactory.setIncludeCipherSuites("TLS_DHE_RSA.*", "TLS_ECDHE.*");
sslContextFactory.setExcludeProtocols("SSL", "SSLv2", "SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.1");
sslContextFactory.setIncludeProtocols("TLSv1.2");
final ServerConnector sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(https_config), new HTTP2CServerConnectionFactory(https_config));
sslConnector.setPort(PORT);
server.setConnectors(new ServerConnector[] { sslConnector });
final WebAppContext handler = new WebAppContext("src/main/webapp", "/");
handler.setExtraClasspath("target/classes");
handler.setParentLoaderPriority(true);
handler.setConfigurationDiscovered(true);
handler.setClassLoader(Thread.currentThread().getContextClassLoader());
final HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { handler, new DefaultHandler() });
server.setHandler(handlers);
}
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);
}
}
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));
}
Aggregations