org.apache.hadoop.http.lib.StaticUserWebFilter Java Examples

The following examples show how to use org.apache.hadoop.http.lib.StaticUserWebFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpServer2.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
/**
 * Get an array of FilterConfiguration specified in the conf.
 */
private static FilterInitializer[] getFilterInitializers(
    ConfigurationSource conf) {
  if (conf == null) {
    return null;
  }

  Class<?>[] classes =
      conf.getClasses(FILTER_INITIALIZER_PROPERTY, StaticUserWebFilter.class);
  if (classes == null) {
    return null;
  }

  FilterInitializer[] initializers = new FilterInitializer[classes.length];
  for (int i = 0; i < classes.length; i++) {
    try {
      initializers[i] = (FilterInitializer) classes[i].newInstance();
    } catch (Exception e) {
      LOG.error("Can't initialize the filter initializer {}",
          classes[i].getCanonicalName(), e);
    }
  }
  return initializers;
}
 
Example #2
Source File: TestApplicationHistoryServer.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 240000)
public void testFilterOverrides() throws Exception {

  HashMap<String, String> driver = new HashMap<String, String>();
  driver.put("", TimelineAuthenticationFilterInitializer.class.getName());
  driver.put(StaticUserWebFilter.class.getName(),
    TimelineAuthenticationFilterInitializer.class.getName() + ","
        + StaticUserWebFilter.class.getName());
  driver.put(AuthenticationFilterInitializer.class.getName(),
    TimelineAuthenticationFilterInitializer.class.getName());
  driver.put(TimelineAuthenticationFilterInitializer.class.getName(),
    TimelineAuthenticationFilterInitializer.class.getName());
  driver.put(AuthenticationFilterInitializer.class.getName() + ","
      + TimelineAuthenticationFilterInitializer.class.getName(),
    TimelineAuthenticationFilterInitializer.class.getName());
  driver.put(AuthenticationFilterInitializer.class.getName() + ", "
      + TimelineAuthenticationFilterInitializer.class.getName(),
    TimelineAuthenticationFilterInitializer.class.getName());

  for (Map.Entry<String, String> entry : driver.entrySet()) {
    String filterInitializer = entry.getKey();
    String expectedValue = entry.getValue();
    ApplicationHistoryServer historyServer = new ApplicationHistoryServer();
    Configuration config = new YarnConfiguration();
    config.setClass(YarnConfiguration.TIMELINE_SERVICE_STORE,
        MemoryTimelineStore.class, TimelineStore.class);
    config.setClass(YarnConfiguration.TIMELINE_SERVICE_STATE_STORE_CLASS,
        MemoryTimelineStateStore.class, TimelineStateStore.class);
    config.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS, "localhost:0");
    try {
      config.set("hadoop.http.filter.initializers", filterInitializer);
      historyServer.init(config);
      historyServer.start();
      Configuration tmp = historyServer.getConfig();
      assertEquals(expectedValue, tmp.get("hadoop.http.filter.initializers"));
    } finally {
      historyServer.stop();
    }
  }
}
 
Example #3
Source File: TestApplicationHistoryServer.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 240000)
public void testFilterOverrides() throws Exception {

  HashMap<String, String> driver = new HashMap<String, String>();
  driver.put("", TimelineAuthenticationFilterInitializer.class.getName());
  driver.put(StaticUserWebFilter.class.getName(),
    TimelineAuthenticationFilterInitializer.class.getName() + ","
        + StaticUserWebFilter.class.getName());
  driver.put(AuthenticationFilterInitializer.class.getName(),
    TimelineAuthenticationFilterInitializer.class.getName());
  driver.put(TimelineAuthenticationFilterInitializer.class.getName(),
    TimelineAuthenticationFilterInitializer.class.getName());
  driver.put(AuthenticationFilterInitializer.class.getName() + ","
      + TimelineAuthenticationFilterInitializer.class.getName(),
    TimelineAuthenticationFilterInitializer.class.getName());
  driver.put(AuthenticationFilterInitializer.class.getName() + ", "
      + TimelineAuthenticationFilterInitializer.class.getName(),
    TimelineAuthenticationFilterInitializer.class.getName());

  for (Map.Entry<String, String> entry : driver.entrySet()) {
    String filterInitializer = entry.getKey();
    String expectedValue = entry.getValue();
    ApplicationHistoryServer historyServer = new ApplicationHistoryServer();
    Configuration config = new YarnConfiguration();
    config.setClass(YarnConfiguration.TIMELINE_SERVICE_STORE,
        MemoryTimelineStore.class, TimelineStore.class);
    config.setClass(YarnConfiguration.TIMELINE_SERVICE_STATE_STORE_CLASS,
        MemoryTimelineStateStore.class, TimelineStateStore.class);
    config.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS, "localhost:0");
    try {
      config.set("hadoop.http.filter.initializers", filterInitializer);
      historyServer.init(config);
      historyServer.start();
      Configuration tmp = historyServer.getConfig();
      assertEquals(expectedValue, tmp.get("hadoop.http.filter.initializers"));
    } finally {
      historyServer.stop();
    }
  }
}