import java.util.HashMap;
import java.util.List;
import java.util.Properties;
-
import org.onap.aaf.cadi.filter.CadiFilter;
import org.onap.policy.common.endpoints.http.server.internal.JettyJerseyServer;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
String restClasses = properties.getProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
+ serviceName + PolicyEndPointProperties.PROPERTY_HTTP_REST_CLASSES_SUFFIX);
+ String filterClasses = properties.getProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
+ + serviceName + PolicyEndPointProperties.PROPERTY_HTTP_FILTER_CLASSES_SUFFIX);
+
String restPackages = properties.getProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
+ serviceName + PolicyEndPointProperties.PROPERTY_HTTP_REST_PACKAGES_SUFFIX);
String restUriPath = properties.getProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
}
HttpServletServer service = build(serviceName, https, hostName, servicePort, contextUriPath, swagger, managed);
- if (userName != null && !userName.isEmpty() && password != null && !password.isEmpty()) {
- service.setBasicAuthentication(userName, password, authUriPath);
+
+ /* authentication method either AAF or HTTP Basic Auth */
+
+ if (aaf) {
+ service.addFilterClass(contextUriPath, CadiFilter.class.getCanonicalName());
+ } else if (userName != null && !userName.isEmpty() && password != null && !password.isEmpty()) {
+ service.setBasicAuthentication(userName, password, authUriPath);
+ }
+
+ if (filterClasses != null && !filterClasses.isEmpty()) {
+ List<String> filterClassesList = Arrays.asList(filterClasses.split(SPACES_COMMA_SPACES));
+ for (String filterClass : filterClassesList) {
+ service.addFilterClass(restUriPath, filterClass);
+ }
}
if (restClasses != null && !restClasses.isEmpty()) {
}
}
- if (aaf) {
- service.addFilterClass(contextUriPath, CadiFilter.class.getCanonicalName());
- }
serviceList.add(service);
}
HttpServletServer.factory.build("echo", true, "localhost", 6667, "/", false, true);
echoServerAuth.setBasicAuthentication("x", "y", null);
echoServerAuth.addServletPackage("/*", HttpClientTest.class.getPackage().getName());
+ echoServerAuth.addFilterClass("/*", TestFilter.class.getCanonicalName());
echoServerAuth.waitedStart(5000);
if (!NetworkUtil.isTcpPortOpen("localhost", echoServerAuth.getPort(), 5, 10000L)) {
PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "PAP"
+ PolicyEndPointProperties.PROPERTY_HTTP_REST_CLASSES_SUFFIX,
RestMockHealthCheck.class.getName());
+ httpProperties.setProperty(
+ PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + "PAP"
+ + PolicyEndPointProperties.PROPERTY_HTTP_FILTER_CLASSES_SUFFIX,
+ TestFilter.class.getName());
httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + "." + "PAP"
+ PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX, "true");