Java Code Examples for com.sun.org.apache.xalan.internal.utils.SecuritySupport

The following examples show how to use com.sun.org.apache.xalan.internal.utils.SecuritySupport. These examples are extracted from open source projects. 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
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example 2
Source Project: jdk1.8-source-analysis   Source File: FuncSystemProperty.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example 3
Source Project: TencentKona-8   Source File: Encodings.java    License: GNU General Public License v2.0 6 votes vote down vote up
private InputStream openEncodingsFileStream() throws MalformedURLException, IOException {
    String urlString = null;
    InputStream is = null;

    try {
        urlString = SecuritySupport.getSystemProperty(ENCODINGS_PROP, "");
    } catch (SecurityException e) {
    }

    if (urlString != null && urlString.length() > 0) {
        URL url = new URL(urlString);
        is = url.openStream();
    }

    if (is == null) {
        is = SecuritySupport.getResourceAsStream(ENCODINGS_FILE);
    }
    return is;
}
 
Example 4
Source Project: openjdk-jdk9   Source File: Encodings.java    License: GNU General Public License v2.0 6 votes vote down vote up
private InputStream openEncodingsFileStream() throws MalformedURLException, IOException {
    String urlString = null;
    InputStream is = null;

    try {
        urlString = SecuritySupport.getSystemProperty(ENCODINGS_PROP, "");
    } catch (SecurityException e) {
    }

    if (urlString != null && urlString.length() > 0) {
        URL url = new URL(urlString);
        is = url.openStream();
    }

    if (is == null) {
        is = SecuritySupport.getResourceAsStream(ENCODINGS_FILE);
    }
    return is;
}
 
Example 5
Source Project: jdk8u60   Source File: TreeWalker.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor.
 * @param   contentHandler The implemention of the
 * @param   systemId System identifier for the document.
 * contentHandler operation (toXMLString, digest, ...)
 */
public TreeWalker(ContentHandler contentHandler, DOMHelper dh, String systemId)
{
  this.m_contentHandler = contentHandler;
  m_contentHandler.setDocumentLocator(m_locator);
  if (systemId != null)
      m_locator.setSystemId(systemId);
  else {
      try {
        // Bug see Bugzilla  26741
        m_locator.setSystemId(SecuritySupport.getSystemProperty("user.dir") + File.separator + "dummy.xsl");
       }
       catch (SecurityException se) {// user.dir not accessible from applet
       }
  }
  m_dh = dh;
}
 
Example 6
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example 7
Source Project: jdk8u60   Source File: FuncSystemProperty.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example 8
Source Project: hottub   Source File: Encodings.java    License: GNU General Public License v2.0 6 votes vote down vote up
private InputStream openEncodingsFileStream() throws MalformedURLException, IOException {
    String urlString = null;
    InputStream is = null;

    try {
        urlString = SecuritySupport.getSystemProperty(ENCODINGS_PROP, "");
    } catch (SecurityException e) {
    }

    if (urlString != null && urlString.length() > 0) {
        URL url = new URL(urlString);
        is = url.openStream();
    }

    if (is == null) {
        is = SecuritySupport.getResourceAsStream(ENCODINGS_FILE);
    }
    return is;
}
 
Example 9
Source Project: JDKSourceCode1.8   Source File: FuncSystemProperty.java    License: MIT License 6 votes vote down vote up
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example 10
/**
 *  Overrides the default readObject implementation since we decided
 *  it would be cleaner not to serialize the entire tranformer
 *  factory.  [ ref bugzilla 12317 ]
 *  We need to check if the user defined class for URIResolver also
 *  implemented Serializable
 *  if yes then we need to deserialize the URIResolver
 *  Fix for bugzilla bug 22438
 */
