diff --git a/src/main/java/org/takes/facets/auth/PsBasic.java b/src/main/java/org/takes/facets/auth/PsBasic.java index 30d642b17..ebf7bf19d 100644 --- a/src/main/java/org/takes/facets/auth/PsBasic.java +++ b/src/main/java/org/takes/facets/auth/PsBasic.java @@ -29,6 +29,7 @@ import java.net.HttpURLConnection; import java.net.URLDecoder; import java.net.URLEncoder; +import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -224,6 +225,14 @@ public static final class Default implements PsBasic.Entry { */ private final Map usernames; + /** + * Public ctor. + * @param users Strings with user's login, password and URNs + */ + public Default(final Iterable users) { + this.usernames = Default.converted(users); + } + /** * Public ctor. * @param users Strings with user's login, password and URN with @@ -232,7 +241,7 @@ public static final class Default implements PsBasic.Entry { * {@code "mike my%20password urn:jcabi-users:michael"}. */ public Default(final String... users) { - this.usernames = Default.converted(users); + this(Arrays.asList(users)); } @Override @@ -268,8 +277,8 @@ public Opt enter(final String user, final String pwd) { * {@code "mike my%20password urn:jcabi-users:michael"}. * @return Map from login/password pairs to URNs. */ - private static Map converted(final String... users) { - final Map result = new HashMap<>(users.length); + private static Map converted(final Iterable users) { + final Map result = new HashMap<>(0); for (final String user : users) { final String unified = user.replace("%20", "+"); PsBasic.Default.validateUser(unified);