[java-opensaml] branch master updated: Remove generic from collection method, sanitize types when marshalling.
Scott Cantor
cantor.2 at osu.edu
Tue Dec 17 11:47:01 EST 2019
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=7b3ceb3911c647db9857f7bba7694addcc3173df
The following commit(s) were added to refs/heads/master by this push:
new 7b3ceb3 Remove generic from collection method, sanitize types when marshalling.
7b3ceb3 is described below
commit 7b3ceb3911c647db9857f7bba7694addcc3173df
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Dec 17 10:46:57 2019 -0600
Remove generic from collection method, sanitize types when marshalling.
---
.../opensaml/saml/ext/saml2mdattr/EntityAttributes.java | 2 +-
.../saml/ext/saml2mdattr/impl/EntityAttributesImpl.java | 17 +++++++++--------
.../resolver/filter/impl/EntityAttributesFilter.java | 4 ++--
.../saml/ext/saml2mdattr/impl/EntityAttributesTest.java | 5 +++++
4 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdattr/EntityAttributes.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdattr/EntityAttributes.java
index 49a02e4..3ae20fe 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdattr/EntityAttributes.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/ext/saml2mdattr/EntityAttributes.java
@@ -50,7 +50,7 @@ public interface EntityAttributes extends SAMLObject {
*
* @since 4.0.0
*/
- public List<? extends SAMLObject> getEntityAttributesChildren();
+ public List<SAMLObject> getEntityAttributesChildren();
/**
* Gets the attributes about the entity.
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/ext/saml2mdattr/impl/EntityAttributesImpl.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/ext/saml2mdattr/impl/EntityAttributesImpl.java
index 1fa6888..1b6c389 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/ext/saml2mdattr/impl/EntityAttributesImpl.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/ext/saml2mdattr/impl/EntityAttributesImpl.java
@@ -17,9 +17,8 @@
package org.opensaml.saml.ext.saml2mdattr.impl;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
+import java.util.stream.Collectors;
import org.opensaml.core.xml.AbstractXMLObject;
import org.opensaml.core.xml.XMLObject;
@@ -29,11 +28,13 @@ import org.opensaml.saml.ext.saml2mdattr.EntityAttributes;
import org.opensaml.saml.saml2.core.Assertion;
import org.opensaml.saml.saml2.core.Attribute;
+import com.google.common.base.Predicates;
+
/** Concrete implementation of {@link EntityAttributes}. */
public class EntityAttributesImpl extends AbstractXMLObject implements EntityAttributes {
/** Extension data. */
- private final IndexedXMLObjectChildrenList<? extends SAMLObject> attributeInfo;
+ private final IndexedXMLObjectChildrenList<SAMLObject> attributeInfo;
/**
* Constructor.
@@ -59,20 +60,20 @@ public class EntityAttributesImpl extends AbstractXMLObject implements EntityAtt
}
/** {@inheritDoc} */
- public List<? extends SAMLObject> getEntityAttributesChildren() {
+ public List<SAMLObject> getEntityAttributesChildren() {
return attributeInfo;
}
/** {@inheritDoc} */
public List<XMLObject> getOrderedChildren() {
- final ArrayList<XMLObject> children = new ArrayList<>();
if (attributeInfo.size() == 0) {
return null;
}
- children.addAll(attributeInfo);
-
- return Collections.unmodifiableList(children);
+ return attributeInfo
+ .stream()
+ .filter(Predicates.or(Assertion.class::isInstance, Attribute.class::isInstance))
+ .collect(Collectors.toUnmodifiableList());
}
}
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/filter/impl/EntityAttributesFilter.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/filter/impl/EntityAttributesFilter.java
index f80060d..ab803d0 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/filter/impl/EntityAttributesFilter.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/filter/impl/EntityAttributesFilter.java
@@ -213,8 +213,8 @@ public class EntityAttributesFilter extends AbstractInitializableComponent imple
if (!entityAttributesCollection.isEmpty()) {
final EntityAttributes entityAttributes =
(EntityAttributes) entityAttributesCollection.iterator().next();
- final List<? extends SAMLObject> attributes = entityAttributes.getEntityAttributesChildren();
- final Iterator<? extends SAMLObject> iter = attributes.iterator();
+ final List<SAMLObject> attributes = entityAttributes.getEntityAttributesChildren();
+ final Iterator<SAMLObject> iter = attributes.iterator();
while (iter.hasNext()) {
final SAMLObject attribute = iter.next();
if (attribute instanceof Attribute) {
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/ext/saml2mdattr/impl/EntityAttributesTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/ext/saml2mdattr/impl/EntityAttributesTest.java
index 5e9f5b5..3563694 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/ext/saml2mdattr/impl/EntityAttributesTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/ext/saml2mdattr/impl/EntityAttributesTest.java
@@ -26,6 +26,7 @@ import org.opensaml.core.xml.XMLObjectProviderBaseTestCase;
import org.opensaml.saml.ext.saml2mdattr.EntityAttributes;
import org.opensaml.saml.saml2.core.Assertion;
import org.opensaml.saml.saml2.core.Attribute;
+import org.opensaml.saml.saml2.core.Issuer;
/** Unit test for {@link EntityAttributes}. */
public class EntityAttributesTest extends XMLObjectProviderBaseTestCase {
@@ -78,8 +79,12 @@ public class EntityAttributesTest extends XMLObjectProviderBaseTestCase {
Attribute attrib3 = (Attribute) buildXMLObject(Attribute.DEFAULT_ELEMENT_NAME);
attrib3.setName("attrib3");
+ Issuer bogus = (Issuer) buildXMLObject(Issuer.DEFAULT_ELEMENT_NAME);
+ bogus.setValue("foo");
+
EntityAttributes attributes = (EntityAttributes) buildXMLObject(EntityAttributes.DEFAULT_ELEMENT_NAME);
attributes.getAssertions().add(assertion1);
+ attributes.getEntityAttributesChildren().add(bogus); // will not be marshalled due to type checking later
attributes.getAttributes().add(attrib1);
attributes.getAssertions().add(assertion2);
attributes.getAttributes().add(attrib2);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list