use of com.haulmont.cuba.security.auth.AnonymousUserCredentials in project cuba by cuba-platform.
the class AnonymousAuthenticationProvider method authenticate.
@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);
}
Aggregations