diff options
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/roles')
5 files changed, 22 insertions, 20 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/AlwaysValidRoleValidator.java b/vid-app-common/src/main/java/org/onap/vid/roles/AlwaysValidRoleValidator.java index 4e5340fc2..e12f5403f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/roles/AlwaysValidRoleValidator.java +++ b/vid-app-common/src/main/java/org/onap/vid/roles/AlwaysValidRoleValidator.java @@ -32,7 +32,7 @@ public class AlwaysValidRoleValidator implements RoleValidator { } @Override - public boolean isServicePermitted(String subscriberName, String serviceType) { + public boolean isServicePermitted(WithPermissionProperties permissionProperties) { return true; } diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/PermissionProperties.kt b/vid-app-common/src/main/java/org/onap/vid/roles/PermissionProperties.kt new file mode 100644 index 000000000..f62b98aef --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/roles/PermissionProperties.kt @@ -0,0 +1,17 @@ +package org.onap.vid.roles + +import org.onap.vid.aai.ServiceSubscription + + +interface WithPermissionProperties { + val subscriberId: String? + val serviceType: String? +} + +data class PermissionProperties( + override val subscriberId: String, + override val serviceType: String +) : WithPermissionProperties { + constructor(serviceSubscription: ServiceSubscription, subscriberId: String) : this(subscriberId, serviceSubscription.serviceType) +} + diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java index f0ee26b0b..4ad168c4f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java +++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java @@ -40,7 +40,7 @@ public interface RoleValidator { boolean isSubscriberPermitted(String subscriberName); - boolean isServicePermitted(String subscriberName, String serviceType); + boolean isServicePermitted(WithPermissionProperties serviceInstanceSearchResult); boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName); } diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorByOwningEntity.java b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorByOwningEntity.java index e615c1302..726567cc6 100644 --- a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorByOwningEntity.java +++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorByOwningEntity.java @@ -33,7 +33,7 @@ public class RoleValidatorByOwningEntity implements RoleValidator{ } @Override - public boolean isServicePermitted(String subscriberName, String serviceType) { + public boolean isServicePermitted(WithPermissionProperties permissionProperties) { return false; } diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorBySubscriberAndServiceType.java b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorBySubscriberAndServiceType.java index 244610c89..95d8a1627 100644 --- a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorBySubscriberAndServiceType.java +++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidatorBySubscriberAndServiceType.java @@ -21,8 +21,6 @@ package org.onap.vid.roles; import java.util.List; -import java.util.Map; -import org.onap.vid.mso.rest.RequestDetails; public class RoleValidatorBySubscriberAndServiceType implements RoleValidator { @@ -43,9 +41,9 @@ public class RoleValidatorBySubscriberAndServiceType implements RoleValidator { } @Override - public boolean isServicePermitted(String subscriberName, String serviceType) { + public boolean isServicePermitted(WithPermissionProperties permissionProperties) { for (Role role : userRoles) { - if (role.getSubscribeName().equals(subscriberName) && role.getServiceType().equals(serviceType)) { + if (role.getSubscribeName().equals(permissionProperties.getSubscriberId()) && role.getServiceType().equals(permissionProperties.getServiceType())) { return true; } } @@ -64,17 +62,4 @@ public class RoleValidatorBySubscriberAndServiceType implements RoleValidator { return false; } - boolean isMsoRequestValid(RequestDetails msoRequest) { - try { - String globalSubscriberIdRequested = (String) ((Map) ((Map) msoRequest.getAdditionalProperties() - .get("requestDetails")).get("subscriberInfo")).get("globalSubscriberId"); - String serviceType = (String) ((Map) ((Map) msoRequest.getAdditionalProperties().get("requestDetails")) - .get("requestParameters")).get("subscriptionServiceType"); - return isServicePermitted(globalSubscriberIdRequested, serviceType); - } catch (Exception e) { - //Until we'll get the exact information regarding the tenants and the global customer id, we'll return true on unknown requests to mso - return true; - } - } - } |