[java-opensaml COMMIT] in /trunk: opensaml-saml-api/src/main/java/org/opensaml/saml/criterion/StartsWithLocationCrite...
noreply at shibboleth.net
noreply at shibboleth.net
Thu Oct 6 19:13:05 EDT 2016
Author: putmanb
Date: Thu Oct 6 19:13:05 2016
New Revision: 4521
URL: http://svn.shibboleth.net/view/java-opensaml?rev=4521&view=rev
Log:
More work on OSJ-129: Create metadata index impl for endpoints
Add implementation of production of index keys from criteria.
This includes optional generation of path-trimmed variants to
support the CAS metadata use case.
Added:
trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/criterion/StartsWithLocationCriterion.java (with props)
trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/index/impl/MetadataIndexSupportTest.java (with props)
Modified:
trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/index/impl/EndpointMetadataIndex.java
trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/index/impl/MetadataIndexSupport.java
trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/index/impl/EndpointMetadataIndexTest.java
Modified: trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/index/impl/EndpointMetadataIndex.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/index/impl/EndpointMetadataIndex.java?rev=4521&r1=4520&r2=4521&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/index/impl/EndpointMetadataIndex.java (original)
+++ trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/index/impl/EndpointMetadataIndex.java Thu Oct 6 19:13:05 2016
@@ -28,6 +28,9 @@
import javax.annotation.Nullable;
import javax.xml.namespace.QName;
+import org.opensaml.saml.criterion.EndpointCriterion;
+import org.opensaml.saml.criterion.EntityRoleCriterion;
+import org.opensaml.saml.criterion.StartsWithLocationCriterion;
import org.opensaml.saml.metadata.resolver.index.MetadataIndex;
import org.opensaml.saml.metadata.resolver.index.MetadataIndexKey;
import org.opensaml.saml.saml2.metadata.Endpoint;
@@ -45,7 +48,6 @@
import net.shibboleth.utilities.java.support.annotation.constraint.NotLive;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.net.SimpleURLCanonicalizer;
import net.shibboleth.utilities.java.support.net.URLBuilder;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
@@ -127,10 +129,96 @@
/** {@inheritDoc} */
@Nullable @NonnullElements @Unmodifiable @NotLive
public Set<MetadataIndexKey> generateKeys(@Nonnull final CriteriaSet criteriaSet) {
- // TODO Auto-generated method stub
- return null;
- }
-
+ Constraint.isNotNull(criteriaSet, "CriteriaSet was null");
+ EntityRoleCriterion roleCrit = criteriaSet.get(EntityRoleCriterion.class);
+ EndpointCriterion<Endpoint> endpointCrit = criteriaSet.get(EndpointCriterion.class);
+ if (roleCrit != null && endpointCrit != null) {
+ HashSet<MetadataIndexKey> result = new HashSet<>();
+ result.addAll(processCriteria(criteriaSet, roleCrit.getRole(), endpointCrit.getEndpoint()));
+ return result;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Process the specified role and endpoint.
+ *
+ * @param criteriaSet the criteria being processed
+ * @param roleType the type of role containing the endpoint
+ * @param endpoint the endpoint to process
+ * @return the set of metadata index keys for the endpoint
+ */
+ @Nonnull private Set<MetadataIndexKey> processCriteria(@Nonnull final CriteriaSet criteriaSet,
+ @Nonnull final QName roleType, @Nonnull final Endpoint endpoint) {
+
+ final HashSet<MetadataIndexKey> result = new HashSet<>();
+
+ QName endpointType = endpoint.getSchemaType();
+ if (endpointType == null) {
+ endpointType = endpoint.getElementQName();
+ }
+
+ final String location = StringSupport.trimOrNull(endpoint.getLocation());
+ if (location != null) {
+ for (final String variant : processLocation(criteriaSet, location)) {
+ result.add(new EndpointMetadataIndexKey(roleType, endpointType, variant, false));
+ }
+ }
+ final String responseLocation = StringSupport.trimOrNull(endpoint.getResponseLocation());
+ if (responseLocation != null) {
+ for (final String variant : processLocation(criteriaSet, responseLocation)) {
+ result.add(new EndpointMetadataIndexKey(roleType, endpointType, variant, true));
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Process the specified location.
+ *
+ * @param criteriaSet the criteria being processed
+ * @param location the location to process
[... 234 lines stripped ...]
More information about the commits
mailing list