[java-opensaml COMMIT] in /trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic: AbstractRegi...
noreply at shibboleth.net
noreply at shibboleth.net
Wed Sep 24 12:15:33 EDT 2014
Author: scantor
Date: Wed Sep 24 12:15:32 2014
New Revision: 4059
URL: http://svn.shibboleth.net/view/java-opensaml?rev=4059&view=rev
Log:
Refactor, and add flag for what to do if extension is missing.
Modified:
trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/AbstractRegistrationInfoPredicate.java
trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/RegistrationAuthorityPredicate.java
trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/RegistrationPolicyPredicate.java
Modified: trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/AbstractRegistrationInfoPredicate.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/AbstractRegistrationInfoPredicate.java?rev=4059&r1=4058&r2=4059&view=diff
==============================================================================
--- trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/AbstractRegistrationInfoPredicate.java (original)
+++ trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/AbstractRegistrationInfoPredicate.java Wed Sep 24 12:15:32 2014
@@ -17,6 +17,7 @@
package org.opensaml.saml.common.profile.logic;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensaml.core.xml.XMLObject;
@@ -31,6 +32,27 @@
* Base class for predicate that acts on {@link RegistrationInfo} content.
*/
public abstract class AbstractRegistrationInfoPredicate implements Predicate<EntityDescriptor> {
+
+ /** What to do if no extension data exists. */
+ private boolean matchIfMetadataSilent;
+
+ /**
+ * Set whether a predicate should evaluate to true if the data being matched on does not exist.
+ *
+ * @param flag flag to set
+ */
+ public void setMatchIfMetadataSilent(final boolean flag) {
+ matchIfMetadataSilent = flag;
+ }
+
+ /**
+ * Get whether a predicate should evaluate to true if the data being matched on does not exist.
+ *
+ * @return true iff missing data should evaluate to true
+ */
+ public boolean getMatchIfMetadataSilent() {
+ return matchIfMetadataSilent;
+ }
/**
* Get the {@link RegistrationInfo} extension associated with an entity, if any.
@@ -70,4 +92,25 @@
return null;
}
+ /** {@inheritDoc} */
+ @Override
+ public boolean apply(@Nullable final EntityDescriptor input) {
+
+ final RegistrationInfo info = getRegistrationInfo(input);
+ if (info != null) {
+ return doApply(info);
+ }
+
+ return matchIfMetadataSilent;
+ }
+
+ /**
+ * Override this method to implement the predicate.
+ *
+ * @param info the information to evaluate
+ *
+ * @return the result of the predicate
+ */
+ protected abstract boolean doApply(@Nonnull final RegistrationInfo info);
+
}
Modified: trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/RegistrationAuthorityPredicate.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/RegistrationAuthorityPredicate.java?rev=4059&r1=4058&r2=4059&view=diff
==============================================================================
--- trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/RegistrationAuthorityPredicate.java (original)
+++ trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/RegistrationAuthorityPredicate.java Wed Sep 24 12:15:32 2014
@@ -21,7 +21,6 @@
import java.util.Set;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.NotLive;
@@ -30,7 +29,6 @@
import net.shibboleth.utilities.java.support.primitive.StringSupport;
import org.opensaml.saml.ext.saml2mdrpi.RegistrationInfo;
-import org.opensaml.saml.saml2.metadata.EntityDescriptor;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
@@ -72,14 +70,8 @@
/** {@inheritDoc} */
@Override
- public boolean apply(@Nullable final EntityDescriptor input) {
-
- final RegistrationInfo info = getRegistrationInfo(input);
- if (info != null) {
- return authorities.contains(info.getRegistrationAuthority());
- }
-
- return false;
+ protected boolean doApply(@Nonnull final RegistrationInfo info) {
+ return authorities.contains(info.getRegistrationAuthority());
}
}
Modified: trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/profile/logic/RegistrationPolicyPredicate.java
[... 45 lines stripped ...]
More information about the commits
mailing list