2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
4 * Modifications Copyright (C) 2023 Nordix Foundation.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.pdpx.main.startstop;
24 import jakarta.servlet.Filter;
25 import java.util.List;
26 import java.util.Properties;
27 import org.onap.policy.common.endpoints.http.server.JsonExceptionMapper;
28 import org.onap.policy.common.endpoints.http.server.RestServer;
29 import org.onap.policy.common.endpoints.http.server.YamlExceptionMapper;
30 import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
31 import org.onap.policy.common.endpoints.parameters.RestServerParameters;
32 import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
33 import org.onap.policy.common.gson.GsonMessageBodyHandler;
34 import org.onap.policy.pdpx.main.rest.serialization.XacmlJsonExceptionMapper;
35 import org.onap.policy.pdpx.main.rest.serialization.XacmlJsonMessageBodyHandler;
36 import org.onap.policy.pdpx.main.rest.serialization.XacmlXmlExceptionMapper;
37 import org.onap.policy.pdpx.main.rest.serialization.XacmlXmlMessageBodyHandler;
40 * Class to manage life cycle of a rest server that is particularly used by xacml pdp.
42 * @author Chenfei Gao (cgao@research.att.com)
44 public class XacmlPdpRestServer extends RestServer {
47 * Constructs the object.
49 * @param restServerParameters the rest server parameters
50 * @param filters class of object to use to filter requests, or {@code null}
51 * @param jaxrsProviders classes providing the services
53 public XacmlPdpRestServer(final RestServerParameters restServerParameters,
54 List<Class<? extends Filter>> filters, List<Class<?>> jaxrsProviders) {
56 super(restServerParameters, filters, jaxrsProviders);
60 protected Properties getServerProperties(RestServerParameters restServerParameters, String names) {
62 final var props = super.getServerProperties(restServerParameters, names);
64 PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + restServerParameters.getName();
66 props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_SERIALIZATION_PROVIDER,
67 String.join(",", GsonMessageBodyHandler.class.getName(), YamlMessageBodyHandler.class.getName(),
68 JsonExceptionMapper.class.getName(), YamlExceptionMapper.class.getName(),
69 XacmlJsonMessageBodyHandler.class.getName(), XacmlJsonExceptionMapper.class.getName(),
70 XacmlXmlMessageBodyHandler.class.getName(), XacmlXmlExceptionMapper.class.getName()));