Indicate whether each download scheme supports authentication isAuthSupported() defaults to isAuthRequired(), which is the value used here, so no behavior change intended. Explicitly specifying whether authentication is supported makes it clearer which download schemes should be shown for changes that are not visible to anonymous users. Later we can stop providing a default implementation in DownloadScheme to prevent new download schemes from getting a wrong setting by forgetting to override the default. Change-Id: If6f11bf906c58c721b0a9c39b9dbee48384b6e32
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/AnonymousHttpScheme.java b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/AnonymousHttpScheme.java index 905b0b6..1ea2cf0 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/AnonymousHttpScheme.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/AnonymousHttpScheme.java
@@ -71,6 +71,11 @@ return false; } + @Override + public boolean isAuthSupported() { + return false; + } + private static String ensureSlash(String in) { if (in != null && !in.endsWith("/")) { return in + "/";
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/GitScheme.java b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/GitScheme.java index 77b12b0..e185fdc 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/GitScheme.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/GitScheme.java
@@ -56,6 +56,11 @@ return false; } + @Override + public boolean isAuthSupported() { + return false; + } + private static String ensureSlash(String in) { if (in != null && !in.endsWith("/")) { return in + "/";
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/HttpScheme.java b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/HttpScheme.java index b97a1bd..af75046 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/HttpScheme.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/HttpScheme.java
@@ -86,6 +86,11 @@ return true; } + @Override + public boolean isAuthSupported() { + return true; + } + private static String ensureSlash(String in) { if (in != null && !in.endsWith("/")) { return in + "/";
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/SshScheme.java b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/SshScheme.java index f662060..8253b66 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/scheme/SshScheme.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/scheme/SshScheme.java
@@ -79,6 +79,11 @@ return true; } + @Override + public boolean isAuthSupported() { + return true; + } + private static String ensureSlash(String in) { if (in != null && !in.endsWith("/")) { return in + "/";