1 package org.onap.vid.roles;
3 import org.onap.vid.mso.rest.RequestDetails;
9 * Created by Oren on 7/12/17.
11 public class RoleValidator {
13 private List<Role> userRoles;
15 public RoleValidator(List<Role> roles) {
16 this.userRoles = roles;
19 public boolean isSubscriberPermitted(String subscriberName) {
20 for (Role role : userRoles) {
21 if (role.getSubscribeName().equals(subscriberName))
27 public boolean isServicePermitted(String subscriberName, String serviceType) {
28 for (Role role : userRoles) {
29 if (role.getSubscribeName().equals(subscriberName) && role.getServiceType().equals(serviceType))
35 public boolean isMsoRequestValid(RequestDetails mso_request) {
37 String globalSubscriberIdRequested = (String) ((Map) ((Map) mso_request.getAdditionalProperties().get("requestDetails")).get("subscriberInfo")).get("globalSubscriberId");
38 String serviceType = (String) ((Map) ((Map) mso_request.getAdditionalProperties().get("requestDetails")).get("requestParameters")).get("subscriptionServiceType");
39 return isServicePermitted(globalSubscriberIdRequested, serviceType);
40 } catch (Exception e) {
41 //Until we'll get the exact information regarding the tenants and the global customer id, we'll return true on unknown requests to mso
47 public boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName) {
48 for (Role role : userRoles) {
49 if (role.getSubscribeName().equals(globalCustomerId)
50 && role.getServiceType().equals(serviceType)
51 && (role.getTenant() == null || role.getTenant().equalsIgnoreCase(tenantName))) {