diff --git a/src/main/java/org/libj/net/AuthScheme.java b/src/main/java/org/libj/net/AuthScheme.java index 0a9f497..be8b867 100644 --- a/src/main/java/org/libj/net/AuthScheme.java +++ b/src/main/java/org/libj/net/AuthScheme.java @@ -123,6 +123,11 @@ Basic newInstance(final String authorization) { return decode(authorization); } + @Override + int schemeLength() { + return 6; + } + @Override public boolean equals(final Object obj) { if (obj == this) @@ -182,7 +187,7 @@ public static String encode(final String token) { * @throws IllegalArgumentException If {@code authorization} is not in valid Base64 scheme. */ public static Bearer decode(final String authorization) { - return prototype.matches(Objects.requireNonNull(authorization)) ? new Bearer(authorization.substring(7)) : null; + return prototype.matches(Objects.requireNonNull(authorization)) ? new Bearer(authorization.substring(prototype.schemeLength() + 1)) : null; } private final String token; @@ -225,6 +230,11 @@ Bearer newInstance(final String authorization) { return decode(authorization); } + @Override + int schemeLength() { + return 6; + } + @Override public boolean equals(final Object obj) { if (obj == this) @@ -296,4 +306,5 @@ public final boolean matches(final String authorization) { public abstract String encode(); abstract AuthScheme newInstance(String authorization); + abstract int schemeLength(); } \ No newline at end of file