[java-opensaml] branch main updated: Migrate class from SP.
Codeberg
noreply at shibboleth.net
Tue Nov 17 17:20:36 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-opensaml.
View the commit online:
https://codeberg.org/Shibboleth/java-opensaml/commit/760d2c6a368d67ad626a3a7ba707bc0b0480e5a6
The following commit(s) were added to refs/heads/main by this push:
new 760d2c6a3 Migrate class from SP.
760d2c6a3 is described below
commit 760d2c6a368d67ad626a3a7ba707bc0b0480e5a6
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Tue Nov 17 12:20:06 2026 -0500
Migrate class from SP.
---
.../profile/logic/HttpServletRequestPredicate.java | 99 ++++++++++++++++++++++
1 file changed, 99 insertions(+)
diff --git a/opensaml-profile-api/src/main/java/org/opensaml/profile/logic/HttpServletRequestPredicate.java b/opensaml-profile-api/src/main/java/org/opensaml/profile/logic/HttpServletRequestPredicate.java
new file mode 100644
index 000000000..02d4746b9
--- /dev/null
+++ b/opensaml-profile-api/src/main/java/org/opensaml/profile/logic/HttpServletRequestPredicate.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opensaml.profile.logic;
+
+import java.util.function.Predicate;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.slf4j.Logger;
+
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletRequest;
+import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
+import net.shibboleth.shared.component.AbstractInitializableComponent;
+import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
+import net.shibboleth.shared.primitive.NonnullSupplier;
+import net.shibboleth.shared.servlet.HttpServletRequestValidator;
+
+/**
+ * A predicate that supports configurable evaluation of servlet request state to
+ * produce a result via the {@link HttpServletRequestValidator} interface.
+ *
+ * @since 5.3.0
+ */
+public class HttpServletRequestPredicate extends AbstractInitializableComponent
+ implements Predicate<ProfileRequestContext> {
+
+ /** Class logger. */
+ @Nonnull private Logger log = LoggerFactory.getLogger(HttpServletRequestPredicate.class);
+
+ /** Request supplier. */
+ @NonnullAfterInit private NonnullSupplier<HttpServletRequest> httpServletRequestSupplier;
+
+ /** Validator to use. */
+ @NonnullAfterInit private HttpServletRequestValidator requestValidator;
+
+ /**
+ * Sets the supplier for the {@link HttpServletRequest} to evaluate.
+ *
+ * @param supplier request supplier
+ */
+ public void setHttpServletRequestSupplier(@Nullable final NonnullSupplier<HttpServletRequest> supplier) {
+ httpServletRequestSupplier = supplier;
+ }
+
+ /**
+ * Sets the validator to apply.
+ *
+ * @param validator request validator
+ */
+ public void setHttpServletRequestValidator(@Nonnull final HttpServletRequestValidator validator) {
+ requestValidator = Constraint.isNotNull(validator, "HttpServletRequestValidator cannot be null");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected void doInitialize() throws ComponentInitializationException {
+ super.doInitialize();
+
+ if (httpServletRequestSupplier == null) {
+ throw new ComponentInitializationException("HttpServletRequest supplier was null");
+ } else if (requestValidator == null) {
+ throw new ComponentInitializationException("HttpServletRequestValidator was null");
+ }
+ }
+
+ /** {@inheritDoc} */
+ public boolean test(@Nullable final ProfileRequestContext input) {
+
+ try {
+ requestValidator.validate(httpServletRequestSupplier.get());
+ } catch (final ServletException e) {
+ log.debug("Request failed validation: {}", e.getMessage());
+ return false;
+ } catch (final IllegalStateException e) {
+ log.debug("HttpServletRequest not present, failing validation");
+ return false;
+ }
+
+ return true;
+ }
+
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list