X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-BE-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportalapp%2Fportal%2Fcontroller%2FUserRolesController.java;h=b3d64dbca00f87f9469a5542b7f67cd61371c7f9;hb=3bd3ecd644964416972ecc3e6e6eb7e5e1fb132d;hp=852e2bb83bc9309322071eb7650a571f74d87584;hpb=a084a8b0c35ddc1ea3a3159043b30f43f221c787;p=portal.git diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java index 852e2bb8..b3d64dbc 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java @@ -2,7 +2,7 @@ * ============LICENSE_START========================================== * ONAP Portal * =================================================================== - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * =================================================================== * * Unless otherwise specified, all software contained herein is licensed @@ -75,6 +75,7 @@ import org.onap.portalsdk.core.domain.AuditLog; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.restful.domain.EcompRole; import org.onap.portalsdk.core.service.AuditService; +import org.onap.portalsdk.core.service.DataAccessService; import org.onap.portalsdk.core.util.SystemProperties; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; @@ -103,6 +104,8 @@ public class UserRolesController extends EPRestrictedBaseController { private ApplicationsRestClientService applicationsRestClientService; @Autowired private AuditService auditService; + @Autowired + private DataAccessService dataAccessService; private static final String FAILURE = "failure"; @@ -288,6 +291,18 @@ public class UserRolesController extends EPRestrictedBaseController { EcompPortalUtils.setBadPermissions(user, response, "getAppRolesForUser"); feErrorString = EcompPortalUtils.getFEErrorString(true, response.getStatus()); } else { + try { + if(orgUserId!=null) { + EPUser localUser = getUserInfo(orgUserId,applicationsRestClientService); + if(localUser !=null) { + if(localUser.isSystemUser()) { + isSystemUser = true; + } + } + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "isSystemUser update failed", e); + } if ((!isSystemUser && EcompPortalUtils.legitimateUserId(orgUserId)) || isSystemUser) { result = userRolesService.getAppRolesForUser(appid, orgUserId, extRequestValue, user); logger.debug(EELFLoggerDelegate.debugLogger, "getAppRolesForUser: result {}, appId {}", result, appid); @@ -572,4 +587,23 @@ public class UserRolesController extends EPRestrictedBaseController { } return isSuperAdmin; } + + /** + * + * @param userId + * @param app + * @param applicationsRestClientService + * @return EPUser + * @throws HTTPException + */ + protected EPUser getUserInfo(String userId, ApplicationsRestClientService applicationsRestClientService) + throws HTTPException { + @SuppressWarnings("unchecked") + List userList = (List) dataAccessService + .executeQuery("from EPUser where orgUserId='" + userId + "'", null); + if (userList != null && !userList.isEmpty()) + return userList.get(0); + else + return null; + } }