public void addServlet(String name, String pathSpec, Class<? extends HttpServlet> clazz) { this.httpServer.addServlet(name, pathSpec, clazz); }
/** * Add default servlets. */ protected void addDefaultServlets() { // set up default servlets addServlet("stacks", "/stacks", StackServlet.class); addServlet("logLevel", "/logLevel", LogLevel.Servlet.class); // Hadoop3 has moved completely to metrics2, and dropped support for Metrics v1's // MetricsServlet (see HADOOP-12504). We'll using reflection to load if against hadoop2. // Remove when we drop support for hbase on hadoop2.x. try { Class clz = Class.forName("org.apache.hadoop.metrics.MetricsServlet"); addServlet("metrics", "/metrics", clz); } catch (Exception e) { // do nothing } addServlet("jmx", "/jmx", JMXJsonServlet.class); addServlet("conf", "/conf", ConfServlet.class); }
@BeforeClass public static void setup() throws Exception { Configuration conf = new Configuration(); conf.setInt(HttpServer.HTTP_MAX_THREADS, MAX_THREADS); server = createTestServer(conf); server.addServlet("echo", "/echo", EchoServlet.class); server.addServlet("echomap", "/echomap", EchoMapServlet.class); server.addServlet("htmlcontent", "/htmlcontent", HtmlContentServlet.class); server.addServlet("longheader", "/longheader", LongHeaderServlet.class); server.addJerseyResourcePackage( JerseyResource.class.getPackage().getName(), "/jersey/*"); server.start(); baseUrl = getServerURL(server); LOG.info("HTTP server started: "+ baseUrl); }
@Test(expected = IllegalArgumentException.class) public void testMissingConfigurationThrowsException() throws Exception { Configuration conf = new Configuration(); conf.setInt(HttpServer.HTTP_MAX_THREADS, TestHttpServer.MAX_THREADS); // Enable Kerberos (pre-req) conf.set("hbase.security.authentication", "kerberos"); // Intentionally skip keytab and principal HttpServer customServer = createTestServerWithSecurity(conf); customServer.addServlet("echo", "/echo", EchoServlet.class); customServer.addJerseyResourcePackage(JerseyResource.class.getPackage().getName(), "/jersey/*"); customServer.start(); } }
@BeforeClass public static void setupServer() throws Exception { final String serverPrincipal = "HTTP/" + KDC_SERVER_HOST; final File target = new File(System.getProperty("user.dir"), "target"); assertTrue(target.exists()); kdc = buildMiniKdc(); kdc.start(); File keytabDir = new File(target, TestSpnegoHttpServer.class.getSimpleName() + "_keytabs"); if (keytabDir.exists()) { deleteRecursively(keytabDir); } keytabDir.mkdirs(); infoServerKeytab = new File(keytabDir, serverPrincipal.replace('/', '_') + ".keytab"); clientKeytab = new File(keytabDir, CLIENT_PRINCIPAL + ".keytab"); setupUser(kdc, clientKeytab, CLIENT_PRINCIPAL); setupUser(kdc, infoServerKeytab, serverPrincipal); Configuration conf = buildSpnegoConfiguration(serverPrincipal, infoServerKeytab); server = createTestServerWithSecurity(conf); server.addServlet("echo", "/echo", EchoServlet.class); server.addJerseyResourcePackage(JerseyResource.class.getPackage().getName(), "/jersey/*"); server.start(); baseUrl = getServerURL(server); LOG.info("HTTP server started: "+ baseUrl); }
@Test public void testXFrameHeaderSameOrigin() throws Exception { Configuration conf = new Configuration(); conf.set("hbase.http.filter.xframeoptions.mode", "SAMEORIGIN"); HttpServer myServer = new HttpServer.Builder().setName("test") .addEndpoint(new URI("http://localhost:0")) .setFindPort(true).setConf(conf).build(); myServer.setAttribute(HttpServer.CONF_CONTEXT_ATTRIBUTE, conf); myServer.addServlet("echo", "/echo", EchoServlet.class); myServer.start(); String serverURL = "http://" + NetUtils.getHostPortString(myServer.getConnectorAddress(0)); URL url = new URL(new URL(serverURL), "/echo?a=b&c=d"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode()); assertEquals("SAMEORIGIN", conn.getHeaderField("X-Frame-Options")); myServer.stop(); }
HBaseConfiguration.getPassword(sslConf, "ssl.server.truststore.password", null), sslConf.get("ssl.server.truststore.type", "jks")).build(); server.addServlet("echo", "/echo", TestHttpServer.EchoServlet.class); server.start(); baseUrl = new URL("https://"
/** * Add default servlets. */ protected void addDefaultServlets() { // set up default servlets addServlet("stacks", "/stacks", StackServlet.class); addServlet("logLevel", "/logLevel", LogLevel.Servlet.class); addServlet("metrics", "/metrics", MetricsServlet.class); addServlet("jmx", "/jmx", JMXJsonServlet.class); addServlet("conf", "/conf", ConfServlet.class); }
public void addServlet(String name, String pathSpec, Class<? extends HttpServlet> clazz) { this.httpServer.addServlet(name, pathSpec, clazz); }
public void addServlet(String name, String pathSpec, Class<? extends HttpServlet> clazz) { this.httpServer.addServlet(name, pathSpec, clazz); }
public void addServlet(String name, String pathSpec, Class<? extends HttpServlet> clazz) { this.httpServer.addServlet(name, pathSpec, clazz); }
/** * Add default servlets. */ protected void addDefaultServlets() { // set up default servlets addServlet("stacks", "/stacks", StackServlet.class); addServlet("logLevel", "/logLevel", LogLevel.Servlet.class); // Hadoop3 has moved completely to metrics2, and dropped support for Metrics v1's // MetricsServlet (see HADOOP-12504). We'll using reflection to load if against hadoop2. // Remove when we drop support for hbase on hadoop2.x. try { Class clz = Class.forName("org.apache.hadoop.metrics.MetricsServlet"); addServlet("metrics", "/metrics", clz); } catch (Exception e) { // do nothing } addServlet("jmx", "/jmx", JMXJsonServlet.class); addServlet("conf", "/conf", ConfServlet.class); }
/** * Add default servlets. */ protected void addDefaultServlets() { // set up default servlets addServlet("stacks", "/stacks", StackServlet.class); addServlet("logLevel", "/logLevel", LogLevel.Servlet.class); // Hadoop3 has moved completely to metrics2, and dropped support for Metrics v1's // MetricsServlet (see HADOOP-12504). We'll using reflection to load if against hadoop2. // Remove when we drop support for hbase on hadoop2.x. try { Class clz = Class.forName("org.apache.hadoop.metrics.MetricsServlet"); addServlet("metrics", "/metrics", clz); } catch (Exception e) { // do nothing } addServlet("jmx", "/jmx", JMXJsonServlet.class); addServlet("conf", "/conf", ConfServlet.class); }