From 99bf2f25da788da5899a2177bd5344cce8f13f4b Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 24 Jun 2024 13:23:19 +0200 Subject: [PATCH] SEBSERV-549 fixed. was introduced by fix of SEBSERV-515 + code cleanup --- pom.xml | 39 +++++++------------ .../ch/ethz/seb/sebserver/gbl/util/Utils.java | 31 +++++---------- 2 files changed, 22 insertions(+), 48 deletions(-) diff --git a/pom.xml b/pom.xml index b1cc15f3..82ad6768 100644 --- a/pom.xml +++ b/pom.xml @@ -70,7 +70,7 @@ let_reporting - 1.8 + 17 @@ -79,8 +79,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 - 1.8 + ${java.version} + UTF-8 @@ -89,6 +89,9 @@ maven-surefire-plugin UTF-8 + + UTF-8 + @@ -119,27 +122,6 @@ - com.github.spotbugs spotbugs-maven-plugin @@ -163,7 +145,7 @@ org.jacoco jacoco-maven-plugin - 0.8.3 + 0.8.12 prepare-agent @@ -367,13 +349,18 @@ org.apache.commons commons-text - 1.8 + 1.10.0 com.github.vladimir-bukhtoyarov bucket4j-core 4.10.0 + + io.jsonwebtoken + jjwt + 0.9.1 + diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java index 63e01f70..bc4c28ef 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java @@ -9,7 +9,6 @@ package ch.ethz.seb.sebserver.gbl.util; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; @@ -404,12 +403,7 @@ public final class Utils { return value; } - try { - return URLEncoder.encode(value, StandardCharsets.UTF_8.name()); - } catch (final UnsupportedEncodingException e) { - log.error("Failed to encode FormURL_UTF_8 for: {}", value, e); - return value; - } + return URLEncoder.encode(value, StandardCharsets.UTF_8); } public static String decodeFormURL_UTF_8(final String value) { @@ -417,16 +411,11 @@ public final class Utils { return value; } - try { - return URLDecoder.decode( - (value.indexOf('+') >= 0) - ? value.replaceAll("\\+", "%2b") - : value, - StandardCharsets.UTF_8.name()); - } catch (final UnsupportedEncodingException e) { - log.error("Failed to decode FormURL_UTF_8 for: {}", value, e); - return value; - } + return URLDecoder.decode( + (value.indexOf('+') >= 0) + ? value.replaceAll("\\+", "%2b") + : value, + StandardCharsets.UTF_8); } public static void clearCharArray(final char[] array) { @@ -656,12 +645,10 @@ public final class Utils { return StringUtils.EMPTY; } - for (String key : attributes.keySet()) { - List values = attributes.get(key); + for (final String key : attributes.keySet()) { + final List values = attributes.get(key); if (values != null) { - for (int i = 0; i < values.size(); i++) { - values.set(i, encodeFormURL_UTF_8(values.get(i))); - } + values.replaceAll(Utils::encodeFormURL_UTF_8); } }