com.sun.org.apache.xerces.internal.utils.SecuritySupport Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.utils.SecuritySupport. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CatalogManager.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtain the preferPublic setting from the properties.
 *
 * <p>In the properties, a value of 'public' is true,
 * anything else is false.</p>
 *
 * @return True if prefer is public or the
 * defaultPreferSetting.
 */
private boolean queryPreferPublic () {
  String prefer = SecuritySupport.getSystemProperty(pPrefer);

  if (prefer == null) {
    if (resources==null) readProperties();
    if (resources==null) return defaultPreferPublic;
    try {
      prefer = resources.getString("prefer");
    } catch (MissingResourceException e) {
      return defaultPreferPublic;
    }
  }

  if (prefer == null) {
    return defaultPreferPublic;
  }

  return (prefer.equalsIgnoreCase("public"));
}
 
Example #2
Source File: CatalogManager.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Obtain the Catalog class name setting from the properties.
 *
 */
public String queryCatalogClassName () {
  String className = SecuritySupport.getSystemProperty(pClassname);

  if (className == null) {
    if (resources==null) readProperties();
    if (resources==null) return null;
    try {
      return resources.getString("catalog-class-name");
    } catch (MissingResourceException e) {
      return null;
    }
  }

  return className;
}
 
Example #3
Source File: CatalogManager.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Obtain the static-catalog setting from the properties.
 *
 * <p>In the properties, a value of 'yes', 'true', or '1' is considered
 * true, anything else is false.</p>
 *
 * @return The static-catalog setting from the propertyFile or the
 * defaultUseStaticCatalog.
 */
private boolean queryUseStaticCatalog () {
  String staticCatalog = SecuritySupport.getSystemProperty(pStatic);

  if (staticCatalog == null) {
    if (resources==null) readProperties();
    if (resources==null) return defaultUseStaticCatalog;
    try {
      staticCatalog = resources.getString("static-catalog");
    } catch (MissingResourceException e) {
      return defaultUseStaticCatalog;
    }
  }

  if (staticCatalog == null) {
    return defaultUseStaticCatalog;
  }

  return (staticCatalog.equalsIgnoreCase("true")
          || staticCatalog.equalsIgnoreCase("yes")
          || staticCatalog.equalsIgnoreCase("1"));
}
 
Example #4
Source File: Resolver.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Find the URNs for a given system identifier in the current catalog.
 *
 * @param systemId The system ID to locate.
 *
 * @return A vector of URNs that map to the systemId.
 */
private Vector resolveLocalSystemReverse(String systemId) {
    Vector map = new Vector();
    String osname = SecuritySupport.getSystemProperty("os.name");
    boolean windows = (osname.indexOf("Windows") >= 0);
    Enumeration en = catalogEntries.elements();
    while (en.hasMoreElements()) {
        CatalogEntry e = (CatalogEntry) en.nextElement();
        if (e.getEntryType() == SYSTEM
            && (e.getEntryArg(1).equals(systemId)
                || (windows
                    && e.getEntryArg(1).equalsIgnoreCase(systemId)))) {
            map.addElement(e.getEntryArg(0));
        }
    }
    if (map.size() == 0) {
        return null;
    } else {
        return map;
    }
}
 
Example #5
Source File: XMLSchemaLoader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method is called either from XMLGrammarLoader.loadGrammar or from XMLSchemaValidator.
 * Note: in either case, the EntityManager (or EntityResolvers) are not going to be invoked
 * to resolve the location of the schema in XSDDescription
 * @param desc
 * @param source
 * @param locationPairs
 * @return An XML Schema grammar
 * @throws IOException
 * @throws XNIException
 */
