2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
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
26 * https://creativecommons.org/licenses/by/4.0/
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.
34 * ============LICENSE_END============================================
36 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
38 package org.onap.portalsdk.core.onboarding.crossapi;
40 import java.util.List;
42 import javax.servlet.http.HttpServletRequest;
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;
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.
53 public interface IPortalRestAPIService {
55 // EcompUser Interface
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.
64 * Model object with attributes of user to be created.
65 * @throws PortalAPIException
66 * If any error occurs while processing the request; for example,
69 public void pushUser(EcompUser user) throws PortalAPIException;
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.
78 * EcompUser ID to be updated.
80 * Model object with attributes of user to be updated.
81 * @throws PortalAPIException
82 * If any error occurs while processing the request; for example,
85 public void editUser(String loginId, EcompUser user) throws PortalAPIException;
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
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,
100 public EcompUser getUser(String loginId) throws PortalAPIException;
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.
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.
111 public List<EcompUser> getUsers() throws PortalAPIException;
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.
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.
126 public List<EcompRole> getAvailableRoles(String requestedLoginId) throws PortalAPIException;
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.
139 * EcompUser ID to be updated.
141 * List of role attribute objects
142 * @throws PortalAPIException
143 * If any error occurs while processing the request.
145 public void pushUserRole(String loginId, List<EcompRole> roles) throws PortalAPIException;
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.
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
160 public List<EcompRole> getUserRoles(String loginId) throws PortalAPIException;
162 // Security Interface
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.
174 * @return true if the request contains appropriate credentials, else false.
175 * @throws PortalAPIException
176 * If an unexpected error occurs while processing the request.
178 public boolean isAppAuthenticated(HttpServletRequest request) throws PortalAPIException;
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.
188 * @return true if the request contains appropriate credentials, else false.
189 * @throws PortalAPIException
190 * If an unexpected error occurs while processing the request.
192 public String getUserId(HttpServletRequest request) throws PortalAPIException;