[java-idp-oidc] branch main updated: JOIDC-112 - PROTOCOL_MESSAGE.OAUTH2 log appender to trace all the exchanged protocol messages

Henri Mikkonen henri.mikkonen at iki.fi
Tue Jun 28 13:41:45 UTC 2022


This is an automated email from the git hooks/post-receive script.

hjmikkon pushed a commit to branch main
in repository java-idp-oidc.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-oidc.git;a=commit;h=b174efbd061876248139690e8af12b76eaf28b98

The following commit(s) were added to refs/heads/main by this push:
     new b174efbd JOIDC-112 - PROTOCOL_MESSAGE.OAUTH2 log appender to trace all the exchanged protocol messages
b174efbd is described below

commit b174efbd061876248139690e8af12b76eaf28b98
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Tue Jun 28 16:40:39 2022 +0300

    JOIDC-112 - PROTOCOL_MESSAGE.OAUTH2 log appender to trace all the exchanged protocol messages
    
    https://shibboleth.atlassian.net/browse/JOIDC-112
    
    Helper method for JSONSuccessResponse to get configuration and keyset responses parsed
    for protocol message logging.
---
 .../plugin/oidc/op/messaging/JSONSuccessResponse.java  | 11 +++++++++++
 .../idp/plugin/oidc/op/encoding/impl/ResponseUtil.java | 18 ++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/idp-oidc-extension-api/src/main/java/net/shibboleth/idp/plugin/oidc/op/messaging/JSONSuccessResponse.java b/idp-oidc-extension-api/src/main/java/net/shibboleth/idp/plugin/oidc/op/messaging/JSONSuccessResponse.java
index 6a8955a3..ce316ab2 100644
--- a/idp-oidc-extension-api/src/main/java/net/shibboleth/idp/plugin/oidc/op/messaging/JSONSuccessResponse.java
+++ b/idp-oidc-extension-api/src/main/java/net/shibboleth/idp/plugin/oidc/op/messaging/JSONSuccessResponse.java
@@ -20,6 +20,7 @@ package net.shibboleth.idp.plugin.oidc.op.messaging;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import com.google.common.base.MoreObjects;
 import com.nimbusds.common.contenttype.ContentType;
 import com.nimbusds.oauth2.sdk.SuccessResponse;
 import com.nimbusds.oauth2.sdk.http.HTTPResponse;
@@ -70,6 +71,16 @@ public class JSONSuccessResponse implements SuccessResponse {
         return true;
     }
 
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this).omitNullValues()
+                .add("content", content.toJSONString())
+                .add("cacheControl", cacheControl)
+                .add("pragma", pragma)
+                .toString();
+    }
+
     /** {@inheritDoc} */
     @Override
     public HTTPResponse toHTTPResponse() {
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/encoding/impl/ResponseUtil.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/encoding/impl/ResponseUtil.java
index 746b017f..e597478e 100644
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/encoding/impl/ResponseUtil.java
+++ b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/encoding/impl/ResponseUtil.java
@@ -51,6 +51,7 @@ import com.nimbusds.openid.connect.sdk.rp.OIDCClientInformationResponse;
 import com.nimbusds.openid.connect.sdk.token.OIDCTokens;
 
 import net.shibboleth.idp.plugin.oidc.op.decoding.impl.RequestUtil;
+import net.shibboleth.idp.plugin.oidc.op.messaging.JSONSuccessResponse;
 import net.shibboleth.idp.plugin.oidc.op.oauth2.messaging.impl.OAuth2RevocationErrorResponse;
 import net.shibboleth.idp.plugin.oidc.op.oauth2.messaging.impl.OAuth2RevocationSuccessResponse;
 
@@ -141,6 +142,8 @@ public final class ResponseUtil {
             return getProtocolMessageForRevocationResponse(response);
         } else if (response instanceof OAuth2RevocationErrorResponse) {
             return getProtocolMessageForRevocationResponse(response);
+        } else if (response instanceof JSONSuccessResponse) {
+            return getProtocolMessageForJSONSuccessResponse(response);
         } else if (response instanceof ErrorResponse) {
             final ErrorResponse genericError = (ErrorResponse) response;
             return MoreObjects.toStringHelper(genericError).omitNullValues()
@@ -363,4 +366,19 @@ public final class ResponseUtil {
             return null;
         }
     }
+
+    /**
+     * Helper method for getting protocol message for JSON success response.
+     * 
+     * @param response The response message
+     * @return  The response message specific log message
+     */
+    @Nullable public static String getProtocolMessageForJSONSuccessResponse(@Nonnull Response response) {
+        if (response instanceof JSONSuccessResponse) {
+            final JSONSuccessResponse successResponse = (JSONSuccessResponse) response;
+            return successResponse.toString();
+        }
+        return null;
+    }
+
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list