SchemaGrammar loadSchema(XSDDescription desc, XMLInputSource source,
        Map<String, LocationArray> locationPairs) throws IOException, XNIException {

    // this should only be done once per invocation of this object;
    // unless application alters JAXPSource in the mean time.
    if(!fJAXPProcessed) {
        processJAXPSchemaSource(locationPairs);
    }

    if (desc.isExternal()) {
        String accessError = SecuritySupport.checkAccess(desc.getExpandedSystemId(), faccessExternalSchema, Constants.ACCESS_EXTERNAL_ALL);
        if (accessError != null) {
            throw new XNIException(fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                    "schema_reference.access",
                    new Object[] { SecuritySupport.sanitizePath(desc.getExpandedSystemId()), accessError }, XMLErrorReporter.SEVERITY_ERROR));
        }
    }
    SchemaGrammar grammar = fSchemaHandler.parseSchema(source, desc, locationPairs);

    return grammar;
}
 
Example #6
Source File: Resolver.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Find the URNs for a given system identifier in the current catalog.
 *
 * @param systemId The system ID to locate.
 *
 * @return A vector of URNs that map to the systemId.
 */
private Vector resolveLocalSystemReverse(String systemId) {
    Vector map = new Vector();
    String osname = SecuritySupport.getSystemProperty("os.name");
    boolean windows = (osname.indexOf("Windows") >= 0);
    Enumeration en = catalogEntries.elements();
    while (en.hasMoreElements()) {
        CatalogEntry e = (CatalogEntry) en.nextElement();
        if (e.getEntryType() == SYSTEM
            && (e.getEntryArg(1).equals(systemId)
                || (windows
                    && e.getEntryArg(1).equalsIgnoreCase(systemId)))) {
            map.addElement(e.getEntryArg(0));
        }
    }
    if (map.size() == 0) {
        return null;
    } else {
        return map;
    }
}
 
Example #7
Source File: CatalogManager.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Obtain the list of catalog files from the properties.
 *
 * @return A semicolon delimited list of catlog file URIs
 */
private String queryCatalogFiles () {
  String catalogList = SecuritySupport.getSystemProperty(pFiles);
  fromPropertiesFile = false;

  if (catalogList == null) {
    if (resources == null) readProperties();
    if (resources != null) {
      try {
        catalogList = resources.getString("catalogs");
        fromPropertiesFile = true;
      } catch (MissingResourceException e) {
        System.err.println(propertyFile + ": catalogs not found.");
        catalogList = null;
      }
    }
  }

  if (catalogList == null) {
    catalogList = defaultCatalogFiles;
  }

  return catalogList;
}
 
Example #8
Source File: CatalogManager.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Obtain the preferPublic setting from the properties.
 *
 * <p>In the properties, a value of 'public' is true,
 * anything else is false.</p>
 *
 * @return True if prefer is public or the
 * defaultPreferSetting.
 */
private boolean queryPreferPublic () {
  String prefer = SecuritySupport.getSystemProperty(pPrefer);

  if (prefer == null) {
    if (resources==null) readProperties();
    if (resources==null) return defaultPreferPublic;
    try {
      prefer = resources.getString("prefer");
    } catch (MissingResourceException e) {
      return defaultPreferPublic;
    }
  }

  if (prefer == null) {
    return defaultPreferPublic;
  }

  return (prefer.equalsIgnoreCase("public"));
}
 
Example #9
Source File: XMLStreamWriterImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Utility method to create a writer when passed an OutputStream. Make
 * sure to wrap an <code>OutputStreamWriter</code> using an
 * <code>XMLWriter</code> for performance reasons.
 *
 * @param os        Underlying OutputStream
 * @param encoding  Encoding used to convert chars into bytes
 */
private void setOutputUsingStream(OutputStream os, String encoding)
    throws IOException {
    fOutputStream = os;

    if (encoding != null) {
        if (encoding.equalsIgnoreCase("utf-8")) {
            fWriter = new UTF8OutputStreamWriter(os);
        }
        else {
            fWriter = new XMLWriter(new OutputStreamWriter(os, encoding));
            fEncoder = Charset.forName(encoding).newEncoder();
        }
    } else {
        encoding = SecuritySupport.getSystemProperty("file.encoding");
        if (encoding != null && encoding.equalsIgnoreCase("utf-8")) {
            fWriter = new UTF8OutputStreamWriter(os);
        } else {
            fWriter = new XMLWriter(new OutputStreamWriter(os));
        }
    }
}
 
