Java Code Examples for com.sun.org.apache.xerces.internal.utils.SecuritySupport#getSystemProperty()

The following examples show how to use com.sun.org.apache.xerces.internal.utils.SecuritySupport#getSystemProperty() . 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 openjdk-jdk9 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 2
Source File: Resolver.java    From JDKSourceCode1.8 with MIT License 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 3
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 4
Source File: Resolver.java    From openjdk-jdk9 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 5
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 6
Source File: CatalogManager.java    From openjdk-jdk8u 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 7
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 8
Source File: CatalogManager.java    From jdk8u60 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 9
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 10
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 11
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 12
Source File: Resolver.java    From jdk1.8-source-analysis with Apache License 2.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 13
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"));
}
 
Example 14
Source File: CoreDocumentImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/** Constructor. */
public CoreDocumentImpl(boolean grammarAccess) {
    super(null);
    ownerDocument = this;
    allowGrammarAccess = grammarAccess;
    String systemProp = SecuritySupport.getSystemProperty(Constants.SUN_DOM_PROPERTY_PREFIX+Constants.SUN_DOM_ANCESTOR_CHECCK);
    if (systemProp != null) {
        if (systemProp.equalsIgnoreCase("false")) {
            ancestorChecking = false;
        }
    }
}
 
Example 15
Source File: Constants.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static boolean isJavaVersionAtLeast(int compareTo) {
    String javaVersion = SecuritySupport.getSystemProperty("java.version");
    String versions[] = javaVersion.split("\\.", 3);
    if (Integer.parseInt(versions[0]) >= compareTo ||
        Integer.parseInt(versions[1]) >= compareTo) {
        return true;
    }
    return false;
}
 
Example 16
Source File: CoreDocumentImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** Constructor. */
public CoreDocumentImpl(boolean grammarAccess) {
    super(null);
    ownerDocument = this;
    allowGrammarAccess = grammarAccess;
    String systemProp = SecuritySupport.getSystemProperty(Constants.SUN_DOM_PROPERTY_PREFIX+Constants.SUN_DOM_ANCESTOR_CHECCK);
    if (systemProp != null) {
        if (systemProp.equalsIgnoreCase("false")) {
            ancestorChecking = false;
        }
    }
}
 
Example 17
Source File: Constants.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static boolean isJavaVersionAtLeast(int compareTo) {
    String javaVersion = SecuritySupport.getSystemProperty("java.version");
    String versions[] = javaVersion.split("\\.", 3);
    if (Integer.parseInt(versions[0]) >= compareTo ||
        Integer.parseInt(versions[1]) >= compareTo) {
        return true;
    }
    return false;
}
 
Example 18
Source File: Constants.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public static boolean isJavaVersionAtLeast(int compareTo) {
    String javaVersion = SecuritySupport.getSystemProperty("java.version");
    String versions[] = javaVersion.split("\\.", 3);
    if (Integer.parseInt(versions[0]) >= compareTo ||
        Integer.parseInt(versions[1]) >= compareTo) {
        return true;
    }
    return false;
}
 
Example 19
Source File: CoreDocumentImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** Constructor. */
public CoreDocumentImpl(boolean grammarAccess) {
    super(null);
    ownerDocument = this;
    allowGrammarAccess = grammarAccess;
    String systemProp = SecuritySupport.getSystemProperty(Constants.SUN_DOM_PROPERTY_PREFIX+Constants.SUN_DOM_ANCESTOR_CHECCK);
    if (systemProp != null) {
        if (systemProp.equalsIgnoreCase("false")) {
            ancestorChecking = false;
        }
    }
}
 
Example 20
Source File: XMLEntityStorage.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static synchronized String getUserDir() {
    // get the user.dir property
    String userDir = "";
    try {
        userDir = SecuritySupport.getSystemProperty("user.dir");
    }
    catch (SecurityException se) {
    }

    // return empty string if property value is empty string.
    if (userDir.length() == 0)
        return "";

    // compute the new escaped value if the new property value doesn't
    // match the previous one
    if (userDir.equals(gUserDir)) {
        return gEscapedUserDir;
    }

    // record the new value as the global property value
    gUserDir = userDir;

    char separator = java.io.File.separatorChar;
    userDir = userDir.replace(separator, '/');

    int len = userDir.length(), ch;
    StringBuffer buffer = new StringBuffer(len*3);
    // change C:/blah to /C:/blah
    if (len >= 2 && userDir.charAt(1) == ':') {
        ch = Character.toUpperCase(userDir.charAt(0));
        if (ch >= 'A' && ch <= 'Z') {
            buffer.append('/');
        }
    }

    // for each character in the path
    int i = 0;
    for (; i < len; i++) {
        ch = userDir.charAt(i);
        // if it's not an ASCII character, break here, and use UTF-8 encoding
        if (ch >= 128)
            break;
        if (gNeedEscaping[ch]) {
            buffer.append('%');
            buffer.append(gAfterEscaping1[ch]);
            buffer.append(gAfterEscaping2[ch]);
            // record the fact that it's escaped
        }
        else {
            buffer.append((char)ch);
        }
    }

    // we saw some non-ascii character
    if (i < len) {
        // get UTF-8 bytes for the remaining sub-string
        byte[] bytes = null;
        byte b;
        try {
            bytes = userDir.substring(i).getBytes("UTF-8");
        } catch (java.io.UnsupportedEncodingException e) {
            // should never happen
            return userDir;
        }
        len = bytes.length;

        // for each byte
        for (i = 0; i < len; i++) {
            b = bytes[i];
            // for non-ascii character: make it positive, then escape
            if (b < 0) {
                ch = b + 256;
                buffer.append('%');
                buffer.append(gHexChs[ch >> 4]);
                buffer.append(gHexChs[ch & 0xf]);
            }
            else if (gNeedEscaping[b]) {
                buffer.append('%');
                buffer.append(gAfterEscaping1[b]);
                buffer.append(gAfterEscaping2[b]);
            }
            else {
                buffer.append((char)b);
            }
        }
    }

    // change blah/blah to blah/blah/
    if (!userDir.endsWith("/"))
        buffer.append('/');

    gEscapedUserDir = buffer.toString();

    return gEscapedUserDir;
}