[java-identity-provider] branch main updated: Audit logging tweaks for SP use.

Codeberg noreply at shibboleth.net
Tue Nov 17 16:10:43 UTC 2026


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

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

View the commit online:
https://codeberg.org/Shibboleth/java-identity-provider/commit/5e138dedbe50966afbebef75fdfb9727d1722c1f

The following commit(s) were added to refs/heads/main by this push:
     new 5e138dedb Audit logging tweaks for SP use.
5e138dedb is described below

commit 5e138dedbe50966afbebef75fdfb9727d1722c1f
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Tue Nov 17 11:10:06 2026 -0500

    Audit logging tweaks for SP use.
---
 .../idp/profile/audit/impl/WriteAuditLog.java      | 50 +++++++++++++---------
 1 file changed, 30 insertions(+), 20 deletions(-)

diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/audit/impl/WriteAuditLog.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/audit/impl/WriteAuditLog.java
index 5d038a772..3c32609a5 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/audit/impl/WriteAuditLog.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/audit/impl/WriteAuditLog.java
@@ -31,10 +31,10 @@ import javax.annotation.Nullable;
 
 import org.opensaml.messaging.context.navigate.ChildContextLookup;
 import org.opensaml.profile.action.EventIds;
+import org.opensaml.profile.context.EventContext;
 import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.profile.context.navigate.CurrentOrPreviousEventLookup;
 import org.slf4j.Logger;
-import org.springframework.webflow.execution.Event;
-import org.springframework.webflow.execution.RequestContext;
 
 import net.shibboleth.idp.profile.AbstractProfileAction;
 import net.shibboleth.idp.profile.IdPAuditFields;
@@ -64,6 +64,9 @@ public class WriteAuditLog extends AbstractProfileAction {
     /** Strategy used to locate the {@link AuditContext} associated with a given {@link ProfileRequestContext}. */
     @Nonnull private Function<ProfileRequestContext,AuditContext> auditContextLookupStrategy;
     
+    /** Strategy function for access to {@link EventContext} to check. */
+    @Nonnull private Function<ProfileRequestContext,EventContext> eventContextLookupStrategy;
+    
     /** Map of log category to formatting tokens and literals to output. */
     @Nonnull @NotEmpty private Map<String,List<String>> formattingMap;
 
@@ -78,17 +81,14 @@ public class WriteAuditLog extends AbstractProfileAction {
 
     /** Include profile's logging ID in category. */
     private boolean includeProfileLoggingId;
-    
-    /** The Spring RequestContext to operate on. */
-    @Nullable private RequestContext requestContext;
 
     /** The AuditContext to operate on. */
     @Nullable private AuditContext auditCtx;
 
     /** Constructor. */
-    @SuppressWarnings("null")
     public WriteAuditLog() {
         auditContextLookupStrategy = new ChildContextLookup<>(AuditContext.class);
+        eventContextLookupStrategy = new CurrentOrPreviousEventLookup();
         formattingMap = CollectionSupport.emptyMap();
         categoriesToLog = CollectionSupport.emptyList();
         dateTimeFormatter = DateTimeFormatter.ISO_INSTANT;
@@ -106,6 +106,19 @@ public class WriteAuditLog extends AbstractProfileAction {
         auditContextLookupStrategy = Constraint.isNotNull(strategy, "AuditContext lookup strategy cannot be null");
     }
     
+    /**
+     * Set lookup strategy for {@link EventContext} to check.
+     * 
+     * @param strategy  lookup strategy
+     * 
+     * @since 5.3.0
+     */
+    public void setEventContextLookupStrategy(@Nonnull final Function<ProfileRequestContext,EventContext> strategy) {
+        checkSetterPreconditions();
+        
+        eventContextLookupStrategy = Constraint.isNotNull(strategy, "EventContext lookup strategy cannot be null");
+    }
+    
     /**
      * Get the map of logging category to formatting tokens for log entries.
      * 
@@ -199,7 +212,6 @@ public class WriteAuditLog extends AbstractProfileAction {
      * 
      * @param format formatting string
      */
-    @SuppressWarnings("null")
     public void setDateTimeFormat(@Nullable @NotEmpty final String format) {
         checkSetterPreconditions();
         if (format != null) {
@@ -232,7 +244,6 @@ public class WriteAuditLog extends AbstractProfileAction {
     }
     
     /** {@inheritDoc} */
-    @SuppressWarnings("null")
     @Override
     protected void doInitialize() throws ComponentInitializationException {
         super.doInitialize();
@@ -244,14 +255,6 @@ public class WriteAuditLog extends AbstractProfileAction {
         }
     }
 
-    /** {@inheritDoc} */
-    @Override
-    @Nullable protected Event doExecute(@Nonnull final RequestContext springRequestContext,
-            @Nonnull final ProfileRequestContext profileRequestContext) {
-        requestContext = springRequestContext;
-        return super.doExecute(springRequestContext, profileRequestContext);
-    }
-
     /** {@inheritDoc} */
     @Override
     protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
@@ -277,6 +280,14 @@ public class WriteAuditLog extends AbstractProfileAction {
                 continue;
             }
         
+            // Tolerate nulls.
+            HttpServletRequest httpRequest;
+            try {
+                httpRequest = getHttpServletRequest();
+            } catch (final IllegalStateException e) {
+                httpRequest = null;
+            }
+            
             final StringBuilder record = new StringBuilder();
     
             for (final String token : entry.getValue()) {
@@ -285,7 +296,6 @@ public class WriteAuditLog extends AbstractProfileAction {
                         record.append('%');
                     } else {
                         final String field = token.substring(1);
-                        final HttpServletRequest httpRequest = getHttpServletRequest();
                         
                         if (IdPAuditFields.EVENT_TIME.equals(field)) {
                             record.append(dateTimeFormatter.format(Instant.now()));
@@ -353,10 +363,10 @@ public class WriteAuditLog extends AbstractProfileAction {
      * @since 5.3.0
      */
     @Nullable protected String getEvent(@Nonnull final ProfileRequestContext profileRequestContext) {
-        assert requestContext != null;
-        final Event event = requestContext.getCurrentEvent();
+        final EventContext eventCtx = eventContextLookupStrategy.apply(profileRequestContext);
+        final Object event = eventCtx != null ? eventCtx.getEvent() : null;
         if (event != null) {
-            return event.getId();
+            return event.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