33 |
33 |
34 import com.sun.xml.internal.bind.v2.util.XmlFactory; |
34 import com.sun.xml.internal.bind.v2.util.XmlFactory; |
35 import javax.xml.XMLConstants; |
35 import javax.xml.XMLConstants; |
36 import org.xml.sax.SAXException; |
36 import org.xml.sax.SAXException; |
37 |
37 |
38 import static com.sun.xml.internal.bind.v2.util.XmlFactory.allowFileAccess; |
38 import static com.sun.xml.internal.bind.v2.util.XmlFactory.allowExternalAccess; |
39 |
39 |
40 /** |
40 /** |
41 * Wraps a JAXP {@link Schema} object and lazily instantiate it. |
41 * Wraps a JAXP {@link Schema} object and lazily instantiate it. |
42 * |
42 * |
43 * This object is thread-safe. There should be only one instance of |
43 * This object is thread-safe. There should be only one instance of |
59 synchronized(this) { |
59 synchronized(this) { |
60 if(schema==null) { |
60 if(schema==null) { |
61 try { |
61 try { |
62 // do not disable secure processing - these are well-known schemas |
62 // do not disable secure processing - these are well-known schemas |
63 SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false); |
63 SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false); |
64 schema = allowFileAccess(sf, false).newSchema(source); |
64 schema = allowExternalAccess(sf, "file", false).newSchema(source); |
65 } catch (SAXException e) { |
65 } catch (SAXException e) { |
66 // we make sure that the schema is correct before we ship. |
66 // we make sure that the schema is correct before we ship. |
67 throw new AssertionError(e); |
67 throw new AssertionError(e); |
68 } |
68 } |
69 } |
69 } |