use of com.haulmont.cuba.security.global.NoUserSessionException in project cuba by cuba-platform.
the class FileUploadController method getSession.
protected UserSession getSession(HttpServletRequest request, HttpServletResponse response) {
UUID sessionId;
try {
sessionId = UUID.fromString(request.getParameter("s"));
} catch (Exception e) {
return null;
}
AppContext.setSecurityContext(new SecurityContext(sessionId));
try {
return userSessionService.getUserSession(sessionId);
} catch (NoUserSessionException e) {
return null;
} finally {
AppContext.setSecurityContext(null);
}
}
use of com.haulmont.cuba.security.global.NoUserSessionException in project cuba by cuba-platform.
the class App method onHeartbeat.
/**
* Called from heartbeat request. <br>
* Used for ping middleware session and show session messages
*/
public void onHeartbeat() {
Connection connection = getConnection();
boolean sessionIsAlive = false;
if (connection.isAuthenticated()) {
// Ping middleware session if connected and show messages
log.debug("Ping middleware session");
try {
String message = userSessionService.getMessages();
sessionIsAlive = true;
if (message != null) {
message = message.replace("\n", "<br/>");
getWindowManager().showNotification(message, Frame.NotificationType.ERROR_HTML);
}
} catch (NoUserSessionException ignored) {
// ignore no user session exception
} catch (Exception e) {
log.warn("Exception while session ping", e);
}
}
if (sessionIsAlive) {
events.publish(new SessionHeartbeatEvent(this));
}
}
Aggregations