@Override @Nullable public SessionLogEntry updateSessionLogRecord(UserSession userSession, @Nullable SessionAction action) { Preconditions.checkNotNullArgument(userSession); if (!shouldLogSession(userSession)) { return null; } return authentication.withSystemUser(() -> { SessionLogEntry sessionLogEntry = getLastSessionLogRecord(userSession.getId()); if (sessionLogEntry != null) { if (userSession.getClientInfo() != null) { sessionLogEntry.setClientInfo(userSession.getClientInfo()); } if (userSession.getAddress() != null) { sessionLogEntry.setAddress(userSession.getAddress()); } if (action != null) { sessionLogEntry.setLastAction(action); if (action != SessionAction.LOGIN) { sessionLogEntry.setFinishedTs(timeSource.currentTimestamp()); } } return dataManager.commit(sessionLogEntry); } return null; }); }
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; }
sessionLogEntry.setClientInfo(userSession.getClientInfo()); sessionLogEntry.setStartedTs(timeSource.currentTimestamp()); sessionLogEntry.setServer(serverInfoAPI.getServerId()); sessionLogEntry.setClientType(ClientType.valueOf((String) params.get(SessionParams.CLIENT_TYPE.getId()))); sessionLogEntry.setClientInfo(userSession.getClientInfo()); sessionLogEntry.setAddress(userSession.getAddress());
@Override public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) { SecurityContext securityContext = AppContext.getSecurityContext(); CubaRemoteInvocation remoteInvocation = new CubaRemoteInvocation(methodInvocation, securityContext == null ? null : securityContext.getSessionId()); if (securityContext != null) { UserSession session = securityContext.getSession(); if (session instanceof ClientBasedSession && ((ClientBasedSession) session).hasRequestScopedInfo()) { remoteInvocation.setLocale(session.getLocale() != null ? session.getLocale().toLanguageTag() : null); remoteInvocation.setTimeZone(session.getTimeZone()); remoteInvocation.setAddress(session.getAddress()); remoteInvocation.setClientInfo(session.getClientInfo()); } } return remoteInvocation; } }
invocation.setTimeZone(session.getTimeZone()); invocation.setAddress(session.getAddress()); invocation.setClientInfo(session.getClientInfo());
invocation.setTimeZone(session.getTimeZone()); invocation.setAddress(session.getAddress()); invocation.setClientInfo(session.getClientInfo());