From: Simon Brandhof Date: Sun, 29 Jan 2017 14:58:28 +0000 (+0100) Subject: SONAR-8716 Remove unused method UserSession#checkAnyPermissions(Collection) X-Git-Tag: 6.3-RC1~269 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=177413e959ac1efd6e6f0601ecc9b6b5536e6046;p=sonarqube.git SONAR-8716 Remove unused method UserSession#checkAnyPermissions(Collection) --- diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/user/CeUserSession.java b/server/sonar-ce/src/main/java/org/sonar/ce/user/CeUserSession.java index ea40800bfe6..c67c2880f30 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/user/CeUserSession.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/user/CeUserSession.java @@ -85,11 +85,6 @@ public class CeUserSession implements UserSession { return notImplemented(); } - @Override - public UserSession checkAnyPermissions(Collection globalPermissions) { - return notImplemented(); - } - @Override public boolean hasPermission(String globalPermission) { return notImplementedBooleanMethod(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/AbstractUserSession.java b/server/sonar-server/src/main/java/org/sonar/server/user/AbstractUserSession.java index 68e0aabe85a..90507535851 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/AbstractUserSession.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/AbstractUserSession.java @@ -19,8 +19,6 @@ */ package org.sonar.server.user; -import java.util.Collection; -import java.util.List; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.UnauthorizedException; @@ -68,18 +66,6 @@ public abstract class AbstractUserSession implements UserSession { return this; } - @Override - public UserSession checkAnyPermissions(Collection globalPermissionsToTest) { - List userGlobalPermissions = globalPermissions(); - for (String userGlobalPermission : userGlobalPermissions) { - if (globalPermissionsToTest.contains(userGlobalPermission)) { - return this; - } - } - - throw new ForbiddenException(INSUFFICIENT_PRIVILEGES_MESSAGE); - } - @Override public boolean hasPermission(String globalPermission) { return isRoot() || globalPermissions().contains(globalPermission); diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/ThreadLocalUserSession.java b/server/sonar-server/src/main/java/org/sonar/server/user/ThreadLocalUserSession.java index a37169496c6..2a03c9af16d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/ThreadLocalUserSession.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/ThreadLocalUserSession.java @@ -19,7 +19,6 @@ */ package org.sonar.server.user; -import java.util.Collection; import java.util.List; import java.util.Set; import javax.annotation.CheckForNull; @@ -109,12 +108,6 @@ public class ThreadLocalUserSession implements UserSession { return this; } - @Override - public UserSession checkAnyPermissions(Collection globalPermissions) { - get().checkAnyPermissions(globalPermissions); - return this; - } - @Override public boolean hasPermission(String globalPermission) { return get().hasPermission(globalPermission); diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/UserSession.java b/server/sonar-server/src/main/java/org/sonar/server/user/UserSession.java index b2419e2294c..2eb5b598177 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/UserSession.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/UserSession.java @@ -19,7 +19,6 @@ */ package org.sonar.server.user; -import java.util.Collection; import java.util.List; import java.util.Set; import javax.annotation.CheckForNull; @@ -72,23 +71,24 @@ public interface UserSession { /** * Ensures that permission is granted to user, otherwise throws a {@link org.sonar.server.exceptions.ForbiddenException}. + * @deprecated in 6.3 because it doesn't support organizations - * + * @see org.sonar.core.permission.GlobalPermissions * @see #checkIsRoot() for system administrators * @see #checkOrganizationPermission(String, String) for organization members */ @Deprecated UserSession checkPermission(String globalPermission); - /** - * Ensures that at least one of the global permissions is granted to user. If none are granted, - * then throws a {@link org.sonar.server.exceptions.ForbiddenException}. - */ - UserSession checkAnyPermissions(Collection globalPermissions); - /** * Does the user have the given permission ? + + * @deprecated in 6.3 because if doesn't support organizations + * @see org.sonar.core.permission.GlobalPermissions + * @see #isRoot() + * @see #hasOrganizationPermission(String, String) */ + @Deprecated boolean hasPermission(String globalPermission); /** diff --git a/server/sonar-server/src/test/java/org/sonar/server/tester/UserSessionRule.java b/server/sonar-server/src/test/java/org/sonar/server/tester/UserSessionRule.java index c1d09db0ff4..fb6f4995c1f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/tester/UserSessionRule.java +++ b/server/sonar-server/src/test/java/org/sonar/server/tester/UserSessionRule.java @@ -20,7 +20,6 @@ package org.sonar.server.tester; import com.google.common.base.Preconditions; -import java.util.Collection; import java.util.List; import java.util.Set; import javax.annotation.CheckForNull; @@ -321,12 +320,6 @@ public class UserSessionRule implements TestRule, UserSession { return this; } - @Override - public UserSession checkAnyPermissions(Collection globalPermissions) { - currentUserSession.checkAnyPermissions(globalPermissions); - return this; - } - @Override public boolean hasPermission(String globalPermission) { return currentUserSession.hasPermission(globalPermission);