private void  readObject(ObjectInputStream is)
  throws IOException, ClassNotFoundException
{
    SecurityManager security = System.getSecurityManager();
    if (security != null){
        String temp = SecuritySupport.getSystemProperty(DESERIALIZE_TRANSLET);
        if (temp == null || !(temp.length()==0 || temp.equalsIgnoreCase("true"))) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.DESERIALIZE_TRANSLET_ERR);
            throw new UnsupportedOperationException(err.toString());
        }
    }

    is.defaultReadObject();
    if (is.readBoolean()) {
        _uriResolver = (URIResolver) is.readObject();
    }

    _tfactory = new TransformerFactoryImpl();
}
 
Example 11
Source Project: openjdk-jdk8u   Source File: Encodings.java    License: GNU General Public License v2.0 6 votes vote down vote up
private InputStream openEncodingsFileStream() throws MalformedURLException, IOException {
    String urlString = null;
    InputStream is = null;

    try {
        urlString = SecuritySupport.getSystemProperty(ENCODINGS_PROP, "");
    } catch (SecurityException e) {
    }

    if (urlString != null && urlString.length() > 0) {
        URL url = new URL(urlString);
        is = url.openStream();
    }

    if (is == null) {
        is = SecuritySupport.getResourceAsStream(ENCODINGS_FILE);
    }
    return is;
}
 
Example 12
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example 13
/**
 * Retrieve a property bundle from XSLT_PROPERTIES
 *
 * @param target The target property bag the file will be placed into.
 */
private void loadPropertyFile(Properties target)
{
  try
  {
    // Use SecuritySupport class to provide privileged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(XSLT_PROPERTIES);

    // get a buffered version
    try (BufferedInputStream bis = new BufferedInputStream(is)) {
        target.load(bis);  // and load up the property bag from this
    }
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example 14
private InputStream openEncodingsFileStream() throws MalformedURLException, IOException {
    String urlString = null;
    InputStream is = null;

    try {
        urlString = SecuritySupport.getSystemProperty(ENCODINGS_PROP, "");
    } catch (SecurityException e) {
    }

    if (urlString != null && urlString.length() > 0) {
        URL url = new URL(urlString);
        is = url.openStream();
    }

    if (is == null) {
        is = SecuritySupport.getResourceAsStream(ENCODINGS_FILE);
    }
    return is;
}
 
Example 15
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example 16
Source Project: hottub   Source File: XSLTC.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the destination directory for the translet.
 * The current working directory will be used by default.
 */
public boolean setDestDirectory(String dstDirName) {
    final File dir = new File(dstDirName);
    if (SecuritySupport.getFileExists(dir) || dir.mkdirs()) {
        _destDir = dir;
        return true;
    }
    else {
        _destDir = null;
        return false;
    }
}
 
Example 17
Source Project: hottub   Source File: Messages.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a message from the specified key and replacement
 * arguments, localized to the given locale.
 *
 * @param msgKey  The key for the message text.
 * @param args    The arguments to be used as replacement text
 * in the message created.
 *
 * @return The formatted message string.
 * @xsl.usage internal
 */
public final String createMessage(String msgKey, Object args[])
{
    if (m_resourceBundle == null)
        m_resourceBundle = SecuritySupport.getResourceBundle(m_resourceBundleName);

    if (m_resourceBundle != null)
    {
        return createMsg(m_resourceBundle, msgKey, args);
    }
    else
        return "Could not load the resource bundles: "+ m_resourceBundleName;
}
 
Example 18
Source Project: jdk1.8-source-analysis   Source File: XSLMessages.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a message from the specified key and replacement arguments,
 * localized to the given locale.
 *
 * @param msgKey The key for the message text.
 * @param args The arguments to be used as replacement text in the message
 * created.
 *
 * @return The formatted warning string.
 */
public static String createWarning(String msgKey, Object args[]) //throws Exception
{
    if (XSLTBundle == null) {
        XSLTBundle = SecuritySupport.getResourceBundle(XSLT_ERROR_RESOURCES);
    }

    if (XSLTBundle != null) {
        return createMsg(XSLTBundle, msgKey, args);
    } else {
        return "Could not load any resource bundles.";
    }
}
 
Example 19
Source Project: jdk1.8-source-analysis   Source File: TemplatesImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *  Overrides the default readObject implementation since we decided
 *  it would be cleaner not to serialize the entire tranformer
 *  factory.  [ ref bugzilla 12317 ]
 *  We need to check if the user defined class for URIResolver also
 *  implemented Serializable
 *  if yes then we need to deserialize the URIResolver
 *  Fix for bugzilla bug 22438
 */
@SuppressWarnings("unchecked")
private void  readObject(ObjectInputStream is)
  throws IOException, ClassNotFoundException
{
    SecurityManager security = System.getSecurityManager();
    if (security != null){
        String temp = SecuritySupport.getSystemProperty(DESERIALIZE_TRANSLET);
        if (temp == null || !(temp.length()==0 || temp.equalsIgnoreCase("true"))) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.DESERIALIZE_TRANSLET_ERR);
            throw new UnsupportedOperationException(err.toString());
        }
    }

    // We have to read serialized fields first.
    ObjectInputStream.GetField gf = is.readFields();
    _name = (String)gf.get("_name", null);
    _bytecodes = (byte[][])gf.get("_bytecodes", null);
    _class = (Class[])gf.get("_class", null);
    _transletIndex = gf.get("_transletIndex", -1);

    _outputProperties = (Properties)gf.get("_outputProperties", null);
    _indentNumber = gf.get("_indentNumber", 0);

    if (is.readBoolean()) {
        _uriResolver = (URIResolver) is.readObject();
    }

    _tfactory = new TransformerFactoryImpl();
}
 
