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