From 6e11deb01b7cee6f7d6d232cbb5fe1a9be356e6e Mon Sep 17 00:00:00 2001 From: Patrick Dowler Date: Thu, 29 Aug 2024 10:10:28 -0700 Subject: [PATCH] cadc-vosi: capabilities transform remove unsupported security methods --- cadc-vosi/build.gradle | 2 +- .../main/java/ca/nrc/cadc/vosi/CapGetAction.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cadc-vosi/build.gradle b/cadc-vosi/build.gradle index 6ab47c1..6f8392e 100644 --- a/cadc-vosi/build.gradle +++ b/cadc-vosi/build.gradle @@ -16,7 +16,7 @@ sourceCompatibility = 1.8 group = 'org.opencadc' -version = '1.4.6' +version = '1.4.7' description = 'OpenCADC VOSI server library' def git_url = 'https://github.com/opencadc/reg' diff --git a/cadc-vosi/src/main/java/ca/nrc/cadc/vosi/CapGetAction.java b/cadc-vosi/src/main/java/ca/nrc/cadc/vosi/CapGetAction.java index 546ee32..a01f5ce 100644 --- a/cadc-vosi/src/main/java/ca/nrc/cadc/vosi/CapGetAction.java +++ b/cadc-vosi/src/main/java/ca/nrc/cadc/vosi/CapGetAction.java @@ -69,6 +69,7 @@ import ca.nrc.cadc.auth.AuthMethod; import ca.nrc.cadc.auth.AuthenticationUtil; +import ca.nrc.cadc.auth.IdentityManager; import ca.nrc.cadc.auth.NotAuthenticatedException; import ca.nrc.cadc.net.HttpTransfer; import ca.nrc.cadc.net.ResourceNotFoundException; @@ -87,6 +88,7 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URL; +import java.util.ListIterator; import java.util.Set; import java.util.TreeSet; import org.apache.log4j.Logger; @@ -173,6 +175,19 @@ private void transform(Capabilities caps) throws MalformedURLException { URL nurl = new URL(url.getProtocol(), hostname, npath); u.setURL(nurl); log.debug("transform: " + url + " -> " + nurl); + + IdentityManager im = AuthenticationUtil.getIdentityManager(); + log.debug("IM: " + im.getClass().getName()); + ListIterator iter = i.getSecurityMethods().listIterator(); + while (iter.hasNext()) { + URI sm = iter.next(); + if (!im.getSecurityMethods().contains(sm)) { + log.debug("unsupported securityMethod: " + sm + " - REMOVE"); + iter.remove(); + } else { + log.debug("supported securityMethod: " + sm + " - KEEP"); + } + } } } }