use of com.canoo.dp.impl.server.servlet.CrossSiteOriginFilter in project dolphin-platform by canoo.
the class CorsModule method initialize.
@Override
public void initialize(final ServerCoreComponents coreComponents) throws ModuleInitializationException {
Assert.requireNonNull(coreComponents, "coreComponents");
final ServletContext servletContext = coreComponents.getInstance(ServletContext.class);
final PlatformConfiguration configuration = coreComponents.getConfiguration();
final List<String> endpointList = configuration.getListProperty(CORS_ENDPOINTS_URL_MAPPINGS, CORS_ENDPOINTS_URL_MAPPINGS_DEFAULT_VALUE);
final String[] endpoints = endpointList.toArray(new String[endpointList.size()]);
final CrossSiteOriginFilter filter = new CrossSiteOriginFilter(configuration);
final FilterRegistration.Dynamic createdFilter = servletContext.addFilter(CORS_FILTER, filter);
createdFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, endpoints);
}
use of com.canoo.dp.impl.server.servlet.CrossSiteOriginFilter in project dolphin-platform by canoo.
the class CrossSiteOriginFilterTest method testCommaSeparatedStringWithValidList.
@Test
public void testCommaSeparatedStringWithValidList() {
final CrossSiteOriginFilter crossSiteOriginFilter = new CrossSiteOriginFilter(new ServerConfiguration());
final String commaSeparatedList = crossSiteOriginFilter.getAsCommaSeparatedList(Arrays.asList("origin", "authorization", "accept"));
assertEquals("origin,authorization,accept", commaSeparatedList);
}
use of com.canoo.dp.impl.server.servlet.CrossSiteOriginFilter in project dolphin-platform by canoo.
the class CrossSiteOriginFilterTest method testCommaSeparatedList.
@Test(expectedExceptions = NullPointerException.class)
public void testCommaSeparatedList() {
final CrossSiteOriginFilter crossSiteOriginFilter = new CrossSiteOriginFilter(new ServerConfiguration());
crossSiteOriginFilter.getAsCommaSeparatedList(null);
}
Aggregations