[java-opensaml] branch main updated: Add a message handler to detect NoPassive status.
Scott Cantor
cantor.2 at osu.edu
Tue Sep 23 17:58:12 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=cd9404b590ab3b81ae561bb4b904e617a359fec2
The following commit(s) were added to refs/heads/main by this push:
new cd9404b59 Add a message handler to detect NoPassive status.
cd9404b59 is described below
commit cd9404b590ab3b81ae561bb4b904e617a359fec2
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Sep 23 13:58:09 2025 -0400
Add a message handler to detect NoPassive status.
---
.../saml2/binding/impl/CheckNoPassiveHandler.java | 66 ++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/impl/CheckNoPassiveHandler.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/impl/CheckNoPassiveHandler.java
new file mode 100644
index 000000000..799153558
--- /dev/null
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/impl/CheckNoPassiveHandler.java
@@ -0,0 +1,66 @@
+/*
+ * 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.saml.saml2.binding.impl;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.messaging.handler.AbstractMessageHandler;
+import org.opensaml.messaging.handler.MessageHandlerException;
+import org.opensaml.saml.saml2.core.Status;
+import org.opensaml.saml.saml2.core.StatusCode;
+import org.opensaml.saml.saml2.core.StatusResponseType;
+
+/**
+ * Message handler that raises an exception if a SAML message is a response containing the
+ * {@link StatusCode#NO_PASSIVE} status code.
+ *
+ * @since 5.2.0
+ */
+public class CheckNoPassiveHandler extends AbstractMessageHandler {
+
+ /** {@inheritDoc} */
+ @Override
+ protected void doInvoke(@Nonnull final MessageContext messageContext) throws MessageHandlerException {
+ if (isNoPassiveResponse(messageContext.getMessage())) {
+ throw new MessageHandlerException("Message contained NoPassive error.");
+ }
+ }
+
+
+ /**
+ * Get whether the message is a SAML response containing an error status.
+ *
+ * @param message message to check
+ *
+ * @return true iff the message is a SAML response containing an error status
+ */
+ private boolean isNoPassiveResponse(@Nullable final Object message) {
+ if (message instanceof StatusResponseType resp) {
+ final Status status = resp.getStatus();
+ if (status != null) {
+ StatusCode code = status.getStatusCode();
+ if (code != null && !StatusCode.SUCCESS.equals(code.getValue())) {
+ code = code.getStatusCode();
+ return code != null && StatusCode.NO_PASSIVE.equals(code.getValue());
+ }
+ }
+ }
+
+ return false;
+ }
+
+}
\ 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