[java-opensaml COMMIT] in /trunk: opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLSchemaBuilder.java...

noreply at shibboleth.net noreply at shibboleth.net
Thu Jan 16 17:09:14 EST 2014


Author: scantor
Date: Thu Jan 16 17:09:14 2014
New Revision: 3561

URL: http://svn.shibboleth.net/view/java-opensaml?rev=3561&view=rev
Log:
Redesigned SAML schema builder around SchemaBuilder changes.

Modified:
    trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLSchemaBuilder.java
    trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/filter/impl/SchemaValidationFilter.java
    trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/filter/impl/SchemaValidationFilterTest.java
    trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/ChainingMetadataResolverTest.java

Modified: trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLSchemaBuilder.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLSchemaBuilder.java?rev=3561&r1=3560&r2=3561&view=diff
==============================================================================
--- trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLSchemaBuilder.java (original)
+++ trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLSchemaBuilder.java Thu Jan 16 17:09:14 2014
@@ -17,69 +17,60 @@
 
 package org.opensaml.saml.common.xml;
 
+import java.io.InputStream;
 import java.lang.ref.SoftReference;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.xml.XMLConstants;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import javax.annotation.concurrent.ThreadSafe;
 import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-
+
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.logic.Constraint;
 import net.shibboleth.utilities.java.support.xml.ClasspathResolver;
-import net.shibboleth.utilities.java.support.xml.LoggingErrorHandler;
-
-import org.slf4j.LoggerFactory;
+import net.shibboleth.utilities.java.support.xml.SchemaBuilder;
+
 import org.xml.sax.SAXException;
 
 /**
- * A convenience builder for creating {@link Schema}s for validating SAML 1_0, 1_1, and 2_0.
+ * A convenience builder for creating {@link Schema}s for validating SAML 1.0, 1.1, and 2.0.
  * 
- * Additional schema may be registered by {@link #addExtensionSchema(String)} with the given argument a relative or
- * absolute path that will be resolved against the classpath. Note that relative paths are relative to
- * <strong>this</strong> class. Also, schema files must be provided in the order they are referenced, that is
- * if schema B depends on schema A then schema A must appear first in the list of registered extension schemas.
- * 
- * Schemas may use a schema location attribute. These schema locations will be resolved by the
- * {@link ClasspathResolver}. If schema locations are used they will be resolved and will meet the aforementioned
- * schema ordering requirement.
- * 
- * The schema objects produced here are thread safe and should be re-used, to that end the schema builder will cache
- * created schema using {@link SoftReference}s, allowing the VM to reclaim the memory used by schemas if necessary.
+ * <p>Additional schemas may be included in the resulting object by supplying their locations
+ * to a injected {@link SchemaBuilder} object.</p>
  */
-public final class SAMLSchemaBuilder {
-
-    /** SAML 1_0 Schema with SAML 2_0 schemas and extensions. */
-    private static SoftReference<Schema> saml10Schema;
-
-    /** SAML 1_0 Schema with SAML 2_0 schemas and extensions. */
-    private static SoftReference<Schema> saml11Schema;
+ at ThreadSafe
+public class SAMLSchemaBuilder {
 
     /** Classpath relative location of basic XML schemas. */
-    private static String[] baseXMLSchemas = {
+    @Nonnull @NonnullElements @NotEmpty private static String[] baseXMLSchemas = {
         "/schema/xml.xsd",
         "/schema/XMLSchema.xsd",
         "/schema/xmldsig-core-schema.xsd",
         "/schema/xenc-schema.xsd",
         "/schema/xmldsig11-schema.xsd",
         "/schema/xenc11-schema.xsd",
-    };
+        };
 
     /** Classpath relative location of SOAP 1_1 schemas. */
-    private static String[] soapSchemas = { "/schema/soap-envelope.xsd", };
+    @Nonnull @NonnullElements @NotEmpty private static String[] soapSchemas = {
+        "/schema/soap-envelope.xsd",
+        };
 
     /** Classpath relative location of SAML 1_0 schemas. */
-    private static String[] saml10Schemas = { "/schema/cs-sstc-schema-assertion-01.xsd",
-            "/schema/cs-sstc-schema-protocol-01.xsd", };
+    @Nonnull @NonnullElements @NotEmpty private static String[] saml10Schemas = {
+        "/schema/cs-sstc-schema-assertion-01.xsd",
+        "/schema/cs-sstc-schema-protocol-01.xsd",
+        };
 
     /** Classpath relative location of SAML 1_1 schemas. */

[... 419 lines stripped ...]


More information about the commits mailing list