Search in sources :

Example 31 with PermissionSubject

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

the class AddPermissionCommand method getPermissionCheckSubjects.

@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
    Permission permission = getParameters().getPermission();
    List<PermissionSubject> permissionsSubject = new ArrayList<>();
    permissionsSubject.add(new PermissionSubject(permission.getObjectId(), permission.getObjectType(), getActionType().getActionGroup()));
    initUserAndGroupData();
    // user from the directory service
    if ((getParameters().getUser() != null && dbUser == null) || (getParameters().getGroup() != null && dbGroup == null)) {
        permissionsSubject.add(new PermissionSubject(permission.getObjectId(), permission.getObjectType(), ActionGroup.ADD_USERS_AND_GROUPS_FROM_DIRECTORY));
    }
    return permissionsSubject;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) Permission(org.ovirt.engine.core.common.businessentities.Permission) ArrayList(java.util.ArrayList)

Example 32 with PermissionSubject

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

the class AttachStorageDomainToPoolCommand method getPermissionCheckSubjects.

@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
    List<PermissionSubject> permissionList = super.getPermissionCheckSubjects();
    permissionList.add(new PermissionSubject(getStoragePoolId(), VdcObjectType.StoragePool, getActionType().getActionGroup()));
    return permissionList;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject)

Example 33 with PermissionSubject

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

the class AddCpuProfileCommandTest method getPermissionCheckSubjectsTest.

@Test
public void getPermissionCheckSubjectsTest() {
    List<PermissionSubject> permissions = addCpuProfileCommand.getPermissionCheckSubjects();
    assertEquals(1, permissions.size());
    PermissionSubject permissionSubject = permissions.get(0);
    assertEquals(CLUSTER_ID, permissionSubject.getObjectId());
    assertEquals(VdcObjectType.Cluster, permissionSubject.getObjectType());
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 34 with PermissionSubject

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

the class ClusterPermissionsFinder method findPermissionCheckSubjects.

public List<PermissionSubject> findPermissionCheckSubjects(Guid clusterId, ActionType actionType) {
    List<PermissionSubject> permissionList = new ArrayList<>();
    permissionList.add(new PermissionSubject(clusterId, VdcObjectType.Cluster, actionType.getActionGroup()));
    return permissionList;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) ArrayList(java.util.ArrayList)

Example 35 with PermissionSubject

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

the class CommandBase method getJobMessageProperties.

/**
 * Returns the properties which used to populate the job message. The default properties resolving will use
 * {@link #getPermissionCheckSubjects()} to get the entities associated with the command. The property key is the
 * type of the entity by {@code VdcObjectType.name()} and the value is the name of the entity or the entity
 * {@code Guid} in case non-resolvable entity name.
 *
 * @return A map which contains the data to be used to populate the {@code Job} description.
 */
public Map<String, String> getJobMessageProperties() {
    jobProperties = new HashMap<>();
    List<PermissionSubject> subjects = getPermissionCheckSubjects();
    if (!subjects.isEmpty()) {
        VdcObjectType entityType;
        Guid entityId;
        String value;
        for (PermissionSubject permSubject : subjects) {
            entityType = permSubject.getObjectType();
            entityId = permSubject.getObjectId();
            if (entityType != null && entityId != null) {
                value = entityDao.getEntityNameByIdAndType(entityId, entityType);
                if (value == null) {
                    value = entityId.toString();
                }
                jobProperties.put(entityType.name().toLowerCase(), value);
            }
        }
    }
    return jobProperties;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) Guid(org.ovirt.engine.core.compat.Guid) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType)

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