From 7f5c9a6291638ad0f81facc0913d8240f253a702 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Fri, 30 Nov 2018 13:50:20 +0100 Subject: [PATCH] SONARCLOUD-213 rename classes related to auth by credentials - rename "Authenticator" to "Authentication" - add a bit of javadoc - highlight the relations BasicAuthentication |- UserTokenAuthentication |- CredentialsAuthentication |- CredentialsExternalAuthentication |- CredentialsLocalAuthentication --- .../authentication/AuthenticationModule.java | 10 +++--- ...nticator.java => BasicAuthentication.java} | 27 ++++++++++------ ...or.java => CredentialsAuthentication.java} | 18 +++++++---- ...=> CredentialsExternalAuthentication.java} | 9 ++++-- ...va => CredentialsLocalAuthentication.java} | 8 +++-- ...or.java => HttpHeadersAuthentication.java} | 10 ++++-- .../RequestAuthenticatorImpl.java | 16 +++++----- .../server/authentication/ws/LoginAction.java | 12 +++---- .../authentication/ws/ValidateAction.java | 10 +++--- .../org/sonar/server/user/UserUpdater.java | 6 ++-- .../server/user/ws/ChangePasswordAction.java | 6 ++-- ...ator.java => UserTokenAuthentication.java} | 7 ++-- .../server/usertoken/UserTokenModule.java | 2 +- ...Test.java => BasicAuthenticationTest.java} | 30 ++++++++--------- ...ava => CredentialsAuthenticationTest.java} | 32 ++++++++----------- ...redentialsExternalAuthenticationTest.java} | 4 +-- ...> CredentialsLocalAuthenticationTest.java} | 8 ++--- ...ava => HttpHeadersAuthenticationTest.java} | 6 ++-- .../RequestAuthenticatorImplTest.java | 22 ++++++------- .../UserIdentityAuthenticatorImplTest.java | 2 +- .../authentication/ws/LoginActionTest.java | 14 ++++---- .../authentication/ws/ValidateActionTest.java | 18 +++++------ .../server/user/UserUpdaterCreateTest.java | 6 ++-- .../user/UserUpdaterReactivateTest.java | 6 ++-- .../server/user/UserUpdaterUpdateTest.java | 4 +-- .../user/ws/ChangePasswordActionTest.java | 4 +-- .../server/user/ws/CreateActionTest.java | 4 +-- .../server/user/ws/UpdateActionTest.java | 4 +-- .../org/sonar/server/user/ws/UsersWsTest.java | 4 +-- ....java => UserTokenAuthenticationTest.java} | 4 +-- 30 files changed, 165 insertions(+), 148 deletions(-) rename server/sonar-server/src/main/java/org/sonar/server/authentication/{BasicAuthenticator.java => BasicAuthentication.java} (83%) rename server/sonar-server/src/main/java/org/sonar/server/authentication/{CredentialsAuthenticator.java => CredentialsAuthentication.java} (79%) rename server/sonar-server/src/main/java/org/sonar/server/authentication/{RealmAuthenticator.java => CredentialsExternalAuthentication.java} (95%) rename server/sonar-server/src/main/java/org/sonar/server/authentication/{LocalAuthentication.java => CredentialsLocalAuthentication.java} (97%) rename server/sonar-server/src/main/java/org/sonar/server/authentication/{HttpHeadersAuthenticator.java => HttpHeadersAuthentication.java} (96%) rename server/sonar-server/src/main/java/org/sonar/server/usertoken/{UserTokenAuthenticator.java => UserTokenAuthentication.java} (89%) rename server/sonar-server/src/test/java/org/sonar/server/authentication/{BasicAuthenticatorTest.java => BasicAuthenticationTest.java} (82%) rename server/sonar-server/src/test/java/org/sonar/server/authentication/{CredentialsAuthenticatorTest.java => CredentialsAuthenticationTest.java} (80%) rename server/sonar-server/src/test/java/org/sonar/server/authentication/{RealmAuthenticatorTest.java => CredentialsExternalAuthenticationTest.java} (98%) rename server/sonar-server/src/test/java/org/sonar/server/authentication/{LocalAuthenticationTest.java => CredentialsLocalAuthenticationTest.java} (95%) rename server/sonar-server/src/test/java/org/sonar/server/authentication/{HttpHeadersAuthenticatorTest.java => HttpHeadersAuthenticationTest.java} (98%) rename server/sonar-server/src/test/java/org/sonar/server/usertoken/{UserTokenAuthenticatorTest.java => UserTokenAuthenticationTest.java} (93%) diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/AuthenticationModule.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/AuthenticationModule.java index 91a527ce855..ccdf9bbfea8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/authentication/AuthenticationModule.java +++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/AuthenticationModule.java @@ -46,12 +46,12 @@ public class AuthenticationModule extends Module { OAuth2AuthenticationParametersImpl.class, LoginAction.class, LogoutAction.class, - CredentialsAuthenticator.class, - LocalAuthentication.class, - RealmAuthenticator.class, - BasicAuthenticator.class, + CredentialsAuthentication.class, + CredentialsLocalAuthentication.class, + CredentialsExternalAuthentication.class, + BasicAuthentication.class, ValidateAction.class, - HttpHeadersAuthenticator.class, + HttpHeadersAuthentication.class, RequestAuthenticatorImpl.class); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/BasicAuthenticator.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/BasicAuthentication.java similarity index 83% rename from server/sonar-server/src/main/java/org/sonar/server/authentication/BasicAuthenticator.java rename to server/sonar-server/src/main/java/org/sonar/server/authentication/BasicAuthentication.java index d029585a138..28dc21f8573 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/authentication/BasicAuthenticator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/BasicAuthentication.java @@ -27,14 +27,21 @@ import org.sonar.db.DbSession; import org.sonar.db.user.UserDto; import org.sonar.server.authentication.event.AuthenticationEvent; import org.sonar.server.authentication.event.AuthenticationException; -import org.sonar.server.usertoken.UserTokenAuthenticator; +import org.sonar.server.usertoken.UserTokenAuthentication; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Locale.ENGLISH; import static org.sonar.server.authentication.event.AuthenticationEvent.Method; import static org.sonar.server.authentication.event.AuthenticationEvent.Source; -public class BasicAuthenticator { +/** + * HTTP BASIC authentication relying on tuple {login, password}. + * Login can represent a user access token. + * + * @see CredentialsAuthentication for standard login/password authentication + * @see UserTokenAuthentication for user access token + */ +public class BasicAuthentication { private static final Base64.Decoder BASE64_DECODER = Base64.getDecoder(); @@ -42,15 +49,15 @@ public class BasicAuthenticator { private static final String BASIC_AUTHORIZATION = "BASIC"; private final DbClient dbClient; - private final CredentialsAuthenticator credentialsAuthenticator; - private final UserTokenAuthenticator userTokenAuthenticator; + private final CredentialsAuthentication credentialsAuthentication; + private final UserTokenAuthentication userTokenAuthentication; private final AuthenticationEvent authenticationEvent; - public BasicAuthenticator(DbClient dbClient, CredentialsAuthenticator credentialsAuthenticator, - UserTokenAuthenticator userTokenAuthenticator, AuthenticationEvent authenticationEvent) { + public BasicAuthentication(DbClient dbClient, CredentialsAuthentication credentialsAuthentication, + UserTokenAuthentication userTokenAuthentication, AuthenticationEvent authenticationEvent) { this.dbClient = dbClient; - this.credentialsAuthenticator = credentialsAuthenticator; - this.userTokenAuthenticator = userTokenAuthenticator; + this.credentialsAuthentication = credentialsAuthentication; + this.userTokenAuthentication = userTokenAuthentication; this.authenticationEvent = authenticationEvent; } @@ -98,12 +105,12 @@ public class BasicAuthenticator { authenticationEvent.loginSuccess(request, userDto.getLogin(), Source.local(Method.BASIC_TOKEN)); return userDto; } else { - return credentialsAuthenticator.authenticate(credentials, request, Method.BASIC); + return credentialsAuthentication.authenticate(credentials, request, Method.BASIC); } } private UserDto authenticateFromUserToken(String token) { - Optional authenticatedUserUuid = userTokenAuthenticator.authenticate(token); + Optional authenticatedUserUuid = userTokenAuthentication.authenticate(token); if (!authenticatedUserUuid.isPresent()) { throw AuthenticationException.newBuilder() .setSource(Source.local(Method.BASIC_TOKEN)) diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/CredentialsAuthenticator.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/CredentialsAuthentication.java similarity index 79% rename from server/sonar-server/src/main/java/org/sonar/server/authentication/CredentialsAuthenticator.java rename to server/sonar-server/src/main/java/org/sonar/server/authentication/CredentialsAuthentication.java index 81b496a22cc..2d9d6667bef 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/authentication/CredentialsAuthenticator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/CredentialsAuthentication.java @@ -30,18 +30,22 @@ import org.sonar.server.authentication.event.AuthenticationException; import static org.sonar.server.authentication.event.AuthenticationEvent.Method; import static org.sonar.server.authentication.event.AuthenticationEvent.Source; -public class CredentialsAuthenticator { +/** + * Authentication based on the tuple {login, password}. Validation can be + * delegated to an external system, e.g. LDAP. + */ +public class CredentialsAuthentication { private final DbClient dbClient; - private final RealmAuthenticator externalAuthenticator; private final AuthenticationEvent authenticationEvent; - private final LocalAuthentication localAuthentication; + private final CredentialsExternalAuthentication externalAuthentication; + private final CredentialsLocalAuthentication localAuthentication; - public CredentialsAuthenticator(DbClient dbClient, RealmAuthenticator externalAuthenticator, AuthenticationEvent authenticationEvent, - LocalAuthentication localAuthentication) { + public CredentialsAuthentication(DbClient dbClient, AuthenticationEvent authenticationEvent, + CredentialsExternalAuthentication externalAuthentication, CredentialsLocalAuthentication localAuthentication) { this.dbClient = dbClient; - this.externalAuthenticator = externalAuthenticator; this.authenticationEvent = authenticationEvent; + this.externalAuthentication = externalAuthentication; this.localAuthentication = localAuthentication; } @@ -59,7 +63,7 @@ public class CredentialsAuthenticator { authenticationEvent.loginSuccess(request, localUser.getLogin(), Source.local(method)); return localUser; } - Optional externalUser = externalAuthenticator.authenticate(credentials, request, method); + Optional externalUser = externalAuthentication.authenticate(credentials, request, method); if (externalUser.isPresent()) { return externalUser.get(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/RealmAuthenticator.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/CredentialsExternalAuthentication.java similarity index 95% rename from server/sonar-server/src/main/java/org/sonar/server/authentication/RealmAuthenticator.java rename to server/sonar-server/src/main/java/org/sonar/server/authentication/CredentialsExternalAuthentication.java index b58f19381f6..0f5edacfe63 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/authentication/RealmAuthenticator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/CredentialsExternalAuthentication.java @@ -49,9 +49,12 @@ import static org.apache.commons.lang.StringUtils.isEmpty; import static org.apache.commons.lang.StringUtils.trimToNull; import static org.sonar.server.user.ExternalIdentity.SQ_AUTHORITY; -public class RealmAuthenticator implements Startable { +/** + * Delegates the validation of credentials to an external system, e.g. LDAP. + */ +public class CredentialsExternalAuthentication implements Startable { - private static final Logger LOG = Loggers.get(RealmAuthenticator.class); + private static final Logger LOG = Loggers.get(CredentialsExternalAuthentication.class); private final Configuration config; private final SecurityRealmFactory securityRealmFactory; @@ -63,7 +66,7 @@ public class RealmAuthenticator implements Startable { private ExternalUsersProvider externalUsersProvider; private ExternalGroupsProvider externalGroupsProvider; - public RealmAuthenticator(Configuration config, SecurityRealmFactory securityRealmFactory, + public CredentialsExternalAuthentication(Configuration config, SecurityRealmFactory securityRealmFactory, UserIdentityAuthenticator userIdentityAuthenticator, AuthenticationEvent authenticationEvent) { this.config = config; this.securityRealmFactory = securityRealmFactory; diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/LocalAuthentication.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/CredentialsLocalAuthentication.java similarity index 97% rename from server/sonar-server/src/main/java/org/sonar/server/authentication/LocalAuthentication.java rename to server/sonar-server/src/main/java/org/sonar/server/authentication/CredentialsLocalAuthentication.java index 73fef18b235..e28a278d4c9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/authentication/LocalAuthentication.java +++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/CredentialsLocalAuthentication.java @@ -35,16 +35,17 @@ import static java.lang.String.format; import static java.util.Objects.requireNonNull; /** - * This class is responsible of handling local authentication + * Validates the password of a "local" user (password is stored in + * database). */ -public class LocalAuthentication { +public class CredentialsLocalAuthentication { private final DbClient dbClient; private static final SecureRandom SECURE_RANDOM = new SecureRandom(); // The default hash method that must be used is BCRYPT private static final HashMethod DEFAULT = HashMethod.BCRYPT; - public LocalAuthentication(DbClient dbClient) { + public CredentialsLocalAuthentication(DbClient dbClient) { this.dbClient = dbClient; } @@ -139,6 +140,7 @@ public class LocalAuthentication { public interface HashFunction { AuthenticationResult checkCredentials(UserDto user, String password); + void storeHashPassword(UserDto user, String password); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/HttpHeadersAuthenticator.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/HttpHeadersAuthentication.java similarity index 96% rename from server/sonar-server/src/main/java/org/sonar/server/authentication/HttpHeadersAuthenticator.java rename to server/sonar-server/src/main/java/org/sonar/server/authentication/HttpHeadersAuthentication.java index d2eb32b0009..11ddd8377fb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/authentication/HttpHeadersAuthenticator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/HttpHeadersAuthentication.java @@ -58,9 +58,13 @@ import static org.sonar.process.ProcessProperties.Property.SONAR_WEB_SSO_NAME_HE import static org.sonar.process.ProcessProperties.Property.SONAR_WEB_SSO_REFRESH_INTERVAL_IN_MINUTES; import static org.sonar.server.user.ExternalIdentity.SQ_AUTHORITY; -public class HttpHeadersAuthenticator implements Startable { +/** + * Authentication based on the HTTP request headers. The front proxy + * is responsible for validating user identity. + */ +public class HttpHeadersAuthentication implements Startable { - private static final Logger LOG = Loggers.get(HttpHeadersAuthenticator.class); + private static final Logger LOG = Loggers.get(HttpHeadersAuthentication.class); private static final Splitter COMA_SPLITTER = Splitter.on(",").trimResults().omitEmptyStrings(); @@ -82,7 +86,7 @@ public class HttpHeadersAuthenticator implements Startable { private boolean enabled = false; private Map settingsByKey = new HashMap<>(); - public HttpHeadersAuthenticator(System2 system2, Configuration config, UserIdentityAuthenticator userIdentityAuthenticator, + public HttpHeadersAuthentication(System2 system2, Configuration config, UserIdentityAuthenticator userIdentityAuthenticator, JwtHttpHandler jwtHttpHandler, AuthenticationEvent authenticationEvent) { this.system2 = system2; this.config = config; diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/RequestAuthenticatorImpl.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/RequestAuthenticatorImpl.java index 76d3f68513a..ee0f3e53816 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/authentication/RequestAuthenticatorImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/RequestAuthenticatorImpl.java @@ -30,15 +30,15 @@ import org.sonar.server.user.UserSessionFactory; public class RequestAuthenticatorImpl implements RequestAuthenticator { private final JwtHttpHandler jwtHttpHandler; - private final BasicAuthenticator basicAuthenticator; - private final HttpHeadersAuthenticator httpHeadersAuthenticator; + private final BasicAuthentication basicAuthentication; + private final HttpHeadersAuthentication httpHeadersAuthentication; private final UserSessionFactory userSessionFactory; - public RequestAuthenticatorImpl(JwtHttpHandler jwtHttpHandler, BasicAuthenticator basicAuthenticator, HttpHeadersAuthenticator httpHeadersAuthenticator, - UserSessionFactory userSessionFactory) throws AuthenticationException { + public RequestAuthenticatorImpl(JwtHttpHandler jwtHttpHandler, BasicAuthentication basicAuthentication, HttpHeadersAuthentication httpHeadersAuthentication, + UserSessionFactory userSessionFactory) throws AuthenticationException { this.jwtHttpHandler = jwtHttpHandler; - this.basicAuthenticator = basicAuthenticator; - this.httpHeadersAuthenticator = httpHeadersAuthenticator; + this.basicAuthentication = basicAuthentication; + this.httpHeadersAuthentication = httpHeadersAuthentication; this.userSessionFactory = userSessionFactory; } @@ -55,7 +55,7 @@ public class RequestAuthenticatorImpl implements RequestAuthenticator { // Try first to authenticate from SSO, then JWT token, then try from basic http header // SSO authentication should come first in order to update JWT if user from header is not the same is user from JWT - Optional user = httpHeadersAuthenticator.authenticate(request, response); + Optional user = httpHeadersAuthentication.authenticate(request, response); if (user.isPresent()) { return user; } @@ -63,6 +63,6 @@ public class RequestAuthenticatorImpl implements RequestAuthenticator { if (user.isPresent()) { return user; } - return basicAuthenticator.authenticate(request); + return basicAuthentication.authenticate(request); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/ws/LoginAction.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/ws/LoginAction.java index 573f6efa832..8771c9f175e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/authentication/ws/LoginAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/ws/LoginAction.java @@ -29,7 +29,7 @@ import org.sonar.api.server.ws.WebService; import org.sonar.api.web.ServletFilter; import org.sonar.db.user.UserDto; import org.sonar.server.authentication.Credentials; -import org.sonar.server.authentication.CredentialsAuthenticator; +import org.sonar.server.authentication.CredentialsAuthentication; import org.sonar.server.authentication.JwtHttpHandler; import org.sonar.server.authentication.event.AuthenticationEvent; import org.sonar.server.authentication.event.AuthenticationException; @@ -51,15 +51,15 @@ public class LoginAction extends ServletFilter implements AuthenticationWsAction private static final String LOGIN_ACTION = "login"; public static final String LOGIN_URL = "/" + AUTHENTICATION_CONTROLLER + "/" + LOGIN_ACTION; - private final CredentialsAuthenticator credentialsAuthenticator; + private final CredentialsAuthentication credentialsAuthentication; private final JwtHttpHandler jwtHttpHandler; private final ThreadLocalUserSession threadLocalUserSession; private final AuthenticationEvent authenticationEvent; private final UserSessionFactory userSessionFactory; - public LoginAction(CredentialsAuthenticator credentialsAuthenticator, JwtHttpHandler jwtHttpHandler, - ThreadLocalUserSession threadLocalUserSession, AuthenticationEvent authenticationEvent, UserSessionFactory userSessionFactory) { - this.credentialsAuthenticator = credentialsAuthenticator; + public LoginAction(CredentialsAuthentication credentialsAuthentication, JwtHttpHandler jwtHttpHandler, + ThreadLocalUserSession threadLocalUserSession, AuthenticationEvent authenticationEvent, UserSessionFactory userSessionFactory) { + this.credentialsAuthentication = credentialsAuthentication; this.jwtHttpHandler = jwtHttpHandler; this.threadLocalUserSession = threadLocalUserSession; this.authenticationEvent = authenticationEvent; @@ -118,7 +118,7 @@ public class LoginAction extends ServletFilter implements AuthenticationWsAction .setMessage("Empty login and/or password") .build(); } - return credentialsAuthenticator.authenticate(new Credentials(login, password), request, Method.FORM); + return credentialsAuthentication.authenticate(new Credentials(login, password), request, Method.FORM); } @Override diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/ws/ValidateAction.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/ws/ValidateAction.java index af33d4b0bab..aa061488449 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/authentication/ws/ValidateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/ws/ValidateAction.java @@ -33,7 +33,7 @@ import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.text.JsonWriter; import org.sonar.api.web.ServletFilter; import org.sonar.db.user.UserDto; -import org.sonar.server.authentication.BasicAuthenticator; +import org.sonar.server.authentication.BasicAuthentication; import org.sonar.server.authentication.JwtHttpHandler; import org.sonar.server.authentication.event.AuthenticationException; import org.sonar.server.ws.ServletFilterHandler; @@ -49,11 +49,11 @@ public class ValidateAction extends ServletFilter implements AuthenticationWsAct private final Configuration config; private final JwtHttpHandler jwtHttpHandler; - private final BasicAuthenticator basicAuthenticator; + private final BasicAuthentication basicAuthentication; - public ValidateAction(Configuration config, BasicAuthenticator basicAuthenticator, JwtHttpHandler jwtHttpHandler) { + public ValidateAction(Configuration config, BasicAuthentication basicAuthentication, JwtHttpHandler jwtHttpHandler) { this.config = config; - this.basicAuthenticator = basicAuthenticator; + this.basicAuthentication = basicAuthentication; this.jwtHttpHandler = jwtHttpHandler; } @@ -92,7 +92,7 @@ public class ValidateAction extends ServletFilter implements AuthenticationWsAct if (user.isPresent()) { return true; } - user = basicAuthenticator.authenticate(request); + user = basicAuthentication.authenticate(request); if (user.isPresent()) { return true; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java index 9086a9c453b..94e252d16e1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java @@ -39,7 +39,7 @@ import org.sonar.db.organization.OrganizationMemberDto; import org.sonar.db.user.GroupDto; import org.sonar.db.user.UserDto; import org.sonar.db.user.UserGroupDto; -import org.sonar.server.authentication.LocalAuthentication; +import org.sonar.server.authentication.CredentialsLocalAuthentication; import org.sonar.server.organization.DefaultOrganizationProvider; import org.sonar.server.organization.OrganizationFlags; import org.sonar.server.organization.OrganizationUpdater; @@ -82,11 +82,11 @@ public class UserUpdater { private final OrganizationUpdater organizationUpdater; private final DefaultGroupFinder defaultGroupFinder; private final Configuration config; - private final LocalAuthentication localAuthentication; + private final CredentialsLocalAuthentication localAuthentication; public UserUpdater(NewUserNotifier newUserNotifier, DbClient dbClient, UserIndexer userIndexer, OrganizationFlags organizationFlags, DefaultOrganizationProvider defaultOrganizationProvider, OrganizationUpdater organizationUpdater, DefaultGroupFinder defaultGroupFinder, Configuration config, - LocalAuthentication localAuthentication) { + CredentialsLocalAuthentication localAuthentication) { this.newUserNotifier = newUserNotifier; this.dbClient = dbClient; this.userIndexer = userIndexer; diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/ws/ChangePasswordAction.java b/server/sonar-server/src/main/java/org/sonar/server/user/ws/ChangePasswordAction.java index ad35e69857d..00fad86c1d9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/ws/ChangePasswordAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/ws/ChangePasswordAction.java @@ -25,7 +25,7 @@ import org.sonar.api.server.ws.WebService; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.user.UserDto; -import org.sonar.server.authentication.LocalAuthentication; +import org.sonar.server.authentication.CredentialsLocalAuthentication; import org.sonar.server.authentication.event.AuthenticationEvent; import org.sonar.server.authentication.event.AuthenticationException; import org.sonar.server.exceptions.NotFoundException; @@ -44,9 +44,9 @@ public class ChangePasswordAction implements UsersWsAction { private final DbClient dbClient; private final UserUpdater userUpdater; private final UserSession userSession; - private final LocalAuthentication localAuthentication; + private final CredentialsLocalAuthentication localAuthentication; - public ChangePasswordAction(DbClient dbClient, UserUpdater userUpdater, UserSession userSession, LocalAuthentication localAuthentication) { + public ChangePasswordAction(DbClient dbClient, UserUpdater userUpdater, UserSession userSession, CredentialsLocalAuthentication localAuthentication) { this.dbClient = dbClient; this.userUpdater = userUpdater; this.userSession = userSession; diff --git a/server/sonar-server/src/main/java/org/sonar/server/usertoken/UserTokenAuthenticator.java b/server/sonar-server/src/main/java/org/sonar/server/usertoken/UserTokenAuthentication.java similarity index 89% rename from server/sonar-server/src/main/java/org/sonar/server/usertoken/UserTokenAuthenticator.java rename to server/sonar-server/src/main/java/org/sonar/server/usertoken/UserTokenAuthentication.java index f6c4f2e2e0b..5e19ad19e6d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/usertoken/UserTokenAuthenticator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/usertoken/UserTokenAuthentication.java @@ -19,6 +19,7 @@ */ package org.sonar.server.usertoken; +import java.util.Optional; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.user.UserTokenDto; @@ -26,11 +27,11 @@ import org.sonar.db.user.UserTokenDto; import static java.util.Optional.empty; import static java.util.Optional.of; -public class UserTokenAuthenticator { +public class UserTokenAuthentication { private final TokenGenerator tokenGenerator; private final DbClient dbClient; - public UserTokenAuthenticator(TokenGenerator tokenGenerator, DbClient dbClient) { + public UserTokenAuthentication(TokenGenerator tokenGenerator, DbClient dbClient) { this.tokenGenerator = tokenGenerator; this.dbClient = dbClient; } @@ -40,7 +41,7 @@ public class UserTokenAuthenticator { * The returned uuid is not validated. If database is corrupted (table USER_TOKENS badly purged * for instance), then the uuid may not relate to a valid user. */ - public java.util.Optional authenticate(String token) { + public Optional authenticate(String token) { String tokenHash = tokenGenerator.hash(token); try (DbSession dbSession = dbClient.openSession(false)) { UserTokenDto userToken = dbClient.userTokenDao().selectByTokenHash(dbSession, tokenHash); diff --git a/server/sonar-server/src/main/java/org/sonar/server/usertoken/UserTokenModule.java b/server/sonar-server/src/main/java/org/sonar/server/usertoken/UserTokenModule.java index cd1cfe07723..cbaa7477ff4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/usertoken/UserTokenModule.java +++ b/server/sonar-server/src/main/java/org/sonar/server/usertoken/UserTokenModule.java @@ -35,7 +35,7 @@ public class UserTokenModule extends Module { GenerateAction.class, RevokeAction.class, SearchAction.class, - UserTokenAuthenticator.class, + UserTokenAuthentication.class, TokenGeneratorImpl.class); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/authentication/BasicAuthenticatorTest.java b/server/sonar-server/src/test/java/org/sonar/server/authentication/BasicAuthenticationTest.java similarity index 82% rename from server/sonar-server/src/test/java/org/sonar/server/authentication/BasicAuthenticatorTest.java rename to server/sonar-server/src/test/java/org/sonar/server/authentication/BasicAuthenticationTest.java index b8efa9d5d1d..83d92832395 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/authentication/BasicAuthenticatorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/authentication/BasicAuthenticationTest.java @@ -31,7 +31,7 @@ import org.sonar.db.DbTester; import org.sonar.db.user.UserDto; import org.sonar.db.user.UserTesting; import org.sonar.server.authentication.event.AuthenticationEvent; -import org.sonar.server.usertoken.UserTokenAuthenticator; +import org.sonar.server.usertoken.UserTokenAuthentication; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; @@ -47,7 +47,7 @@ import static org.sonar.server.authentication.event.AuthenticationEvent.Method.B import static org.sonar.server.authentication.event.AuthenticationEvent.Source; import static org.sonar.server.authentication.event.AuthenticationExceptionMatcher.authenticationException; -public class BasicAuthenticatorTest { +public class BasicAuthenticationTest { private static final Base64.Encoder BASE64_ENCODER = Base64.getEncoder(); @@ -65,24 +65,24 @@ public class BasicAuthenticatorTest { private DbClient dbClient = db.getDbClient(); - private CredentialsAuthenticator credentialsAuthenticator = mock(CredentialsAuthenticator.class); - private UserTokenAuthenticator userTokenAuthenticator = mock(UserTokenAuthenticator.class); + private CredentialsAuthentication credentialsAuthentication = mock(CredentialsAuthentication.class); + private UserTokenAuthentication userTokenAuthentication = mock(UserTokenAuthentication.class); private HttpServletRequest request = mock(HttpServletRequest.class); private AuthenticationEvent authenticationEvent = mock(AuthenticationEvent.class); - private BasicAuthenticator underTest = new BasicAuthenticator(dbClient, credentialsAuthenticator, userTokenAuthenticator, authenticationEvent); + private BasicAuthentication underTest = new BasicAuthentication(dbClient, credentialsAuthentication, userTokenAuthentication, authenticationEvent); @Test public void authenticate_from_basic_http_header() { when(request.getHeader("Authorization")).thenReturn("Basic " + CREDENTIALS_IN_BASE64); Credentials credentials = new Credentials(A_LOGIN, A_PASSWORD); - when(credentialsAuthenticator.authenticate(credentials, request, BASIC)).thenReturn(USER); + when(credentialsAuthentication.authenticate(credentials, request, BASIC)).thenReturn(USER); underTest.authenticate(request); - verify(credentialsAuthenticator).authenticate(credentials, request, BASIC); + verify(credentialsAuthentication).authenticate(credentials, request, BASIC); verifyNoMoreInteractions(authenticationEvent); } @@ -90,11 +90,11 @@ public class BasicAuthenticatorTest { public void authenticate_from_basic_http_header_with_password_containing_semi_colon() { String password = "!ascii-only:-)@"; when(request.getHeader("Authorization")).thenReturn("Basic " + toBase64(A_LOGIN + ":" + password)); - when(credentialsAuthenticator.authenticate(new Credentials(A_LOGIN, password), request, BASIC)).thenReturn(USER); + when(credentialsAuthentication.authenticate(new Credentials(A_LOGIN, password), request, BASIC)).thenReturn(USER); underTest.authenticate(request); - verify(credentialsAuthenticator).authenticate(new Credentials(A_LOGIN, password), request, BASIC); + verify(credentialsAuthentication).authenticate(new Credentials(A_LOGIN, password), request, BASIC); verifyNoMoreInteractions(authenticationEvent); } @@ -102,7 +102,7 @@ public class BasicAuthenticatorTest { public void does_not_authenticate_when_no_authorization_header() { underTest.authenticate(request); - verifyZeroInteractions(credentialsAuthenticator, authenticationEvent); + verifyZeroInteractions(credentialsAuthentication, authenticationEvent); } @Test @@ -111,7 +111,7 @@ public class BasicAuthenticatorTest { underTest.authenticate(request); - verifyZeroInteractions(credentialsAuthenticator, authenticationEvent); + verifyZeroInteractions(credentialsAuthentication, authenticationEvent); } @Test @@ -138,7 +138,7 @@ public class BasicAuthenticatorTest { @Test public void authenticate_from_user_token() { UserDto user = db.users().insertUser(); - when(userTokenAuthenticator.authenticate("token")).thenReturn(Optional.of(user.getUuid())); + when(userTokenAuthentication.authenticate("token")).thenReturn(Optional.of(user.getUuid())); when(request.getHeader("Authorization")).thenReturn("Basic " + toBase64("token:")); Optional userAuthenticated = underTest.authenticate(request); @@ -150,7 +150,7 @@ public class BasicAuthenticatorTest { @Test public void does_not_authenticate_from_user_token_when_token_is_invalid() { - when(userTokenAuthenticator.authenticate("token")).thenReturn(Optional.empty()); + when(userTokenAuthentication.authenticate("token")).thenReturn(Optional.empty()); when(request.getHeader("Authorization")).thenReturn("Basic " + toBase64("token:")); expectedException.expect(authenticationException().from(Source.local(BASIC_TOKEN)).withoutLogin().andNoPublicMessage()); @@ -163,7 +163,7 @@ public class BasicAuthenticatorTest { @Test public void does_not_authenticate_from_user_token_when_token_does_not_match_existing_user() { - when(userTokenAuthenticator.authenticate("token")).thenReturn(Optional.of("Unknown user")); + when(userTokenAuthentication.authenticate("token")).thenReturn(Optional.of("Unknown user")); when(request.getHeader("Authorization")).thenReturn("Basic " + toBase64("token:")); expectedException.expect(authenticationException().from(Source.local(Method.BASIC_TOKEN)).withoutLogin().andNoPublicMessage()); @@ -177,7 +177,7 @@ public class BasicAuthenticatorTest { @Test public void does_not_authenticate_from_user_token_when_token_does_not_match_active_user() { UserDto user = db.users().insertDisabledUser(); - when(userTokenAuthenticator.authenticate("token")).thenReturn(Optional.of(user.getUuid())); + when(userTokenAuthentication.authenticate("token")).thenReturn(Optional.of(user.getUuid())); when(request.getHeader("Authorization")).thenReturn("Basic " + toBase64("token:")); expectedException.expect(authenticationException().from(Source.local(Method.BASIC_TOKEN)).withoutLogin().andNoPublicMessage()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/authentication/CredentialsAuthenticatorTest.java b/server/sonar-server/src/test/java/org/sonar/server/authentication/CredentialsAuthenticationTest.java similarity index 80% rename from server/sonar-server/src/test/java/org/sonar/server/authentication/CredentialsAuthenticatorTest.java rename to server/sonar-server/src/test/java/org/sonar/server/authentication/CredentialsAuthenticationTest.java index 5216bc3eed3..e617a33881c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/authentication/CredentialsAuthenticatorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/authentication/CredentialsAuthenticationTest.java @@ -43,35 +43,31 @@ import static org.sonar.server.authentication.event.AuthenticationEvent.Method.B import static org.sonar.server.authentication.event.AuthenticationEvent.Method.BASIC_TOKEN; import static org.sonar.server.authentication.event.AuthenticationExceptionMatcher.authenticationException; -public class CredentialsAuthenticatorTest { +public class CredentialsAuthenticationTest { private static final String LOGIN = "LOGIN"; private static final String PASSWORD = "PASSWORD"; private static final String SALT = "0242b0b4c0a93ddfe09dd886de50bc25ba000b51"; - private static final String CRYPTED_PASSWORD = "540e4fc4be4e047db995bc76d18374a5b5db08cc"; + private static final String ENCRYPTED_PASSWORD = "540e4fc4be4e047db995bc76d18374a5b5db08cc"; @Rule public ExpectedException expectedException = none(); @Rule public DbTester dbTester = DbTester.create(System2.INSTANCE); - private DbClient dbClient = dbTester.getDbClient(); - private DbSession dbSession = dbTester.getSession(); - - private RealmAuthenticator externalAuthenticator = mock(RealmAuthenticator.class); private HttpServletRequest request = mock(HttpServletRequest.class); private AuthenticationEvent authenticationEvent = mock(AuthenticationEvent.class); - private LocalAuthentication localAuthentication = new LocalAuthentication(dbClient); - - private CredentialsAuthenticator underTest = new CredentialsAuthenticator(dbClient, externalAuthenticator, authenticationEvent, localAuthentication); + private CredentialsExternalAuthentication externalAuthentication = mock(CredentialsExternalAuthentication.class); + private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(dbClient); + private CredentialsAuthentication underTest = new CredentialsAuthentication(dbClient, authenticationEvent, externalAuthentication, localAuthentication); @Test public void authenticate_local_user() { insertUser(newUserDto() .setLogin(LOGIN) - .setCryptedPassword(CRYPTED_PASSWORD) - .setHashMethod(LocalAuthentication.HashMethod.SHA1.name()) + .setCryptedPassword(ENCRYPTED_PASSWORD) + .setHashMethod(CredentialsLocalAuthentication.HashMethod.SHA1.name()) .setSalt(SALT) .setLocal(true)); @@ -86,7 +82,7 @@ public class CredentialsAuthenticatorTest { .setLogin(LOGIN) .setCryptedPassword("Wrong password") .setSalt("Wrong salt") - .setHashMethod(LocalAuthentication.HashMethod.SHA1.name()) + .setHashMethod(CredentialsLocalAuthentication.HashMethod.SHA1.name()) .setLocal(true)); expectedException.expect(authenticationException().from(Source.local(BASIC)).withLogin(LOGIN).andNoPublicMessage()); @@ -100,20 +96,20 @@ public class CredentialsAuthenticatorTest { @Test public void authenticate_external_user() { - when(externalAuthenticator.authenticate(new Credentials(LOGIN, PASSWORD), request, BASIC)).thenReturn(Optional.of(newUserDto())); + when(externalAuthentication.authenticate(new Credentials(LOGIN, PASSWORD), request, BASIC)).thenReturn(Optional.of(newUserDto())); insertUser(newUserDto() .setLogin(LOGIN) .setLocal(false)); executeAuthenticate(BASIC); - verify(externalAuthenticator).authenticate(new Credentials(LOGIN, PASSWORD), request, BASIC); + verify(externalAuthentication).authenticate(new Credentials(LOGIN, PASSWORD), request, BASIC); verifyZeroInteractions(authenticationEvent); } @Test public void fail_to_authenticate_authenticate_external_user_when_no_external_authentication() { - when(externalAuthenticator.authenticate(new Credentials(LOGIN, PASSWORD), request, BASIC_TOKEN)).thenReturn(Optional.empty()); + when(externalAuthentication.authenticate(new Credentials(LOGIN, PASSWORD), request, BASIC_TOKEN)).thenReturn(Optional.empty()); insertUser(newUserDto() .setLogin(LOGIN) .setLocal(false)); @@ -133,7 +129,7 @@ public class CredentialsAuthenticatorTest { .setLogin(LOGIN) .setCryptedPassword(null) .setSalt(SALT) - .setHashMethod(LocalAuthentication.HashMethod.SHA1.name()) + .setHashMethod(CredentialsLocalAuthentication.HashMethod.SHA1.name()) .setLocal(true)); expectedException.expect(authenticationException().from(Source.local(BASIC)).withLogin(LOGIN).andNoPublicMessage()); @@ -149,9 +145,9 @@ public class CredentialsAuthenticatorTest { public void fail_to_authenticate_local_user_that_have_no_salt() { insertUser(newUserDto() .setLogin(LOGIN) - .setCryptedPassword(CRYPTED_PASSWORD) + .setCryptedPassword(ENCRYPTED_PASSWORD) .setSalt(null) - .setHashMethod(LocalAuthentication.HashMethod.SHA1.name()) + .setHashMethod(CredentialsLocalAuthentication.HashMethod.SHA1.name()) .setLocal(true)); expectedException.expect(authenticationException().from(Source.local(BASIC_TOKEN)).withLogin(LOGIN).andNoPublicMessage()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/authentication/RealmAuthenticatorTest.java b/server/sonar-server/src/test/java/org/sonar/server/authentication/CredentialsExternalAuthenticationTest.java similarity index 98% rename from server/sonar-server/src/test/java/org/sonar/server/authentication/RealmAuthenticatorTest.java rename to server/sonar-server/src/test/java/org/sonar/server/authentication/CredentialsExternalAuthenticationTest.java index 7510e0b7e06..e0aed101188 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/authentication/RealmAuthenticatorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/authentication/CredentialsExternalAuthenticationTest.java @@ -49,7 +49,7 @@ import static org.sonar.server.authentication.event.AuthenticationEvent.Method.B import static org.sonar.server.authentication.event.AuthenticationEvent.Method.BASIC_TOKEN; import static org.sonar.server.authentication.event.AuthenticationExceptionMatcher.authenticationException; -public class RealmAuthenticatorTest { +public class CredentialsExternalAuthenticationTest { private static final String LOGIN = "LOGIN"; private static final String PASSWORD = "PASSWORD"; @@ -72,7 +72,7 @@ public class RealmAuthenticatorTest { private HttpServletRequest request = mock(HttpServletRequest.class); - private RealmAuthenticator underTest = new RealmAuthenticator(settings.asConfig(), securityRealmFactory, userIdentityAuthenticator, authenticationEvent); + private CredentialsExternalAuthentication underTest = new CredentialsExternalAuthentication(settings.asConfig(), securityRealmFactory, userIdentityAuthenticator, authenticationEvent); @Before public void setUp() throws Exception { diff --git a/server/sonar-server/src/test/java/org/sonar/server/authentication/LocalAuthenticationTest.java b/server/sonar-server/src/test/java/org/sonar/server/authentication/CredentialsLocalAuthenticationTest.java similarity index 95% rename from server/sonar-server/src/test/java/org/sonar/server/authentication/LocalAuthenticationTest.java rename to server/sonar-server/src/test/java/org/sonar/server/authentication/CredentialsLocalAuthenticationTest.java index 63803d3d010..7fb6b3a08f5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/authentication/LocalAuthenticationTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/authentication/CredentialsLocalAuthenticationTest.java @@ -35,10 +35,10 @@ import org.sonar.server.authentication.event.AuthenticationException; import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; import static org.assertj.core.api.Assertions.assertThat; import static org.sonar.db.user.UserTesting.newUserDto; -import static org.sonar.server.authentication.LocalAuthentication.HashMethod.BCRYPT; -import static org.sonar.server.authentication.LocalAuthentication.HashMethod.SHA1; +import static org.sonar.server.authentication.CredentialsLocalAuthentication.HashMethod.BCRYPT; +import static org.sonar.server.authentication.CredentialsLocalAuthentication.HashMethod.SHA1; -public class LocalAuthenticationTest { +public class CredentialsLocalAuthenticationTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Rule @@ -46,7 +46,7 @@ public class LocalAuthenticationTest { private static final Random RANDOM = new Random(); - private LocalAuthentication underTest = new LocalAuthentication(db.getDbClient()); + private CredentialsLocalAuthentication underTest = new CredentialsLocalAuthentication(db.getDbClient()); @Test public void incorrect_hash_should_throw_AuthenticationException() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticatorTest.java b/server/sonar-server/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticationTest.java similarity index 98% rename from server/sonar-server/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticatorTest.java rename to server/sonar-server/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticationTest.java index cc604880c26..e21f7eebb86 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticatorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/authentication/HttpHeadersAuthenticationTest.java @@ -64,7 +64,7 @@ import static org.mockito.Mockito.when; import static org.sonar.db.user.UserTesting.newUserDto; import static org.sonar.server.authentication.event.AuthenticationExceptionMatcher.authenticationException; -public class HttpHeadersAuthenticatorTest { +public class HttpHeadersAuthenticationTest { private MapSettings settings = new MapSettings(); @@ -100,7 +100,7 @@ public class HttpHeadersAuthenticatorTest { private OrganizationUpdater organizationUpdater = mock(OrganizationUpdater.class); private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db); private TestOrganizationFlags organizationFlags = TestOrganizationFlags.standalone(); - private LocalAuthentication localAuthentication = new LocalAuthentication(db.getDbClient()); + private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient()); private UserIndexer userIndexer = new UserIndexer(db.getDbClient(), es.client()); private UserIdentityAuthenticatorImpl userIdentityAuthenticator = new UserIdentityAuthenticatorImpl( @@ -113,7 +113,7 @@ public class HttpHeadersAuthenticatorTest { private JwtHttpHandler jwtHttpHandler = mock(JwtHttpHandler.class); private AuthenticationEvent authenticationEvent = mock(AuthenticationEvent.class); - private HttpHeadersAuthenticator underTest = new HttpHeadersAuthenticator(system2, settings.asConfig(), userIdentityAuthenticator, jwtHttpHandler, authenticationEvent); + private HttpHeadersAuthentication underTest = new HttpHeadersAuthentication(system2, settings.asConfig(), userIdentityAuthenticator, jwtHttpHandler, authenticationEvent); @Before public void setUp() throws Exception { diff --git a/server/sonar-server/src/test/java/org/sonar/server/authentication/RequestAuthenticatorImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/authentication/RequestAuthenticatorImplTest.java index c395407b5c7..e6cd47ea8e4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/authentication/RequestAuthenticatorImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/authentication/RequestAuthenticatorImplTest.java @@ -45,10 +45,10 @@ public class RequestAuthenticatorImplTest { private HttpServletRequest request = mock(HttpServletRequest.class); private HttpServletResponse response = mock(HttpServletResponse.class); private JwtHttpHandler jwtHttpHandler = mock(JwtHttpHandler.class); - private BasicAuthenticator basicAuthenticator = mock(BasicAuthenticator.class); - private HttpHeadersAuthenticator httpHeadersAuthenticator = mock(HttpHeadersAuthenticator.class); + private BasicAuthentication basicAuthentication = mock(BasicAuthentication.class); + private HttpHeadersAuthentication httpHeadersAuthentication = mock(HttpHeadersAuthentication.class); private UserSessionFactory sessionFactory = mock(UserSessionFactory.class); - private RequestAuthenticator underTest = new RequestAuthenticatorImpl(jwtHttpHandler, basicAuthenticator, httpHeadersAuthenticator, sessionFactory); + private RequestAuthenticator underTest = new RequestAuthenticatorImpl(jwtHttpHandler, basicAuthentication, httpHeadersAuthentication, sessionFactory); @Before public void setUp() throws Exception { @@ -58,7 +58,7 @@ public class RequestAuthenticatorImplTest { @Test public void authenticate_from_jwt_token() { - when(httpHeadersAuthenticator.authenticate(request, response)).thenReturn(Optional.empty()); + when(httpHeadersAuthentication.authenticate(request, response)).thenReturn(Optional.empty()); when(jwtHttpHandler.validateToken(request, response)).thenReturn(Optional.of(A_USER)); assertThat(underTest.authenticate(request, response).getUuid()).isEqualTo(A_USER.getUuid()); @@ -67,25 +67,25 @@ public class RequestAuthenticatorImplTest { @Test public void authenticate_from_basic_header() { - when(basicAuthenticator.authenticate(request)).thenReturn(Optional.of(A_USER)); - when(httpHeadersAuthenticator.authenticate(request, response)).thenReturn(Optional.empty()); + when(basicAuthentication.authenticate(request)).thenReturn(Optional.of(A_USER)); + when(httpHeadersAuthentication.authenticate(request, response)).thenReturn(Optional.empty()); when(jwtHttpHandler.validateToken(request, response)).thenReturn(Optional.empty()); assertThat(underTest.authenticate(request, response).getUuid()).isEqualTo(A_USER.getUuid()); verify(jwtHttpHandler).validateToken(request, response); - verify(basicAuthenticator).authenticate(request); + verify(basicAuthentication).authenticate(request); verify(response, never()).setStatus(anyInt()); } @Test public void authenticate_from_sso() { - when(httpHeadersAuthenticator.authenticate(request, response)).thenReturn(Optional.of(A_USER)); + when(httpHeadersAuthentication.authenticate(request, response)).thenReturn(Optional.of(A_USER)); when(jwtHttpHandler.validateToken(request, response)).thenReturn(Optional.empty()); assertThat(underTest.authenticate(request, response).getUuid()).isEqualTo(A_USER.getUuid()); - verify(httpHeadersAuthenticator).authenticate(request, response); + verify(httpHeadersAuthentication).authenticate(request, response); verify(jwtHttpHandler, never()).validateToken(request, response); verify(response, never()).setStatus(anyInt()); } @@ -93,8 +93,8 @@ public class RequestAuthenticatorImplTest { @Test public void return_empty_if_not_authenticated() { when(jwtHttpHandler.validateToken(request, response)).thenReturn(Optional.empty()); - when(httpHeadersAuthenticator.authenticate(request, response)).thenReturn(Optional.empty()); - when(basicAuthenticator.authenticate(request)).thenReturn(Optional.empty()); + when(httpHeadersAuthentication.authenticate(request, response)).thenReturn(Optional.empty()); + when(basicAuthentication.authenticate(request)).thenReturn(Optional.empty()); UserSession session = underTest.authenticate(request, response); assertThat(session.isLoggedIn()).isFalse(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/authentication/UserIdentityAuthenticatorImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/authentication/UserIdentityAuthenticatorImplTest.java index 3593f9f1bef..d054ddb9492 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/authentication/UserIdentityAuthenticatorImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/authentication/UserIdentityAuthenticatorImplTest.java @@ -97,7 +97,7 @@ public class UserIdentityAuthenticatorImplTest { private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db); private OrganizationUpdater organizationUpdater = mock(OrganizationUpdater.class); private TestOrganizationFlags organizationFlags = TestOrganizationFlags.standalone(); - private LocalAuthentication localAuthentication = new LocalAuthentication(db.getDbClient()); + private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient()); private UserUpdater userUpdater = new UserUpdater( mock(NewUserNotifier.class), db.getDbClient(), diff --git a/server/sonar-server/src/test/java/org/sonar/server/authentication/ws/LoginActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/authentication/ws/LoginActionTest.java index b5d6ae15c4e..d1340ddca8c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/authentication/ws/LoginActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/authentication/ws/LoginActionTest.java @@ -34,7 +34,7 @@ import org.sonar.db.DbTester; import org.sonar.db.user.UserDto; import org.sonar.db.user.UserTesting; import org.sonar.server.authentication.Credentials; -import org.sonar.server.authentication.CredentialsAuthenticator; +import org.sonar.server.authentication.CredentialsAuthentication; import org.sonar.server.authentication.JwtHttpHandler; import org.sonar.server.authentication.event.AuthenticationEvent; import org.sonar.server.authentication.event.AuthenticationException; @@ -70,13 +70,13 @@ public class LoginActionTest { private HttpServletResponse response = mock(HttpServletResponse.class); private FilterChain chain = mock(FilterChain.class); - private CredentialsAuthenticator credentialsAuthenticator = mock(CredentialsAuthenticator.class); + private CredentialsAuthentication credentialsAuthentication = mock(CredentialsAuthentication.class); private JwtHttpHandler jwtHttpHandler = mock(JwtHttpHandler.class); private AuthenticationEvent authenticationEvent = mock(AuthenticationEvent.class); private TestUserSessionFactory userSessionFactory = TestUserSessionFactory.standalone(); private UserDto user = UserTesting.newUserDto().setLogin(LOGIN); - private LoginAction underTest = new LoginAction(credentialsAuthenticator, jwtHttpHandler, threadLocalUserSession, authenticationEvent, userSessionFactory); + private LoginAction underTest = new LoginAction(credentialsAuthentication, jwtHttpHandler, threadLocalUserSession, authenticationEvent, userSessionFactory); @Before public void setUp() throws Exception { @@ -94,12 +94,12 @@ public class LoginActionTest { @Test public void do_authenticate() throws Exception { - when(credentialsAuthenticator.authenticate(new Credentials(LOGIN, PASSWORD), request, FORM)).thenReturn(user); + when(credentialsAuthentication.authenticate(new Credentials(LOGIN, PASSWORD), request, FORM)).thenReturn(user); executeRequest(LOGIN, PASSWORD); assertThat(threadLocalUserSession.isLoggedIn()).isTrue(); - verify(credentialsAuthenticator).authenticate(new Credentials(LOGIN, PASSWORD), request, FORM); + verify(credentialsAuthentication).authenticate(new Credentials(LOGIN, PASSWORD), request, FORM); verify(jwtHttpHandler).generateToken(user, request, response); verifyZeroInteractions(chain); verifyZeroInteractions(authenticationEvent); @@ -111,13 +111,13 @@ public class LoginActionTest { underTest.doFilter(request, response, chain); - verifyZeroInteractions(credentialsAuthenticator, jwtHttpHandler, chain); + verifyZeroInteractions(credentialsAuthentication, jwtHttpHandler, chain); verifyZeroInteractions(authenticationEvent); } @Test public void return_authorized_code_when_unauthorized_exception_is_thrown() throws Exception { - doThrow(new UnauthorizedException("error !")).when(credentialsAuthenticator).authenticate(new Credentials(LOGIN, PASSWORD), request, FORM); + doThrow(new UnauthorizedException("error !")).when(credentialsAuthentication).authenticate(new Credentials(LOGIN, PASSWORD), request, FORM); executeRequest(LOGIN, PASSWORD); diff --git a/server/sonar-server/src/test/java/org/sonar/server/authentication/ws/ValidateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/authentication/ws/ValidateActionTest.java index 60307c38aeb..b1b390ba76b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/authentication/ws/ValidateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/authentication/ws/ValidateActionTest.java @@ -28,7 +28,7 @@ import javax.servlet.http.HttpServletResponse; import org.junit.Before; import org.junit.Test; import org.sonar.api.config.internal.MapSettings; -import org.sonar.server.authentication.BasicAuthenticator; +import org.sonar.server.authentication.BasicAuthentication; import org.sonar.server.authentication.JwtHttpHandler; import org.sonar.server.authentication.event.AuthenticationException; import org.sonar.test.JsonAssert; @@ -48,12 +48,12 @@ public class ValidateActionTest { HttpServletResponse response = mock(HttpServletResponse.class); FilterChain chain = mock(FilterChain.class); - BasicAuthenticator basicAuthenticator = mock(BasicAuthenticator.class); + BasicAuthentication basicAuthentication = mock(BasicAuthentication.class); JwtHttpHandler jwtHttpHandler = mock(JwtHttpHandler.class); MapSettings settings = new MapSettings(); - ValidateAction underTest = new ValidateAction(settings.asConfig(), basicAuthenticator, jwtHttpHandler); + ValidateAction underTest = new ValidateAction(settings.asConfig(), basicAuthentication, jwtHttpHandler); @Before public void setUp() throws Exception { @@ -64,7 +64,7 @@ public class ValidateActionTest { @Test public void return_true_when_jwt_token_is_set() throws Exception { when(jwtHttpHandler.validateToken(request, response)).thenReturn(Optional.of(newUserDto())); - when(basicAuthenticator.authenticate(request)).thenReturn(Optional.empty()); + when(basicAuthentication.authenticate(request)).thenReturn(Optional.empty()); underTest.doFilter(request, response, chain); @@ -75,7 +75,7 @@ public class ValidateActionTest { @Test public void return_true_when_basic_auth() throws Exception { when(jwtHttpHandler.validateToken(request, response)).thenReturn(Optional.empty()); - when(basicAuthenticator.authenticate(request)).thenReturn(Optional.of(newUserDto())); + when(basicAuthentication.authenticate(request)).thenReturn(Optional.of(newUserDto())); underTest.doFilter(request, response, chain); @@ -87,7 +87,7 @@ public class ValidateActionTest { public void return_true_when_no_jwt_nor_basic_auth_and_no_force_authentication() throws Exception { settings.setProperty("sonar.forceAuthentication", "false"); when(jwtHttpHandler.validateToken(request, response)).thenReturn(Optional.empty()); - when(basicAuthenticator.authenticate(request)).thenReturn(Optional.empty()); + when(basicAuthentication.authenticate(request)).thenReturn(Optional.empty()); underTest.doFilter(request, response, chain); @@ -99,7 +99,7 @@ public class ValidateActionTest { public void return_false_when_no_jwt_nor_basic_auth_and_force_authentication_is_true() throws Exception { settings.setProperty("sonar.forceAuthentication", "true"); when(jwtHttpHandler.validateToken(request, response)).thenReturn(Optional.empty()); - when(basicAuthenticator.authenticate(request)).thenReturn(Optional.empty()); + when(basicAuthentication.authenticate(request)).thenReturn(Optional.empty()); underTest.doFilter(request, response, chain); @@ -110,7 +110,7 @@ public class ValidateActionTest { @Test public void return_false_when_jwt_throws_unauthorized_exception() throws Exception { doThrow(AuthenticationException.class).when(jwtHttpHandler).validateToken(request, response); - when(basicAuthenticator.authenticate(request)).thenReturn(Optional.empty()); + when(basicAuthentication.authenticate(request)).thenReturn(Optional.empty()); underTest.doFilter(request, response, chain); @@ -121,7 +121,7 @@ public class ValidateActionTest { @Test public void return_false_when_basic_authenticator_throws_unauthorized_exception() throws Exception { when(jwtHttpHandler.validateToken(request, response)).thenReturn(Optional.empty()); - doThrow(AuthenticationException.class).when(basicAuthenticator).authenticate(request); + doThrow(AuthenticationException.class).when(basicAuthentication).authenticate(request); underTest.doFilter(request, response, chain); diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterCreateTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterCreateTest.java index c231333770a..e1731a7926a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterCreateTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterCreateTest.java @@ -37,8 +37,8 @@ import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.user.GroupDto; import org.sonar.db.user.UserDto; -import org.sonar.server.authentication.LocalAuthentication; -import org.sonar.server.authentication.LocalAuthentication.HashMethod; +import org.sonar.server.authentication.CredentialsLocalAuthentication; +import org.sonar.server.authentication.CredentialsLocalAuthentication.HashMethod; import org.sonar.server.es.EsTester; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.organization.DefaultOrganizationProvider; @@ -86,7 +86,7 @@ public class UserUpdaterCreateTest { private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db); private TestOrganizationFlags organizationFlags = TestOrganizationFlags.standalone(); private MapSettings settings = new MapSettings(); - private LocalAuthentication localAuthentication = new LocalAuthentication(db.getDbClient()); + private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient()); private UserUpdater underTest = new UserUpdater(newUserNotifier, dbClient, userIndexer, organizationFlags, defaultOrganizationProvider, organizationUpdater, new DefaultGroupFinder(dbClient), settings.asConfig(), localAuthentication); diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterReactivateTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterReactivateTest.java index d677e4fbd7d..1222dc34c4c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterReactivateTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterReactivateTest.java @@ -32,8 +32,8 @@ import org.sonar.db.DbTester; import org.sonar.db.user.GroupDto; import org.sonar.db.user.GroupTesting; import org.sonar.db.user.UserDto; -import org.sonar.server.authentication.LocalAuthentication; -import org.sonar.server.authentication.LocalAuthentication.HashMethod; +import org.sonar.server.authentication.CredentialsLocalAuthentication; +import org.sonar.server.authentication.CredentialsLocalAuthentication.HashMethod; import org.sonar.server.es.EsTester; import org.sonar.server.organization.DefaultOrganizationProvider; import org.sonar.server.organization.OrganizationUpdater; @@ -69,7 +69,7 @@ public class UserUpdaterReactivateTest { private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db); private TestOrganizationFlags organizationFlags = TestOrganizationFlags.standalone(); private MapSettings settings = new MapSettings(); - private LocalAuthentication localAuthentication = new LocalAuthentication(db.getDbClient()); + private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient()); private UserUpdater underTest = new UserUpdater(newUserNotifier, dbClient, userIndexer, organizationFlags, defaultOrganizationProvider, organizationUpdater, new DefaultGroupFinder(dbClient), settings.asConfig(), localAuthentication); diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterUpdateTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterUpdateTest.java index 26327f14d60..8b47869c40c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterUpdateTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterUpdateTest.java @@ -37,7 +37,7 @@ import org.sonar.db.property.PropertyQuery; import org.sonar.db.user.GroupDto; import org.sonar.db.user.UserDto; import org.sonar.db.user.UserTesting; -import org.sonar.server.authentication.LocalAuthentication; +import org.sonar.server.authentication.CredentialsLocalAuthentication; import org.sonar.server.es.EsTester; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.organization.DefaultOrganizationProvider; @@ -81,7 +81,7 @@ public class UserUpdaterUpdateTest { private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db); private TestOrganizationFlags organizationFlags = TestOrganizationFlags.standalone(); private MapSettings settings = new MapSettings(); - private LocalAuthentication localAuthentication = new LocalAuthentication(db.getDbClient()); + private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient()); private UserUpdater underTest = new UserUpdater(newUserNotifier, dbClient, userIndexer, organizationFlags, defaultOrganizationProvider, organizationUpdater, new DefaultGroupFinder(dbClient), settings.asConfig(), localAuthentication); diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java index df6242d80f1..331fd58c945 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java @@ -25,7 +25,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.config.internal.MapSettings; import org.sonar.db.DbTester; -import org.sonar.server.authentication.LocalAuthentication; +import org.sonar.server.authentication.CredentialsLocalAuthentication; import org.sonar.server.es.EsTester; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.ForbiddenException; @@ -58,7 +58,7 @@ public class ChangePasswordActionTest { public UserSessionRule userSessionRule = UserSessionRule.standalone().logIn(); private TestOrganizationFlags organizationFlags = TestOrganizationFlags.standalone(); - private LocalAuthentication localAuthentication = new LocalAuthentication(db.getDbClient()); + private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient()); private UserUpdater userUpdater = new UserUpdater(mock(NewUserNotifier.class), db.getDbClient(), new UserIndexer(db.getDbClient(), es.client()), organizationFlags, diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java index 8812dde814e..a47678b4ffb 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java @@ -34,7 +34,7 @@ import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.user.GroupDto; import org.sonar.db.user.UserDto; -import org.sonar.server.authentication.LocalAuthentication; +import org.sonar.server.authentication.CredentialsLocalAuthentication; import org.sonar.server.es.EsTester; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.organization.DefaultOrganizationProvider; @@ -88,7 +88,7 @@ public class CreateActionTest { private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db); private TestOrganizationFlags organizationFlags = TestOrganizationFlags.standalone(); private OrganizationUpdater organizationUpdater = mock(OrganizationUpdater.class); - private LocalAuthentication localAuthentication = new LocalAuthentication(db.getDbClient()); + private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient()); private WsActionTester tester = new WsActionTester(new CreateAction( db.getDbClient(), new UserUpdater(mock(NewUserNotifier.class), db.getDbClient(), userIndexer, organizationFlags, defaultOrganizationProvider, diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java index 6b9960605f4..5d4d97aa472 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java @@ -30,7 +30,7 @@ import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.user.UserDto; -import org.sonar.server.authentication.LocalAuthentication; +import org.sonar.server.authentication.CredentialsLocalAuthentication; import org.sonar.server.es.EsTester; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; @@ -71,7 +71,7 @@ public class UpdateActionTest { private UserIndexer userIndexer = new UserIndexer(dbClient, es.client()); private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db); private TestOrganizationFlags organizationFlags = TestOrganizationFlags.standalone(); - private LocalAuthentication localAuthentication = new LocalAuthentication(db.getDbClient()); + private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient()); private WsActionTester ws = new WsActionTester(new UpdateAction( new UserUpdater(mock(NewUserNotifier.class), dbClient, userIndexer, organizationFlags, defaultOrganizationProvider, ORGANIZATION_CREATION_NOT_USED_FOR_UPDATE, diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/UsersWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/UsersWsTest.java index d0e7da3a51f..09efe11a6a5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/user/ws/UsersWsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/UsersWsTest.java @@ -25,7 +25,7 @@ import org.junit.Test; import org.sonar.api.server.ws.WebService; import org.sonar.db.DbClient; import org.sonar.db.DbTester; -import org.sonar.server.authentication.LocalAuthentication; +import org.sonar.server.authentication.CredentialsLocalAuthentication; import org.sonar.server.issue.ws.AvatarResolver; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.user.UserUpdater; @@ -42,7 +42,7 @@ public class UsersWsTest { public DbTester db = DbTester.create(); private WebService.Controller controller; - private LocalAuthentication localAuthentication = new LocalAuthentication(db.getDbClient()); + private CredentialsLocalAuthentication localAuthentication = new CredentialsLocalAuthentication(db.getDbClient()); @Before public void setUp() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/usertoken/UserTokenAuthenticatorTest.java b/server/sonar-server/src/test/java/org/sonar/server/usertoken/UserTokenAuthenticationTest.java similarity index 93% rename from server/sonar-server/src/test/java/org/sonar/server/usertoken/UserTokenAuthenticatorTest.java rename to server/sonar-server/src/test/java/org/sonar/server/usertoken/UserTokenAuthenticationTest.java index 611a4553e1d..90c842020f6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/usertoken/UserTokenAuthenticatorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/usertoken/UserTokenAuthenticationTest.java @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class UserTokenAuthenticatorTest { +public class UserTokenAuthenticationTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @@ -41,7 +41,7 @@ public class UserTokenAuthenticatorTest { private TokenGenerator tokenGenerator = mock(TokenGenerator.class); - private UserTokenAuthenticator underTest = new UserTokenAuthenticator(tokenGenerator, db.getDbClient()); + private UserTokenAuthentication underTest = new UserTokenAuthentication(tokenGenerator, db.getDbClient()); @Test public void return_login_when_token_hash_found_in_db() { -- 2.39.5