From c0cbcef18427ec1d0edfb872385f128352487464 Mon Sep 17 00:00:00 2001 From: Alexey Sandler Date: Wed, 29 Jan 2020 16:02:03 +0200 Subject: RoleValidatorFactory respects owning-entity feature flag Add FLAG_2006_USER_PERMISSIONS_BY_OWNING_ENTITY flag to response with correct type of RoleValidator Issue-ID: VID-758 Change-Id: I464fc1a155e72fedbe3f15d9745c80817db22391 Signed-off-by: Alexey Sandler --- .../java/org/onap/vid/roles/RoleValidatorFactory.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'vid-app-common/src/main/java') diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorFactory.java b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorFactory.java index 12865401d..f4334b1be 100644 --- a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorFactory.java +++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorFactory.java @@ -25,6 +25,7 @@ package org.onap.vid.roles; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.onap.portalsdk.core.util.SystemProperties; +import org.onap.vid.properties.Features; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.togglz.core.manager.FeatureManager; @@ -46,8 +47,18 @@ public class RoleValidatorFactory { } public RoleValidator by(List roles, boolean disableRoles) { - return disableRoles - ? new AlwaysValidRoleValidator() - : new RoleValidatorBySubscriberAndServiceType(roles); + + if(disableRoles) { + return new AlwaysValidRoleValidator(); + } + else if (featureManager.isActive(Features.FLAG_2006_USER_PERMISSIONS_BY_OWNING_ENTITY)){ + return new RoleValidatorsComposer( + new RoleValidatorBySubscriberAndServiceType(roles), + new RoleValidatorByOwningEntity() + ); + } + else { + return new RoleValidatorBySubscriberAndServiceType(roles); + } } } -- cgit 1.2.3-korg