[java-opensaml] branch main updated: OSJ-418 - Allow various classes to skip servlet request check at init

Scott Cantor cantor.2 at osu.edu
Wed Apr 2 14:59:08 UTC 2025


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

scantor pushed a commit to branch main
in repository java-opensaml.

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

The following commit(s) were added to refs/heads/main by this push:
     new e867b5036 OSJ-418 - Allow various classes to skip servlet request check at init
e867b5036 is described below

commit e867b503619e29582546f2dd8bb7de5e3d00eec1
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Apr 2 10:59:04 2025 -0400

    OSJ-418 - Allow various classes to skip servlet request check at init
    
    https://shibboleth.atlassian.net/browse/OSJ-418
    
    Apply to new validation action.
---
 .../action/impl/ValidateHttpServletRequest.java    | 27 ++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/ValidateHttpServletRequest.java b/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/ValidateHttpServletRequest.java
index 8d58f3669..1150e095c 100644
--- a/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/ValidateHttpServletRequest.java
+++ b/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/ValidateHttpServletRequest.java
@@ -37,9 +37,17 @@ public class ValidateHttpServletRequest extends AbstractConditionalProfileAction
     /** Logger. */
     @Nonnull private Logger log = LoggerFactory.getLogger(ValidateHttpServletRequest.class);
     
+    /** Flag for whether to check for servlet request during init. */
+    private boolean checkDuringInit;
+        
     /** Request validator. */
     @NonnullAfterInit private HttpServletRequestValidator validator;
 
+    /** Constructor. */
+    public ValidateHttpServletRequest() {
+        checkDuringInit = true;
+    }
+    
     /**
      * Get the request validator. 
      * 
@@ -59,12 +67,27 @@ public class ValidateHttpServletRequest extends AbstractConditionalProfileAction
         validator = newValidator;
     }
 
+    /**
+     * Set whether {{@link #initialize()} should throw an exception if {@link #getHttpServletRequest()}
+     * returns null.
+     * 
+     * <p>Defaults to true.</p>
+     * 
+     * @param flag
+     * 
+     * @since 5.2.0
+     */
+    public void setCheckDuringInit(final boolean flag) {
+        checkSetterPreconditions();
+        checkDuringInit = flag;
+    }
+        
     /** {@inheritDoc} */
     @Override
     protected void doInitialize() throws ComponentInitializationException {
         super.doInitialize();
         
-        if (getHttpServletRequest() == null) {
+        if (checkDuringInit && getHttpServletRequest() == null) {
             throw new ComponentInitializationException("HttpServletRequest was null");
         }
         
@@ -81,7 +104,7 @@ public class ValidateHttpServletRequest extends AbstractConditionalProfileAction
             getValidator().validate(ensureHttpServletRequest());
             ActionSupport.buildProceedEvent(profileContext);
         } catch (final ServletException e) {
-            log.warn("HttpServletRequest failed validation", e);
+            log.warn("{} HttpServletRequest failed validation", getLogPrefix(), e);
             ActionSupport.buildEvent(profileContext, EventIds.INVALID_MESSAGE);
         }
     }

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


More information about the commits mailing list