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;
45 import org.hibernate.Session;
46 import org.json.JSONArray;
47 import org.onap.portalapp.portal.domain.CentralV2RoleFunction;
48 import org.onap.portalapp.portal.domain.CentralizedApp;
49 import org.onap.portalapp.portal.domain.EPApp;
50 import org.onap.portalapp.portal.domain.EPRole;
51 import org.onap.portalapp.portal.domain.EPUser;
52 import org.onap.portalapp.portal.domain.ExternalRoleDetails;
53 import org.onap.portalapp.portal.ecomp.model.UploadRoleFunctionExtSystem;
54 import org.onap.portalapp.portal.exceptions.InvalidUserException;
55 import org.onap.portalapp.portal.exceptions.RoleFunctionException;
56 import org.onap.portalapp.portal.transport.CentralRole;
57 import org.onap.portalapp.portal.transport.CentralRoleFunction;
58 import org.onap.portalapp.portal.transport.CentralUser;
59 import org.onap.portalapp.portal.transport.CentralV2Role;
60 import org.onap.portalapp.portal.transport.ExternalRequestFieldsValidator;
61 import org.onap.portalsdk.core.domain.Role;
62 import org.onap.portalsdk.core.restful.domain.EcompRole;
63 import org.onap.portalsdk.core.restful.domain.EcompUser;
64 import org.springframework.http.HttpEntity;
65 import org.springframework.http.ResponseEntity;
66 import org.springframework.web.client.HttpClientErrorException;
68 import com.fasterxml.jackson.core.JsonParseException;
69 import com.fasterxml.jackson.databind.JsonMappingException;
70 import com.fasterxml.jackson.databind.ObjectMapper;
72 public interface ExternalAccessRolesService {
75 * It gets list of application roles
81 public List<EPRole> getAppRoles(Long appId) throws Exception;
84 * It returns single app record
90 public List<EPApp> getApp(String uebkey) throws Exception;
93 * Adds role in the external access system if fails throws exception
100 public boolean addRole(Role addRoles, String uebkey) throws Exception;
103 * It returns complete user information
106 * @return EPUser object
109 List<EPUser> getUser(String loginId) throws InvalidUserException;
112 * It returns complete user information including application roles permissions
119 String getV2UserWithRoles(String loginId, String uebkey) throws Exception;
122 * It returns list of all role functions
127 List<CentralV2RoleFunction> getRoleFuncList(String string) throws Exception;
130 * It return list of role provided by the app uebkey and roleId
134 * @return CentralRole
137 CentralV2Role getRoleInfo(Long roleId, String uebkey) throws Exception;
140 * It returns the CentralV2RoleFunction object
142 * @param functionCode
144 * @return CentralV2RoleFunction
147 public CentralV2RoleFunction getRoleFunction(String functionCode, String uebkey) throws Exception;
150 * It saves role function in the DB
152 * @param domainCentralRoleFunction
153 * @param requestedApp
154 * @return true else false
157 public boolean saveCentralRoleFunction(CentralV2RoleFunction domainCentralRoleFunction, EPApp requestedApp) throws Exception;
160 * It deletes role function in the DB
165 public boolean deleteCentralRoleFunction(String code, EPApp app);
168 * It gets all roles the applications
174 public List<CentralV2Role> getRolesForApp(String uebkey) throws Exception;
178 * It saves role function in the DB
182 * @return message and true or false
185 ExternalRequestFieldsValidator saveRoleForApplication(Role saveRole, String uebkey) throws Exception;
188 * It deletes role in the DB
192 * @return true else false
195 boolean deleteRoleForApplication(String code, String uebkey) throws Exception;
198 * It gets all active roles for single application
204 List<CentralV2Role> getActiveRoles(String uebkey) throws Exception;
207 * It deletes user related roles for an application in the table
211 * @return true else false
214 public ExternalRequestFieldsValidator deleteDependencyRoleRecord(Long roleId, String uebkey, String LoginId) throws Exception;
217 * It sync new functions codes and names from and updates role functions from external access system
222 public void syncRoleFunctionFromExternalAccessSystem(EPApp app) throws Exception;
225 * It uploads portal functions into external auth system
230 public Integer bulkUploadFunctions(String uebkey) throws Exception;
233 * It uploads portal roles into external auth system
238 public Integer bulkUploadRoles(String uebkey) throws Exception;
241 * It uploads partner application role functions into external auth system
247 public Integer bulkUploadPartnerFunctions(String uebkey) throws Exception;
250 * It uploads partner application role functions into external auth system
256 public void bulkUploadPartnerRoles(String uebkey, List<Role> upload) throws Exception;
259 * It returns total no. of portal application role functions records added in external auth system
264 Integer bulkUploadRolesFunctions(String uebkey) throws Exception;
267 * It syncs the roles and rolefunctions to the ONAP DB from AAF
271 void syncApplicationRolesWithEcompDB(EPApp app) throws Exception;
274 * It uploads list of user roles of the application into external auth system
280 public Integer bulkUploadUserRoles(String uebkey) throws Exception;
283 * It Uploads partner application role functions into external auth system
289 Integer bulkUploadPartnerRoleFunctions(String uebkey) throws Exception;
292 * it deletes all dependency role records
294 * @param localSession
297 * @param isPortalRequest
300 public void deleteRoleDependencyRecords(Session localSession, Long roleId, Long appId, boolean isPortalRequest) throws Exception;
303 * It returns list of applications functions along with functions associated with global role
309 List<String> getMenuFunctionsList(String uebkey) throws Exception;
313 * @param uebkey applications UebKey
316 * Method getAllUsers returns all the active users of application
318 List<EcompUser> getAllAppUsers(String uebkey) throws Exception;
323 * @return returns Role Object
324 * Method ConvertCentralRoleToRole converts the CentralRole String to Role Object
326 public Role ConvertCentralRoleToRole(String result);
329 * It returns the list of centralized applications
334 public List<CentralizedApp> getCentralizedAppsOfUser(String userId);
337 * It returns the list of globalRoles of Portal
340 public List<EPRole> getGlobalRolesOfPortal();
343 * It converts list of CentralV2RoleFunction objects to older version of CentralRoleFunction objects
344 * @param answer contains list of CentralRoleFunction objects
345 * @return List of CentralRoleFunction objects
347 public List<CentralRoleFunction> convertCentralRoleFunctionToRoleFunctionObject(List<CentralV2RoleFunction> answer);
351 * It returns user roles for older version
358 public CentralUser getUserRoles(String loginId, String uebkey) throws Exception;
361 * It converts list of V2 CentralRole objects to old version CentralRole objects
364 * @return List of CentralRole objects
366 public List<CentralRole> convertV2CentralRoleListToOldVerisonCentralRoleList(List<CentralV2Role> v2CenRole);
370 * It finds namespace in external auth system if found returns namespace information
373 * @return Http response
375 public ResponseEntity<String> getNameSpaceIfExists(EPApp epApp) throws Exception, HttpClientErrorException;
379 * It converts V2 CentralRole objects to old version CentralRole objects
384 public CentralRole convertV2CentralRoleToOldVerisonCentralRole(CentralV2Role answer);
388 * Returns list of EPRole Objects if exists
391 * @return List of EPRole objects
393 Map<String, EPRole> getAppRoleNamesWithUnderscoreMap(EPApp app);
398 * It uploads list of users for single role when role name is re-named
403 * @return number of user roles added in External Auth System
406 public Integer bulkUploadUsersSingleRole(String uebkey, Long roleId, String roleName) throws Exception;
410 * It returns JSON array of external auth roles and its corresponding functions
416 public JSONArray getAppRolesJSONFromExtAuthSystem(EPApp app) throws Exception;
420 * It returns list of ExternalRoleDetails which is converted from JSON array of roles
424 * @param extRole contains external auth application roles JSON array
425 * @return List of ExternalRoleDetails objects
426 * @throws IOException
427 * @throws JsonParseException
428 * @throws JsonMappingException
430 public List<ExternalRoleDetails> getExternalRoleDetailsList(EPApp app,
431 ObjectMapper mapper, JSONArray extRole) throws IOException, JsonParseException, JsonMappingException;
433 public JSONArray getAllUsersByRole(String roleName) throws Exception;
437 * It check function code has any pipes, if found return function type
439 * @param roleFuncItem
441 * @return function type
443 String getFunctionCodeType(String roleFuncItem);
446 * It return function action
448 * @param roleFuncItem
449 * @return String action
451 String getFunctionCodeAction(String roleFuncItem);
455 * Adds function to role in external auth system
460 void bulkUploadRoleFunc(UploadRoleFunctionExtSystem data, EPApp app) throws Exception;
464 * Syncs user roles from external auth system to ecomp portal
469 public void syncApplicationUserRolesFromExtAuthSystem(String orgUserId) throws Exception;
473 * Gets all user roles from external auth system
476 * @param getUserRolesEntity
477 * @return user roles from external auth system
479 ResponseEntity<String> getUserRolesFromExtAuthSystem(String orgUserId, HttpEntity<String> getUserRolesEntity) throws Exception;
483 * Updates app role description in external auth system
486 * @return number of updates
488 public Integer updateAppRoleDescription(String uebkey);
491 * Creates centralRoleObject
496 * @return returns List<CentralV2Role>
497 * @throws RoleFunctionException
499 public List<CentralV2Role> createCentralRoleObject(List<EPApp> app, List<EPRole> roleInfo,
500 List<CentralV2Role> roleList, Map<String, Long> params) throws RoleFunctionException;
506 * @param CurrentUserRoles
507 * @return returns list of user roles
510 public List<EcompRole> missingUserApplicationRoles(String uebkey, String loginId, Set<EcompRole> CurrentUserRoles) throws Exception;
512 List<EPRole> getPortalAppRoleInfo(Long roleId);