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.exceptions.InvalidUserException;
 
  53 import org.onap.portalapp.portal.transport.CentralRole;
 
  54 import org.onap.portalapp.portal.transport.CentralUser;
 
  55 import org.onap.portalapp.portal.transport.CentralV2Role;
 
  56 import org.onap.portalapp.portal.transport.ExternalRequestFieldsValidator;
 
  57 import org.onap.portalsdk.core.domain.Role;
 
  58 import org.onap.portalsdk.core.domain.RoleFunction;
 
  59 import org.onap.portalsdk.core.restful.domain.EcompUser;
 
  60 import org.springframework.http.ResponseEntity;
 
  61 import org.springframework.web.client.HttpClientErrorException;
 
  63 import com.fasterxml.jackson.core.JsonParseException;
 
  64 import com.fasterxml.jackson.databind.JsonMappingException;
 
  65 import com.fasterxml.jackson.databind.ObjectMapper;
 
  67 public interface ExternalAccessRolesService {
 
  70          * It gets list of application roles 
 
  76         public List<EPRole> getAppRoles(Long appId) throws Exception;
 
  79          * It returns single app record
 
  85         public List<EPApp> getApp(String uebkey) throws Exception;
 
  88          * Adds role in the external access system if fails throws exception
 
  95         public boolean addRole(Role addRoles, String uebkey) throws Exception;
 
  98          * It returns complete user information
 
 101          * @return EPUser object
 
 104         List<EPUser> getUser(String loginId) throws InvalidUserException;
 
 107          * It returns complete user information including application roles permissions
 
 114         String getV2UserWithRoles(String loginId, String uebkey) throws Exception;
 
 117          * It returns list of all role functions
 
 122         List<CentralV2RoleFunction> getRoleFuncList(String string) throws Exception;
 
 125          * It return list of role provided by the app uebkey and roleId
 
 129          * @return CentralRole
 
 132         CentralV2Role getRoleInfo(Long roleId, String uebkey) throws Exception;
 
 135          *  It returns the CentralRoleFunction object 
 
 137          * @param functionCode
 
 139          * @return CentralRoleFunction
 
 142         public CentralV2RoleFunction getRoleFunction(String functionCode, String uebkey) throws Exception;
 
 145          *  It saves role function in the DB
 
 147          * @param domainCentralRoleFunction
 
 148          * @param requestedApp 
 
 149          * @return true else false
 
 152         public boolean saveCentralRoleFunction(CentralV2RoleFunction domainCentralRoleFunction, EPApp requestedApp) throws Exception;
 
 155          * It deletes role function in the DB
 
 160         public boolean deleteCentralRoleFunction(String code, EPApp app);
 
 163          * It gets all roles the applications
 
 169         public List<CentralV2Role> getRolesForApp(String uebkey) throws Exception;
 
 173          * It saves role function in the DB
 
 177          * @return message and true or false  
 
 180         ExternalRequestFieldsValidator saveRoleForApplication(Role saveRole, String uebkey) throws Exception;
 
 183          *  It deletes role in the DB
 
 187          * @return true else false
 
 190         boolean deleteRoleForApplication(String code, String uebkey) throws Exception;
 
 193          * It gets all active roles for single application 
 
 199         List<CentralV2Role> getActiveRoles(String uebkey) throws Exception;
 
 202          * It deletes user related roles for an application in the table
 
 206          * @return true else false
 
 209         public ExternalRequestFieldsValidator deleteDependencyRoleRecord(Long roleId, String uebkey, String LoginId) throws Exception;
 
 212          * It sync new functions codes and names from and updates role functions from external access system
 
 217         public void syncRoleFunctionFromExternalAccessSystem(EPApp app) throws Exception;
 
 220          * It uploads portal functions into external auth system
 
 225         public Integer bulkUploadFunctions(String uebkey) throws Exception;
 
 228          * It uploads portal roles into external auth system
 
 233         public Integer bulkUploadRoles(String uebkey) throws Exception;
 
 236          * It uploads partner application role functions into external auth system
 
 242         public void bulkUploadPartnerFunctions(String uebkey, List<RoleFunction> upload) throws Exception;
 
 245          * It uploads partner application role functions into external auth system
 
 251         public void bulkUploadPartnerRoles(String uebkey, List<Role> upload) throws Exception;
 
 254          * It returns total no. of portal application role functions records added in external auth system 
 
 259         Integer bulkUploadRolesFunctions(String uebkey) throws Exception;
 
 262          *  It syncs the roles and rolefunctions to the ecomp DB from AAF
 
 266         void syncApplicationRolesWithEcompDB(EPApp app) throws Exception;
 
 269          * It uploads list of user roles of the application into external auth system 
 
 275         public Integer bulkUploadUserRoles(String uebkey) throws Exception;
 
 278          * It Uploads partner application role functions into external auth system
 
 284         void bulkUploadPartnerRoleFunctions(String uebkey, List<Role> roleList) throws Exception;
 
 287          * it deletes all dependency role records 
 
 289          * @param localSession
 
 292          * @param isPortalRequest 
 
 295         public void deleteRoleDependencyRecords(Session localSession, Long roleId, Long appId, boolean isPortalRequest) throws Exception;
 
 298          * It returns list of applications functions along with functions associated with global role
 
 304         List<String> getMenuFunctionsList(String uebkey) throws Exception;
 
 308          * @param uebkey applications UebKey
 
 311          * Method getAllUsers returns all the active users of application
 
 313         List<EcompUser> getAllAppUsers(String uebkey) throws Exception;
 
 318          * @return returns Role Object
 
 319          * Method ConvertCentralRoleToRole converts the CentralRole String to Role Object
 
 321         public Role ConvertCentralRoleToRole(String result);
 
 324          * It returns the list of centralized applications
 
 329         public List<CentralizedApp> getCentralizedAppsOfUser(String userId);
 
 332          * It returns the list of globalRoles of Portal
 
 335         public  List<EPRole> getGlobalRolesOfPortal();
 
 338          * It converts list of CentralRoleFunction objects to RoleFunction objects
 
 339          * @param answer contains list of CentralRoleFunction objects
 
 340          * @return List of RoleFunction objects
 
 342         public List<RoleFunction> convertCentralRoleFunctionToRoleFunctionObject(List<CentralV2RoleFunction> answer);
 
 346          * It returns user roles for older version
 
 353         public CentralUser getUserRoles(String loginId, String uebkey) throws Exception;
 
 356          * It converts list of V2 CentralRole objects to old version CentralRole objects
 
 359          * @return List of CentralRole objects
 
 361         public List<CentralRole> convertV2CentralRoleListToOldVerisonCentralRoleList(List<CentralV2Role> v2CenRole);
 
 365          * It finds namespace in external auth system if found returns namespace information
 
 368          * @return Http response
 
 370         public ResponseEntity<String> getNameSpaceIfExists(EPApp epApp) throws Exception, HttpClientErrorException;
 
 374          * It converts V2 CentralRole objects to old version CentralRole objects
 
 379         public CentralRole convertV2CentralRoleToOldVerisonCentralRole(CentralV2Role answer);
 
 383          * Returns list of EPRole Objects if exists
 
 386          * @return List of EPRole objects
 
 388         Map<String, EPRole> getCurrentRolesInDB(EPApp app);
 
 393          * It uploads list of users for single role when role name is re-named
 
 398          * @return number of user roles added in External Auth System
 
 401         public Integer bulkUploadUsersSingleRole(String uebkey, Long roleId, String roleName) throws Exception;
 
 405          * It returns JSON array of external auth roles and its corresponding functions
 
 411         public JSONArray getAppRolesJSONFromExtAuthSystem(EPApp app) throws Exception;
 
 414          * It encodes the function code  based on Hex encoding
 
 418         public String encodeFunctionCode(String funCode);
 
 422          * It returns list of ExternalRoleDetails which is converted from JSON array of roles
 
 426          * @param extRole contains external auth application roles JSON array
 
 427          * @return List of ExternalRoleDetails objects
 
 428          * @throws IOException
 
 429          * @throws JsonParseException
 
 430          * @throws JsonMappingException
 
 432         public List<ExternalRoleDetails> getExternalRoleDetailsList(EPApp app,
 
 433                         ObjectMapper mapper, JSONArray extRole) throws IOException, JsonParseException, JsonMappingException;
 
 435         public JSONArray getAllUsersByRole(String roleName) throws Exception;