public UserSession getUserSession() { return authenticationDetails.getSession(); }
public UserSession getUserSession() { return authenticationDetails.getSession(); }
@Nullable public UserSession getUserSession() { return authenticationDetails != null ? authenticationDetails.getSession() : null; }
@Nullable public UserSession getUserSession() { return authenticationDetails != null ? authenticationDetails.getSession() : null; }
protected void setSessionAttributes(Credentials credentials, AuthenticationDetails authenticationDetails) { if (credentials instanceof SessionAttributesProvider) { Map<String, Serializable> sessionAttributes = ((SessionAttributesProvider) credentials).getSessionAttributes(); if (sessionAttributes != null) { UserSession session = authenticationDetails.getSession(); for (Map.Entry<String, Serializable> attribute : sessionAttributes.entrySet()) { session.setAttribute(attribute.getKey(), attribute.getValue()); } } } }
@Override public UserSession loginSystem(String login) throws LoginException { return authenticationManager.login(new SystemUserCredentials(login)).getSession(); }
@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(); }
protected UserSession loginAnonymous() throws LoginException { return authenticationManager.login(new AnonymousUserCredentials()).getSession(); }
@Override public UserSession login(String login, String password, Locale locale, Map<String, Object> params) throws LoginException { LoginPasswordCredentials credentials = new LoginPasswordCredentials(login, password, locale, params); copyParamsToCredentials(params, credentials); return authenticationService.login(credentials).getSession(); }
@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(); }
protected void setTimeZone(Credentials credentials, AuthenticationDetails authenticationDetails) { if (credentials instanceof TimeZoneProvider) { TimeZone timeZone = ((TimeZoneProvider) credentials).getTimeZone(); UserSession session = authenticationDetails.getSession(); if (Boolean.TRUE.equals(session.getUser().getTimeZoneAuto())) { session.setTimeZone(timeZone); } } }
@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 authenticationService.login(credentials).getSession(); }
@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(); }
protected void storeSession(Credentials credentials, AuthenticationDetails authenticationDetails) { if (credentials instanceof SyncSessionCredentials && ((SyncSessionCredentials) credentials).isSyncNewUserSessionReplication()) { boolean saved = clusterManager.getSyncSendingForCurrentThread(); clusterManager.setSyncSendingForCurrentThread(true); try { userSessions.add(authenticationDetails.getSession()); } finally { clusterManager.setSyncSendingForCurrentThread(saved); } } else { userSessions.add(authenticationDetails.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 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)); }
@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); } }
try { AbstractClientCredentials credentials = new LoginPasswordCredentials(username, password, locale); UserSession userSession = authenticationService.login(credentials).getSession();
session = authenticationManager.login(new SystemUserCredentials(login)).getSession(); session.setClientInfo("System authentication"); } catch (LoginException e) {
@Override public void check(Credentials credentials, AuthenticationDetails authenticationDetails) throws LoginException { if (credentials instanceof AbstractClientCredentials) { AbstractClientCredentials clientCredentials = (AbstractClientCredentials) credentials; if (clientCredentials.isCheckClientPermissions() && clientCredentials.getClientType() == ClientType.REST_API && !authenticationDetails.getSession().isSpecificPermitted("cuba.restApi.enabled")) { throw new RestApiAccessDeniedException(messages.getMessage(MSG_PACK, "LoginException.restApiAccessDenied")); } } }