Source:
protected void executeCommand() { final AuthenticationProfile profile = AuthenticationProfileRepository.getInstance() .getProfile(getParameters().getProfileName()); sourceIp = getParameters().getSourceIp(); if (profile == null) { setSucceeded(false); } else { final DbUser user = buildUser(getParameters(), profile.getAuthzName()); boolean isAdmin = !roleDao.getAnyAdminRoleForUserAndGroups(user.getId(), StringUtils.join(user.getGroupIds(), ",")).isEmpty(); user.setAdmin(isAdmin); setCurrentUser(user); setUserName(String.format("%s@%s", getCurrentUser().getLoginName(), getCurrentUser().getDomain())); int maxSessions = EngineLocalConfig.getInstance().getMaxUserSessions(); int currentNumSessions = sessionDataContainer.getNumUserSessions(user); if (maxSessions != -1 && currentNumSessions == maxSessions) { setSucceeded(false); String err = String.format("user %s has reached the maximum number of sessions allowed (%d)", user.getLoginName(), maxSessions); log.error(err); throw new EngineException(EngineError.MAX_NUM_OF_SESSIONS_REACHED, err); } else if (getParameters().isAdminRequired() && !isAdmin) { setSucceeded(false); } else if (permissionDao.getEntityPermissionsForUserAndGroups(user.getId(), StringUtils.join(user.getGroupIds(), ","), ActionGroup.LOGIN, BOTTOM_OBJECT_ID, VdcObjectType.Bottom, true) == null) { setSucceeded(false); } else { String engineSessionId = sessionDataContainer.generateEngineSessionId(); sessionDataContainer.setSourceIp(engineSessionId, getParameters().getSourceIp()); sessionDataContainer.setUser(engineSessionId, user); sessionDataContainer.refresh(engineSessionId); sessionDataContainer.setProfile(engineSessionId, profile); sessionDataContainer.setPrincipalName(engineSessionId, getParameters().getPrincipalName()); sessionDataContainer.setSsoAccessToken(engineSessionId, getParameters().getSsoToken()); sessionDataContainer.setSsoOvirtAppApiScope(engineSessionId, getParameters().getAppScope()); getReturnValue().setActionReturnValue(engineSessionId); setSucceeded(true); sessionId = engineSessionId; } } }

Target:
protected void executeCommand() { final AuthenticationProfile profile = AuthenticationProfileRepository.getInstance() .getProfile(getParameters().getProfileName()); sourceIp = getParameters().getSourceIp(); if (profile == null) { setSucceeded(false); } else { final DbUser user = buildUser(getParameters(), profile.getAuthzName()); boolean isAdmin = !roleDao.getAnyAdminRoleForUserAndGroups(user.getId(), StringUtils.join(user.getGroupIds(), ",")).isEmpty(); user.setAdmin(isAdmin); setCurrentUser(user); setUserName(String.format("%s@%s", getCurrentUser().getLoginName(), getCurrentUser().getDomain())); int maxSessions = EngineLocalConfig.getInstance().getInteger("ENGINE_MAX_USER_SESSIONS"); long currentNumSessions = sessionDataContainer.getNumUserSessions(user); if (maxSessions != MAX_ALLOWED_SESSIONS && currentNumSessions >= maxSessions) { setSucceeded(false); } else if (getParameters().isAdminRequired() && !isAdmin) { setSucceeded(false); } else if (permissionDao.getEntityPermissionsForUserAndGroups(user.getId(), StringUtils.join(user.getGroupIds(), ","), ActionGroup.LOGIN, BOTTOM_OBJECT_ID, VdcObjectType.Bottom, true) == null) { setSucceeded(false); } else { String engineSessionId = sessionDataContainer.generateEngineSessionId(); sessionDataContainer.setSourceIp(engineSessionId, getParameters().getSourceIp()); sessionDataContainer.setUser(engineSessionId, user); sessionDataContainer.refresh(engineSessionId); sessionDataContainer.setProfile(engineSessionId, profile); sessionDataContainer.setPrincipalName(engineSessionId, getParameters().getPrincipalName()); sessionDataContainer.setSsoAccessToken(engineSessionId, getParameters().getSsoToken()); sessionDataContainer.setSsoOvirtAppApiScope(engineSessionId, getParameters().getAppScope()); getReturnValue().setActionReturnValue(engineSessionId); setSucceeded(true); sessionId = engineSessionId; } } }