[java-metadata-aggregator] 08/09: MDA-168 - add getDescriptorExtensionList method to SAMLMetadataSupport
Ian Young
ian at iay.org.uk
Wed Oct 5 05:34:51 EDT 2016
This is an automated email from the git hooks/post-receive script.
iay pushed a commit to branch master
in repository java-metadata-aggregator.
View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=ba0ff65ff5346a4abd1caea8fdcb96bf20190e05
commit ba0ff65ff5346a4abd1caea8fdcb96bf20190e05
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Wed Oct 5 09:40:56 2016 +0100
MDA-168 - add getDescriptorExtensionList method to SAMLMetadataSupport
(cherry picked from commit 30db186e5135a84eaaabe893db7ab17f32961406)
---
.../metadata/dom/saml/SAMLMetadataSupport.java | 35 ++++++++++++++++++----
1 file changed, 29 insertions(+), 6 deletions(-)
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/SAMLMetadataSupport.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/SAMLMetadataSupport.java
index 7276410..ddfc327 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/SAMLMetadataSupport.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/SAMLMetadataSupport.java
@@ -17,14 +17,17 @@
package net.shibboleth.metadata.dom.saml;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
import javax.xml.namespace.QName;
import net.shibboleth.metadata.dom.XMLSignatureSigningStage;
+import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
import org.w3c.dom.Element;
@@ -93,6 +96,31 @@ public final class SAMLMetadataSupport {
}
/**
+ * Gets a list of all instances of an extension element for a given descriptor.
+ *
+ * An empty list is returned if the descriptor has no extensions, or if it
+ * has no extensions of the requested type.
+ *
+ * @param descriptor the descriptor, never <code>null</code>
+ * @param extensionName name of the extension element, never <code>null</code>
+ * @return a possibly empty list of all extension instances
+ */
+ @Nonnull
+ public static List<Element> getDescriptorExtensionList(@Nonnull final Element descriptor,
+ @Nonnull final QName extensionName) {
+ Constraint.isNotNull(descriptor, "descriptor may not be null");
+ Constraint.isNotNull(extensionName, "extension name may not be null");
+
+ // Locate the Extensions element
+ final List<Element> extensions = ElementSupport.getChildElements(descriptor, EXTENSIONS_NAME);
+ if (extensions.isEmpty()) {
+ return Collections.EMPTY_LIST;
+ }
+
+ return ElementSupport.getChildElements(extensions.get(0), extensionName);
+ }
+
+ /**
* Gets the first instance of an extension element for a given descriptor.
*
* @param descriptor the descriptor, never <code>null</code>
@@ -107,12 +135,7 @@ public final class SAMLMetadataSupport {
return null;
}
- final List<Element> extensions = ElementSupport.getChildElements(descriptor, EXTENSIONS_NAME);
- if (extensions.isEmpty()) {
- return null;
- }
-
- final List<Element> results = ElementSupport.getChildElements(extensions.get(0), extensionName);
+ final List<Element> results = getDescriptorExtensionList(descriptor, extensionName);
if (results.isEmpty()) {
return null;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list