]> source.dussan.org Git - sonarqube.git/commitdiff
NO-JIRA cleanup dead code related to organisations
authorPierre <pierre.guillot@sonarsource.com>
Mon, 30 Jan 2023 10:06:00 +0000 (11:06 +0100)
committersonartech <sonartech@sonarsource.com>
Mon, 30 Jan 2023 20:03:00 +0000 (20:03 +0000)
server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/OAuth2CallbackContext.java [deleted file]
server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/OAuth2ContextFactory.java
server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/UserRegistration.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2ContextFactoryTest.java

diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/OAuth2CallbackContext.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/OAuth2CallbackContext.java
deleted file mode 100644 (file)
index ce28d07..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2023 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.authentication;
-
-import java.util.Set;
-import javax.annotation.Nullable;
-import org.sonar.api.server.authentication.OAuth2IdentityProvider;
-import org.sonar.api.server.authentication.UserIdentity;
-
-public interface OAuth2CallbackContext extends OAuth2IdentityProvider.CallbackContext {
-
-  void authenticate(UserIdentity userIdentity, @Nullable Set<String> organizationAlmIds);
-
-}
index dee6d82bbaebcf1597ddc6d02441992637a92f44..fe3522f846d440708e5295e1d7b2cfb6a180e6fe 100644 (file)
@@ -73,7 +73,7 @@ public class OAuth2ContextFactory {
     return server.getPublicRootUrl() + CALLBACK_PATH + identityProviderKey;
   }
 
-  public class OAuthContextImpl implements OAuth2IdentityProvider.InitContext, OAuth2CallbackContext {
+  public class OAuthContextImpl implements OAuth2IdentityProvider.InitContext, OAuth2IdentityProvider.CallbackContext {
 
     private final HttpServletRequest request;
     private final HttpServletResponse response;
@@ -137,17 +137,11 @@ public class OAuth2ContextFactory {
 
     @Override
     public void authenticate(UserIdentity userIdentity) {
-      authenticate(userIdentity, null);
-    }
-
-    @Override
-    public void authenticate(UserIdentity userIdentity, @Nullable Set<String> organizationAlmIds) {
       UserDto userDto = userRegistrar.register(
         UserRegistration.builder()
           .setUserIdentity(userIdentity)
           .setProvider(identityProvider)
           .setSource(AuthenticationEvent.Source.oauth2(identityProvider))
-          .setOrganizationAlmIds(organizationAlmIds)
           .build());
       jwtHttpHandler.generateToken(userDto, request, response);
       threadLocalUserSession.set(userSessionFactory.create(userDto));
index e4c316b79bd347e18e52ff868894513f51e42452..a3bbc60bf1617ad7098713e7fd2c27251c86c988 100644 (file)
@@ -33,13 +33,11 @@ public class UserRegistration {
   private final UserIdentity userIdentity;
   private final IdentityProvider provider;
   private final AuthenticationEvent.Source source;
-  private final Set<String> organizationAlmIds;
 
   UserRegistration(Builder builder) {
     this.userIdentity = builder.userIdentity;
     this.provider = builder.provider;
     this.source = builder.source;
-    this.organizationAlmIds = builder.organizationAlmIds;
   }
 
   public UserIdentity getUserIdentity() {
@@ -54,11 +52,6 @@ public class UserRegistration {
     return source;
   }
 
-  @CheckForNull
-  public Set<String> getOrganizationAlmIds() {
-    return organizationAlmIds;
-  }
-
   public static UserRegistration.Builder builder() {
     return new Builder();
   }
@@ -67,7 +60,6 @@ public class UserRegistration {
     private UserIdentity userIdentity;
     private IdentityProvider provider;
     private AuthenticationEvent.Source source;
-    private Set<String> organizationAlmIds;
 
     public Builder setUserIdentity(UserIdentity userIdentity) {
       this.userIdentity = userIdentity;
@@ -84,15 +76,6 @@ public class UserRegistration {
       return this;
     }
 
-    /**
-     * List of ALM organization the user is member of.
-     * When set to null, it means that no organization membership synchronization should be done.
-     */
-    public Builder setOrganizationAlmIds(@Nullable Set<String> organizationAlmIds) {
-      this.organizationAlmIds = organizationAlmIds;
-      return this;
-    }
-
     public UserRegistration build() {
       requireNonNull(userIdentity, "userIdentity must be set");
       requireNonNull(provider, "identityProvider must be set");
index 8f672428043cc0c87d5e9f2fd71791101911bb86..507391bd9ce1b60980e9397160146289b21d094d 100644 (file)
@@ -134,16 +134,6 @@ public class OAuth2ContextFactoryTest {
     assertThat(userArgumentCaptor.getValue().getExternalIdentityProvider()).isEqualTo(PROVIDER_KEY);
   }
 
-  @Test
-  public void authenticate_with_organization_alm_ids() {
-    OAuthContextImpl callback = (OAuthContextImpl) newCallbackContext();
-    Set<String> organizationAlmIds = ImmutableSet.of("ABCD", "EFGH");
-
-    callback.authenticate(USER_IDENTITY, organizationAlmIds);
-
-    assertThat(userIdentityAuthenticator.getAuthenticatorParameters().getOrganizationAlmIds()).containsAll(organizationAlmIds);
-  }
-
   @Test
   public void redirect_to_home() throws Exception {
     when(server.getContextPath()).thenReturn("");