Search in sources :

Example 1 with UserSessionEntity

use of com.haulmont.cuba.security.entity.UserSessionEntity in project cuba by cuba-platform.

the class UserSessions method createUserSessionEntity.

protected UserSessionEntity createUserSessionEntity(UserSession session, long since, long lastUsedTs) {
    UserSessionEntity use = metadata.create(UserSessionEntity.class);
    use.setId(session.getId());
    use.setLogin(session.getUser().getLoginLowerCase());
    use.setUserName(session.getUser().getName());
    use.setAddress(session.getAddress());
    use.setClientInfo(session.getClientInfo());
    use.setSince(new Date(since));
    use.setLastUsedTs(new Date(lastUsedTs));
    use.setSystem(session.isSystem());
    return use;
}
Also used : UserSessionEntity(com.haulmont.cuba.security.entity.UserSessionEntity)

Example 2 with UserSessionEntity

use of com.haulmont.cuba.security.entity.UserSessionEntity in project cuba by cuba-platform.

the class SessionMessageWindow method send.

public void send() {
    String text = messageField.getValue();
    Set<UserSessionEntity> sessions = TO_ALL.equals(whomOptionsGroup.getValue()) ? allSessions : selectedSessions;
    if (!sessions.isEmpty() && !StringUtils.isBlank(text)) {
        List<UUID> sessionIds = new ArrayList<>(sessions.size());
        for (UserSessionEntity session : sessions) {
            sessionIds.add(session.getId());
        }
        uss.postMessage(sessionIds, text);
        result = messages.formatMessage(getClass(), "messageWindow.report", sessions.size());
    }
    close();
}
Also used : UserSessionEntity(com.haulmont.cuba.security.entity.UserSessionEntity)

Example 3 with UserSessionEntity

use of com.haulmont.cuba.security.entity.UserSessionEntity in project cuba by cuba-platform.

the class UserSessionsDatasource method loadData.

@Override
protected void loadData(Map<String, Object> params) {
    TimeSource timeSource = AppBeans.get(TimeSource.NAME);
    updateTs = timeSource.currentTimestamp();
    data.clear();
    if (!AppBeans.get(Security.class).isEntityOpPermitted(UserSessionEntity.class, EntityOp.READ))
        return;
    UserSessionService uss = AppBeans.get(UserSessionService.NAME);
    Collection<UserSessionEntity> userSessionList = uss.loadUserSessionEntities(createFilter(params));
    for (UserSessionEntity entity : userSessionList) {
        if (!sessionFilter.test(entity)) {
            continue;
        }
        data.put(entity.getId(), entity);
    }
}
Also used : UserSessionService(com.haulmont.cuba.security.app.UserSessionService) TimeSource(com.haulmont.cuba.core.global.TimeSource) UserSessionEntity(com.haulmont.cuba.security.entity.UserSessionEntity)

Aggregations

UserSessionEntity (com.haulmont.cuba.security.entity.UserSessionEntity)3 TimeSource (com.haulmont.cuba.core.global.TimeSource)1 UserSessionService (com.haulmont.cuba.security.app.UserSessionService)1