@Override public void setClientInfo(String clientInfo) { super.setClientInfo(clientInfo); if (authenticated) { UserSessionService uss = AppBeans.get(UserSessionService.NAME); uss.setSessionClientInfo(id, clientInfo); } }
@Override public void setSessionClientInfo(UUID sessionId, String clientInfo) { UserSession userSession = userSessions.getNN(sessionId); checkSession(userSession); userSession.setClientInfo(clientInfo); userSessions.propagate(sessionId); }
protected void setClientSessionParams(AbstractClientCredentials clientCredentials, UserSession userSession) { userSession.setClientInfo(clientCredentials.getClientInfo()); if (clientCredentials.getHostName() != null) { StringBuilder addressBuilder = new StringBuilder(); addressBuilder.append(clientCredentials.getHostName()); if (clientCredentials.getIpAddress() != null) { addressBuilder.append(" (").append(clientCredentials.getIpAddress()).append(")"); } userSession.setAddress(addressBuilder.toString()); } else { userSession.setAddress(clientCredentials.getIpAddress()); } } }
try { session = authenticationManager.login(new SystemUserCredentials(login)).getSession(); session.setClientInfo("System authentication"); } catch (LoginException e) { throw new RuntimeException("Unable to perform system login", e);
@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); }
@Override public AuthenticationDetails authenticate(Credentials credentials) throws LoginException { AnonymousUserCredentials anonymous = (AnonymousUserCredentials) credentials; String login = serverConfig.getAnonymousLogin(); Locale credentialsLocale = anonymous.getLocale() == null ? messages.getTools().trimLocale(messages.getTools().getDefaultLocale()) : anonymous.getLocale(); User user = loadUser(login); if (user == null) { throw new LoginException(getInvalidCredentialsMessage(login, credentialsLocale)); } Locale userLocale = getUserLocale(anonymous, user); UUID anonymousSessionId = globalConfig.getAnonymousSessionId(); UserSession session = createSession(anonymous, user, userLocale, anonymousSessionId); session.setClientInfo("System anonymous session"); return new SimpleAuthenticationDetails(session); }