X-Git-Url: https://gerrit.onap.org/r/gitweb?p=portal.git;a=blobdiff_plain;f=ecomp-portal-BE-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportalapp%2Fportal%2Fservice%2FExternalAccessRolesServiceImpl.java;h=3778a00ff48c36d0f937fe7f7e1135440f567809;hp=3a86952b2c9053673af407e7a3771f7c23532ab0;hb=d13dacf060ff58d36f7d8995d185d78085bfd669;hpb=a70761c096192e38800bf38d6c7f61f52bf72007 diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java index 3a86952b..3778a00f 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java @@ -47,11 +47,9 @@ import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; -import java.util.regex.Pattern; import java.util.stream.Collectors; import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; @@ -78,28 +76,7 @@ import org.onap.portalapp.portal.exceptions.RoleFunctionException; import org.onap.portalapp.portal.logging.aop.EPAuditLog; import org.onap.portalapp.portal.logging.aop.EPMetricsLog; import org.onap.portalapp.portal.logging.logic.EPLogUtil; -import org.onap.portalapp.portal.transport.BulkUploadRoleFunction; -import org.onap.portalapp.portal.transport.BulkUploadUserRoles; -import org.onap.portalapp.portal.transport.CentralApp; -import org.onap.portalapp.portal.transport.CentralRole; -import org.onap.portalapp.portal.transport.CentralRoleFunction; -import org.onap.portalapp.portal.transport.CentralUser; -import org.onap.portalapp.portal.transport.CentralUserApp; -import org.onap.portalapp.portal.transport.CentralV2Role; -import org.onap.portalapp.portal.transport.CentralV2User; -import org.onap.portalapp.portal.transport.CentralV2UserApp; -import org.onap.portalapp.portal.transport.CentralizedAppRoles; -import org.onap.portalapp.portal.transport.EPUserAppCurrentRoles; -import org.onap.portalapp.portal.transport.EcompUserRoles; -import org.onap.portalapp.portal.transport.ExternalAccessPerms; -import org.onap.portalapp.portal.transport.ExternalAccessPermsDetail; -import org.onap.portalapp.portal.transport.ExternalAccessRole; -import org.onap.portalapp.portal.transport.ExternalAccessRolePerms; -import org.onap.portalapp.portal.transport.ExternalAccessUser; -import org.onap.portalapp.portal.transport.ExternalAccessUserRoleDetail; -import org.onap.portalapp.portal.transport.ExternalRequestFieldsValidator; -import org.onap.portalapp.portal.transport.GlobalRoleWithApplicationRoleFunction; -import org.onap.portalapp.portal.transport.LocalRole; +import org.onap.portalapp.portal.transport.*; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalapp.portal.utils.PortalConstants; @@ -219,8 +196,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic logger.debug(EELFLoggerDelegate.debugLogger, "getSingleAppRole: Connecting to External Auth system"); response = template.exchange( SystemProperties.getProperty(EPCommonSystemProperties.EXTERNAL_CENTRAL_ACCESS_URL) + "roles/" - + app.getNameSpace() - + "." + addRole + + app.getNameSpace() + "." + addRole .replaceAll(EcompPortalUtils.EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS, "_"), HttpMethod.GET, entity, String.class); logger.debug(EELFLoggerDelegate.debugLogger, @@ -284,9 +260,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic * @param updateExtRole * @param app * @return true if success else false - * @throws Exception - * If updateRoleInExternalSystem fails we catch it in logger for - * detail message + * @throws Exception If updateRoleInExternalSystem fails we catch it in logger + * for detail message */ private boolean updateRoleInExternalSystem(Role updateExtRole, EPApp app, boolean isGlobalRole) throws Exception { boolean response = false; @@ -444,8 +419,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic } /* - * Adds function to the role in the external auth system while editing a - * role or updating new functions to a role + * Adds function to the role in the external auth system while editing a role or + * updating new functions to a role * */ private boolean addFunctionsToRoleInExternalAuthSystem(Role updateExtRole, EPApp app, ObjectMapper mapper, @@ -673,8 +648,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic /** * - * It converts list of functions in updateExtRole parameter to the - * RoleFunction object + * It converts list of functions in updateExtRole parameter to the RoleFunction + * object * * @param updateExtRole * @return list of functions @@ -736,8 +711,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic * @param newRole * @param app * @return true if successfully added in the system else false - * @throws Exception - * If fails to add role in the system + * @throws Exception If fails to add role in the system */ private void addNewRoleInExternalSystem(List newRole, EPApp app) throws Exception, HttpClientErrorException { @@ -773,8 +747,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic * * It updates existing role in the External Auth System * - * @param addRole - * It Contains role information + * @param addRole It Contains role information * @param app * @return string which is formatted to match with the external auth system * @throws JsonProcessingException @@ -913,8 +886,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic * * @param checkRole * @param app - * @throws Exception - * If role exits + * @throws Exception If role exits */ private void checkIfRoleExitsInExternalSystem(Role checkRole, EPApp app) throws Exception { getNameSpaceIfExists(app); @@ -974,8 +946,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic /** * - * It filters the app functions which starts with similar name in the result - * set + * It filters the app functions which starts with similar name in the result set * * @param roleFunc * @param roleFunction @@ -1176,8 +1147,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic } /** - * It returns user detail information which is deep copy of EPUser.class - * object + * It returns user detail information which is deep copy of EPUser.class object * * @param userInfo * @param userAppSet @@ -1188,7 +1158,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic @SuppressWarnings("unchecked") private CentralV2User createEPUser(EPUser userInfo, Set userAppSet, EPApp app) throws Exception { final Map params = new HashMap<>(); - CentralV2User userAppList = new CentralV2User(); + CentralV2User userAppList = new CentralV2User.CentralV2UserBuilder().createCentralV2User(); CentralV2User user1 = null; final Map params1 = new HashMap<>(); List globalRoleList = new ArrayList<>(); @@ -1209,14 +1179,19 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic && (globalRole.toLowerCase().startsWith("global_")))) { CentralV2UserApp cua = new CentralV2UserApp(); cua.setUserId(null); - CentralApp cenApp = new CentralApp(1L, epApp.getCreated(), epApp.getModified(), - epApp.getCreatedId(), epApp.getModifiedId(), epApp.getRowNum(), epApp.getName(), - epApp.getImageUrl(), epApp.getDescription(), epApp.getNotes(), epApp.getUrl(), - epApp.getAlternateUrl(), epApp.getAppRestEndpoint(), epApp.getMlAppName(), - epApp.getMlAppAdminId(), String.valueOf(epApp.getMotsId()), epApp.getAppPassword(), - String.valueOf(epApp.getOpen()), String.valueOf(epApp.getEnabled()), - epApp.getThumbnail(), epApp.getUsername(), epApp.getUebKey(), epApp.getUebSecret(), - epApp.getUebTopicName()); + CentralApp cenApp = new CentralApp.CentralAppBuilder().setId(1L).setCreated(epApp.getCreated()) + .setModified(epApp.getModified()).setCreatedId(epApp.getCreatedId()) + .setModifiedId(epApp.getModifiedId()).setRowNum(epApp.getRowNum()) + .setName(epApp.getName()).setImageUrl(epApp.getImageUrl()) + .setDescription(epApp.getDescription()).setNotes(epApp.getNotes()) + .setUrl(epApp.getUrl()).setAlternateUrl(epApp.getAlternateUrl()) + .setRestEndpoint(epApp.getAppRestEndpoint()).setMlAppName(epApp.getMlAppName()) + .setMlAppAdminId(epApp.getMlAppAdminId()).setMotsId(String.valueOf(epApp.getMotsId())) + .setAppPassword(epApp.getAppPassword()).setOpen(String.valueOf(epApp.getOpen())) + .setEnabled(String.valueOf(epApp.getEnabled())).setThumbnail(epApp.getThumbnail()) + .setUsername(epApp.getUsername()).setUebKey(epApp.getUebKey()) + .setUebSecret(epApp.getUebSecret()).setUebTopicName(epApp.getUebTopicName()) + .createCentralApp(); cenApp.setAppPassword(EPCommonSystemProperties.APP_DISPLAY_PASSWORD); cua.setApp(cenApp); Long appId = null; @@ -1264,21 +1239,32 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic } } } - user1 = new CentralV2User(null, userInfo.getCreated(), userInfo.getModified(), userInfo.getCreatedId(), - userInfo.getModifiedId(), userInfo.getRowNum(), userInfo.getOrgId(), userInfo.getManagerId(), - userInfo.getFirstName(), userInfo.getMiddleInitial(), userInfo.getLastName(), userInfo.getPhone(), - userInfo.getFax(), userInfo.getCellular(), userInfo.getEmail(), userInfo.getAddressId(), - userInfo.getAlertMethodCd(), userInfo.getHrid(), userInfo.getOrgUserId(), userInfo.getOrgCode(), - userInfo.getAddress1(), userInfo.getAddress2(), userInfo.getCity(), userInfo.getState(), - userInfo.getZipCode(), userInfo.getCountry(), userInfo.getOrgManagerUserId(), - userInfo.getLocationClli(), userInfo.getBusinessCountryCode(), userInfo.getBusinessCountryName(), - userInfo.getBusinessUnit(), userInfo.getBusinessUnitName(), userInfo.getDepartment(), - userInfo.getDepartmentName(), userInfo.getCompanyCode(), userInfo.getCompany(), - userInfo.getZipCodeSuffix(), userInfo.getJobTitle(), userInfo.getCommandChain(), - userInfo.getSiloStatus(), userInfo.getCostCenter(), userInfo.getFinancialLocCode(), - userInfo.getLoginId(), userInfo.getLoginPwd(), userInfo.getLastLoginDate(), userInfo.getActive(), - userInfo.getInternal(), userInfo.getSelectedProfileId(), userInfo.getTimeZoneId(), - userInfo.isOnline(), userInfo.getChatId(), userAppList.getUserApps(), null); + user1 = new CentralV2User.CentralV2UserBuilder().setId(null).setCreated(userInfo.getCreated()) + .setModified(userInfo.getModified()).setCreatedId(userInfo.getCreatedId()) + .setModifiedId(userInfo.getModifiedId()).setRowNum(userInfo.getRowNum()) + .setOrgId(userInfo.getOrgId()).setManagerId(userInfo.getManagerId()) + .setFirstName(userInfo.getFirstName()).setMiddleInitial(userInfo.getMiddleInitial()) + .setLastName(userInfo.getLastName()).setPhone(userInfo.getPhone()).setFax(userInfo.getFax()) + .setCellular(userInfo.getCellular()).setEmail(userInfo.getEmail()) + .setAddressId(userInfo.getAddressId()).setAlertMethodCd(userInfo.getAlertMethodCd()) + .setHrid(userInfo.getHrid()).setOrgUserId(userInfo.getOrgUserId()).setOrgCode(userInfo.getOrgCode()) + .setAddress1(userInfo.getAddress1()).setAddress2(userInfo.getAddress2()).setCity(userInfo.getCity()) + .setState(userInfo.getState()).setZipCode(userInfo.getZipCode()).setCountry(userInfo.getCountry()) + .setOrgManagerUserId(userInfo.getOrgManagerUserId()).setLocationClli(userInfo.getLocationClli()) + .setBusinessCountryCode(userInfo.getBusinessCountryCode()) + .setBusinessCountryName(userInfo.getBusinessCountryName()) + .setBusinessUnit(userInfo.getBusinessUnit()).setBusinessUnitName(userInfo.getBusinessUnitName()) + .setDepartment(userInfo.getDepartment()).setDepartmentName(userInfo.getDepartmentName()) + .setCompanyCode(userInfo.getCompanyCode()).setCompany(userInfo.getCompany()) + .setZipCodeSuffix(userInfo.getZipCodeSuffix()).setJobTitle(userInfo.getJobTitle()) + .setCommandChain(userInfo.getCommandChain()).setSiloStatus(userInfo.getSiloStatus()) + .setCostCenter(userInfo.getCostCenter()).setFinancialLocCode(userInfo.getFinancialLocCode()) + .setLoginId(userInfo.getLoginId()).setLoginPwd(userInfo.getLoginPwd()) + .setLastLoginDate(userInfo.getLastLoginDate()).setActive(userInfo.getActive()) + .setInternal(userInfo.getInternal()).setSelectedProfileId(userInfo.getSelectedProfileId()) + .setTimeZoneId(userInfo.getTimeZoneId()).setOnline(userInfo.isOnline()) + .setChatId(userInfo.getChatId()).setUserApps(userAppList.getUserApps()).setPseudoRoles(null) + .createCentralV2User(); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "createEPUser: createEPUser failed", e); throw e; @@ -1338,8 +1324,9 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic return roleInfo; } + @Override @SuppressWarnings("unchecked") - private List getPortalAppRoleInfo(Long roleId) { + public List getPortalAppRoleInfo(Long roleId) { List roleInfo; final Map getPortalAppRoleParams = new HashMap<>(); getPortalAppRoleParams.put("roleId", roleId); @@ -1349,8 +1336,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic /** * - * It returns list of app roles along with role functions and which went - * through deep copy + * It returns list of app roles along with role functions and which went through + * deep copy * * @param app * @param roleInfo @@ -1399,7 +1386,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic @Override public CentralV2RoleFunction getRoleFunction(String functionCode, String uebkey) throws Exception { String code = EcompPortalUtils.getFunctionCode(functionCode); - String encodedCode = encodeFunctionCode(code); + String encodedCode = EcompPortalUtils.encodeFunctionCode(code); CentralV2RoleFunction roleFunc = null; EPApp app = getApp(uebkey).get(0); List getRoleFuncList = null; @@ -1457,7 +1444,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic throws Exception { boolean saveOrUpdateFunction = false; try { - domainCentralRoleFunction.setCode(encodeFunctionCode(domainCentralRoleFunction.getCode())); + if(EcompPortalUtils.checkFunctionCodeHasEncodePattern(domainCentralRoleFunction.getCode())) + domainCentralRoleFunction.setCode(EcompPortalUtils.encodeFunctionCode(domainCentralRoleFunction.getCode())); final Map functionParams = new HashMap<>(); functionParams.put("appId", String.valueOf(app.getId())); if (EcompPortalUtils.checkIfRemoteCentralAccessAllowed()) { @@ -2148,7 +2136,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic if (extPerms.getJSONObject(i).has("description")) { description = extPerms.getJSONObject(i).getString(EXTERNAL_AUTH_ROLE_DESCRIPTION); } else { - description = extPerms.getJSONObject(i).getString("type") + "|" + description = extPerms.getJSONObject(i).getString("type").substring(app.getNameSpace().length() + 1) + "|" + extPerms.getJSONObject(i).getString("instance") + "|" + extPerms.getJSONObject(i).getString("action"); } @@ -2248,8 +2236,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic /** * - * While sync functions form external auth system if new role found we - * should add in local and return Role.class object + * While sync functions form external auth system if new role found we should + * add in local and return Role.class object * * @param app * @param role @@ -2768,65 +2756,15 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic } } - /** - * - * It checks description in External Auth System if found any - * changes updates in DB - * - * @param app - * @param finalRoleList - * contains list of External Auth System roles list which is - * converted to EPRole - */ - @SuppressWarnings("unchecked") - private void checkAndUpdateRoleInDB(EPApp app, List finalRoleList) { - for (EPRole roleItem : finalRoleList) { - final Map roleParams = new HashMap<>(); - List currentList = null; - roleParams.put(APP_ROLE_NAME_PARAM, roleItem.getName()); - if (app.getId() == 1) { - currentList = dataAccessService.executeNamedQuery(GET_PORTAL_APP_ROLES_QUERY, roleParams, null); - } else { - roleParams.put(APP_ID, app.getId().toString()); - currentList = dataAccessService.executeNamedQuery(GET_ROLE_TO_UPDATE_IN_EXTERNAL_AUTH_SYSTEM, - roleParams, null); - } - if (!currentList.isEmpty()) { - try { - Boolean aafRoleActive; - Boolean localRoleActive; - boolean result; - aafRoleActive = Boolean.valueOf(roleItem.getActive()); - localRoleActive = Boolean.valueOf(currentList.get(0).getActive()); - result = aafRoleActive.equals(localRoleActive); - EPRole updateRole = currentList.get(0); - if (!result) { - updateRole.setActive(roleItem.getActive()); - dataAccessService.saveDomainObject(updateRole, null); - } - if (roleItem.getPriority() != null - && !currentList.get(0).getPriority().equals(roleItem.getPriority())) { - updateRole.setPriority(roleItem.getPriority()); - dataAccessService.saveDomainObject(updateRole, null); - } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, - "syncApplicationRolesWithEcompDB: Failed to update role ", e); - } - } - } - } - /** * * It de-activates application roles in DB if not present in External Auth - * system + * system * * @param app - * @param finalRoleList - * contains list of current roles present in External Auth System - * @param applicationRolesList - * contains list of current roles present in DB + * @param finalRoleList contains list of current roles present in + * External Auth System + * @param applicationRolesList contains list of current roles present in DB */ @SuppressWarnings("unchecked") private void inactiveRolesNotInExternalAuthSystem(EPApp app, List finalRoleList, @@ -2840,8 +2778,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic final Map extRoleParams = new HashMap<>(); List roleList = null; extRoleParams.put(APP_ROLE_NAME_PARAM, role.getName()); - if (!checkRolesInactive.containsKey(role.getName() - .replaceAll(EcompPortalUtils.EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS, "_"))) { + if (!checkRolesInactive.containsKey(role.getName())) { if (app.getId() == 1) { roleList = dataAccessService.executeNamedQuery(GET_PORTAL_APP_ROLES_QUERY, extRoleParams, null); } else { @@ -3549,22 +3486,31 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic cua.setRole(role); userApps.add(cua); } - return new CentralUser(cenV2User.getId(), cenV2User.getCreated(), cenV2User.getModified(), - cenV2User.getCreatedId(), cenV2User.getModifiedId(), cenV2User.getRowNum(), cenV2User.getOrgId(), - cenV2User.getManagerId(), cenV2User.getFirstName(), cenV2User.getMiddleInitial(), - cenV2User.getLastName(), cenV2User.getPhone(), cenV2User.getFax(), cenV2User.getCellular(), - cenV2User.getEmail(), cenV2User.getAddressId(), cenV2User.getAlertMethodCd(), cenV2User.getHrid(), - cenV2User.getOrgUserId(), cenV2User.getOrgCode(), cenV2User.getAddress1(), cenV2User.getAddress2(), - cenV2User.getCity(), cenV2User.getState(), cenV2User.getZipCode(), cenV2User.getCountry(), - cenV2User.getOrgManagerUserId(), cenV2User.getLocationClli(), cenV2User.getBusinessCountryCode(), - cenV2User.getBusinessCountryName(), cenV2User.getBusinessUnit(), cenV2User.getBusinessUnitName(), - cenV2User.getDepartment(), cenV2User.getDepartmentName(), cenV2User.getCompanyCode(), - cenV2User.getCompany(), cenV2User.getZipCodeSuffix(), cenV2User.getJobTitle(), - cenV2User.getCommandChain(), cenV2User.getSiloStatus(), cenV2User.getCostCenter(), - cenV2User.getFinancialLocCode(), cenV2User.getLoginId(), cenV2User.getLoginPwd(), - cenV2User.getLastLoginDate(), cenV2User.isActive(), cenV2User.isInternal(), - cenV2User.getSelectedProfileId(), cenV2User.getTimeZoneId(), cenV2User.isOnline(), - cenV2User.getChatId(), userApps); + return new CentralUser.CentralUserBuilder().setId(cenV2User.getId()).setCreated(cenV2User.getCreated()) + .setModified(cenV2User.getModified()).setCreatedId(cenV2User.getCreatedId()) + .setModifiedId(cenV2User.getModifiedId()).setRowNum(cenV2User.getRowNum()) + .setOrgId(cenV2User.getOrgId()).setManagerId(cenV2User.getManagerId()) + .setFirstName(cenV2User.getFirstName()).setMiddleInitial(cenV2User.getMiddleInitial()) + .setLastName(cenV2User.getLastName()).setPhone(cenV2User.getPhone()).setFax(cenV2User.getFax()) + .setCellular(cenV2User.getCellular()).setEmail(cenV2User.getEmail()) + .setAddressId(cenV2User.getAddressId()).setAlertMethodCd(cenV2User.getAlertMethodCd()) + .setHrid(cenV2User.getHrid()).setOrgUserId(cenV2User.getOrgUserId()).setOrgCode(cenV2User.getOrgCode()) + .setAddress1(cenV2User.getAddress1()).setAddress2(cenV2User.getAddress2()).setCity(cenV2User.getCity()) + .setState(cenV2User.getState()).setZipCode(cenV2User.getZipCode()).setCountry(cenV2User.getCountry()) + .setOrgManagerUserId(cenV2User.getOrgManagerUserId()).setLocationClli(cenV2User.getLocationClli()) + .setBusinessCountryCode(cenV2User.getBusinessCountryCode()) + .setBusinessCountryName(cenV2User.getBusinessCountryName()).setBusinessUnit(cenV2User.getBusinessUnit()) + .setBusinessUnitName(cenV2User.getBusinessUnitName()).setDepartment(cenV2User.getDepartment()) + .setDepartmentName(cenV2User.getDepartmentName()).setCompanyCode(cenV2User.getCompanyCode()) + .setCompany(cenV2User.getCompany()).setZipCodeSuffix(cenV2User.getZipCodeSuffix()) + .setJobTitle(cenV2User.getJobTitle()).setCommandChain(cenV2User.getCommandChain()) + .setSiloStatus(cenV2User.getSiloStatus()).setCostCenter(cenV2User.getCostCenter()) + .setFinancialLocCode(cenV2User.getFinancialLocCode()).setLoginId(cenV2User.getLoginId()) + .setLoginPwd(cenV2User.getLoginPwd()).setLastLoginDate(cenV2User.getLastLoginDate()) + .setActive(cenV2User.isActive()).setInternal(cenV2User.isInternal()) + .setSelectedProfileId(cenV2User.getSelectedProfileId()).setTimeZoneId(cenV2User.getTimeZoneId()) + .setOnline(cenV2User.isOnline()).setChatId(cenV2User.getChatId()).setUserApps(userApps) + .createCentralUser(); } @Override @@ -3640,20 +3586,6 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic return userRolesAdded; } - @Override - public String encodeFunctionCode(String funCode) { - String encodedString = funCode; - List encodingList = new ArrayList<>(); - encodingList.add(Pattern.compile("/")); - encodingList.add(Pattern.compile("-")); - for (Pattern xssInputPattern : encodingList) { - encodedString = xssInputPattern.matcher(encodedString) - .replaceAll("%" + Hex.encodeHexString(xssInputPattern.toString().getBytes())); - } - encodedString = encodedString.replaceAll("\\*", "%" + Hex.encodeHexString("*".getBytes())); - return encodedString; - } - @Override public void bulkUploadRoleFunc(UploadRoleFunctionExtSystem data, EPApp app) throws Exception { ObjectMapper mapper = new ObjectMapper(); @@ -3662,7 +3594,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic ExternalAccessRolePerms extRolePerms; ExternalAccessPerms extPerms; extPerms = new ExternalAccessPerms(app.getNameSpace() + "." + data.getType(), - encodeFunctionCode(data.getInstance()), data.getAction()); + EcompPortalUtils.encodeFunctionCode(data.getInstance()), data.getAction()); String appNameSpace = ""; if (data.getIsGlobalRolePartnerFunc()) { appNameSpace = epAppService.getApp(1l).getNameSpace(); @@ -3882,4 +3814,5 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic } return roleDescUpdated; } + }