From 21deab2af621b3d42cc17954ac2a12eeea6f5d6f Mon Sep 17 00:00:00 2001 From: Matti Lupari Date: Thu, 7 Nov 2024 10:31:45 +0200 Subject: [PATCH] CSCEXAM-1384 Enrolment permission check: change handling of params - query params must not be url encoded before passing to ws client because it re-encodes them while executing requests --- app/impl/ExternalCourseHandlerImpl.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/impl/ExternalCourseHandlerImpl.java b/app/impl/ExternalCourseHandlerImpl.java index ec9b7e703..d1874acb7 100644 --- a/app/impl/ExternalCourseHandlerImpl.java +++ b/app/impl/ExternalCourseHandlerImpl.java @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2024. The members of the EXAM Consortium +// +// SPDX-License-Identifier: EUPL-1.2 + /* * Copyright (c) 2018 The members of the EXAM Consortium (https://confluence.csc.fi/display/EXAM/Konsortio-organisaatio) * @@ -21,10 +25,8 @@ import io.ebean.DB; import java.io.ByteArrayInputStream; import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; -import java.net.URLEncoder; +import java.net.*; +import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.text.ParseException; @@ -144,7 +146,8 @@ public CompletionStage> getPermittedCourses(User user) throws URL url = parseUrl(user); WSRequest request = wsClient.url(url.toString().split("\\?")[0]); if (url.getQuery() != null) { - request = request.setQueryString(url.getQuery()); + // Ws Client does encode the query so we need to decode it back first, bit dumb though + request = request.setQueryString(URLDecoder.decode(url.getQuery(), Charset.defaultCharset())); } if (configReader.isApiKeyUsed()) { request = request.addHeader(configReader.getApiKeyName(), configReader.getApiKeyValue());