@Override public void setLocale(Locale locale) { super.setLocale(locale); if (authenticated) { UserSessionService uss = AppBeans.get(UserSessionService.NAME); uss.setSessionLocale(id, locale); } }
@Override public void setSessionLocale(UUID sessionId, Locale locale) { UserSession userSession = userSessions.getNN(sessionId); checkSession(userSession); userSession.setLocale(locale); userSessions.propagate(sessionId); }
@SuppressWarnings("RedundantThrows") @Nullable @Override public AuthenticationDetails login(Credentials credentials) throws LoginException { if (!(credentials instanceof AnonymousUserCredentials)) { throw new ClassCastException("Credentials cannot be cast to AnonymousUserCredentials"); } AnonymousUserCredentials anonymousCredentials = (AnonymousUserCredentials) credentials; UserSession anonymousSession = anonymousSessionHolder.getAnonymousSession(); Locale credentialsLocale = anonymousCredentials.getLocale(); if (credentialsLocale != null) { anonymousSession.setLocale(credentialsLocale); } if (anonymousCredentials.getTimeZone() != null && Boolean.TRUE.equals(anonymousSession.getUser().getTimeZoneAuto())) { anonymousSession.setTimeZone(anonymousCredentials.getTimeZone()); } anonymousSession.setAddress(anonymousCredentials.getIpAddress()); anonymousSession.setClientInfo(anonymousCredentials.getClientInfo()); if (anonymousCredentials.getSessionAttributes() != null) { for (Map.Entry<String, Serializable> attribute : anonymousCredentials.getSessionAttributes().entrySet()) { anonymousSession.setAttribute(attribute.getKey(), attribute.getValue()); } } return new SimpleAuthenticationDetails(anonymousSession); }
public void setLocale(Locale locale) { UserSession session = getConnection().getSession(); if (session != null) { session.setLocale(locale); } AppUI currentUi = AppUI.getCurrent(); // it can be null if we handle request in a custom RequestHandler if (currentUi != null) { currentUi.setLocale(locale); currentUi.updateClientSystemMessages(locale); } VaadinSession.getCurrent().setLocale(locale); for (AppUI ui : getAppUIs()) { if (ui != currentUi) { ui.accessSynchronously(() -> { ui.setLocale(locale); ui.updateClientSystemMessages(locale); }); } } }