diff options
author | Matteo Mara <matteo.mara@sonarsource.com> | 2022-04-25 16:18:48 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-04-29 20:03:19 +0000 |
commit | 38ef03badd49880738ea9e1ab686d4e1c68247ac (patch) | |
tree | 3d154accfd457733e2698754ca9bb1edb6e2f9ef /server/sonar-webserver-auth/src | |
parent | ac2259ccb777e0f143d828debc101d34444ad35f (diff) | |
download | sonarqube-38ef03badd49880738ea9e1ab686d4e1c68247ac.tar.gz sonarqube-38ef03badd49880738ea9e1ab686d4e1c68247ac.zip |
SONAR-16263 Handle analysis token lifecycle
Diffstat (limited to 'server/sonar-webserver-auth/src')
6 files changed, 6 insertions, 37 deletions
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/TokenGenerator.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/TokenGenerator.java index b41644530bf..1df9e1f8dad 100644 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/TokenGenerator.java +++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/TokenGenerator.java @@ -19,6 +19,8 @@ */ package org.sonar.server.usertoken; +import org.sonar.db.user.TokenType; + public interface TokenGenerator { /** * Generate a token. It must be unique and non deterministic.<br /> diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/TokenGeneratorImpl.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/TokenGeneratorImpl.java index 235a2fb0285..fee313bd1f0 100644 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/TokenGeneratorImpl.java +++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/TokenGeneratorImpl.java @@ -22,6 +22,7 @@ package org.sonar.server.usertoken; import java.security.SecureRandom; import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.digest.DigestUtils; +import org.sonar.db.user.TokenType; public class TokenGeneratorImpl implements TokenGenerator { diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/TokenType.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/TokenType.java deleted file mode 100644 index 0fcfbd7626a..00000000000 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/TokenType.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2022 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.usertoken; - -public enum TokenType { - - USER_TOKEN("u"), - GLOBAL_ANALYSIS_TOKEN("a"), - PROJECT_ANALYSIS_TOKEN("p"); - - private final String identifier; - - TokenType(String identifier) { - this.identifier = identifier; - } - - public String getIdentifier() { - return identifier; - } -} diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/UserTokenAuthentication.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/UserTokenAuthentication.java index 1bed33677d6..03af54aa1c4 100644 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/UserTokenAuthentication.java +++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/usertoken/UserTokenAuthentication.java @@ -24,6 +24,7 @@ import java.util.Set; import javax.annotation.Nullable; import org.sonar.db.DbClient; import org.sonar.db.DbSession; +import org.sonar.db.user.TokenType; import org.sonar.db.user.UserTokenDto; import org.sonar.server.authentication.UserLastConnectionDatesUpdater; diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/TokenGeneratorImplTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/TokenGeneratorImplTest.java index d0816bca086..08a20be69b2 100644 --- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/TokenGeneratorImplTest.java +++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/TokenGeneratorImplTest.java @@ -20,6 +20,7 @@ package org.sonar.server.usertoken; import org.junit.Test; +import org.sonar.db.user.TokenType; import static org.assertj.core.api.Assertions.assertThat; diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/UserTokenAuthenticationTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/UserTokenAuthenticationTest.java index 7957812dab1..32b2c3948ba 100644 --- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/UserTokenAuthenticationTest.java +++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/UserTokenAuthenticationTest.java @@ -24,6 +24,7 @@ import org.junit.Rule; import org.junit.Test; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; +import org.sonar.db.user.TokenType; import org.sonar.db.user.UserDto; import org.sonar.db.user.UserTokenDto; import org.sonar.server.authentication.UserLastConnectionDatesUpdater; |