[java-opensaml COMMIT] /trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynam...
noreply at shibboleth.net
noreply at shibboleth.net
Fri Oct 21 16:05:53 EDT 2016
Author: putmanb
Date: Fri Oct 21 16:05:52 2016
New Revision: 4548
URL: http://svn.shibboleth.net/view/java-opensaml?rev=4548&view=rev
Log:
Refactor dynamic metadata resolver response Content-Type validation to use MediaType.
Modified:
trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicHTTPMetadataResolver.java
Modified: trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicHTTPMetadataResolver.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicHTTPMetadataResolver.java?rev=4548&r1=4547&r2=4548&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicHTTPMetadataResolver.java (original)
+++ trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicHTTPMetadataResolver.java Fri Oct 21 16:05:52 2016
@@ -24,6 +24,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Set;
import java.util.Timer;
import javax.annotation.Nonnull;
@@ -57,13 +58,16 @@
import com.google.common.base.Strings;
import com.google.common.collect.Collections2;
import com.google.common.io.ByteStreams;
+import com.google.common.net.MediaType;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.annotation.constraint.NotLive;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
+import net.shibboleth.utilities.java.support.collection.LazySet;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.net.MediaTypeSupport;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
import net.shibboleth.utilities.java.support.resolver.ResolverException;
@@ -90,19 +94,22 @@
/** List of supported MIME types for use in Accept request header and validation of
* response Content-Type header.*/
- private List<String> supportedContentTypes;
+ @NonnullAfterInit private List<String> supportedContentTypes;
/** Generated Accept request header value. */
- private String supportedContentTypesValue;
+ @NonnullAfterInit private String supportedContentTypesValue;
+
+ /**Supported {@link MediaType} instances, constructed from the {@link #supportedContentTypes} list. */
+ @NonnullAfterInit private Set<MediaType> supportedMediaTypes;
/** HttpClient ResponseHandler instance to use. */
- private ResponseHandler<XMLObject> responseHandler;
+ @Nonnull private ResponseHandler<XMLObject> responseHandler;
/** HttpClient credentials provider. */
- private CredentialsProvider credentialsProvider;
+ @Nullable private CredentialsProvider credentialsProvider;
/** Optional trust engine used in evaluating server TLS credentials. */
- private TrustEngine<? super X509Credential> tlsTrustEngine;
+ @Nullable private TrustEngine<? super X509Credential> tlsTrustEngine;
/**
* Constructor.
@@ -211,12 +218,28 @@
}
/**
+ * Get the list of supported MIME {@link MediaType} instances used in validation of
+ * the response Content-Type header.
+ *
+ * <p>
+ * Is generated at init time from {@link #getSupportedContentTypes()}.
+ * </p>
+ *
+ * @return the supported content types
+ */
+ @NonnullAfterInit @NotLive @Unmodifiable
+ protected Set<MediaType> getSupportedMediaTypes() {
+ return supportedMediaTypes;
+ }
+
+ /**
* Get the list of supported MIME types for use in Accept request header and validation of
* response Content-Type header.
*
* @return the supported content types
*/
- @NonnullAfterInit @NotLive @Unmodifiable public List<String> getSupportedContentTypes() {
+ @NonnullAfterInit @NotLive @Unmodifiable
+ public List<String> getSupportedContentTypes() {
return supportedContentTypes;
}
@@ -255,7 +278,13 @@
if (! getSupportedContentTypes().isEmpty()) {
supportedContentTypesValue = StringSupport.listToStringValue(getSupportedContentTypes(), ", ");
- }
+ supportedMediaTypes = new LazySet<>();
+ for (String contentType : getSupportedContentTypes()) {
+ supportedMediaTypes.add(MediaType.parse(contentType));
+ }
+ } else {
+ supportedMediaTypes = Collections.emptySet();
+ }
log.debug("Supported content types are: {}", getSupportedContentTypes());
}
@@ -415,42 +444,21 @@
[... 55 lines stripped ...]
More information about the commits
mailing list