@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 getSystemSession(String trustedClientPassword) throws LoginException { try { return trustedClientService.getSystemSession(trustedClientPassword); } catch (LoginException e) { log.info("Login failed: {}", e.toString()); throw e; } catch (Throwable e) { log.error("Login error", e); //noinspection ThrowableResultOfMethodCallIgnored Throwable rootCause = ExceptionUtils.getRootCause(e); if (rootCause == null) rootCause = e; // send text only to avoid ClassNotFoundException when the client has no dependency to some library throw new LoginException(rootCause.toString()); } }
@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); } }
log.info("Login failed: {}", e.toString());