[java-opensaml] branch main updated: Clarify Javadoc and clean up some methods.
Scott Cantor
cantor.2 at osu.edu
Thu Apr 27 19:25:57 UTC 2023
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=3b1142bf24089a2147e9249d874755ce735ce6da
The following commit(s) were added to refs/heads/main by this push:
new 3b1142bf2 Clarify Javadoc and clean up some methods.
3b1142bf2 is described below
commit 3b1142bf24089a2147e9249d874755ce735ce6da
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Apr 27 15:25:27 2023 -0400
Clarify Javadoc and clean up some methods.
---
.../profile/logic/EntityAttributesPredicate.java | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java
index cc852e457..e70dd397c 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/EntityAttributesPredicate.java
@@ -45,6 +45,7 @@ import org.slf4j.Logger;
import com.google.common.collect.Iterables;
import net.shibboleth.shared.annotation.ParameterName;
+import net.shibboleth.shared.annotation.constraint.Live;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.annotation.constraint.NotLive;
@@ -59,7 +60,11 @@ import java.util.function.Predicate;
/**
* Predicate to determine whether an {@link EntityDescriptor} or its parent groups contain an {@link EntityAttributes}
- * extension {@link Attribute} that matches the predicate's criteria.
+ * extension {@link Attribute} that matches the predicate's criteria.
+ *
+ * <p>This class uses a nested helper class, {@link Candidate}, to capture the rules to check for, with each such
+ * object representing a single condition that the predicate can combine either via an AND or OR semantic to produce
+ * the final result. Each {@link Candidate}'s own matching rules must match entirely.</p>
*/
public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
@@ -204,6 +209,9 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
/**
* An object to encapsulate the set of criteria that must be satisfied by an {@link EntityAttributes}
* extension to satisfy the enclosing predicate.
+ *
+ * <p>All of the value and regular expression criteria provided must match for the individual object's result
+ * to be "true".</p>
*/
public static class Candidate {
@@ -314,7 +322,7 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
private class EntityAttributesMatcher implements Predicate<Candidate> {
/** Population to evaluate for a match. */
- private final Collection<Attribute> attributes;
+ @Nonnull private final Collection<Attribute> attributes;
/**
* Constructor.
@@ -412,7 +420,7 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
* @param attribute what to inspect
* @return all possible values, as string.
*/
- @Nonnull List<String> getPossibleAttributeValuesAsStrings(final @Nonnull Attribute attribute) {
+ @Nonnull @Live private List<String> getPossibleAttributeValuesAsStrings(final @Nonnull Attribute attribute) {
final List<XMLObject> cvals = attribute.getAttributeValues();
final List<String> result = new ArrayList<>(cvals.size()*2);
for (final XMLObject cval : cvals) {
@@ -428,7 +436,7 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
* @param object object to convert
* @return the converted value, or null
*/
- @Nullable private List<String> xmlObjectToStrings(@Nonnull final XMLObject object) {
+ @Nullable @Unmodifiable @NotLive private List<String> xmlObjectToStrings(@Nonnull final XMLObject object) {
String toMatch = null;
String toMatchAlt = null;
if (object instanceof XSString xs) {
@@ -459,8 +467,8 @@ public class EntityAttributesPredicate implements Predicate<EntityDescriptor> {
toMatch = wc.getTextContent();
}
}
- if (toMatchAlt != null) {
- return List.of(toMatch, toMatchAlt);
+ if (toMatch != null && toMatchAlt != null) {
+ return CollectionSupport.listOf(toMatch, toMatchAlt);
} else if (toMatch != null) {
return CollectionSupport.singletonList(toMatch);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list