src/share/jaxws_classes/com/sun/xml/internal/bind/v2/util/XmlFactory.java

changeset 397
b99d7e355d4b
parent 368
0989ad8c0860
child 408
b0610cd08440
     1.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/util/XmlFactory.java	Thu Aug 08 10:10:38 2013 -0700
     1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/util/XmlFactory.java	Fri Aug 23 09:57:21 2013 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -38,6 +38,8 @@
    1.11  import javax.xml.validation.SchemaFactory;
    1.12  import javax.xml.xpath.XPathFactory;
    1.13  import javax.xml.xpath.XPathFactoryConfigurationException;
    1.14 +
    1.15 +import org.xml.sax.SAXException;
    1.16  import org.xml.sax.SAXNotRecognizedException;
    1.17  import org.xml.sax.SAXNotSupportedException;
    1.18  
    1.19 @@ -49,6 +51,9 @@
    1.20   */
    1.21  public class XmlFactory {
    1.22  
    1.23 +    // not in older JDK, so must be duplicated here, otherwise javax.xml.XMLConstants should be used
    1.24 +    public static final String ACCESS_EXTERNAL_SCHEMA = "http://javax.xml.XMLConstants/property/accessExternalSchema";
    1.25 +
    1.26      private static final Logger LOGGER = Logger.getLogger(XmlFactory.class.getName());
    1.27  
    1.28      /**
    1.29 @@ -186,4 +191,22 @@
    1.30          }
    1.31      }
    1.32  
    1.33 +    public static SchemaFactory allowFileAccess(SchemaFactory sf, boolean disableSecureProcessing) {
    1.34 +
    1.35 +        // if feature secure processing enabled, nothing to do, file is allowed,
    1.36 +        // or user is able to control access by standard JAXP mechanisms
    1.37 +        if (disableSecureProcessing) {
    1.38 +            return sf;
    1.39 +        }
    1.40 +
    1.41 +        try {
    1.42 +            sf.setProperty(ACCESS_EXTERNAL_SCHEMA, "file");
    1.43 +            LOGGER.log(Level.FINE, Messages.JAXP_SUPPORTED_PROPERTY.format(ACCESS_EXTERNAL_SCHEMA));
    1.44 +        } catch (SAXException ignored) {
    1.45 +            // nothing to do; support depends on version JDK or SAX implementation
    1.46 +            LOGGER.log(Level.CONFIG, Messages.JAXP_UNSUPPORTED_PROPERTY.format(ACCESS_EXTERNAL_SCHEMA), ignored);
    1.47 +        }
    1.48 +        return sf;
    1.49 +    }
    1.50 +
    1.51  }

mercurial