Example #10
Source File: DatatypeException.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Overrides this method to get the formatted&localized error message.
 *
 * REVISIT: the system locale is used to load the property file.
 *          do we want to allow the appilcation to specify a
 *          different locale?
 */
public String getMessage() {
    ResourceBundle resourceBundle = null;
    resourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
    if (resourceBundle == null)
        throw new MissingResourceException("Property file not found!", "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", key);

    String msg = resourceBundle.getString(key);
    if (msg == null) {
        msg = resourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg, "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", key);
    }

    if (args != null) {
        try {
            msg = java.text.MessageFormat.format(msg, args);
        } catch (Exception e) {
            msg = resourceBundle.getString("FormatFailed");
            msg += " " + resourceBundle.getString(key);
        }
    }

    return msg;
}
 
Example #11
Source File: Resolver.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return all applicable SYSTEM system identifiers in this
 * catalog.
 *
 * <p>If one or more SYSTEM entries exists in the catalog file
 * for the system ID specified, return the mapped values.</p>
 *
 * @param systemId The system ID to locate in the catalog
 *
 * @return A vector of the mapped system identifiers or null
 */
private Vector resolveAllLocalSystem(String systemId) {
    Vector map = new Vector();
    String osname = SecuritySupport.getSystemProperty("os.name");
    boolean windows = (osname.indexOf("Windows") >= 0);
    Enumeration en = catalogEntries.elements();
    while (en.hasMoreElements()) {
        CatalogEntry e = (CatalogEntry) en.nextElement();
        if (e.getEntryType() == SYSTEM
            && (e.getEntryArg(0).equals(systemId)
                || (windows
                    && e.getEntryArg(0).equalsIgnoreCase(systemId)))) {
            map.addElement(e.getEntryArg(1));
        }
    }
    if (map.size() == 0) {
        return null;
    } else {
        return map;
    }
}
 
Example #12
Source File: XMLStreamWriterImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Utility method to create a writer when passed an OutputStream. Make
 * sure to wrap an <code>OutputStreamWriter</code> using an
 * <code>XMLWriter</code> for performance reasons.
 *
 * @param os        Underlying OutputStream
 * @param encoding  Encoding used to convert chars into bytes
 */
private void setOutputUsingStream(OutputStream os, String encoding)
    throws IOException {
    fOutputStream = os;

    if (encoding != null) {
        if (encoding.equalsIgnoreCase("utf-8")) {
            fWriter = new UTF8OutputStreamWriter(os);
        }
        else {
            fWriter = new XMLWriter(new OutputStreamWriter(os, encoding));
            fEncoder = Charset.forName(encoding).newEncoder();
        }
    } else {
        encoding = SecuritySupport.getSystemProperty("file.encoding");
        if (encoding != null && encoding.equalsIgnoreCase("utf-8")) {
            fWriter = new UTF8OutputStreamWriter(os);
        } else {
            fWriter = new XMLWriter(new OutputStreamWriter(os));
        }
    }
}
 
Example #13
Source File: XMLSchemaLoader.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method is called either from XMLGrammarLoader.loadGrammar or from XMLSchemaValidator.
 * Note: in either case, the EntityManager (or EntityResolvers) are not going to be invoked
 * to resolve the location of the schema in XSDDescription
 * @param desc
 * @param source
 * @param locationPairs
 * @return An XML Schema grammar
 * @throws IOException
 * @throws XNIException
 */
