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