From abb69004c16707e1dafa7a75050e8c026de9fe31 Mon Sep 17 00:00:00 2001 From: Ittay Stern Date: Mon, 27 Jan 2020 19:09:19 +0200 Subject: RoleValidatorsComposer composite several RoleValidators together Issue-ID: VID-758 Change-Id: I7bd5a4ebc8a0a451716af09cc76e6db6cd5362f7 Signed-off-by: Ittay Stern --- .../java/org/onap/vid/roles/RoleValidatorsComposer.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorsComposer.kt (limited to 'vid-app-common/src/main/java/org') diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorsComposer.kt b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorsComposer.kt new file mode 100644 index 000000000..873622389 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorsComposer.kt @@ -0,0 +1,16 @@ +package org.onap.vid.roles + +class RoleValidatorsComposer(private vararg val roleValidators: RoleValidator) : RoleValidator { + + constructor(roleValidators: Collection) : this(*roleValidators.toTypedArray()) + + override fun isServicePermitted(p: WithPermissionProperties): Boolean = + roleValidators.any { it.isServicePermitted(p) } + + override fun isSubscriberPermitted(subscriberName: String?): Boolean = + roleValidators.any { it.isSubscriberPermitted(subscriberName) } + + override fun isTenantPermitted(globalCustomerId: String?, serviceType: String?, tenantName: String?): Boolean = + roleValidators.any { it.isTenantPermitted(globalCustomerId, serviceType, tenantName) } + +} -- cgit 1.2.3-korg