org.apache.hadoop.http.FilterContainer Java Examples
The following examples show how to use
org.apache.hadoop.http.FilterContainer.
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: StramWSFilterInitializer.java From Bats with Apache License 2.0 | 5 votes |
@Override public void initFilter(FilterContainer container, Configuration conf) { logger.debug("Conf {}", conf); Map<String, String> params = new HashMap<>(); Collection<String> proxies = new ArrayList<>(); if (ConfigUtils.isRMHAEnabled(conf)) { // HA is enabled get all for (String rmId : ConfigUtils.getRMHAIds(conf)) { proxies.add(getResolvedRMWebAppURLWithoutScheme(conf, rmId)); } logger.info("HA proxy addresses {}", proxies); } if (proxies.isEmpty()) { proxies.add(getProxyHostAndPort(conf)); logger.info("Proxy addresses {}", proxies); } StringBuilder proxyBr = new StringBuilder(); for (String proxy : proxies) { if (proxyBr.length() != 0) { proxyBr.append(StramWSFilter.PROXY_DELIMITER); } String[] parts = proxy.split(":"); proxyBr.append(parts[0]); } params.put(StramWSFilter.PROXY_HOST, proxyBr.toString()); container.addFilter(FILTER_NAME, FILTER_CLASS, params); }
Example #2
Source File: RMAuthenticationFilterInitializer.java From hadoop with Apache License 2.0 | 5 votes |
@Override public void initFilter(FilterContainer container, Configuration conf) { Map<String, String> filterConfig = createFilterConfig(conf); container.addFilter("RMAuthenticationFilter", RMAuthenticationFilter.class.getName(), filterConfig); }
Example #3
Source File: StaticUserWebFilter.java From hadoop with Apache License 2.0 | 5 votes |
@Override public void initFilter(FilterContainer container, Configuration conf) { HashMap<String, String> options = new HashMap<String, String>(); String username = getUsernameFromConf(conf); options.put(HADOOP_HTTP_STATIC_USER, username); container.addFilter("static_user_filter", StaticUserFilter.class.getName(), options); }
Example #4
Source File: RMAuthenticationFilterInitializer.java From big-c with Apache License 2.0 | 5 votes |
@Override public void initFilter(FilterContainer container, Configuration conf) { Map<String, String> filterConfig = createFilterConfig(conf); container.addFilter("RMAuthenticationFilter", RMAuthenticationFilter.class.getName(), filterConfig); }
Example #5
Source File: StaticUserWebFilter.java From big-c with Apache License 2.0 | 5 votes |
@Override public void initFilter(FilterContainer container, Configuration conf) { HashMap<String, String> options = new HashMap<String, String>(); String username = getUsernameFromConf(conf); options.put(HADOOP_HTTP_STATIC_USER, username); container.addFilter("static_user_filter", StaticUserFilter.class.getName(), options); }
Example #6
Source File: StramWSFilterInitializer.java From attic-apex-core with Apache License 2.0 | 5 votes |
@Override public void initFilter(FilterContainer container, Configuration conf) { logger.debug("Conf {}", conf); Map<String, String> params = new HashMap<>(); Collection<String> proxies = new ArrayList<>(); if (ConfigUtils.isRMHAEnabled(conf)) { // HA is enabled get all for (String rmId : ConfigUtils.getRMHAIds(conf)) { proxies.add(getResolvedRMWebAppURLWithoutScheme(conf, rmId)); } logger.info("HA proxy addresses {}", proxies); } if (proxies.isEmpty()) { proxies.add(getProxyHostAndPort(conf)); logger.info("Proxy addresses {}", proxies); } StringBuilder proxyBr = new StringBuilder(); for (String proxy : proxies) { if (proxyBr.length() != 0) { proxyBr.append(StramWSFilter.PROXY_DELIMITER); } String[] parts = proxy.split(":"); proxyBr.append(parts[0]); } params.put(StramWSFilter.PROXY_HOST, proxyBr.toString()); container.addFilter(FILTER_NAME, FILTER_CLASS, params); }
Example #7
Source File: CrossOriginFilterInitializer.java From hadoop with Apache License 2.0 | 4 votes |
@Override public void initFilter(FilterContainer container, Configuration conf) { container.addGlobalFilter("Cross Origin Filter", CrossOriginFilter.class.getName(), getFilterParameters(conf)); }
Example #8
Source File: TestTimelineAuthenticationFilterInitializer.java From hadoop with Apache License 2.0 | 4 votes |
@Test public void testProxyUserConfiguration() { FilterContainer container = Mockito.mock(FilterContainer.class); for (int i = 0; i < 3; ++i) { Configuration conf = new YarnConfiguration(); switch (i) { case 0: // hadoop.proxyuser prefix conf.set("hadoop.proxyuser.foo.hosts", "*"); conf.set("hadoop.proxyuser.foo.users", "*"); conf.set("hadoop.proxyuser.foo.groups", "*"); break; case 1: // yarn.timeline-service.http-authentication.proxyuser prefix conf.set("yarn.timeline-service.http-authentication.proxyuser.foo.hosts", "*"); conf.set("yarn.timeline-service.http-authentication.proxyuser.foo.users", "*"); conf.set("yarn.timeline-service.http-authentication.proxyuser.foo.groups", "*"); break; case 2: // hadoop.proxyuser prefix has been overwritten by // yarn.timeline-service.http-authentication.proxyuser prefix conf.set("hadoop.proxyuser.foo.hosts", "bar"); conf.set("hadoop.proxyuser.foo.users", "bar"); conf.set("hadoop.proxyuser.foo.groups", "bar"); conf.set("yarn.timeline-service.http-authentication.proxyuser.foo.hosts", "*"); conf.set("yarn.timeline-service.http-authentication.proxyuser.foo.users", "*"); conf.set("yarn.timeline-service.http-authentication.proxyuser.foo.groups", "*"); break; default: break; } TimelineAuthenticationFilterInitializer initializer = new TimelineAuthenticationFilterInitializer(); initializer.initFilter(container, conf); Assert.assertEquals( "*", initializer.filterConfig.get("proxyuser.foo.hosts")); Assert.assertEquals( "*", initializer.filterConfig.get("proxyuser.foo.users")); Assert.assertEquals( "*", initializer.filterConfig.get("proxyuser.foo.groups")); } }
Example #9
Source File: CrossOriginFilterInitializer.java From big-c with Apache License 2.0 | 4 votes |
@Override public void initFilter(FilterContainer container, Configuration conf) { container.addGlobalFilter("Cross Origin Filter", CrossOriginFilter.class.getName(), getFilterParameters(conf)); }
Example #10
Source File: TestTimelineAuthenticationFilterInitializer.java From big-c with Apache License 2.0 | 4 votes |
@Test public void testProxyUserConfiguration() { FilterContainer container = Mockito.mock(FilterContainer.class); for (int i = 0; i < 3; ++i) { Configuration conf = new YarnConfiguration(); switch (i) { case 0: // hadoop.proxyuser prefix conf.set("hadoop.proxyuser.foo.hosts", "*"); conf.set("hadoop.proxyuser.foo.users", "*"); conf.set("hadoop.proxyuser.foo.groups", "*"); break; case 1: // yarn.timeline-service.http-authentication.proxyuser prefix conf.set("yarn.timeline-service.http-authentication.proxyuser.foo.hosts", "*"); conf.set("yarn.timeline-service.http-authentication.proxyuser.foo.users", "*"); conf.set("yarn.timeline-service.http-authentication.proxyuser.foo.groups", "*"); break; case 2: // hadoop.proxyuser prefix has been overwritten by // yarn.timeline-service.http-authentication.proxyuser prefix conf.set("hadoop.proxyuser.foo.hosts", "bar"); conf.set("hadoop.proxyuser.foo.users", "bar"); conf.set("hadoop.proxyuser.foo.groups", "bar"); conf.set("yarn.timeline-service.http-authentication.proxyuser.foo.hosts", "*"); conf.set("yarn.timeline-service.http-authentication.proxyuser.foo.users", "*"); conf.set("yarn.timeline-service.http-authentication.proxyuser.foo.groups", "*"); break; default: break; } TimelineAuthenticationFilterInitializer initializer = new TimelineAuthenticationFilterInitializer(); initializer.initFilter(container, conf); Assert.assertEquals( "*", initializer.filterConfig.get("proxyuser.foo.hosts")); Assert.assertEquals( "*", initializer.filterConfig.get("proxyuser.foo.users")); Assert.assertEquals( "*", initializer.filterConfig.get("proxyuser.foo.groups")); } }
Example #11
Source File: AuthenticationFilterInitializer.java From hadoop with Apache License 2.0 | 3 votes |
/** * Initializes hadoop-auth AuthenticationFilter. * <p/> * Propagates to hadoop-auth AuthenticationFilter configuration all Hadoop * configuration properties prefixed with "hadoop.http.authentication." * * @param container The filter container * @param conf Configuration for run-time parameters */ @Override public void initFilter(FilterContainer container, Configuration conf) { Map<String, String> filterConfig = getFilterConfigMap(conf, PREFIX); container.addFilter("authentication", AuthenticationFilter.class.getName(), filterConfig); }
Example #12
Source File: AuthenticationFilterInitializer.java From big-c with Apache License 2.0 | 3 votes |
/** * Initializes hadoop-auth AuthenticationFilter. * <p/> * Propagates to hadoop-auth AuthenticationFilter configuration all Hadoop * configuration properties prefixed with "hadoop.http.authentication." * * @param container The filter container * @param conf Configuration for run-time parameters */ @Override public void initFilter(FilterContainer container, Configuration conf) { Map<String, String> filterConfig = getFilterConfigMap(conf, PREFIX); container.addFilter("authentication", AuthenticationFilter.class.getName(), filterConfig); }