SchemaGrammar loadSchema(XSDDescription desc, XMLInputSource source,
        Map<String, LocationArray> locationPairs) throws IOException, XNIException {

    // this should only be done once per invocation of this object;
    // unless application alters JAXPSource in the mean time.
    if(!fJAXPProcessed) {
        processJAXPSchemaSource(locationPairs);
    }

    if (desc.isExternal() && !source.isCreatedByResolver()) {
        String accessError = SecuritySupport.checkAccess(desc.getExpandedSystemId(), faccessExternalSchema, Constants.ACCESS_EXTERNAL_ALL);
        if (accessError != null) {
            throw new XNIException(fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                    "schema_reference.access",
                    new Object[] { SecuritySupport.sanitizePath(desc.getExpandedSystemId()), accessError }, XMLErrorReporter.SEVERITY_ERROR));
        }
    }
    SchemaGrammar grammar = fSchemaHandler.parseSchema(source, desc, locationPairs);

    return grammar;
}
 
Example #14
Source File: Resolver.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find the URNs for a given system identifier in the current catalog.
 *
 * @param systemId The system ID to locate.
 *
 * @return A vector of URNs that map to the systemId.
 */
private Vector resolveLocalSystemReverse(String systemId) {
    Vector map = new Vector();
    String osname = SecuritySupport.getSystemProperty("os.name");
    boolean windows = (osname.indexOf("Windows") >= 0);
    Enumeration en = catalogEntries.elements();
    while (en.hasMoreElements()) {
        CatalogEntry e = (CatalogEntry) en.nextElement();
        if (e.getEntryType() == SYSTEM
            && (e.getEntryArg(1).equals(systemId)
                || (windows
                    && e.getEntryArg(1).equalsIgnoreCase(systemId)))) {
            map.addElement(e.getEntryArg(0));
        }
    }
    if (map.size() == 0) {
        return null;
    } else {
        return map;
    }
}
 
Example #15
Source File: CatalogManager.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtain the list of catalog files from the properties.
 *
 * @return A semicolon delimited list of catlog file URIs
 */
private String queryCatalogFiles () {
  String catalogList = SecuritySupport.getSystemProperty(pFiles);
  fromPropertiesFile = false;

  if (catalogList == null) {
    if (resources == null) readProperties();
    if (resources != null) {
      try {
        catalogList = resources.getString("catalogs");
        fromPropertiesFile = true;
      } catch (MissingResourceException e) {
        System.err.println(propertyFile + ": catalogs not found.");
        catalogList = null;
      }
    }
  }

  if (catalogList == null) {
    catalogList = defaultCatalogFiles;
  }

  return catalogList;
}
 
Example #16
Source File: XMLSchemaLoader.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * This method is called either from XMLGrammarLoader.loadGrammar or from XMLSchemaValidator.
 * Note: in either case, the EntityManager (or EntityResolvers) are not going to be invoked
 * to resolve the location of the schema in XSDDescription
 * @param desc
 * @param source
 * @param locationPairs
 * @return An XML Schema grammar
 * @throws IOException
 * @throws XNIException
 */
SchemaGrammar loadSchema(XSDDescription desc, XMLInputSource source,
        Map<String, LocationArray> locationPairs) throws IOException, XNIException {

    // this should only be done once per invocation of this object;
    // unless application alters JAXPSource in the mean time.
    if(!fJAXPProcessed) {
        processJAXPSchemaSource(locationPairs);
    }

    if (desc.isExternal()) {
        String accessError = SecuritySupport.checkAccess(desc.getExpandedSystemId(), faccessExternalSchema, Constants.ACCESS_EXTERNAL_ALL);
        if (accessError != null) {
            throw new XNIException(fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                    "schema_reference.access",
                    new Object[] { SecuritySupport.sanitizePath(desc.getExpandedSystemId()), accessError }, XMLErrorReporter.SEVERITY_ERROR));
        }
    }
    SchemaGrammar grammar = fSchemaHandler.parseSchema(source, desc, locationPairs);

    return grammar;
}
 
Example #17
Source File: CatalogManager.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtain the static-catalog setting from the properties.
 *
 * <p>In the properties, a value of 'yes', 'true', or '1' is considered
 * true, anything else is false.</p>
 *
 * @return The static-catalog setting from the propertyFile or the
 * defaultUseStaticCatalog.
 */
