Search in sources :

Example 61 with PermissionSubject

use of org.ovirt.engine.core.bll.utils.PermissionSubject in project ovirt-engine by oVirt.

the class MoveOrCopyTemplateCommand method getPermissionCheckSubjects.

@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
    if (permissionCheckSubject == null) {
        if (imageToDestinationDomainMap == null || imageToDestinationDomainMap.isEmpty()) {
            permissionCheckSubject = super.getPermissionCheckSubjects();
        } else {
            permissionCheckSubject = new ArrayList<>();
            Set<PermissionSubject> permissionSet = new HashSet<>();
            for (Guid storageId : imageToDestinationDomainMap.values()) {
                permissionSet.add(new PermissionSubject(storageId, VdcObjectType.Storage, getActionType().getActionGroup()));
            }
            permissionCheckSubject.addAll(permissionSet);
        }
    }
    return permissionCheckSubject;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) Guid(org.ovirt.engine.core.compat.Guid) HashSet(java.util.HashSet)

Example 62 with PermissionSubject

use of org.ovirt.engine.core.bll.utils.PermissionSubject in project ovirt-engine by oVirt.

the class VmCommand method getPermissionCheckSubjects.

@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
    List<PermissionSubject> permissionList = new ArrayList<>();
    permissionList.add(new PermissionSubject(getParameters().getVmId(), VdcObjectType.VM, getActionType().getActionGroup()));
    return permissionList;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) ArrayList(java.util.ArrayList)

Example 63 with PermissionSubject

use of org.ovirt.engine.core.bll.utils.PermissionSubject in project ovirt-engine by oVirt.

the class VmHandler method getPermissionsNeededToChangeCluster.

public static List<PermissionSubject> getPermissionsNeededToChangeCluster(Guid vmId, Guid clusterId) {
    List<PermissionSubject> permissionList = new ArrayList<>();
    permissionList.add(new PermissionSubject(vmId, VdcObjectType.VM, ActionGroup.EDIT_VM_PROPERTIES));
    permissionList.add(new PermissionSubject(clusterId, VdcObjectType.Cluster, ActionGroup.CREATE_VM));
    return permissionList;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) ArrayList(java.util.ArrayList)

Example 64 with PermissionSubject

use of org.ovirt.engine.core.bll.utils.PermissionSubject in project ovirt-engine by oVirt.

the class RolesCommandBase method getPermissionCheckSubjects.

@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
    List<PermissionSubject> permissionList = new ArrayList<>();
    permissionList.add(new PermissionSubject(getParameters().getRoleId(), VdcObjectType.Role, getActionType().getActionGroup()));
    return permissionList;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) ArrayList(java.util.ArrayList)

Example 65 with PermissionSubject

use of org.ovirt.engine.core.bll.utils.PermissionSubject in project ovirt-engine by oVirt.

the class PermissionsCommandBase method getPermissionCheckSubjects.

// TODO - this code is shared with addPermissionCommand - check if
// addPermission can extend this command
@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
    List<PermissionSubject> permissionList = new ArrayList<>();
    Permission permission = getParameters().getPermission();
    permissionList.add(new PermissionSubject(permission.getObjectId(), permission.getObjectType(), getActionType().getActionGroup()));
    return permissionList;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) ArrayList(java.util.ArrayList) Permission(org.ovirt.engine.core.common.businessentities.Permission)

Aggregations

PermissionSubject (org.ovirt.engine.core.bll.utils.PermissionSubject)71 ArrayList (java.util.ArrayList)47 Guid (org.ovirt.engine.core.compat.Guid)15 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)6 HashSet (java.util.HashSet)5 Test (org.junit.Test)5 VdcObjectType (org.ovirt.engine.core.common.VdcObjectType)5 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 ImagesHandler (org.ovirt.engine.core.bll.storage.disk.image.ImagesHandler)3 ActionGroup (org.ovirt.engine.core.common.businessentities.ActionGroup)3 VM (org.ovirt.engine.core.common.businessentities.VM)3 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)3 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)3 VmNic (org.ovirt.engine.core.common.businessentities.network.VmNic)3 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)3 DiskVmElementDao (org.ovirt.engine.core.dao.DiskVmElementDao)3 Arrays (java.util.Arrays)2