use of com.haulmont.cuba.client.ClientUserSession in project cuba by cuba-platform.
the class Connection method login.
public void login(String login, String password, Locale locale) throws LoginException {
UserSession userSession = doLogin(login, password, locale, getLoginParams());
ClientUserSession clientUserSession = new ClientUserSession(userSession);
clientUserSession.setAuthenticated(true);
session = clientUserSession;
AppContext.setSecurityContext(new SecurityContext(session));
log.info("Logged in: {}", session);
updateSessionClientInfo();
connected = true;
fireConnectionListeners();
}
use of com.haulmont.cuba.client.ClientUserSession in project cuba by cuba-platform.
the class AppUI method refresh.
@Override
protected void refresh(VaadinRequest request) {
super.refresh(request);
boolean sessionIsAlive = true;
Connection connection = app.getConnection();
if (connection.isAuthenticated()) {
// Ping middleware session if connected
log.debug("Ping middleware session");
try {
UserSession session = connection.getSession();
if (session instanceof ClientUserSession && ((ClientUserSession) session).isAuthenticated()) {
userSessionService.getUserSession(session.getId());
}
} catch (Exception e) {
sessionIsAlive = false;
app.exceptionHandlers.handle(new com.vaadin.server.ErrorEvent(e));
}
if (sessionIsAlive) {
events.publish(new SessionHeartbeatEvent(app));
}
}
if (sessionIsAlive) {
events.publish(new UIRefreshEvent(this));
}
}
use of com.haulmont.cuba.client.ClientUserSession in project cuba by cuba-platform.
the class ConnectionImpl method substituteUser.
@Override
public void substituteUser(User substitutedUser) {
UserSession previousSession = getSession();
UserSession session = authenticationService.substituteUser(substitutedUser);
ClientUserSession clientUserSession = createSession(session);
clientUserSession.setAuthenticated(true);
setSessionInternal(clientUserSession);
publishUserSessionSubstitutedEvent(previousSession, clientUserSession);
fireSubstitutionListeners();
}
use of com.haulmont.cuba.client.ClientUserSession in project cuba by cuba-platform.
the class ConnectionImpl method logout.
@Override
public void logout() {
backgroundWorker.checkUIAccess();
ClientUserSession session = getSessionInternal();
if (session == null) {
throw new IllegalStateException("There is no active session");
}
if (!session.isAuthenticated()) {
throw new IllegalStateException("Active session is not authenticated");
}
if (session.isAuthenticated()) {
authenticationService.logout();
}
publishUserSessionFinishedEvent(session);
UserSession previousSession = getSession();
setSessionInternal(null);
removeListeners(UserSubstitutionListener.class);
publishDisconnectedEvent(previousSession);
fireStateChangeListeners(previousSession, null);
}
use of com.haulmont.cuba.client.ClientUserSession in project cuba by cuba-platform.
the class ConnectionImpl method login.
@Override
public void login(Credentials credentials) throws LoginException {
backgroundWorker.checkUIAccess();
preprocessCredentials(credentials);
AuthenticationDetails authenticationDetails = loginInternal(credentials);
ClientUserSession clientUserSession = createSession(authenticationDetails.getSession());
if (credentials instanceof AnonymousUserCredentials) {
clientUserSession.setAuthenticated(false);
} else {
clientUserSession.setAuthenticated(true);
}
UserSession previousSession = getSession();
setSessionInternal(clientUserSession);
publishUserConnectedEvent(credentials);
fireStateChangeListeners(previousSession, clientUserSession);
}
Aggregations