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============================================
38 package org.onap.portalsdk.core.onboarding.crossapi;
40 import java.util.List;
43 import javax.servlet.http.HttpServletRequest;
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;
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.
54 public interface IPortalRestAPIService {
56 // EcompUser Interface
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.
65 * Model object with attributes of user to be created.
66 * @throws PortalAPIException
67 * If any error occurs while processing the request; for example,
70 public void pushUser(EcompUser user) throws PortalAPIException;
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.
79 * EcompUser ID to be updated.
81 * Model object with attributes of user to be updated.
82 * @throws PortalAPIException
83 * If any error occurs while processing the request; for example,
86 public void editUser(String loginId, EcompUser user) throws PortalAPIException;
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
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,
101 public EcompUser getUser(String loginId) throws PortalAPIException;
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.
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.
112 public List<EcompUser> getUsers() throws PortalAPIException;
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.
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.
127 public List<EcompRole> getAvailableRoles(String requestedLoginId) throws PortalAPIException;
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.
140 * EcompUser ID to be updated.
142 * List of role attribute objects
143 * @throws PortalAPIException
144 * If any error occurs while processing the request.
146 public void pushUserRole(String loginId, List<EcompRole> roles) throws PortalAPIException;
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.
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
161 public List<EcompRole> getUserRoles(String loginId) throws PortalAPIException;
163 // Security Interface
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.
175 * @return true if the request contains appropriate credentials, else false.
176 * @throws PortalAPIException
177 * If an unexpected error occurs while processing the request.
179 public boolean isAppAuthenticated(HttpServletRequest request) throws PortalAPIException;
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.
189 * @return true if the request contains appropriate credentials, else false.
190 * @throws PortalAPIException
191 * If an unexpected error occurs while processing the request.
193 public String getUserId(HttpServletRequest request) throws PortalAPIException;
195 public Map<String, String> getCredentials() throws PortalAPIException;