Prevent ArrayIndexOutOfBoundsException in JwtTokenFilter.getTokenString

This commit is contained in:
Dario Seidl 2018-04-01 21:42:32 +02:00
parent 1635c21da1
commit 290c4bf4b3

View File

@ -48,10 +48,15 @@ public class JwtTokenFilter extends OncePerRequestFilter {
} }
private Optional<String> getTokenString(String header) { private Optional<String> getTokenString(String header) {
if (header == null || header.split("").length < 2) { if (header == null)
return Optional.empty(); return Optional.empty();
} else { else {
return Optional.ofNullable(header.split(" ")[1]); String[] split = header.split(" ");
if (split.length < 2) {
return Optional.empty();
} else {
return Optional.ofNullable(split[1]);
}
} }
} }
} }