f82e87372afa508f2e2122721cfb904b4f7b0b11
[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  * 
37  */
38 package org.onap.portalsdk.core.onboarding.crossapi;
39
40 import java.util.List;
41 import java.util.Map;
42
43 import javax.servlet.http.HttpServletRequest;
44
45 import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
46 import org.onap.portalsdk.core.restful.domain.EcompRole;
47 import org.onap.portalsdk.core.restful.domain.EcompUser;
48
49 /**
50  * Defines the REST API Interface that an on-boarding application must implement
51  * to answer queries and accept updates from the ECOMP Portal about the
52  * application's users, roles and user-role assignments.
53  */
54 public interface IPortalRestAPIService {
55
56         // EcompUser Interface
57
58         /**
59          * Creates a user with the specified details. If any error occurs, for example
60          * the user exists, the method should throw PortalApiException with an
61          * appropriate message. The FW library will catch the exception and send an
62          * appropriate response to Portal.
63          * 
64          * @param user
65          *            Model object with attributes of user to be created.
66          * @throws PortalAPIException
67          *             If any error occurs while processing the request; for example,
68          *             user exists.
69          */
70         public void pushUser(EcompUser user) throws PortalAPIException;
71
72         /**
73          * Updates details about the user with the specified loginId. For example, mark
74          * user as inactive. If any error occurs, the method should throw
75          * PortalApiException with an appropriate message. The FW library will catch the
76          * exception and send an appropriate response to Portal.
77          * 
78          * @param loginId
79          *            EcompUser ID to be updated.
80          * @param user
81          *            Model object with attributes of user to be updated.
82          * @throws PortalAPIException
83          *             If any error occurs while processing the request; for example,
84          *             unknown user.
85          */
86         public void editUser(String loginId, EcompUser user) throws PortalAPIException;
87
88         /**
89          * Gets and returns the user object with the specified loginId. If any error
90          * occurs, the method should throw PortalApiException with an appropriate
91          * message. The FW library will catch the exception and send an appropriate
92          * response to Portal
93          * 
94          * @param loginId
95          *            EcompUser ID to be fetched
96          * @return Model object with user attributes.
97          * @throws PortalAPIException
98          *             If any error occurs while processing the request; for example,
99          *             unknown user.
100          */
101         public EcompUser getUser(String loginId) throws PortalAPIException;
102
103         /**
104          * Gets and returns a list of active users. If any error occurs, the method
105          * should throw PortalApiException with an appropriate message. The FW library
106          * will catch the exception and send an appropriate response to Portal.
107          * 
108          * @return List of user attribute model objects; empty list if none are found.
109          * @throws PortalAPIException
110          *             If any error occurs while processing the request.
111          */
112         public List<EcompUser> getUsers() throws PortalAPIException;
113
114         // Roles Interface
115
116         /**
117          * Gets and returns a list of active roles. If any error occurs, the method
118          * should throw PortalApiException with an appropriate message. The FW library
119          * will catch the exception and send an appropriate response to Portal.
120          * 
121          * @param requestedLoginId
122          *            requested userloginId to fetch available roles
123          * @return List of role attribute objects; empty list if none are found.
124          * @throws PortalAPIException
125          *             If an unexpected error occurs while processing the request.
126          */
127         public List<EcompRole> getAvailableRoles(String requestedLoginId) throws PortalAPIException;
128
129         /**
130          * Updates roles for the user with the specified loginId to the list of roles
131          * provided as the second argument. After this operation, the should have ONLY
132          * the roles provided in the list above. For example, if user had roles r1, r2
133          * and r3; and a call was made to pushUserRole with a list containing only roles
134          * r3 and r4, this method should leave the user with roles r3 and r4 since those
135          * were the ONLY roles provided in second argument. If any error occurs, the
136          * method should throw PortalApiException with an appropriate message. The FW
137          * library will catch the exception and send an appropriate response to Portal.
138          * 
139          * @param loginId
140          *            EcompUser ID to be updated.
141          * @param roles
142          *            List of role attribute objects
143          * @throws PortalAPIException
144          *             If any error occurs while processing the request.
145          */
146         public void pushUserRole(String loginId, List<EcompRole> roles) throws PortalAPIException;
147
148         /**
149          * Gets and returns a list of roles for the user with the specified loginId. If
150          * any error occurs, the method should throw PortalApiException with an
151          * appropriate message. The FW library will catch the exception and send an
152          * appropriate response to Portal.
153          * 
154          * @param loginId
155          *            Organization user ID
156          * @return List of model objects; empty if no roles are found.
157          * @throws PortalAPIException
158          *             If any error occurs while processing the request; e.g., user not
159          *             found.
160          */
161         public List<EcompRole> getUserRoles(String loginId) throws PortalAPIException;
162
163         // Security Interface
164
165         /**
166          * Should return true if the call should be allowed and false if not. Currently
167          * Portal sends two headers of username and password in each request which the
168          * app should check. If match, return true; else return false. If any error
169          * occurs, the method should throw PortalApiException with an appropriate
170          * message. The FW library will catch the exception and send an appropriate
171          * response to Portal.
172          * 
173          * @param request
174          *            HttpServletRequest
175          * @return true if the request contains appropriate credentials, else false.
176          * @throws PortalAPIException
177          *             If an unexpected error occurs while processing the request.
178          */
179         public boolean isAppAuthenticated(HttpServletRequest request) throws PortalAPIException;
180
181         /**
182          * Gets and returns the userId for the logged-in user based on the request. If
183          * any error occurs, the method should throw PortalApiException with an
184          * appropriate message. The FW library will catch the exception and send an
185          * appropriate response to Portal.
186          * 
187          * @param request
188          *            HttpServletRequest
189          * @return true if the request contains appropriate credentials, else false.
190          * @throws PortalAPIException
191          *             If an unexpected error occurs while processing the request.
192          */
193         public String getUserId(HttpServletRequest request) throws PortalAPIException;
194         
195         public Map<String, String> getCredentials() throws PortalAPIException;
196
197 }