2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 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.portalapp.portal.service;
40 import java.io.IOException;
41 import java.util.List;
44 import org.hibernate.Session;
45 import org.json.JSONArray;
46 import org.onap.portalapp.portal.domain.CentralV2RoleFunction;
47 import org.onap.portalapp.portal.domain.CentralizedApp;
48 import org.onap.portalapp.portal.domain.EPApp;
49 import org.onap.portalapp.portal.domain.EPRole;
50 import org.onap.portalapp.portal.domain.EPUser;
51 import org.onap.portalapp.portal.domain.ExternalRoleDetails;
52 import org.onap.portalapp.portal.transport.CentralRole;
53 import org.onap.portalapp.portal.transport.CentralUser;
54 import org.onap.portalapp.portal.transport.CentralV2Role;
55 import org.onap.portalapp.portal.transport.ExternalRequestFieldsValidator;
56 import org.onap.portalsdk.core.domain.Role;
57 import org.onap.portalsdk.core.domain.RoleFunction;
58 import org.onap.portalsdk.core.restful.domain.EcompUser;
59 import org.springframework.http.ResponseEntity;
60 import org.springframework.web.client.HttpClientErrorException;
62 import com.fasterxml.jackson.core.JsonParseException;
63 import com.fasterxml.jackson.databind.JsonMappingException;
64 import com.fasterxml.jackson.databind.ObjectMapper;
66 public interface ExternalAccessRolesService {
69 * It gets list of application roles
75 public List<EPRole> getAppRoles(Long appId) throws Exception;
78 * It returns single app record
84 public List<EPApp> getApp(String uebkey) throws Exception;
87 * Adds role in the external access system if fails throws exception
94 public boolean addRole(Role addRoles, String uebkey) throws Exception;
97 * It returns complete user information
100 * @return EPUser object
103 List<EPUser> getUser(String loginId) throws Exception;
106 * It returns complete user information including application roles permissions
113 String getV2UserWithRoles(String loginId, String uebkey) throws Exception;
116 * It returns list of all role functions
121 List<CentralV2RoleFunction> getRoleFuncList(String string) throws Exception;
124 * It return list of role provided by the app uebkey and roleId
128 * @return CentralRole
131 CentralV2Role getRoleInfo(Long roleId, String uebkey) throws Exception;
134 * It returns the CentralRoleFunction object
136 * @param functionCode
138 * @return CentralRoleFunction
141 public CentralV2RoleFunction getRoleFunction(String functionCode, String uebkey) throws Exception;
144 * It saves role function in the DB
146 * @param domainCentralRoleFunction
147 * @param requestedApp
148 * @return true else false
151 public boolean saveCentralRoleFunction(CentralV2RoleFunction domainCentralRoleFunction, EPApp requestedApp) throws Exception;
154 * It deletes role function in the DB
159 public boolean deleteCentralRoleFunction(String code, EPApp app);
162 * It gets all roles the applications
168 public List<CentralV2Role> getRolesForApp(String uebkey) throws Exception;
172 * It saves role function in the DB
176 * @return message and true or false
179 ExternalRequestFieldsValidator saveRoleForApplication(Role saveRole, String uebkey) throws Exception;
182 * It deletes role in the DB
186 * @return true else false
189 boolean deleteRoleForApplication(String code, String uebkey) throws Exception;
192 * It gets all active roles for single application
198 List<CentralV2Role> getActiveRoles(String uebkey) throws Exception;
201 * It deletes user related roles for an application in the table
205 * @return true else false
208 public ExternalRequestFieldsValidator deleteDependencyRoleRecord(Long roleId, String uebkey, String LoginId) throws Exception;
211 * It sync new functions codes and names from and updates role functions from external access system
216 public void syncRoleFunctionFromExternalAccessSystem(EPApp app) throws Exception;
219 * It uploads portal functions into external auth system
224 public Integer bulkUploadFunctions(String uebkey) throws Exception;
227 * It uploads portal roles into external auth system
232 public Integer bulkUploadRoles(String uebkey) throws Exception;
235 * It uploads partner application role functions into external auth system
241 public void bulkUploadPartnerFunctions(String uebkey, List<RoleFunction> upload) throws Exception;
244 * It uploads partner application role functions into external auth system
250 public void bulkUploadPartnerRoles(String uebkey, List<Role> upload) throws Exception;
253 * It returns total no. of portal application role functions records added in external auth system
258 Integer bulkUploadRolesFunctions(String uebkey) throws Exception;
261 * It syncs the roles and rolefunctions to the ecomp DB from AAF
265 void syncApplicationRolesWithEcompDB(EPApp app) throws Exception;
268 * It uploads list of user roles of the application into external auth system
274 public Integer bulkUploadUserRoles(String uebkey) throws Exception;
277 * It Uploads partner application role functions into external auth system
283 void bulkUploadPartnerRoleFunctions(String uebkey, List<Role> roleList) throws Exception;
286 * it deletes all dependency role records
288 * @param localSession
291 * @param isPortalRequest
294 public void deleteRoleDependencyRecords(Session localSession, Long roleId, Long appId, boolean isPortalRequest) throws Exception;
297 * It returns list of applications functions along with functions associated with global role
303 List<String> getMenuFunctionsList(String uebkey) throws Exception;
307 * @param uebkey applications UebKey
310 * Method getAllUsers returns all the active users of application
312 List<EcompUser> getAllAppUsers(String uebkey) throws Exception;
317 * @return returns Role Object
318 * Method ConvertCentralRoleToRole converts the CentralRole String to Role Object
320 public Role ConvertCentralRoleToRole(String result);
323 * It returns the list of centralized applications
328 public List<CentralizedApp> getCentralizedAppsOfUser(String userId);
331 * It returns the list of globalRoles of Portal
334 public List<EPRole> getGlobalRolesOfPortal();
337 * It converts list of CentralRoleFunction objects to RoleFunction objects
338 * @param answer contains list of CentralRoleFunction objects
339 * @return List of RoleFunction objects
341 public List<RoleFunction> convertCentralRoleFunctionToRoleFunctionObject(List<CentralV2RoleFunction> answer);
345 * It returns user roles for older version
352 public CentralUser getUserRoles(String loginId, String uebkey) throws Exception;
355 * It converts list of V2 CentralRole objects to old version CentralRole objects
358 * @return List of CentralRole objects
360 public List<CentralRole> convertV2CentralRoleListToOldVerisonCentralRoleList(List<CentralV2Role> v2CenRole);
364 * It finds namespace in external auth system if found returns namespace information
367 * @return Http response
369 public ResponseEntity<String> getNameSpaceIfExists(EPApp epApp) throws Exception, HttpClientErrorException;
373 * It converts V2 CentralRole objects to old version CentralRole objects
378 public CentralRole convertV2CentralRoleToOldVerisonCentralRole(CentralV2Role answer);
382 * Returns list of EPRole Objects if exists
385 * @return List of EPRole objects
387 Map<String, EPRole> getCurrentRolesInDB(EPApp app);
392 * It uploads list of users for single role when role name is re-named
397 * @return number of user roles added in External Auth System
400 public Integer bulkUploadUsersSingleRole(String uebkey, Long roleId, String roleName) throws Exception;
404 * It returns JSON array of external auth roles and its corresponding functions
410 public JSONArray getAppRolesJSONFromExtAuthSystem(EPApp app) throws Exception;
413 * It encodes the function code based on Hex encoding
417 public String encodeFunctionCode(String funCode);
421 * It returns list of ExternalRoleDetails which is converted from JSON array of roles
425 * @param extRole contains external auth application roles JSON array
426 * @return List of ExternalRoleDetails objects
427 * @throws IOException
428 * @throws JsonParseException
429 * @throws JsonMappingException
431 public List<ExternalRoleDetails> getExternalRoleDetailsList(EPApp app,
432 ObjectMapper mapper, JSONArray extRole) throws IOException, JsonParseException, JsonMappingException;
434 public JSONArray getAllUsersByRole(String roleName) throws Exception;