private boolean queryUseStaticCatalog () {
  String staticCatalog = SecuritySupport.getSystemProperty(pStatic);

  if (staticCatalog == null) {
    if (resources==null) readProperties();
    if (resources==null) return defaultUseStaticCatalog;
    try {
      staticCatalog = resources.getString("static-catalog");
    } catch (MissingResourceException e) {
      return defaultUseStaticCatalog;
    }
  }

  if (staticCatalog == null) {
    return defaultUseStaticCatalog;
  }

  return (staticCatalog.equalsIgnoreCase("true")
          || staticCatalog.equalsIgnoreCase("yes")
          || staticCatalog.equalsIgnoreCase("1"));
}
 
Example #18
Source File: CatalogManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtain the list of catalog files from the properties.
 *
 * @return A semicolon delimited list of catlog file URIs
 */
private String queryCatalogFiles () {
  String catalogList = SecuritySupport.getSystemProperty(pFiles);
  fromPropertiesFile = false;

  if (catalogList == null) {
    if (resources == null) readProperties();
    if (resources != null) {
      try {
        catalogList = resources.getString("catalogs");
        fromPropertiesFile = true;
      } catch (MissingResourceException e) {
        System.err.println(propertyFile + ": catalogs not found.");
        catalogList = null;
      }
    }
  }

  if (catalogList == null) {
    catalogList = defaultCatalogFiles;
  }

  return catalogList;
}
 
Example #19
Source File: CatalogManager.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtain the Catalog class name setting from the properties.
 *
 */
public String queryCatalogClassName () {
  String className = SecuritySupport.getSystemProperty(pClassname);

  if (className == null) {
    if (resources==null) readProperties();
    if (resources==null) return null;
    try {
      return resources.getString("catalog-class-name");
    } catch (MissingResourceException e) {
      return null;
    }
  }

  return className;
}
 
Example #20
Source File: CatalogManager.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtain the Catalog class name setting from the properties.
 *
 */
public String queryCatalogClassName () {
  String className = SecuritySupport.getSystemProperty(pClassname);

  if (className == null) {
    if (resources==null) readProperties();
    if (resources==null) return null;
    try {
      return resources.getString("catalog-class-name");
    } catch (MissingResourceException e) {
      return null;
    }
  }

  return className;
}
 
Example #21
Source File: CatalogManager.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtain the Catalog class name setting from the properties.
 *
 */
public String queryCatalogClassName () {
  String className = SecuritySupport.getSystemProperty(pClassname);

  if (className == null) {
    if (resources==null) readProperties();
    if (resources==null) return null;
    try {
      return resources.getString("catalog-class-name");
    } catch (MissingResourceException e) {
      return null;
    }
  }

  return className;
}
 
Example #22
Source File: CatalogManager.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <p>Obtain the oasisXMLCatalogPI setting from the properties.</p>
 *
 * <p>In the properties, a value of 'yes', 'true', or '1' is considered
 * true, anything else is false.</p>
 *
 * @return The oasisXMLCatalogPI setting from the propertyFile or the
 * defaultOasisXMLCatalogPI.
 */
public boolean queryAllowOasisXMLCatalogPI () {
  String allow = SecuritySupport.getSystemProperty(pAllowPI);

  if (allow == null) {
    if (resources==null) readProperties();
    if (resources==null) return defaultOasisXMLCatalogPI;
    try {
      allow = resources.getString("allow-oasis-xml-catalog-pi");
    } catch (MissingResourceException e) {
      return defaultOasisXMLCatalogPI;
    }
  }

  if (allow == null) {
    return defaultOasisXMLCatalogPI;
  }

  return (allow.equalsIgnoreCase("true")
          || allow.equalsIgnoreCase("yes")
          || allow.equalsIgnoreCase("1"));
}
 
