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============================================
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.ecomp.model.UploadRoleFunctionExtSystem;
53 import org.onap.portalapp.portal.exceptions.InvalidUserException;
54 import org.onap.portalapp.portal.transport.CentralRole;
55 import org.onap.portalapp.portal.transport.CentralRoleFunction;
56 import org.onap.portalapp.portal.transport.CentralUser;
57 import org.onap.portalapp.portal.transport.CentralV2Role;
58 import org.onap.portalapp.portal.transport.ExternalRequestFieldsValidator;
59 import org.onap.portalsdk.core.domain.Role;
60 import org.onap.portalsdk.core.restful.domain.EcompUser;
61 import org.springframework.http.HttpEntity;
62 import org.springframework.http.ResponseEntity;
63 import org.springframework.web.client.HttpClientErrorException;
65 import com.fasterxml.jackson.core.JsonParseException;
66 import com.fasterxml.jackson.databind.JsonMappingException;
67 import com.fasterxml.jackson.databind.ObjectMapper;
69 public interface ExternalAccessRolesService {
72 * It gets list of application roles
78 public List<EPRole> getAppRoles(Long appId) throws Exception;
81 * It returns single app record
87 public List<EPApp> getApp(String uebkey) throws Exception;
90 * Adds role in the external access system if fails throws exception
97 public boolean addRole(Role addRoles, String uebkey) throws Exception;
100 * It returns complete user information
103 * @return EPUser object
106 List<EPUser> getUser(String loginId) throws InvalidUserException;
109 * It returns complete user information including application roles permissions
116 String getV2UserWithRoles(String loginId, String uebkey) throws Exception;
119 * It returns list of all role functions
124 List<CentralV2RoleFunction> getRoleFuncList(String string) throws Exception;
127 * It return list of role provided by the app uebkey and roleId
131 * @return CentralRole
134 CentralV2Role getRoleInfo(Long roleId, String uebkey) throws Exception;
137 * It returns the CentralV2RoleFunction object
139 * @param functionCode
141 * @return CentralV2RoleFunction
144 public CentralV2RoleFunction getRoleFunction(String functionCode, String uebkey) throws Exception;
147 * It saves role function in the DB
149 * @param domainCentralRoleFunction
150 * @param requestedApp
151 * @return true else false
154 public boolean saveCentralRoleFunction(CentralV2RoleFunction domainCentralRoleFunction, EPApp requestedApp) throws Exception;
157 * It deletes role function in the DB
162 public boolean deleteCentralRoleFunction(String code, EPApp app);
165 * It gets all roles the applications
171 public List<CentralV2Role> getRolesForApp(String uebkey) throws Exception;
175 * It saves role function in the DB
179 * @return message and true or false
182 ExternalRequestFieldsValidator saveRoleForApplication(Role saveRole, String uebkey) throws Exception;
185 * It deletes role in the DB
189 * @return true else false
192 boolean deleteRoleForApplication(String code, String uebkey) throws Exception;
195 * It gets all active roles for single application
201 List<CentralV2Role> getActiveRoles(String uebkey) throws Exception;
204 * It deletes user related roles for an application in the table
208 * @return true else false
211 public ExternalRequestFieldsValidator deleteDependencyRoleRecord(Long roleId, String uebkey, String LoginId) throws Exception;
214 * It sync new functions codes and names from and updates role functions from external access system
219 public void syncRoleFunctionFromExternalAccessSystem(EPApp app) throws Exception;
222 * It uploads portal functions into external auth system
227 public Integer bulkUploadFunctions(String uebkey) throws Exception;
230 * It uploads portal roles into external auth system
235 public Integer bulkUploadRoles(String uebkey) throws Exception;
238 * It uploads partner application role functions into external auth system
244 public Integer bulkUploadPartnerFunctions(String uebkey) throws Exception;
247 * It uploads partner application role functions into external auth system
253 public void bulkUploadPartnerRoles(String uebkey, List<Role> upload) throws Exception;
256 * It returns total no. of portal application role functions records added in external auth system
261 Integer bulkUploadRolesFunctions(String uebkey) throws Exception;
264 * It syncs the roles and rolefunctions to the ONAP DB from AAF
268 void syncApplicationRolesWithEcompDB(EPApp app) throws Exception;
271 * It uploads list of user roles of the application into external auth system
277 public Integer bulkUploadUserRoles(String uebkey) throws Exception;
280 * It Uploads partner application role functions into external auth system
286 Integer bulkUploadPartnerRoleFunctions(String uebkey) throws Exception;
289 * it deletes all dependency role records
291 * @param localSession
294 * @param isPortalRequest
297 public void deleteRoleDependencyRecords(Session localSession, Long roleId, Long appId, boolean isPortalRequest) throws Exception;
300 * It returns list of applications functions along with functions associated with global role
306 List<String> getMenuFunctionsList(String uebkey) throws Exception;
310 * @param uebkey applications UebKey
313 * Method getAllUsers returns all the active users of application
315 List<EcompUser> getAllAppUsers(String uebkey) throws Exception;
320 * @return returns Role Object
321 * Method ConvertCentralRoleToRole converts the CentralRole String to Role Object
323 public Role ConvertCentralRoleToRole(String result);
326 * It returns the list of centralized applications
331 public List<CentralizedApp> getCentralizedAppsOfUser(String userId);
334 * It returns the list of globalRoles of Portal
337 public List<EPRole> getGlobalRolesOfPortal();
340 * It converts list of CentralV2RoleFunction objects to older version of CentralRoleFunction objects
341 * @param answer contains list of CentralRoleFunction objects
342 * @return List of CentralRoleFunction objects
344 public List<CentralRoleFunction> convertCentralRoleFunctionToRoleFunctionObject(List<CentralV2RoleFunction> answer);
348 * It returns user roles for older version
355 public CentralUser getUserRoles(String loginId, String uebkey) throws Exception;
358 * It converts list of V2 CentralRole objects to old version CentralRole objects
361 * @return List of CentralRole objects
363 public List<CentralRole> convertV2CentralRoleListToOldVerisonCentralRoleList(List<CentralV2Role> v2CenRole);
367 * It finds namespace in external auth system if found returns namespace information
370 * @return Http response
372 public ResponseEntity<String> getNameSpaceIfExists(EPApp epApp) throws Exception, HttpClientErrorException;
376 * It converts V2 CentralRole objects to old version CentralRole objects
381 public CentralRole convertV2CentralRoleToOldVerisonCentralRole(CentralV2Role answer);
385 * Returns list of EPRole Objects if exists
388 * @return List of EPRole objects
390 Map<String, EPRole> getCurrentRolesInDB(EPApp app);
395 * It uploads list of users for single role when role name is re-named
400 * @return number of user roles added in External Auth System
403 public Integer bulkUploadUsersSingleRole(String uebkey, Long roleId, String roleName) throws Exception;
407 * It returns JSON array of external auth roles and its corresponding functions
413 public JSONArray getAppRolesJSONFromExtAuthSystem(EPApp app) throws Exception;
416 * It encodes the function code based on Hex encoding
420 public String encodeFunctionCode(String funCode);
424 * It returns list of ExternalRoleDetails which is converted from JSON array of roles
428 * @param extRole contains external auth application roles JSON array
429 * @return List of ExternalRoleDetails objects
430 * @throws IOException
431 * @throws JsonParseException
432 * @throws JsonMappingException
434 public List<ExternalRoleDetails> getExternalRoleDetailsList(EPApp app,
435 ObjectMapper mapper, JSONArray extRole) throws IOException, JsonParseException, JsonMappingException;
437 public JSONArray getAllUsersByRole(String roleName) throws Exception;
441 * It check function code has any pipes, if found return function type
443 * @param roleFuncItem
445 * @return function type
447 String getFunctionCodeType(String roleFuncItem);
450 * It return function action
452 * @param roleFuncItem
453 * @return String action
455 String getFunctionCodeAction(String roleFuncItem);
459 * Adds function to role in external auth system
464 void bulkUploadRoleFunc(UploadRoleFunctionExtSystem data, EPApp app) throws Exception;
468 * Syncs user roles from external auth system to ecomp portal
473 public void syncApplicationUserRolesFromExtAuthSystem(String orgUserId) throws Exception;
477 * Gets all user roles from external auth system
480 * @param getUserRolesEntity
481 * @return user roles from external auth system
483 ResponseEntity<String> getUserRolesFromExtAuthSystem(String orgUserId, HttpEntity<String> getUserRolesEntity) throws Exception;