use of com.haulmont.cuba.security.app.UserSessionService in project cuba by cuba-platform.
the class ClientUserSession method setTimeZone.
@Override
public void setTimeZone(TimeZone timeZone) {
super.setTimeZone(timeZone);
if (authenticated) {
UserSessionService uss = AppBeans.get(UserSessionService.NAME);
uss.setSessionTimeZone(id, timeZone);
}
}
use of com.haulmont.cuba.security.app.UserSessionService in project cuba by cuba-platform.
the class ClientUserSession method setClientInfo.
@Override
public void setClientInfo(String clientInfo) {
super.setClientInfo(clientInfo);
if (authenticated) {
UserSessionService uss = AppBeans.get(UserSessionService.NAME);
uss.setSessionClientInfo(id, clientInfo);
}
}
use of com.haulmont.cuba.security.app.UserSessionService in project cuba by cuba-platform.
the class SessionMessagesNotifier method syncMessages.
protected void syncMessages() {
Connection connection = App.getInstance().getConnection();
if (connection.isConnected()) {
log.trace("Check session messages");
asyncMessageLoader = new SwingWorker<String, Void>() {
@Override
protected String doInBackground() throws Exception {
try {
UserSessionService uss = AppBeans.get(UserSessionService.NAME);
return uss.getMessages();
} catch (NoUserSessionException e) {
log.warn("Unable to get messages for session, user session not found");
} catch (Exception e) {
log.warn("Session messages exception: " + e.toString());
}
return null;
}
@Override
protected void done() {
try {
if (!isCancelled()) {
processServerMessage(get());
}
} catch (InterruptedException | ExecutionException ignored) {
// do nothing
} finally {
asyncMessageLoader = null;
}
}
};
asyncMessageLoader.execute();
}
}
use of com.haulmont.cuba.security.app.UserSessionService in project cuba by cuba-platform.
the class SecurityContextHandlerInterceptor method preHandle.
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// filter resource requests
if (ClassUtils.isAssignableValue(ResourceHttpRequestHandler.class, handler)) {
return true;
}
PortalSecurityContext portalSecurityContext;
HttpSession httpSession = request.getSession();
Connection connection = (Connection) httpSession.getAttribute(Connection.NAME);
if (connection == null || connection.getSession() == null || !connection.isConnected()) {
connection = AppBeans.get(Connection.NAME);
connection.login(request.getLocale(), request.getRemoteAddr(), request.getHeader("User-Agent"));
httpSession.setAttribute(Connection.NAME, connection);
portalSecurityContext = new PortalSecurityContext(connection.getSession());
AppContext.setSecurityContext(portalSecurityContext);
} else {
PortalSession session = connection.getSession();
portalSecurityContext = new PortalSecurityContext(session);
AppContext.setSecurityContext(portalSecurityContext);
// ping only authenticated sessions
if (session != null && session.isAuthenticated()) {
UserSessionService userSessionSource = AppBeans.get(UserSessionService.NAME);
try {
userSessionSource.getMessages();
} catch (NoUserSessionException e) {
httpSession.invalidate();
response.sendRedirect(request.getRequestURI());
return false;
}
}
}
App app = new App(connection, request, response);
portalSecurityContext.setPortalApp(app);
return true;
}
Aggregations