From 0dcb4b9a7ab26d51f20302ae3fa7bd085f1221b3 Mon Sep 17 00:00:00 2001 From: David Kocher Date: Fri, 5 Jun 2020 11:11:50 +0200 Subject: [PATCH] Review interface to return collection for allowed authentication methods that allows to query for elements. (#593) --- src/main/java/net/schmizz/sshj/userauth/UserAuth.java | 4 +++- src/main/java/net/schmizz/sshj/userauth/UserAuthImpl.java | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/schmizz/sshj/userauth/UserAuth.java b/src/main/java/net/schmizz/sshj/userauth/UserAuth.java index f931cfe86..dea91b35b 100644 --- a/src/main/java/net/schmizz/sshj/userauth/UserAuth.java +++ b/src/main/java/net/schmizz/sshj/userauth/UserAuth.java @@ -19,6 +19,8 @@ import net.schmizz.sshj.transport.TransportException; import net.schmizz.sshj.userauth.method.AuthMethod; +import java.util.Collection; + /** User authentication API. See RFC 4252. */ public interface UserAuth { @@ -58,6 +60,6 @@ boolean authenticate(String username, Service nextService, AuthMethod methods, i boolean hadPartialSuccess(); /** The available authentication methods. This is only defined once an unsuccessful authentication has taken place. */ - Iterable getAllowedMethods(); + Collection getAllowedMethods(); } diff --git a/src/main/java/net/schmizz/sshj/userauth/UserAuthImpl.java b/src/main/java/net/schmizz/sshj/userauth/UserAuthImpl.java index d6b7cc776..26499e8c0 100644 --- a/src/main/java/net/schmizz/sshj/userauth/UserAuthImpl.java +++ b/src/main/java/net/schmizz/sshj/userauth/UserAuthImpl.java @@ -27,6 +27,7 @@ import net.schmizz.sshj.userauth.method.AuthMethod; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -99,7 +100,7 @@ public boolean hadPartialSuccess() { } @Override - public Iterable getAllowedMethods() { + public Collection getAllowedMethods() { return Collections.unmodifiableList(allowedMethods); }