2fd141a0c2d8297796dcd2805a44afccf49c5f5a
[portal/sdk.git] /
1 /*
2  * ============LICENSE_START==========================================
3  * ONAP Portal SDK
4  * ===================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  *
8  * Unless otherwise specified, all software contained herein is licensed
9  * under the Apache License, Version 2.0 (the "License");
10  * you may not use this software except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *             http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * Unless otherwise specified, all documentation contained herein is licensed
22  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23  * you may not use this documentation except in compliance with the License.
24  * You may obtain a copy of the License at
25  *
26  *             https://creativecommons.org/licenses/by/4.0/
27  *
28  * Unless required by applicable law or agreed to in writing, documentation
29  * distributed under the License is distributed on an "AS IS" BASIS,
30  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31  * See the License for the specific language governing permissions and
32  * limitations under the License.
33  *
34  * ============LICENSE_END============================================
35  *
36  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
37  */
38 package org.onap.portalsdk.core.onboarding.crossapi;
39
40 import java.util.List;
41
42 import javax.servlet.http.HttpServletRequest;
43
44 import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
45 import org.onap.portalsdk.core.restful.domain.EcompRole;
46 import org.onap.portalsdk.core.restful.domain.EcompUser;
47
48 /**
49  * Defines the REST API Interface that an on-boarding application must implement
50  * to answer queries and accept updates from the ECOMP Portal about the
51  * application's users, roles and user-role assignments.
52  */
53 public interface IPortalRestAPIService {
54
55         // EcompUser Interface
56
57         /**
58          * Creates a user with the specified details. If any error occurs, for example
59          * the user exists, the method should throw PortalApiException with an
60          * appropriate message. The FW library will catch the exception and send an
61          * appropriate response to Portal.
62          * 
63          * @param user
64          *            Model object with attributes of user to be created.
65          * @throws PortalAPIException
66          *             If any error occurs while processing the request; for example,
67          *             user exists.
68          */
69         public void pushUser(EcompUser user) throws PortalAPIException;
70
71         /**
72          * Updates details about the user with the specified loginId. For example, mark
73          * user as inactive. If any error occurs, the method should throw
74          * PortalApiException with an appropriate message. The FW library will catch the
75          * exception and send an appropriate response to Portal.
76          * 
77          * @param loginId
78          *            EcompUser ID to be updated.
79          * @param user
80          *            Model object with attributes of user to be updated.
81          * @throws PortalAPIException
82          *             If any error occurs while processing the request; for example,
83          *             unknown user.
84          */
85         public void editUser(String loginId, EcompUser user) throws PortalAPIException;
86
87         /**
88          * Gets and returns the user object with the specified loginId. If any error
89          * occurs, the method should throw PortalApiException with an appropriate
90          * message. The FW library will catch the exception and send an appropriate
91          * response to Portal
92          * 
93          * @param loginId
94          *            EcompUser ID to be fetched
95          * @return Model object with user attributes.
96          * @throws PortalAPIException
97          *             If any error occurs while processing the request; for example,
98          *             unknown user.
99          */
100         public EcompUser getUser(String loginId) throws PortalAPIException;
101
102         /**
103          * Gets and returns a list of active users. If any error occurs, the method
104          * should throw PortalApiException with an appropriate message. The FW library
105          * will catch the exception and send an appropriate response to Portal.
106          * 
107          * @return List of user attribute model objects; empty list if none are found.
108          * @throws PortalAPIException
109          *             If any error occurs while processing the request.
110          */
111         public List<EcompUser> getUsers() throws PortalAPIException;
112
113         // Roles Interface
114
115         /**
116          * Gets and returns a list of active roles. If any error occurs, the method
117          * should throw PortalApiException with an appropriate message. The FW library
118          * will catch the exception and send an appropriate response to Portal.
119          * 
120          * @param requestedLoginId
121          *            requested userloginId to fetch available roles
122          * @return List of role attribute objects; empty list if none are found.
123          * @throws PortalAPIException
124          *             If an unexpected error occurs while processing the request.
125          */
126         public List<EcompRole> getAvailableRoles(String requestedLoginId) throws PortalAPIException;
127
128         /**
129          * Updates roles for the user with the specified loginId to the list of roles
130          * provided as the second argument. After this operation, the should have ONLY
131          * the roles provided in the list above. For example, if user had roles r1, r2
132          * and r3; and a call was made to pushUserRole with a list containing only roles
133          * r3 and r4, this method should leave the user with roles r3 and r4 since those
134          * were the ONLY roles provided in second argument. If any error occurs, the
135          * method should throw PortalApiException with an appropriate message. The FW
136          * library will catch the exception and send an appropriate response to Portal.
137          * 
138          * @param loginId
139          *            EcompUser ID to be updated.
140          * @param roles
141          *            List of role attribute objects
142          * @throws PortalAPIException
143          *             If any error occurs while processing the request.
144          */
145         public void pushUserRole(String loginId, List<EcompRole> roles) throws PortalAPIException;
146
147         /**
148          * Gets and returns a list of roles for the user with the specified loginId. If
149          * any error occurs, the method should throw PortalApiException with an
150          * appropriate message. The FW library will catch the exception and send an
151          * appropriate response to Portal.
152          * 
153          * @param loginId
154          *            Organization user ID
155          * @return List of model objects; empty if no roles are found.
156          * @throws PortalAPIException
157          *             If any error occurs while processing the request; e.g., user not
158          *             found.
159          */
160         public List<EcompRole> getUserRoles(String loginId) throws PortalAPIException;
161
162         // Security Interface
163
164         /**
165          * Should return true if the call should be allowed and false if not. Currently
166          * Portal sends two headers of username and password in each request which the
167          * app should check. If match, return true; else return false. If any error
168          * occurs, the method should throw PortalApiException with an appropriate
169          * message. The FW library will catch the exception and send an appropriate
170          * response to Portal.
171          * 
172          * @param request
173          *            HttpServletRequest
174          * @return true if the request contains appropriate credentials, else false.
175          * @throws PortalAPIException
176          *             If an unexpected error occurs while processing the request.
177          */
178         public boolean isAppAuthenticated(HttpServletRequest request) throws PortalAPIException;
179
180         /**
181          * Gets and returns the userId for the logged-in user based on the request. If
182          * any error occurs, the method should throw PortalApiException with an
183          * appropriate message. The FW library will catch the exception and send an
184          * appropriate response to Portal.
185          * 
186          * @param request
187          *            HttpServletRequest
188          * @return true if the request contains appropriate credentials, else false.
189          * @throws PortalAPIException
190          *             If an unexpected error occurs while processing the request.
191          */
192         public String getUserId(HttpServletRequest request) throws PortalAPIException;
193
194 }