protected boolean shouldLogSession(UserSession userSession) { return globalConfig.getUserSessionLogEnabled() && !userSession.isSystem(); } }
@Override public void init(Map<String, Object> params) { enableBtn.setCaption(globalConfig.getUserSessionLogEnabled() ? getMessage("disableLogging") : getMessage("enableLogging")); }
/** * Set <code>finishedTs</code> to all sessions that were interrupted by server reboot */ protected void closeDeadSessionsOnStartup() { if (!globalConfig.getUserSessionLogEnabled()) { return; } if (clusterManager.isMaster()) { authentication.withSystemUser(() -> { LoadContext<SessionLogEntry> lc = LoadContext.create(SessionLogEntry.class).setView(SessionLogEntry.DEFAULT_VIEW) .setQuery(createQuery("select e from sec$SessionLogEntry e where e.finishedTs is null")); List<SessionLogEntry> sessionLogEntries = dataManager.loadList(lc); CommitContext cc = new CommitContext(); Set<UUID> activeSessionsIds = userSessionsAPI.getUserSessionsStream() .map(UserSession::getId) .collect(Collectors.toSet()); for (SessionLogEntry entry : sessionLogEntries) { if (activeSessionsIds.contains(entry.getSessionId())) { continue; // do not touch active session records } entry.setFinishedTs(timeSource.currentTimestamp()); entry.setLastAction(SessionAction.EXPIRATION); cc.addInstanceToCommit(entry); } dataManager.commit(cc); log.info("Dead session records have been closed"); return null; }); } }
public void enableLogging() { if (globalConfig.getUserSessionLogEnabled()) { showOptionDialog(getMessage("dialogs.Confirmation"), getMessage("confirmDisable"), MessageType.CONFIRMATION, new Action[] { new DialogAction(DialogAction.Type.YES, true).withHandler(actionPerformedEvent -> { globalConfig.setUserSessionLogEnabled(false); enableBtn.setCaption(getMessage("enableLogging")); }), new DialogAction(DialogAction.Type.NO) }); } else { globalConfig.setUserSessionLogEnabled(true); enableBtn.setCaption(getMessage("disableLogging")); } } }