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;
}
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);
}
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)));
}
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;
}
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;
}
Aggregations