Search in sources :

Example 26 with DbUser

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

the class AttachUserToTagCommand method executeCommand.

@Override
protected void executeCommand() {
    TagsUserMap map;
    if (getTagId() != null) {
        for (Guid userGuid : getUserList()) {
            DbUser user = dbUserDao.get(userGuid);
            if (tagDao.getTagUserByTagIdAndByuserId(getTagId(), userGuid) == null) {
                map = new TagsUserMap(getTagId(), userGuid);
                tagDao.attachUserToTag(map);
                noActionDone = false;
                if (user != null) {
                    appendCustomCommaSeparatedValue("AttachUsersNames", user.getLoginName());
                }
            } else {
                if (user != null) {
                    appendCustomCommaSeparatedValue("AttachUsersNamesExists", user.getLoginName());
                }
            }
        }
        setSucceeded(true);
    }
}
Also used : TagsUserMap(org.ovirt.engine.core.common.businessentities.TagsUserMap) Guid(org.ovirt.engine.core.compat.Guid) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 27 with DbUser

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

the class AttachUserToVmFromPoolAndRunCommand method initPoolUser.

private void initPoolUser() {
    DbUser user = getDbUser();
    if (user != null && user.getId() == null) {
        user.setId(Guid.newGuid());
        dbUserDao.save(user);
    }
}
Also used : DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 28 with DbUser

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

the class SsoPostLoginFilter method doFilter.

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    log.debug("Entered SsoPostLoginFilter");
    HttpServletRequest req = (HttpServletRequest) request;
    try {
        String engineSessionId = (String) req.getAttribute(SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY);
        if (StringUtils.isEmpty(engineSessionId) && req.getSession(false) != null) {
            engineSessionId = (String) req.getSession(false).getAttribute(SessionConstants.HTTP_SESSION_ENGINE_SESSION_ID_KEY);
        }
        if (StringUtils.isNotEmpty(engineSessionId)) {
            InitialContext ctx = new InitialContext();
            try {
                String ssoToken = (String) runQuery(QueryType.GetEngineSessionIdToken, engineSessionId, ctx);
                Object loggedInUser = runQuery(QueryType.GetUserBySessionId, engineSessionId, ctx);
                if (loggedInUser != null) {
                    log.debug("Adding userInfo to session");
                    req.getSession(true).setAttribute(ATTR_USER_INFO, getUserInfoObject((DbUser) loggedInUser, ssoToken));
                } else {
                    log.info("Failed to find logged user by sessionId");
                }
                chain.doFilter(request, response);
            } finally {
                ctx.close();
            }
        } else {
            log.warn("Missing sessionId in either request or session scope. " + "Please configure SSO properly with SsoPostLoginServlet.");
        }
    } catch (Exception ex) {
        log.error("Unable to get token for engine session {}", ex.getMessage());
        log.debug("Exception", ex);
    }
    log.debug("Exiting SsoPostLoginFilter");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) InitialContext(javax.naming.InitialContext) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 29 with DbUser

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

the class DbUserDaoTest method testSaveOrUpdateExisting.

@Test
public void testSaveOrUpdateExisting() {
    int sizeBeforeSave = dao.getAll().size();
    existingUser.setFirstName("changedname");
    existingUser.setLastName("changedsurname");
    dao.saveOrUpdate(existingUser);
    int sizeAfterSave = dao.getAll().size();
    DbUser result = dao.get(existingUser.getId());
    assertEquals(existingUser, result);
    assertEquals(0, sizeAfterSave - sizeBeforeSave);
}
Also used : DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) Test(org.junit.Test)

Example 30 with DbUser

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

the class DbUserDaoTest method testGet.

/**
 * Ensures that retrieving an object by id works as expected.
 */
@Test
public void testGet() {
    DbUser result = dao.get(existingUser.getId());
    assertNotNull(result);
    assertEquals(existingUser, result);
}
Also used : DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) Test(org.junit.Test)

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