@Override public void logout() { authenticationManager.logout(); }
@Override public UserSession substituteUser(User substitutedUser) { return authenticationManager.substituteUser(substitutedUser); }
@Override public UserSession loginSystem(String login) throws LoginException { return authenticationManager.login(new SystemUserCredentials(login)).getSession(); }
@Nonnull @Override public AuthenticationDetails authenticate(Credentials credentials) throws LoginException { try { preprocessCredentials(credentials); //noinspection UnnecessaryLocalVariable AuthenticationDetails authenticationDetails = authenticationManager.authenticate(credentials); return authenticationDetails; } catch (InternalAuthenticationException ie) { log.error("Authentication error", ie); throw ie; } catch (LoginException e) { log.info("Authentication failed: {}", e.toString()); throw e; } catch (Throwable e) { log.error("Authentication error", e); throw wrapInLoginException(e); } }
@Override public UserSession login(String login, String password, Locale locale, Map<String, Object> params) throws LoginException { return authenticationManager.login(new LoginPasswordCredentials(login, password, locale, params)).getSession(); }
@Override public User authenticate(String login, String password, Locale locale, Map<String, Object> params) throws LoginException { LoginPasswordCredentials credentials = new LoginPasswordCredentials(login, password, locale, params); copyParamsToCredentials(params, credentials); AuthenticationDetails sessionDetails = authenticationManager.authenticate(credentials); return sessionDetails.getSession().getUser(); }
protected UserSession loginAnonymous() throws LoginException { return authenticationManager.login(new AnonymousUserCredentials()).getSession(); }
@Override public void logout() { try { UserSession session = userSessionSource.getUserSession(); if (session != null && session.isSystem()) { throw new RuntimeException("Logout of system session from client is not permitted"); } authenticationManager.logout(); userSessionLog.updateSessionLogRecord(session, SessionAction.LOGOUT); } catch (NoUserSessionException e) { log.debug("An attempt to perform logout for expired session", e); throw e; } catch (Throwable e) { log.error("Logout error", e); throw new RuntimeException("Logout error: " + e.toString()); } }
@Nonnull @Override public UserSession substituteUser(User substitutedUser) { try { UserSession currentSession = userSessionSource.getUserSession(); SessionLogEntry logEntry = userSessionLog.updateSessionLogRecord(currentSession, SessionAction.SUBSTITUTION); UserSession substitutionSession = authenticationManager.substituteUser(substitutedUser); Map<String, Object> logParams = emptyMap(); if (logEntry != null && logEntry.getClientType() != null) { logParams = ParamsMap.of(ClientType.class.getName(), logEntry.getClientType().name()); } userSessionLog.createSessionLogRecord(substitutionSession, SessionAction.LOGIN, currentSession, logParams); return substitutionSession; } catch (Throwable e) { log.error("Substitution error", e); throw new RuntimeException("Substitution error: " + e.toString()); } }
@Override public UserSession loginTrusted(String login, String password, Locale locale, Map<String, Object> params) throws LoginException { TrustedClientCredentials credentials = new TrustedClientCredentials(login, password, locale, params); copyParamsToCredentials(params, credentials); return authenticationManager.login(credentials).getSession(); }
AppContext.setSecurityContext(new SecurityContext(session)); try { authenticationManager.logout();
@Override public UserSession loginByRememberMe(String login, String rememberMeToken, Locale locale, Map<String, Object> params) throws LoginException { RememberMeCredentials credentials = new RememberMeCredentials(login, rememberMeToken, locale, params); copyParamsToCredentials(params, credentials); return authenticationManager.login(credentials).getSession(); }
@Nonnull @Override public AuthenticationDetails login(Credentials credentials) throws LoginException { try { preprocessCredentials(credentials); //noinspection UnnecessaryLocalVariable AuthenticationDetails details = authenticationManager.login(credentials); Map<String, Object> logParams = emptyMap(); if (credentials instanceof AbstractClientCredentials) { ClientType clientType = ((AbstractClientCredentials) credentials).getClientType(); if (clientType != null) { logParams = ParamsMap.of(ClientType.class.getName(), clientType.name()); } } userSessionLog.createSessionLogRecord(details.getSession(), SessionAction.LOGIN, logParams); return details; } catch (InternalAuthenticationException ie) { log.error("Login error", ie); throw ie; } catch (LoginException e) { log.info("Login failed: {}", e.toString()); throw e; } catch (Throwable e) { log.error("Login error", e); throw wrapInLoginException(e); } }
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) {