3 * Copyright (C) 2009-2018 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 package org.sonar.server.authentication;
23 import org.sonar.db.user.UserDto;
24 import org.sonar.db.user.UserTesting;
26 public class TestUserIdentityAuthenticator implements UserIdentityAuthenticator {
28 private UserIdentityAuthenticatorParameters authenticatorParameters;
31 public UserDto authenticate(UserIdentityAuthenticatorParameters authenticatorParameters) {
32 this.authenticatorParameters = authenticatorParameters;
33 String providerId = authenticatorParameters.getUserIdentity().getProviderId();
34 return UserTesting.newUserDto()
36 .setLogin(authenticatorParameters.getUserIdentity().getLogin())
37 .setExternalLogin(authenticatorParameters.getUserIdentity().getProviderLogin())
38 .setExternalId(providerId == null ? authenticatorParameters.getUserIdentity().getProviderLogin() : providerId)
39 .setExternalIdentityProvider(authenticatorParameters.getProvider().getKey());
42 boolean isAuthenticated() {
43 return authenticatorParameters != null;
46 UserIdentityAuthenticatorParameters getAuthenticatorParameters() {
47 return authenticatorParameters;