From ac0b444112b222c6c621e368d142d9ae0f64c46e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CAkshay?= <“ayyanchira.akshay@gmail.com”> Date: Wed, 6 Mar 2024 12:12:05 -0800 Subject: [PATCH 1/2] [MOB-6832] - AuthDecode crash fix --- .../java/com/iterable/iterableapi/IterableAuthManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/iterableapi/src/main/java/com/iterable/iterableapi/IterableAuthManager.java b/iterableapi/src/main/java/com/iterable/iterableapi/IterableAuthManager.java index c52e23771..d47eb145f 100644 --- a/iterableapi/src/main/java/com/iterable/iterableapi/IterableAuthManager.java +++ b/iterableapi/src/main/java/com/iterable/iterableapi/IterableAuthManager.java @@ -156,6 +156,10 @@ public void run() { private static long decodedExpiration(String encodedJWT) throws Exception { long exp = 0; String[] split = encodedJWT.split("\\."); + //Check if jwt is valid + if (split.length != 3) { + throw new Exception("Invalid JWT"); + } String body = getJson(split[1]); JSONObject jObj = new JSONObject(body); exp = jObj.getLong(expirationString); From 765298bd75d3ad7473b9eea91c64c4c184fe949f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CAkshay?= <“ayyanchira.akshay@gmail.com”> Date: Fri, 15 Mar 2024 13:22:55 -0700 Subject: [PATCH 2/2] Specifying Exception instead of generic one --- .../main/java/com/iterable/iterableapi/IterableAuthManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iterableapi/src/main/java/com/iterable/iterableapi/IterableAuthManager.java b/iterableapi/src/main/java/com/iterable/iterableapi/IterableAuthManager.java index d47eb145f..562e86bd7 100644 --- a/iterableapi/src/main/java/com/iterable/iterableapi/IterableAuthManager.java +++ b/iterableapi/src/main/java/com/iterable/iterableapi/IterableAuthManager.java @@ -158,7 +158,7 @@ private static long decodedExpiration(String encodedJWT) throws Exception { String[] split = encodedJWT.split("\\."); //Check if jwt is valid if (split.length != 3) { - throw new Exception("Invalid JWT"); + throw new IllegalArgumentException("Invalid JWT"); } String body = getJson(split[1]); JSONObject jObj = new JSONObject(body);