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.exceptions.InvalidUserException;
53 import org.onap.portalapp.portal.transport.CentralRole;
54 import org.onap.portalapp.portal.transport.CentralRoleFunction;
55 import org.onap.portalapp.portal.transport.CentralUser;
56 import org.onap.portalapp.portal.transport.CentralV2Role;
57 import org.onap.portalapp.portal.transport.ExternalRequestFieldsValidator;
58 import org.onap.portalsdk.core.domain.Role;
59 import org.onap.portalsdk.core.domain.RoleFunction;
60 import org.onap.portalsdk.core.restful.domain.EcompUser;
61 import org.springframework.http.ResponseEntity;
62 import org.springframework.web.client.HttpClientErrorException;
64 import com.fasterxml.jackson.core.JsonParseException;
65 import com.fasterxml.jackson.databind.JsonMappingException;
66 import com.fasterxml.jackson.databind.ObjectMapper;
68 public interface ExternalAccessRolesService {
71 * It gets list of application roles
77 public List<EPRole> getAppRoles(Long appId) throws Exception;
80 * It returns single app record
86 public List<EPApp> getApp(String uebkey) throws Exception;
89 * Adds role in the external access system if fails throws exception
96 public boolean addRole(Role addRoles, String uebkey) throws Exception;
99 * It returns complete user information
102 * @return EPUser object
105 List<EPUser> getUser(String loginId) throws InvalidUserException;
108 * It returns complete user information including application roles permissions
115 String getV2UserWithRoles(String loginId, String uebkey) throws Exception;
118 * It returns list of all role functions
123 List<CentralV2RoleFunction> getRoleFuncList(String string) throws Exception;
126 * It return list of role provided by the app uebkey and roleId
130 * @return CentralRole
133 CentralV2Role getRoleInfo(Long roleId, String uebkey) throws Exception;
136 * It returns the CentralV2RoleFunction object
138 * @param functionCode
140 * @return CentralV2RoleFunction
143 public CentralV2RoleFunction getRoleFunction(String functionCode, String uebkey) throws Exception;
146 * It saves role function in the DB
148 * @param domainCentralRoleFunction
149 * @param requestedApp
150 * @return true else false
153 public boolean saveCentralRoleFunction(CentralV2RoleFunction domainCentralRoleFunction, EPApp requestedApp) throws Exception;
156 * It deletes role function in the DB
161 public boolean deleteCentralRoleFunction(String code, EPApp app);
164 * It gets all roles the applications
170 public List<CentralV2Role> getRolesForApp(String uebkey) throws Exception;
174 * It saves role function in the DB
178 * @return message and true or false
181 ExternalRequestFieldsValidator saveRoleForApplication(Role saveRole, String uebkey) throws Exception;
184 * It deletes role in the DB
188 * @return true else false
191 boolean deleteRoleForApplication(String code, String uebkey) throws Exception;
194 * It gets all active roles for single application
200 List<CentralV2Role> getActiveRoles(String uebkey) throws Exception;
203 * It deletes user related roles for an application in the table
207 * @return true else false
210 public ExternalRequestFieldsValidator deleteDependencyRoleRecord(Long roleId, String uebkey, String LoginId) throws Exception;
213 * It sync new functions codes and names from and updates role functions from external access system
218 public void syncRoleFunctionFromExternalAccessSystem(EPApp app) throws Exception;
221 * It uploads portal functions into external auth system
226 public Integer bulkUploadFunctions(String uebkey) throws Exception;
229 * It uploads portal roles into external auth system
234 public Integer bulkUploadRoles(String uebkey) throws Exception;
237 * It uploads partner application role functions into external auth system
243 public void bulkUploadPartnerFunctions(String uebkey, List<RoleFunction> upload) throws Exception;
246 * It uploads partner application role functions into external auth system
252 public void bulkUploadPartnerRoles(String uebkey, List<Role> upload) throws Exception;
255 * It returns total no. of portal application role functions records added in external auth system
260 Integer bulkUploadRolesFunctions(String uebkey) throws Exception;
263 * It syncs the roles and rolefunctions to the ONAP DB from AAF
267 void syncApplicationRolesWithEcompDB(EPApp app) throws Exception;
270 * It uploads list of user roles of the application into external auth system
276 public Integer bulkUploadUserRoles(String uebkey) throws Exception;
279 * It Uploads partner application role functions into external auth system
285 void bulkUploadPartnerRoleFunctions(String uebkey, List<Role> roleList) throws Exception;
288 * it deletes all dependency role records
290 * @param localSession
293 * @param isPortalRequest
296 public void deleteRoleDependencyRecords(Session localSession, Long roleId, Long appId, boolean isPortalRequest) throws Exception;
299 * It returns list of applications functions along with functions associated with global role
305 List<String> getMenuFunctionsList(String uebkey) throws Exception;
309 * @param uebkey applications UebKey
312 * Method getAllUsers returns all the active users of application
314 List<EcompUser> getAllAppUsers(String uebkey) throws Exception;
319 * @return returns Role Object
320 * Method ConvertCentralRoleToRole converts the CentralRole String to Role Object
322 public Role ConvertCentralRoleToRole(String result);
325 * It returns the list of centralized applications
330 public List<CentralizedApp> getCentralizedAppsOfUser(String userId);
333 * It returns the list of globalRoles of Portal
336 public List<EPRole> getGlobalRolesOfPortal();
339 * It converts list of CentralV2RoleFunction objects to older version of CentralRoleFunction objects
340 * @param answer contains list of CentralRoleFunction objects
341 * @return List of CentralRoleFunction objects
343 public List<CentralRoleFunction> convertCentralRoleFunctionToRoleFunctionObject(List<CentralV2RoleFunction> answer);
347 * It returns user roles for older version
354 public CentralUser getUserRoles(String loginId, String uebkey) throws Exception;
357 * It converts list of V2 CentralRole objects to old version CentralRole objects
360 * @return List of CentralRole objects
362 public List<CentralRole> convertV2CentralRoleListToOldVerisonCentralRoleList(List<CentralV2Role> v2CenRole);
366 * It finds namespace in external auth system if found returns namespace information
369 * @return Http response
371 public ResponseEntity<String> getNameSpaceIfExists(EPApp epApp) throws Exception, HttpClientErrorException;
375 * It converts V2 CentralRole objects to old version CentralRole objects
380 public CentralRole convertV2CentralRoleToOldVerisonCentralRole(CentralV2Role answer);
384 * Returns list of EPRole Objects if exists
387 * @return List of EPRole objects
389 Map<String, EPRole> getCurrentRolesInDB(EPApp app);
394 * It uploads list of users for single role when role name is re-named
399 * @return number of user roles added in External Auth System
402 public Integer bulkUploadUsersSingleRole(String uebkey, Long roleId, String roleName) throws Exception;
406 * It returns JSON array of external auth roles and its corresponding functions
412 public JSONArray getAppRolesJSONFromExtAuthSystem(EPApp app) throws Exception;
415 * It encodes the function code based on Hex encoding
419 public String encodeFunctionCode(String funCode);
423 * It returns list of ExternalRoleDetails which is converted from JSON array of roles
427 * @param extRole contains external auth application roles JSON array
428 * @return List of ExternalRoleDetails objects
429 * @throws IOException
430 * @throws JsonParseException
431 * @throws JsonMappingException
433 public List<ExternalRoleDetails> getExternalRoleDetailsList(EPApp app,
434 ObjectMapper mapper, JSONArray extRole) throws IOException, JsonParseException, JsonMappingException;
436 public JSONArray getAllUsersByRole(String roleName) throws Exception;
440 * It check function code has any pipes, if found return function type
442 * @param roleFuncItem
444 * @return function type
446 String getFunctionCodeType(String roleFuncItem);
449 * It return function action
451 * @param roleFuncItem
452 * @return String action
454 String getFunctionCodeAction(String roleFuncItem);