[java-identity-provider] branch main updated: OSJ-354: Suffix the PROTOCOL_MESSAGE category with .SAML

Brent Putman putmanb at georgetown.edu
Wed Aug 2 23:28:35 UTC 2023


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

putmanb pushed a commit to branch main
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=b5932c4d4234af685fa3b344acff0211eae4d763

The following commit(s) were added to refs/heads/main by this push:
     new b5932c4d4 OSJ-354: Suffix the PROTOCOL_MESSAGE category with .SAML
b5932c4d4 is described below

commit b5932c4d4234af685fa3b344acff0211eae4d763
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Wed Aug 2 00:02:22 2023 -0400

    OSJ-354: Suffix the PROTOCOL_MESSAGE category with .SAML
---
 .../BaseIdPInitiatedSSORequestMessageDecoder.java  | 36 +++++-----------------
 .../impl/IdPInitiatedSSORequestMessageDecoder.java |  9 +++---
 .../impl/IdPInitiatedSSORequestMessageDecoder.java |  8 ++---
 3 files changed, 15 insertions(+), 38 deletions(-)

diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/profile/impl/BaseIdPInitiatedSSORequestMessageDecoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/profile/impl/BaseIdPInitiatedSSORequestMessageDecoder.java
index 49a5b4d85..f060c0e9f 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/profile/impl/BaseIdPInitiatedSSORequestMessageDecoder.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/profile/impl/BaseIdPInitiatedSSORequestMessageDecoder.java
@@ -58,9 +58,12 @@ public abstract class BaseIdPInitiatedSSORequestMessageDecoder extends AbstractH
      */
     @Nullable private BindingDescriptor bindingDescriptor;
     
-    /** Used to log protocol messages. */
-    @Nonnull private final Logger protocolMessageLog = LoggerFactory.getLogger("PROTOCOL_MESSAGE");
-    
+    /** Constructor. */
+    public BaseIdPInitiatedSSORequestMessageDecoder() {
+        super();
+        setProtocolMessageLoggerCategory(BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY + ".SAML");
+    }
+
     /** ID generator. */
     @Nonnull private final IdentifierGenerationStrategy idGenerator =
             IdentifierGenerationStrategy.getInstance(ProviderType.UUID);
@@ -90,7 +93,6 @@ public abstract class BaseIdPInitiatedSSORequestMessageDecoder extends AbstractH
     public void decode() throws MessageDecodingException {        
         log.debug("Beginning to decode message from HttpServletRequest");
         super.decode();
-        logDecodedMessage();
         log.debug("Successfully decoded message from HttpServletRequest.");
     }
     
@@ -175,22 +177,7 @@ public abstract class BaseIdPInitiatedSSORequestMessageDecoder extends AbstractH
             throw new MessageDecodingException("Shibboleth Authentication Request contained a non-numeric time value");
         }
     }
-    
-    /**
-     * Log the decoded message to the protocol message logger.
-     */
-    protected void logDecodedMessage() {
-        if (protocolMessageLog.isDebugEnabled() ){
-            final String message = getMessageToLog();
-            if (message == null) {
-                log.warn("Decoded message was null, nothing to log");
-                return;
-            }
-            
-            protocolMessageLog.debug("\n" + message);
-        }
-    }
-    
+
     /**
      * Construct a message ID for the request.
      * 
@@ -212,12 +199,5 @@ public abstract class BaseIdPInitiatedSSORequestMessageDecoder extends AbstractH
         }
         return idGenerator.generateIdentifier();
     }
-    
-    /**
-     * Get the string representation of what will be logged as the protocol message.
-     * 
-     * @return the string representing the protocol message for logging purposes
-     */
-    @Nullable protected abstract String getMessageToLog();
-    
+ 
 }
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/IdPInitiatedSSORequestMessageDecoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/IdPInitiatedSSORequestMessageDecoder.java
index 9ac8979fc..743644362 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/IdPInitiatedSSORequestMessageDecoder.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/IdPInitiatedSSORequestMessageDecoder.java
@@ -94,12 +94,11 @@ public class IdPInitiatedSSORequestMessageDecoder extends BaseIdPInitiatedSSOReq
 
     /** {@inheritDoc} */
     @Override
-    @Nullable protected String getMessageToLog() {
-        final MessageContext request = getMessageContext();
-        if (request == null) {
-            return "SAML1 initiated request did not exist?";
+    @Nullable protected String serializeMessageForLogging(@Nullable final Object message) {
+        if (message == null) {
+            log.debug("Message was null, can not serialize");
+            return null;
         }
-        final  Object message = Constraint.isNotNull(request.getMessage(), "No message");
         return "SAML 1 IdP-initiated request was: " + message.toString();
     }
     
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/IdPInitiatedSSORequestMessageDecoder.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/IdPInitiatedSSORequestMessageDecoder.java
index 9a0b24982..b765bda31 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/IdPInitiatedSSORequestMessageDecoder.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/IdPInitiatedSSORequestMessageDecoder.java
@@ -149,11 +149,9 @@ public class IdPInitiatedSSORequestMessageDecoder extends BaseIdPInitiatedSSOReq
 
     /** {@inheritDoc} */
     @Override
-    @Nullable protected String getMessageToLog() {
-        final MessageContext ctx = getMessageContext();
-        final Object message = ctx == null ? null : ctx.getMessage();
-        if (message == null || !(message instanceof XMLObject)) {
-            log.warn("Decoded message was null or invalid, nothing to log");
+    @Nullable protected String serializeMessageForLogging(@Nullable final Object message) {
+        if (message == null || !XMLObject.class.isInstance(message)) {
+            log.debug("Message was null or unsupported, can not serialize");
             return null;
         }
         

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


More information about the commits mailing list