Example 20
Source Project: jdk1.8-source-analysis   Source File: XSLTC.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Set the destination directory for the translet.
 * The current working directory will be used by default.
 */
public boolean setDestDirectory(String dstDirName) {
    final File dir = new File(dstDirName);
    if (SecuritySupport.getFileExists(dir) || dir.mkdirs()) {
        _destDir = dir;
        return true;
    }
    else {
        _destDir = null;
        return false;
    }
}
 
Example 21
Source Project: openjdk-8-source   Source File: XSLMessages.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a message from the specified key and replacement arguments,
 * localized to the given locale.
 *
 * @param msgKey The key for the message text.
 * @param args The arguments to be used as replacement text in the message
 * created.
 *
 * @return The formatted warning string.
 */
public static String createWarning(String msgKey, Object args[]) //throws Exception
{
    if (XSLTBundle == null) {
        XSLTBundle = SecuritySupport.getResourceBundle(XSLT_ERROR_RESOURCES);
    }

    if (XSLTBundle != null) {
        return createMsg(XSLTBundle, msgKey, args);
    } else {
        return "Could not load any resource bundles.";
    }
}
 
Example 22
Source Project: jdk1.8-source-analysis   Source File: XMLMessages.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a message from the specified key and replacement
 * arguments, localized to the given locale.
 *
 * @param msgKey    The key for the message text.
 * @param args      The arguments to be used as replacement text
 *                  in the message created.
 *
 * @return The formatted message string.
 */
public static final String createXMLMessage(String msgKey, Object args[])
{
  if (XMLBundle == null) {
      XMLBundle = SecuritySupport.getResourceBundle(XML_ERROR_RESOURCES);
  }

  if (XMLBundle != null)
  {
    return createMsg(XMLBundle, msgKey, args);
  }
  else
    return "Could not load any resource bundles.";
}
 
Example 23
Source Project: TencentKona-8   Source File: XalanConstants.java    License: 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 24
Source Project: openjdk-8-source   Source File: TreeWalker.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor.
 * @param   contentHandler The implemention of the
 * contentHandler operation (toXMLString, digest, ...)
 */
public TreeWalker(ContentHandler contentHandler, DOMHelper dh)
{
  this.m_contentHandler = contentHandler;
  m_contentHandler.setDocumentLocator(m_locator);
  try {
     // Bug see Bugzilla  26741
    m_locator.setSystemId(SecuritySupport.getSystemProperty("user.dir") + File.separator + "dummy.xsl");
  }
  catch (SecurityException se){// user.dir not accessible from applet
  }
  m_dh = dh;
}
 
