1 package org.openecomp.vid.roles;
3 import org.openecomp.vid.mso.rest.RequestDetails;
9 * Created by Oren on 7/12/17.
11 public class RoleValidator {
13 //Disable roles until AAF integration finishes
14 private boolean disableRoles = true;
15 private List<Role> userRoles;
17 public RoleValidator(List<Role> roles) {
18 this.userRoles = roles;
21 public boolean isSubscriberPermitted(String subscriberName) {
22 if(this.disableRoles) return true;
24 for (Role role : userRoles) {
25 if (role.getSubscribeName().equals(subscriberName))
31 public boolean isServicePermitted(String subscriberName, String serviceType) {
32 if(this.disableRoles) return true;
34 for (Role role : userRoles) {
35 if (role.getSubscribeName().equals(subscriberName) && role.getServiceType().equals(serviceType))
41 public boolean isMsoRequestValid(RequestDetails mso_request) {
42 if(this.disableRoles) return true;
45 String globalSubscriberIdRequested = (String) ((Map) ((Map) mso_request.getAdditionalProperties().get("requestDetails")).get("subscriberInfo")).get("globalSubscriberId");
46 String serviceType = (String) ((Map) ((Map) mso_request.getAdditionalProperties().get("requestDetails")).get("requestParameters")).get("subscriptionServiceType");
47 return isServicePermitted(globalSubscriberIdRequested, serviceType);
48 } catch (Exception e) {
49 //Until we'll get the exact information regarding the tenants and the global customer id, we'll return true on unknown requests to mso
55 public boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenant) {
56 if(this.disableRoles) return true;
58 for (Role role : userRoles) {
59 if (role.getSubscribeName().equals(globalCustomerId)
60 && role.getServiceType().equals(serviceType)
61 && (role.getTenant() == null || role.getTenant().equals(tenant))) {