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)); }
@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")); } } }
@Override @Nonnull public AuthenticationDetails authenticate(Credentials credentials) throws LoginException { checkNotNullArgument(credentials, "credentials should not be null"); SecurityContext previousSecurityContext = AppContext.getSecurityContext(); AppContext.setSecurityContext(new SecurityContext(serverSession)); try (Transaction tx = persistence.createTransaction()) { AuthenticationDetails authenticationDetails = authenticateInternal(credentials); tx.commit(); userSessionManager.clearPermissionsOnUser(authenticationDetails.getSession()); return authenticationDetails; } finally { AppContext.setSecurityContext(previousSecurityContext); } }
@Override public UserSession loginTrusted(String login, String password, Locale locale, Map<String, Object> params) throws LoginException { checkRemoteClientTrusted(); TrustedClientCredentials credentials = new TrustedClientCredentials(login, password, locale, params); RemoteClientInfo remoteClientInfo = RemoteClientInfo.get(); if (remoteClientInfo != null) { credentials.setClientIpAddress(remoteClientInfo.getAddress()); } else { credentials.setClientIpAddress(null); } copyParamsToCredentials(params, credentials); return authenticationService.login(credentials).getSession(); }
@Override public void login(Credentials credentials) throws LoginException { backgroundWorker.checkUIAccess(); preprocessCredentials(credentials); AuthenticationDetails authenticationDetails = loginInternal(credentials); ClientUserSession clientUserSession = createSession(authenticationDetails.getSession()); if (credentials instanceof AnonymousUserCredentials) { clientUserSession.setAuthenticated(false); } else { clientUserSession.setAuthenticated(true); } UserSession previousSession = getSession(); setSessionInternal(clientUserSession); publishUserConnectedEvent(credentials); fireStateChangeListeners(previousSession, clientUserSession); }