package com.hubspot.blazar;

import com.google.common.base.Throwables;
import com.google.common.collect.Iterators;
import io.dropwizard.Bundle;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.eclipse.jetty.servlets.CrossOriginFilter;

import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Enumeration;

public class CorsBundle implements Bundle {
  private static final String FILTER_NAME = "Cross Origin Request Filter";

  @Override
  public void initialize(Bootstrap<?> bootstrap) {}

  @Override
  public void run(Environment environment) {
    final Filter corsFilter = new CrossOriginFilter();
    final FilterConfig corsFilterConfig = new FilterConfig() {

      @Override
      public String getFilterName() {
        return FILTER_NAME;
      }

      @Override
      public ServletContext getServletContext() {
        return null;
      }

      @Override
      public String getInitParameter(final String name) {
        return null;
      }

      @Override
      public Enumeration<String> getInitParameterNames() {
        return Iterators.asEnumeration(Collections.<String>emptyIterator());
      }
    };

    try {
      corsFilter.init(corsFilterConfig);
    } catch (final Exception e) {
      throw Throwables.propagate(e);
    }

    environment.servlets().addFilter(FILTER_NAME, corsFilter).addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*");
  }
}

@@ -68,52 +68,8 @@
 es;%0A
-import com.google.common.collect.Iterators;%0A
 impo
@@ -93,16 +93,16 @@
 Bundle;%0A
+
 import i
@@ -448,16 +448,38 @@
 eration;
+%0Aimport java.util.Map;
 %0A%0Apublic
@@ -768,16 +768,156 @@
 ilter();
+%0A%0A    final Map%3CString, String%3E parameters = Collections.singletonMap(CrossOriginFilter.EXPOSED_HEADERS_PARAM, %22x-last-modified-timestamp%22);
 %0A    fin
@@ -1241,36 +1241,52 @@
 %0A        return 
-null
+parameters.get(name)
 ;%0A      %7D%0A%0A     
@@ -1374,65 +1374,49 @@
 urn 
-Iterators.asEnumeration(Collections.%3CString%3EemptyIterator
+Collections.enumeration(parameters.keySet
 ());

Put this back