Search in sources :

Example 46 with DbUser

use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.

the class RemoveUserCommand method validate.

@Override
protected boolean validate() {
    // Get the identifier of the user to be removed:
    Guid id = getParameters().getId();
    // Check that the current user isn't trying to remove himself:
    if (getCurrentUser().getId().equals(id)) {
        addValidationMessage(EngineMessage.USER_CANNOT_REMOVE_HIMSELF);
        return false;
    }
    // Check that the user exists in the database:
    DbUser dbUser = dbUserDao.get(id);
    if (dbUser == null) {
        addValidationMessage(EngineMessage.USER_MUST_EXIST_IN_DB);
        return false;
    }
    return true;
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 47 with DbUser

use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.

the class SessionDataContainer method removeSessionImpl.

private void removeSessionImpl(String sessionId, int reason, String message, Object... msgArgs) {
    // Only remove session if there are no running commands for this session
    if (ssoSessionUtils.isSessionInUse(getEngineSessionSeqId(sessionId))) {
        DbUser dbUser = getUser(sessionId, false);
        log.info("Not removing session '{}', session has running commands{}", sessionId, dbUser == null ? "." : String.format(" for user '%s@%s'.", dbUser.getLoginName(), dbUser.getDomain()));
        return;
    }
    /*
         * So we won't need to add profile to tests
         */
    String authzName = null;
    if (getProfile(sessionId) != null) {
        authzName = getProfile(sessionId).getAuthzName();
    }
    AcctUtils.reportRecords(reason, authzName, getPrincipalName(sessionId), message, msgArgs);
    engineSessionDao.remove(getEngineSessionSeqId(sessionId));
    sessionInfoMap.remove(sessionId);
}
Also used : DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 48 with DbUser

use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.

the class TerminateSessionCommand method executeCommand.

@Override
protected void executeCommand() {
    sessionId = sessionDataContainer.getSessionIdBySeqId(getParameters().getTerminatedSessionDbId());
    if (sessionId == null) {
        log.info("Cannot terminate session with database id '{}', it doesn't exist anymore.", getParameters().getTerminatedSessionDbId());
        setSucceeded(false);
        return;
    }
    sourceIp = sessionDataContainer.getSourceIp(sessionId);
    // store terminated user username for audit log
    DbUser terminatedUser = sessionDataContainer.getUser(sessionId, false);
    if (terminatedUser != null) {
        addCustomValue("TerminatedSessionUsername", String.format("%s@%s", terminatedUser.getLoginName(), terminatedUser.getDomain()));
    }
    setReturnValue(backend.logoff(new ActionParametersBase(sessionId)));
}
Also used : ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 49 with DbUser

use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.

the class BaseBackendResource method isFiltered.

/**
 * Indicate whether data retrieval should be filtered according to user permissions.
 *
 * @return true if data should be filtered, otherwise queries are executed as admin.
 */
protected boolean isFiltered() {
    Boolean result = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, FILTER, true, null);
    if (result == null) {
        DbUser user = getCurrent().getUser();
        if (!user.isAdmin()) {
            LocalConfig config = LocalConfig.getInstance();
            result = config.getFilterByDefault();
        } else {
            result = Boolean.FALSE;
        }
    }
    return result;
}
Also used : LocalConfig(org.ovirt.engine.api.restapi.LocalConfig) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 50 with DbUser

use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.

the class AbstractBackendAssignedPermissionsResourceTest method getUserByIdx.

protected DbUser getUserByIdx(int idx) {
    DbUser user = new DbUser();
    user.setId(GUIDS[idx]);
    user.setFirstName(NAMES[idx]);
    user.setLoginName(NAMES[idx]);
    return user;
}
Also used : DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Aggregations

DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)109 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)18 Guid (org.ovirt.engine.core.compat.Guid)18 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)13 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)10 HashSet (java.util.HashSet)9 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)9 HashMap (java.util.HashMap)8 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)8 Collection (java.util.Collection)7 Before (org.junit.Before)7 Permission (org.ovirt.engine.core.common.businessentities.Permission)7 List (java.util.List)5 Map (java.util.Map)5 AttachEntityToTagParameters (org.ovirt.engine.core.common.action.AttachEntityToTagParameters)5 PermissionsOperationsParameters (org.ovirt.engine.core.common.action.PermissionsOperationsParameters)5 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)5 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)5 TagListModel (org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)5