1 /* ============LICENSE_START=======================================================
3 * ================================================================================
4 * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
5 * Modifications Copyright (C) 2021 Nordix Foundation.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.pdp.xacml.application.common;
25 import com.att.research.xacml.api.Response;
26 import java.nio.file.Path;
27 import java.util.List;
29 import org.apache.commons.lang3.tuple.Pair;
30 import org.onap.policy.common.endpoints.http.client.HttpClient;
31 import org.onap.policy.models.decisions.concepts.DecisionRequest;
32 import org.onap.policy.models.decisions.concepts.DecisionResponse;
33 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
34 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
37 * This interface is how the XACML REST controller can communicate
38 * with Policy Type implementation applications.
39 * Applications should register themselves as this service provider
40 * and implement these methods.
42 * @author pameladragosh
45 public interface XacmlApplicationServiceProvider {
48 * Name of the application for auditing and organization of its data.
52 String applicationName();
55 * Returns a list of action decisions supported by the application.
57 * @return List of String (eg. "configure", "placement", "naming")
59 List<String> actionDecisionsSupported();
62 * Initializes the application and gives it a Path for storing its
63 * data. The Path may be already populated with previous data.
64 * Also gives api rest parameters if needed.
66 * @param pathForData Local Path
67 * @param policyApiClient API rest client
69 void initialize(Path pathForData, HttpClient policyApiClient)
70 throws XacmlApplicationException;
73 * Returns a list of supported Tosca Policy Types.
75 * @return List of Strings (eg. "onap.policy.foo.bar")
77 List<ToscaConceptIdentifier> supportedPolicyTypes();
80 * Asks whether the application can support the incoming
81 * Tosca Policy Type and version.
83 * @param toscaPolicyId Identifier for policy type
84 * @return true if supported
86 boolean canSupportPolicyType(ToscaConceptIdentifier toscaPolicyId);
89 * Load a Tosca Policy.
91 * @param toscaPolicy object
93 void loadPolicy(ToscaPolicy toscaPolicy) throws XacmlApplicationException;
96 * unloadPolicy a Tosca Policy.
98 * @param toscaPolicy object
100 boolean unloadPolicy(ToscaPolicy toscaPolicy) throws XacmlApplicationException;
103 * Makes a decision given the incoming request and returns a response.
105 * @param request Incoming DecisionRequest object
106 * @param requestQueryParameters Http request query parameters
107 * @return response Responding DecisionResponse object
109 Pair<DecisionResponse, Response> makeDecision(DecisionRequest request,
110 Map<String, String[]> requestQueryParameters);