[java-plugin-shibd] branch main updated: Allow for absent content type.

Scott Cantor cantor.2 at osu.edu
Tue Aug 27 17:22:48 UTC 2024


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

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

View the commit online:
http://git.shibboleth.net/view/?p=java-plugin-shibd.git;a=commit;h=58e53069853354854778b0880bf6640c76007e34

The following commit(s) were added to refs/heads/main by this push:
     new 58e5306  Allow for absent content type.
58e5306 is described below

commit 58e53069853354854778b0880bf6640c76007e34
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Aug 27 13:22:45 2024 -0400

    Allow for absent content type.
---
 .../context/logic/HttpSeevletRequestPredicate.java | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/profile/context/logic/HttpSeevletRequestPredicate.java b/sp-server-api/src/main/java/net/shibboleth/sp/profile/context/logic/HttpSeevletRequestPredicate.java
index 8c7d919..a3cda6d 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/profile/context/logic/HttpSeevletRequestPredicate.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/profile/context/logic/HttpSeevletRequestPredicate.java
@@ -47,6 +47,9 @@ public class HttpSeevletRequestPredicate implements Predicate<ProfileRequestCont
     /** Required content types. */
     @Nonnull private Set<String> allowedContentTypes;
     
+    /** Whether an absent content type is allowed. */
+    private boolean allowNullContentType;
+    
     /** Required parameters. */
     @Nonnull private Set<String> requiredParameters;
     
@@ -83,6 +86,17 @@ public class HttpSeevletRequestPredicate implements Predicate<ProfileRequestCont
     public void setAllowedContentTypes(@Nonnull final Collection<String> types) {
         allowedContentTypes = CollectionSupport.copyToSet(types);
     }
+    
+    /**
+     * Sets whether to allow an absent content type.
+     * 
+     * <p>Defaults to false.</p>
+     * 
+     * @param flag flag to set
+     */
+    public void setAllowNullContentType(final boolean flag) {
+        allowNullContentType = flag;
+    }
 
     /**
      * Sets the required HTTP parameters.
@@ -107,7 +121,13 @@ public class HttpSeevletRequestPredicate implements Predicate<ProfileRequestCont
             return false;
         }
 
-        if (!allowedContentTypes.contains(request.getContentType())) {
+        final String contentType = request.getContentType();
+        if (contentType == null) {
+            if (!allowNullContentType) {
+                log.debug("Disallowd absent content type");
+                return false;
+            }
+        } else if (!allowedContentTypes.contains(request.getContentType())) {
             log.debug("Disallowed content type: {}", request.getContentType());
             return false;
         }

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


More information about the commits mailing list