Example 25
Source Project: TencentKona-8   Source File: XSLMessages.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a message from the specified key and replacement arguments,
 * localized to the given locale.
 *
 * @param msgKey The key for the message text.
 * @param args The arguments to be used as replacement text in the message
 * created.
 *
 * @return The formatted warning string.
 */
public static String createWarning(String msgKey, Object args[]) //throws Exception
{
    if (XSLTBundle == null) {
        XSLTBundle = SecuritySupport.getResourceBundle(XSLT_ERROR_RESOURCES);
    }

    if (XSLTBundle != null) {
        return createMsg(XSLTBundle, msgKey, args);
    } else {
        return "Could not load any resource bundles.";
    }
}
 
Example 26
Source Project: TencentKona-8   Source File: TemplatesImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Overrides the default readObject implementation since we decided
 *  it would be cleaner not to serialize the entire tranformer
 *  factory.  [ ref bugzilla 12317 ]
 *  We need to check if the user defined class for URIResolver also
 *  implemented Serializable
 *  if yes then we need to deserialize the URIResolver
 *  Fix for bugzilla bug 22438
 */
@SuppressWarnings("unchecked")
private void  readObject(ObjectInputStream is)
  throws IOException, ClassNotFoundException
{
    SecurityManager security = System.getSecurityManager();
    if (security != null){
        String temp = SecuritySupport.getSystemProperty(DESERIALIZE_TRANSLET);
        if (temp == null || !(temp.length()==0 || temp.equalsIgnoreCase("true"))) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.DESERIALIZE_TRANSLET_ERR);
            throw new UnsupportedOperationException(err.toString());
        }
    }

    // We have to read serialized fields first.
    ObjectInputStream.GetField gf = is.readFields();
    _name = (String)gf.get("_name", null);
    _bytecodes = (byte[][])gf.get("_bytecodes", null);
    _class = (Class[])gf.get("_class", null);
    _transletIndex = gf.get("_transletIndex", -1);

    _outputProperties = (Properties)gf.get("_outputProperties", null);
    _indentNumber = gf.get("_indentNumber", 0);

    if (is.readBoolean()) {
        _uriResolver = (URIResolver) is.readObject();
    }

    _tfactory = new TransformerFactoryImpl();
}
 
Example 27
Source Project: TencentKona-8   Source File: XSLTC.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the destination directory for the translet.
 * The current working directory will be used by default.
 */
public boolean setDestDirectory(String dstDirName) {
    final File dir = new File(dstDirName);
    if (SecuritySupport.getFileExists(dir) || dir.mkdirs()) {
        _destDir = dir;
        return true;
    }
    else {
        _destDir = null;
        return false;
    }
}
 
Example 28
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 29
Source Project: hottub   Source File: XSLMessages.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a message from the specified key and replacement arguments,
 * localized to the given locale.
 *
 * @param msgKey The key for the message text.
 * @param args The arguments to be used as replacement text in the message
 * created.
 *
 * @return The formatted warning string.
 */
public static String createWarning(String msgKey, Object args[]) //throws Exception
{
    if (XSLTBundle == null) {
        XSLTBundle = SecuritySupport.getResourceBundle(XSLT_ERROR_RESOURCES);
    }

    if (XSLTBundle != null) {
        return createMsg(XSLTBundle, msgKey, args);
    } else {
        return "Could not load any resource bundles.";
    }
}
 
Example 30
Source Project: openjdk-8   Source File: XSLTC.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the destination directory for the translet.
 * The current working directory will be used by default.
 */
public boolean setDestDirectory(String dstDirName) {
    final File dir = new File(dstDirName);
    if (SecuritySupport.getFileExists(dir) || dir.mkdirs()) {
        _destDir = dir;
        return true;
    }
    else {
        _destDir = null;
        return false;
    }
}