Example #23
Source File: CatalogManager.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <p>Obtain the oasisXMLCatalogPI setting from the properties.</p>
 *
 * <p>In the properties, a value of 'yes', 'true', or '1' is considered
 * true, anything else is false.</p>
 *
 * @return The oasisXMLCatalogPI setting from the propertyFile or the
 * defaultOasisXMLCatalogPI.
 */
public boolean queryAllowOasisXMLCatalogPI () {
    String allow = SecuritySupport.getSystemProperty(pAllowPI);

    if (allow == null) {
        if (resources==null) readProperties();
        if (resources==null) return defaultOasisXMLCatalogPI;
        try {
            allow = resources.getString("allow-oasis-xml-catalog-pi");
        } catch (MissingResourceException e) {
            return defaultOasisXMLCatalogPI;
        }
    }

    if (allow == null) {
        return defaultOasisXMLCatalogPI;
    }

    return (allow.equalsIgnoreCase("true")
            || allow.equalsIgnoreCase("yes")
            || allow.equalsIgnoreCase("1"));
}
 
Example #24
Source File: XMLSchemaLoader.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method is called either from XMLGrammarLoader.loadGrammar or from XMLSchemaValidator.
 * Note: in either case, the EntityManager (or EntityResolvers) are not going to be invoked
 * to resolve the location of the schema in XSDDescription
 * @param desc
 * @param source
 * @param locationPairs
 * @return An XML Schema grammar
 * @throws IOException
 * @throws XNIException
 */
SchemaGrammar loadSchema(XSDDescription desc, XMLInputSource source,
        Map<String, LocationArray> locationPairs) throws IOException, XNIException {

    // this should only be done once per invocation of this object;
    // unless application alters JAXPSource in the mean time.
    if(!fJAXPProcessed) {
        processJAXPSchemaSource(locationPairs);
    }

    if (desc.isExternal()) {
        String accessError = SecuritySupport.checkAccess(desc.getExpandedSystemId(), faccessExternalSchema, Constants.ACCESS_EXTERNAL_ALL);
        if (accessError != null) {
            throw new XNIException(fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                    "schema_reference.access",
                    new Object[] { SecuritySupport.sanitizePath(desc.getExpandedSystemId()), accessError }, XMLErrorReporter.SEVERITY_ERROR));
        }
    }
    SchemaGrammar grammar = fSchemaHandler.parseSchema(source, desc, locationPairs);

    return grammar;
}
 
Example #25
Source File: DatatypeException.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Overrides this method to get the formatted&localized error message.
 *
 * REVISIT: the system locale is used to load the property file.
 *          do we want to allow the appilcation to specify a
 *          different locale?
 */
public String getMessage() {
    ResourceBundle resourceBundle = null;
    resourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
    if (resourceBundle == null)
        throw new MissingResourceException("Property file not found!", "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", key);

    String msg = resourceBundle.getString(key);
    if (msg == null) {
        msg = resourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg, "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", key);
    }

    if (args != null) {
        try {
            msg = java.text.MessageFormat.format(msg, args);
        } catch (Exception e) {
            msg = resourceBundle.getString("FormatFailed");
            msg += " " + resourceBundle.getString(key);
        }
    }

    return msg;
}
 
Example #26
Source File: XMLSchemaLoader.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method is called either from XMLGrammarLoader.loadGrammar or from XMLSchemaValidator.
 * Note: in either case, the EntityManager (or EntityResolvers) are not going to be invoked
 * to resolve the location of the schema in XSDDescription
 * @param desc
 * @param source
 * @param locationPairs
 * @return An XML Schema grammar
 * @throws IOException
 * @throws XNIException
 */
