Gets the most current session for given user.<p>

@param user CmsUser to get session for
@return CmsSessionInfo or null if no session is available for user
4350
private CmsSessionInfo getSessionForUser(CmsUser user) {

        List<CmsSessionInfo> sessions = OpenCms.getSessionManager().getSessionInfos(user.getId());

        if (sessions.isEmpty()) {
            return null;
        }

        CmsSessionInfo currentSession = sessions.get(0);
        for (CmsSessionInfo session : sessions) {
            if (session.getTimeUpdated() > currentSession.getTimeUpdated()) {
                currentSession = session;
            }
        }
        return currentSession;
    }
1192390
protected List<CmsUser> getUsers() throws CmsException {

        return CmsPrincipal.filterCoreUsers(OpenCms.getOrgUnitManager().getUsers(getCms(), "", true));
    }
447200
public Principal getUserPrincipal()
    {
        if (_userPrincipal == __NO_USER) return null;

        if (_userPrincipal == __NOT_CHECKED)
        {
            _userPrincipal = __NO_USER;

            // Try a lazy authentication
            HttpContext context = getHttpResponse().getHttpContext();
            if (context != null)
            {
                Authenticator auth = context.getAuthenticator();
                UserRealm realm = context.getRealm();
                if (realm != null && auth != null)
                {
                    try
                    {
                        // TODO - should not need to recalculate this!
                        String pathInContext = getPath().substring(
                                context.getContextPath().length());
                        auth.authenticate(realm, pathInContext, this, null);
                    }
                    catch (Exception e)
                    {
                        LogSupport.ignore(log, e);
                    }
                }
            }

            if (_userPrincipal == __NO_USER) return null;
        }
        return _userPrincipal;
    }
115298
public String getDbWorkUser() {

        String user = getExtProperty(CmsDbPoolV11.KEY_DATABASE_POOL + '.' + getPool() + ".user");
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(user)) {
            return getDbCreateUser();
        }
        return user;
    }
1153418
public String getUserLastModifiedName(CmsObject cms) {

        try {
            return CmsPrincipal.readPrincipalIncludingHistory(cms, getUserLastModified()).getName();
        } catch (CmsException e) {
            return getUserLastModified().toString();
        }
    }
200026
public I_CmsSessionStorageProvider getSessionStorageProvider() {

        if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_sessionStorageProvider)) {
            return new CmsDefaultSessionStorageProvider();
        }
        try {
            I_CmsSessionStorageProvider sessionCacheProvider = (I_CmsSessionStorageProvider)Class.forName(
                m_sessionStorageProvider).newInstance();
            if (CmsLog.INIT.isInfoEnabled()) {
                CmsLog.INIT.info(
                    Messages.get().getBundle().key(
                        Messages.INIT_SESSION_STORAGEPROVIDER_SUCCESS_1,
                        m_sessionStorageProvider));
            }
            return sessionCacheProvider;
        } catch (Throwable t) {
            LOG.error(
                Messages.get().getBundle().key(
                    Messages.LOG_INIT_SESSION_STORAGEPROVIDER_FAILURE_1,
                    m_sessionStorageProvider),
                t);
            return new CmsDefaultSessionStorageProvider();
        }
    }
242156
public Session getSysSession(String schema, User user) {

        sysSession.currentSchema =
            sysSession.database.schemaManager.getSchemaHsqlName(schema);
        sysSession.isProcessingScript = false;
        sysSession.isProcessingLog    = false;

        sysSession.setUser(user);

        return sysSession;
    }
