[java-opensaml] branch main updated: Add null-returning getEndpointURL variant, for logging use cases.
Scott Cantor
cantor.2 at osu.edu
Thu Apr 24 16:26:15 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=6264583ab2a65633cbd09f2ae284cac86d1c2150
The following commit(s) were added to refs/heads/main by this push:
new 6264583ab Add null-returning getEndpointURL variant, for logging use cases.
6264583ab is described below
commit 6264583ab2a65633cbd09f2ae284cac86d1c2150
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Apr 24 12:26:08 2025 -0400
Add null-returning getEndpointURL variant, for logging use cases.
---
.../saml/common/binding/SAMLBindingSupport.java | 51 ++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java
index 62c05d202..f2fd88571 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java
@@ -98,6 +98,57 @@ public final class SAMLBindingSupport {
return false;
}
+ /**
+ * Get the response URL from the relying party endpoint. If the SAML message is a
+ * response and the relying party endpoint contains a response location
+ * then that location is returned otherwise the normal endpoint location is returned.
+ *
+ * <p>Instead of raising an exception, this variant returns null in the event of an
+ * inability to identify a URL to return.</p>
+ *
+ * @param messageContext current message context
+ *
+ * @return response URL from the relying party endpoint or null
+ *
+ * @since 5.2.0
+ */
+ @Nullable public static URI getEndpointURLOrNull(@Nonnull final MessageContext messageContext) {
+ final SAMLPeerEntityContext peerContext = messageContext.getSubcontext(SAMLPeerEntityContext.class);
+ if (peerContext == null) {
+ return null;
+ }
+
+ final SAMLEndpointContext endpointContext = peerContext.getSubcontext(SAMLEndpointContext.class);
+ if (endpointContext == null) {
+ return null;
+ }
+
+ final Endpoint endpoint = endpointContext.getEndpoint();
+ if (endpoint == null) {
+ return null;
+ }
+
+ final Object message = messageContext.getMessage();
+ if ((message instanceof org.opensaml.saml.saml2.core.StatusResponseType
+ || message instanceof org.opensaml.saml.saml1.core.Response)
+ && !Strings.isNullOrEmpty(endpoint.getResponseLocation())) {
+ try {
+ return new URI(endpoint.getResponseLocation());
+ } catch (final URISyntaxException e) {
+ return null;
+ }
+ }
+
+ if (Strings.isNullOrEmpty(endpoint.getLocation())) {
+ return null;
+ }
+ try {
+ return new URI(endpoint.getLocation());
+ } catch (final URISyntaxException e) {
+ return null;
+ }
+ }
+
/**
* Get the response URL from the relying party endpoint. If the SAML message is a
* response and the relying party endpoint contains a response location
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list