SchemaGrammar loadSchema(XSDDescription desc,
        XMLInputSource source,
        Map locationPairs) throws IOException, XNIException {

    // this should only be done once per invocation of this object;
    // unless application alters JAXPSource in the mean time.
    if(!fJAXPProcessed) {
        processJAXPSchemaSource(locationPairs);
    }

    if (desc.isExternal()) {
        String accessError = SecuritySupport.checkAccess(desc.getExpandedSystemId(), faccessExternalSchema, Constants.ACCESS_EXTERNAL_ALL);
        if (accessError != null) {
            throw new XNIException(fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                    "schema_reference.access",
                    new Object[] { SecuritySupport.sanitizePath(desc.getExpandedSystemId()), accessError }, XMLErrorReporter.SEVERITY_ERROR));
        }
    }
    SchemaGrammar grammar = fSchemaHandler.parseSchema(source, desc, locationPairs);

    return grammar;
}
 
Example #27
Source File: CatalogManager.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtain the preferPublic setting from the properties.
 *
 * <p>In the properties, a value of 'public' is true,
 * anything else is false.</p>
 *
 * @return True if prefer is public or the
 * defaultPreferSetting.
 */
private boolean queryPreferPublic () {
  String prefer = SecuritySupport.getSystemProperty(pPrefer);

  if (prefer == null) {
    if (resources==null) readProperties();
    if (resources==null) return defaultPreferPublic;
    try {
      prefer = resources.getString("prefer");
    } catch (MissingResourceException e) {
      return defaultPreferPublic;
    }
  }

  if (prefer == null) {
    return defaultPreferPublic;
  }

  return (prefer.equalsIgnoreCase("public"));
}
 
Example #28
Source File: XMLStreamWriterImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Utility method to create a writer when passed an OutputStream. Make
 * sure to wrap an <code>OutputStreamWriter</code> using an
 * <code>XMLWriter</code> for performance reasons.
 *
 * @param os        Underlying OutputStream
 * @param encoding  Encoding used to convert chars into bytes
 */
private void setOutputUsingStream(OutputStream os, String encoding)
    throws IOException {
    fOutputStream = os;

    if (encoding != null) {
        if (encoding.equalsIgnoreCase("utf-8")) {
            fWriter = new UTF8OutputStreamWriter(os);
        }
        else {
            fWriter = new XMLWriter(new OutputStreamWriter(os, encoding));
            fEncoder = Charset.forName(encoding).newEncoder();
        }
    } else {
        encoding = SecuritySupport.getSystemProperty("file.encoding");
        if (encoding != null && encoding.equalsIgnoreCase("utf-8")) {
            fWriter = new UTF8OutputStreamWriter(os);
        } else {
            fWriter = new XMLWriter(new OutputStreamWriter(os));
        }
    }
}
 
Example #29
Source File: CatalogManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtain the preferPublic setting from the properties.
 *
 * <p>In the properties, a value of 'public' is true,
 * anything else is false.</p>
 *
 * @return True if prefer is public or the
 * defaultPreferSetting.
 */
private boolean queryPreferPublic () {
  String prefer = SecuritySupport.getSystemProperty(pPrefer);

  if (prefer == null) {
    if (resources==null) readProperties();
    if (resources==null) return defaultPreferPublic;
    try {
      prefer = resources.getString("prefer");
    } catch (MissingResourceException e) {
      return defaultPreferPublic;
    }
  }

  if (prefer == null) {
    return defaultPreferPublic;
  }

  return (prefer.equalsIgnoreCase("public"));
}
 
Example #30
Source File: CatalogManager.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtain the preferPublic setting from the properties.
 *
 * <p>In the properties, a value of 'public' is true,
 * anything else is false.</p>
 *
 * @return True if prefer is public or the
 * defaultPreferSetting.
 */
private boolean queryPreferPublic () {
    String prefer = SecuritySupport.getSystemProperty(pPrefer);

    if (prefer == null) {
        if (resources==null) readProperties();
        if (resources==null) return defaultPreferPublic;
        try {
            prefer = resources.getString("prefer");
        } catch (MissingResourceException e) {
            return defaultPreferPublic;
        }
    }

    if (prefer == null) {
        return defaultPreferPublic;
    }

    return (prefer.equalsIgnoreCase("public"));
}