1206350
private List<CmsUserAddInfoBean> createAddInfoList(CmsUser user) {

        List<CmsUserAddInfoBean> addInfoList = new ArrayList<CmsUserAddInfoBean>();
        // add beans
        Iterator<CmsWorkplaceUserInfoBlock> itBlocks = OpenCms.getWorkplaceManager().getUserInfoManager().getBlocks().iterator();
        while (itBlocks.hasNext()) {
            CmsWorkplaceUserInfoBlock block = itBlocks.next();
            Iterator<CmsWorkplaceUserInfoEntry> itEntries = block.getEntries().iterator();
            while (itEntries.hasNext()) {
                CmsWorkplaceUserInfoEntry entry = itEntries.next();
                Object value = user.getAdditionalInfo(entry.getKey());
                if (value == null) {
                    value = "";
                }
                addInfoList.add(new CmsUserAddInfoBean(entry.getKey(), value.toString(), entry.getClassType()));
            }
        }
        return addInfoList;
    }
30078
public static CmsADESessionCache getCache(HttpServletRequest request, CmsObject cms) {

        CmsADESessionCache cache = (CmsADESessionCache)request.getSession().getAttribute(
            CmsADESessionCache.SESSION_ATTR_ADE_CACHE);
        if (cache == null) {
            cache = new CmsADESessionCache(cms, request);
            request.getSession().setAttribute(CmsADESessionCache.SESSION_ATTR_ADE_CACHE, cache);
        }
        return cache;
    }
363254
public static IndexedContainer getRoleContainerForUser(CmsObject cms, CmsUser user, String captionPropertyName) {

        IndexedContainer result = new IndexedContainer();
        result.addContainerProperty(captionPropertyName, String.class, "");
        try {
            List<CmsRole> roles = OpenCms.getRoleManager().getRoles(cms, user.getOuFqn(), false);
            CmsRole.applySystemRoleOrder(roles);
            for (CmsRole role : roles) {
                Item item = result.addItem(role);
                item.getItemProperty(captionPropertyName).setValue(role.getDisplayName(cms, A_CmsUI.get().getLocale()));
            }
        } catch (CmsException e) {
            LOG.error("Unabel to read roles for user", e);
        }
        return result;
    }
670373
private CmsADESessionCache getSessionCache() {

        if (m_sessionCache == null) {
            m_sessionCache = CmsADESessionCache.getCache(getRequest(), getCmsObject());
        }
        return m_sessionCache;
    }
1237623
public AccessLevel getAccessForPrincipal(String user) {
        AccessLevel result = AccessLevel.NOTHING;
        for (Access item : getAccessList()) {
            if (item.isNegativeRule()) {
                if (!item.getPrincipal().contains(user)) {
                    result = item.getLevel();
                }
            } else {
                if (item.getPrincipal().contains(user)) {
                    result = item.getLevel();
                }
            }
        }
        return result;
    }
824430
public List<CmsUser> searchUsers(CmsObject cms, CmsUserSearchParameters params) throws CmsException {

        return m_securityManager.searchUsers(cms.getRequestContext(), params);
    }
368660
public String getUserCreatedName(CmsObject cms) {

        try {
            return CmsPrincipal.readPrincipalIncludingHistory(cms, getUserCreated()).getName();
        } catch (CmsException e) {
            return getUserCreated().toString();
        }
    }
787077
public boolean canLockBecauseOfInactivity(CmsObject cms, CmsUser user) {

        return !user.isManaged()
            && !user.isWebuser()
            && !OpenCms.getDefaultUsers().isDefaultUser(user.getName())
            && !OpenCms.getRoleManager().hasRole(cms, user.getName(), CmsRole.ROOT_ADMIN);
    }
638975
public CmsUser readUser(CmsRequestContext context, CmsUUID id) throws CmsException {

        CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
        CmsUser result = null;
        try {
            result = m_driverManager.readUser(dbc, id);
        } catch (Exception e) {
            dbc.report(null, Messages.get().container(Messages.ERR_READ_USER_FOR_ID_1, id.toString()), e);
        } finally {
            dbc.clear();
        }
        return result;
    }
649412
private boolean isAllowedUser(CmsUser user) throws CmsException {

        if (user.getOuFqn().startsWith(m_cms.getRequestContext().getOuFqn())) {
            return true;
        }
        return OpenCms.getRoleManager().getRolesOfUser(m_cms, user.getName(), m_ou, true, true, false).size() > 0;
    }