@Override public UserSession loginSystem(String login) throws LoginException { return authenticationManager.login(new SystemUserCredentials(login)).getSession(); }
@Override public AuthenticationDetails authenticate(Credentials credentials) throws LoginException { SystemUserCredentials systemLogin = (SystemUserCredentials) credentials; String login = systemLogin.getLogin(); Locale credentialsLocale = systemLogin.getLocale() == null ? messages.getTools().getDefaultLocale() : systemLogin.getLocale(); User user = loadUser(login); if (user == null) { throw new LoginException(getInvalidCredentialsMessage(login, credentialsLocale)); } Locale userLocale = getUserLocale(systemLogin, user); UserSession session = userSessionManager.createSession(user, userLocale, true); return new SimpleAuthenticationDetails(session); }
protected void setSecurityContext(ScheduledTask task, @Nullable UserSession userSession) throws LoginException { if (userSession == null) { UUID sessionId = userSessionIds.get(task.getUserName()); userSession = sessionId == null ? null : userSessions.getAndRefresh(sessionId); if (userSession == null) { userSession = authenticationManager.login(new SystemUserCredentials(task.getUserName())).getSession(); userSessionIds.put(task.getUserName(), userSession.getId()); } } AppContext.setSecurityContext(new SecurityContext(userSession)); }
session = authenticationManager.login(new SystemUserCredentials(login)).getSession(); session.setClientInfo("System authentication"); } catch (LoginException e) {