edd33c0e44dc5857cbeba9654cecf38d3f87744f
[policy/xacml-pdp.git] /
1 /* ============LICENSE_START=======================================================
2  * ONAP
3  * ================================================================================
4  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
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
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.pdp.xacml.application.common;
23
24 import com.att.research.xacml.api.Response;
25 import java.nio.file.Path;
26 import java.util.List;
27 import java.util.Map;
28 import org.apache.commons.lang3.tuple.Pair;
29 import org.onap.policy.common.endpoints.parameters.RestServerParameters;
30 import org.onap.policy.models.decisions.concepts.DecisionRequest;
31 import org.onap.policy.models.decisions.concepts.DecisionResponse;
32 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
33 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
34
35 /**
36  * This interface is how the XACML REST controller can communicate
37  * with Policy Type implementation applications.
38  * Applications should register themselves as this service provider
39  * and implement these methods.
40  *
41  * @author pameladragosh
42  *
43  */
44 public interface XacmlApplicationServiceProvider {
45
46     /**
47      * Name of the application for auditing and organization of its data.
48      *
49      * @return String
50      */
51     String           applicationName();
52
53     /**
54      * Returns a list of action decisions supported by the application.
55      *
56      * @return List of String (eg. "configure", "placement", "naming")
57      */
58     List<String>     actionDecisionsSupported();
59
60     /**
61      * Initializes the application and gives it a Path for storing its
62      * data. The Path may be already populated with previous data.
63      * Also gives api rest parameters if needed.
64      *
65      * @param pathForData Local Path
66      * @param policyApiParameters API rest parameters
67      */
68     void             initialize(Path pathForData, RestServerParameters policyApiParameters)
69             throws XacmlApplicationException;
70
71     /**
72      * Returns a list of supported Tosca Policy Types.
73      *
74      * @return List of Strings (eg. "onap.policy.foo.bar")
75      */
76     List<ToscaPolicyTypeIdentifier>     supportedPolicyTypes();
77
78     /**
79      * Asks whether the application can support the incoming
80      * Tosca Policy Type and version.
81      *
82      * @param toscaPolicyId Identifier for policy type
83      * @return true if supported
84      */
85     boolean          canSupportPolicyType(ToscaPolicyTypeIdentifier toscaPolicyId);
86
87     /**
88      * Load a Tosca Policy.
89      *
90      * @param toscaPolicy object
91      */
92     void          loadPolicy(ToscaPolicy toscaPolicy) throws XacmlApplicationException;
93
94     /**
95      * unloadPolicy a Tosca Policy.
96      *
97      * @param toscaPolicy object
98      */
99     boolean          unloadPolicy(ToscaPolicy toscaPolicy) throws XacmlApplicationException;
100
101     /**
102      * Makes a decision given the incoming request and returns a response.
103      *
104      * @param request Incoming DecisionRequest object
105      * @param requestQueryParameters Http request query parameters
106      * @return response Responding DecisionResponse object
107      */
108     Pair<DecisionResponse, Response>       makeDecision(DecisionRequest request,
109             Map<String, String[]> requestQueryParameters);
110
111 }