[java-idp-oidc] branch main updated: JOIDC-280 - Protocol request logs should make difference between query and body parameters
Codeberg
noreply at shibboleth.net
Wed Jun 17 15:12:17 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-idp-oidc.
View the commit online:
https://codeberg.org/Shibboleth/java-idp-oidc/commit/2a1cc7f35882677a985c08cfc742cc38903225e0
The following commit(s) were added to refs/heads/main by this push:
new 2a1cc7f3 JOIDC-280 - Protocol request logs should make difference between query and body parameters
2a1cc7f3 is described below
commit 2a1cc7f35882677a985c08cfc742cc38903225e0
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Wed Jun 17 18:10:43 2026 +0300
JOIDC-280 - Protocol request logs should make difference between query and body parameters
https://shibboleth.atlassian.net/browse/JOIDC-280
Provide 'Query parameters' and 'Body parameters'
---
.../plugin/oidc/op/decoding/impl/RequestUtil.java | 79 ++++++++++++----------
1 file changed, 42 insertions(+), 37 deletions(-)
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/decoding/impl/RequestUtil.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/decoding/impl/RequestUtil.java
index 920e39eb..7a124b41 100644
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/decoding/impl/RequestUtil.java
+++ b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/decoding/impl/RequestUtil.java
@@ -17,6 +17,7 @@ package net.shibboleth.idp.plugin.oidc.op.decoding.impl;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
import javax.annotation.Nullable;
@@ -26,12 +27,16 @@ import com.google.common.base.MoreObjects;
import com.nimbusds.oauth2.sdk.AuthorizationCodeGrant;
import com.nimbusds.oauth2.sdk.AuthorizationGrant;
import com.nimbusds.oauth2.sdk.ClientCredentialsGrant;
+import com.nimbusds.oauth2.sdk.ParseException;
import com.nimbusds.oauth2.sdk.RefreshTokenGrant;
import com.nimbusds.oauth2.sdk.auth.ClientAuthentication;
import com.nimbusds.oauth2.sdk.http.HTTPRequest;
import com.nimbusds.oauth2.sdk.token.AccessToken;
import com.nimbusds.oauth2.sdk.token.RefreshToken;
+import net.shibboleth.shared.collection.CollectionSupport;
+import net.shibboleth.shared.primitive.StringSupport;
+
/** Request logging helper class. */
public final class RequestUtil {
@@ -47,29 +52,7 @@ public final class RequestUtil {
* @return request as formatted string.
*/
@Nullable public static String toString(@Nullable final HTTPRequest httpReq) {
- if (httpReq == null) {
- return null;
- }
- final String nl = System.lineSeparator();
- String ret = httpReq.getMethod().toString() + nl;
- final Map<String, List<String>> headers = httpReq.getHeaderMap();
- if (headers != null) {
- ret += "Headers:" + nl;
- for (final Entry<String, List<String>> entry : headers.entrySet()) {
- ret += "\t" + entry.getKey() + ":" + entry.getValue() + nl;
- }
- }
- final Map<String, List<String>> parameters = httpReq.getQueryParameters();
- if (parameters != null) {
- ret += "Parameters:" + nl;
- for (final Entry<String, List<String>> entry : parameters.entrySet()) {
- final List<String> values = entry.getValue();
- for (int i = 0; values != null && i < values.size(); i++) {
- ret += "\t" + entry.getKey() + ":" + values.get(i) + nl;
- }
- }
- }
- return ret;
+ return toString(httpReq, null);
}
/**
@@ -95,22 +78,44 @@ public final class RequestUtil {
ret += "\t" + entry.getKey() + ":" + entry.getValue() + nl;
}
}
- final Map<String, List<String>> parameters = httpReq.getQueryParameters();
- if (parameters != null) {
- if (objectMapper != null && !parameters.isEmpty()) {
- final String rawValue = parameters.keySet().iterator().next();
- try {
- final Object jsonObject = objectMapper.readValue(rawValue, Object.class);
- final String content = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonObject);
- return ret + "Content:" + content.replace("\n", "\n\t");
- } catch (JsonProcessingException e) {
- // fall-back into not using object mapper
- }
+ final Map<String, List<String>> queryParameters =
+ Optional.ofNullable(httpReq.getQueryStringParameters()).orElse(CollectionSupport.emptyMap());
+ if (!queryParameters.isEmpty()) {
+ ret += "Query parameters: " + nl;
+ for (final Entry<String, List<String>> entry : queryParameters.entrySet()) {
+ final List<String> values = entry.getValue();
+ for (int i = 0; values != null && i < values.size(); i++) {
+ ret += "\t" + entry.getKey() + ":" + values.get(i) + nl;
+ }
}
- ret += "Parameters:" + nl;
- for (final Entry<String, List<String>> entry : parameters.entrySet()) {
- ret += "\t" + entry.getKey() + ":" + entry.getValue().get(0) + nl;
+ }
+
+ final String body = httpReq.getBody();
+ if (StringSupport.trimOrNull(body) != null) {
+ try {
+ final Map<String, List<String>> bodyParameters = Optional.ofNullable(httpReq.getBodyAsFormParameters())
+ .orElse(CollectionSupport.emptyMap());
+ ret += "Body parameters:" + nl;
+ for (final Entry<String, List<String>> entry : bodyParameters.entrySet()) {
+ final List<String> values = entry.getValue();
+ for (int i = 0; values != null && i < values.size(); i++) {
+ ret += "\t" + entry.getKey() + ":" + values.get(i) + nl;
+ }
+ }
+ } catch (final ParseException e) {
+ if (objectMapper != null) {
+ try {
+ final Object jsonObject = objectMapper.readValue(body, Object.class);
+ final String content =
+ objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonObject);
+ return ret + "Content:" + content.replace("\n", "\n\t");
+ } catch (JsonProcessingException e1) {
+ // fall-back into not using object mapper
+ }
+
+ }
+ return ret + "Content: " + body;
}
}
return ret;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list