in cloud-vmware-server/src/main/java/jetbrains/buildServer/clouds/vmware/connector/VMWareApiConnectorImpl.java [899:938]
public <T extends ManagedEntity> boolean hasPrivilegeOnResource(@NotNull final String entityId,
@NotNull final Class<T> instanceType,
@NotNull final String permission) throws VmwareCheckedCloudException {
final Pair<T, Datacenter> pair = findEntityByIdNameOld(entityId, instanceType);
if (pair.getFirst() == null){
return true;
}
final Set<Integer> rolesSet = new HashSet<>();
final int[] role = pair.getFirst().getEffectiveRole();
if (role == null) {
return true; // don't perform the check
}
for(int roleId : role){
rolesSet.add(roleId);
}
final AuthorizationManager authorizationManager = myServiceInstance.getAuthorizationManager();
if (authorizationManager == null)
return true; // don't perform the check
final AuthorizationRole[] roleList = authorizationManager.getRoleList();
if (roleList == null)
return true; // don't perform the check
for (AuthorizationRole authRole : roleList) {
if (!rolesSet.contains(authRole.getRoleId())) {
continue;
}
for (String p : authRole.getPrivilege()) {
if (p.equalsIgnoreCase(permission)) {
return true;
}
}
}
// can't add
return false;
}