Search in sources :

Example 11 with VdcObjectType

use of org.ovirt.engine.core.common.VdcObjectType in project ovirt-engine by oVirt.

the class JobRepositoryImpl method getJob.

@Override
public Job getJob(final Guid jobId) {
    Job job = jobDao.get(jobId);
    if (job != null) {
        Map<Guid, VdcObjectType> jobSubjectEntity = jobSubjectEntityDao.getJobSubjectEntityByJobId(jobId);
        job.setJobSubjectEntities(jobSubjectEntity);
    }
    return job;
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) Job(org.ovirt.engine.core.common.job.Job) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType)

Example 12 with VdcObjectType

use of org.ovirt.engine.core.common.VdcObjectType in project ovirt-engine by oVirt.

the class GetPermissionsForObjectQueryTest method testExecuteQueryWithoutDirectOnly.

@Test
public void testExecuteQueryWithoutDirectOnly() {
    VdcObjectType type = RandomUtils.instance().pickRandom(VdcObjectType.values());
    when(getQueryParameters().getVdcObjectType()).thenReturn(type);
    when(permissionDaoMock.getTreeForEntity(objectID, type, UNPRIVILEGED_USER_SESSION_ID, getQueryParameters().isFiltered())).thenReturn(mockedPermissions);
    assertQueryDaoCall(false);
}
Also used : VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) Test(org.junit.Test)

Example 13 with VdcObjectType

use of org.ovirt.engine.core.common.VdcObjectType in project ovirt-engine by oVirt.

the class CommandBase method checkSinglePermission.

public final boolean checkSinglePermission(PermissionSubject permSubject, Collection<String> messages) {
    final Guid objectId = permSubject.getObjectId();
    final VdcObjectType objectType = permSubject.getObjectType();
    final ActionGroup objectActionGroup = permSubject.getActionGroup();
    // if objectId is null we can't check permission
    if (objectId == null) {
        if (log.isDebugEnabled()) {
            log.debug("The object to check is null for action '{}'.", getActionType());
        }
        messages.add(EngineMessage.USER_NOT_AUTHORIZED_TO_PERFORM_ACTION.name());
        return false;
    }
    // Check that an action group is defined for this action;
    if (objectActionGroup == null) {
        if (log.isDebugEnabled()) {
            log.debug("No action group is defined for action '{}'.", getActionType());
        }
        return false;
    }
    // Check the authorization:
    if (!checkUserAuthorization(getCurrentUser().getId(), objectActionGroup, objectId, objectType)) {
        messages.add(permSubject.getMessage().name());
        return false;
    }
    return true;
}
Also used : ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) Guid(org.ovirt.engine.core.compat.Guid) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType)

Aggregations

VdcObjectType (org.ovirt.engine.core.common.VdcObjectType)13 Guid (org.ovirt.engine.core.compat.Guid)7 StepSubjectEntity (org.ovirt.engine.core.common.job.StepSubjectEntity)3 Test (org.junit.Test)2 PermissionSubject (org.ovirt.engine.core.bll.utils.PermissionSubject)2 Job (org.ovirt.engine.core.common.job.Job)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ActionGroup (org.ovirt.engine.core.common.businessentities.ActionGroup)1 SubjectEntity (org.ovirt.engine.core.common.businessentities.SubjectEntity)1 BaseDisk (org.ovirt.engine.core.common.businessentities.storage.BaseDisk)1 Step (org.ovirt.engine.core.common.job.Step)1 GetPermissionsForObjectParameters (org.ovirt.engine.core.common.queries.GetPermissionsForObjectParameters)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)1 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)1 QueryType (org.ovirt.engine.core.common.queries.QueryType)1 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)1