}  if (is == null) { if (accessControllerClass != null) { is = ( InputStream) java .security .AccessController .doPrivileged( new java .security .PrivilegedAction() { public Object run() { return OutputPropertiesFactory .class .getResourceAsStream( resourceName); } }); } else {  is = OutputPropertiesFactory.class.getResourceAsStream( resourceName); }
is = OutputPropertiesFactory.class .getResourceAsStream(resourceName);
    static private Properties loadPropertiesFile(        final String resourceName,        Properties defaults)        throws IOException    {        // This static method should eventually be moved to a thread-specific class        // so that we can cache the ContextClassLoader and bottleneck all properties file        // loading throughout Xalan.        Properties props = new Properties(defaults);        InputStream is = null;        BufferedInputStream bis = null;        Class accessControllerClass = null;        try        {            try            {                try                {                    // This Class was introduced in JDK 1.2. With the re-architecture of                    // security mechanism ( starting in JDK 1.2 ), we have option of                    // giving privileges to certain part of code using doPrivileged block.                    // In JDK1.1.X applications won't be having security manager and if                    // there is security manager ( in applets ), code need to be signed                    // and trusted for having access to resources.                    accessControllerClass =                        Utils.ClassForName("java.security.AccessController");                    // If we are here means user is using JDK >= 1.2.                    // Using doPrivileged to be able to read property file without opening                    // up secured container permissions like J2EE container                    is =                        (                            InputStream) java                                .security                                .AccessController                                .doPrivileged(                                    new java                                    .security                                    .PrivilegedAction()                    {                        public Object run()                        {                            try                            {                                java.lang.reflect.Method getCCL =                                    Thread.class.getMethod(                                        "getContextClassLoader",                                        NO_CLASSES);                                if (getCCL != null)                                {                                    ClassLoader contextClassLoader =                                        (ClassLoader) getCCL.invoke(                                            Thread.currentThread(),                                            NO_OBJS);                                    return (                                        contextClassLoader.getResourceAsStream(                                            PROP_DIR + resourceName));                                }                            }                            catch (Exception e)                            {                            }                            return null;                        }                    });                }                catch (ClassNotFoundException e)                {                    //User may be using older JDK ( JDK <1.2 ). Allow him/her to use it.                    // But don't try to use doPrivileged                    try                    {                        java.lang.reflect.Method getCCL =                            Thread.class.getMethod(                                "getContextClassLoader",                                NO_CLASSES);                        if (getCCL != null)                        {                            ClassLoader contextClassLoader =                                (ClassLoader) getCCL.invoke(                                    Thread.currentThread(),                                    NO_OBJS);                            is =                                contextClassLoader.getResourceAsStream(                                    PROP_DIR + resourceName);                        }                    }                    catch (Exception exception)                    {                    }                }            }            catch (Exception e)            {            }            if (is == null)            {                if (accessControllerClass != null)                {                    is =                        (                            InputStream) java                                .security                                .AccessController                                .doPrivileged(                                    new java                                    .security                                    .PrivilegedAction()                    {                        public Object run()                        {                            return OutputPropertiesFactory                                .class                                .getResourceAsStream(                                resourceName);                        }                    });                }                else                {                    // User may be using older JDK ( JDK < 1.2 )                    is =                        OutputPropertiesFactory.class.getResourceAsStream(                            resourceName);                }            }            bis = new BufferedInputStream(is);            props.load(bis);        }        catch (IOException ioe)        {            if (defaults == null)            {                throw ioe;            }            else            {                throw new WrappedRuntimeException(                    XMLMessages.createXMLMessage(                        XMLErrorResources.ER_COULD_NOT_LOAD_RESOURCE,                        new Object[] { resourceName }),                    ioe);                //"Could not load '"+resourceName+"' (check CLASSPATH), now using just the defaults ", ioe);            }        }        catch (SecurityException se)        {            // Repeat IOException handling for sandbox/applet case -sc            if (defaults == null)            {                throw se;            }            else            {                throw new WrappedRuntimeException(                    XMLMessages.createXMLMessage(                        XMLErrorResources.ER_COULD_NOT_LOAD_RESOURCE,                        new Object[] { resourceName }),                    se);                //"Could not load '"+resourceName+"' (check CLASSPATH, applet security), now using just the defaults ", se);            }        }        finally        {            if (bis != null)            {                bis.close();            }            if (is != null)            {                is.close();            }        }        // Note that we're working at the HashTable level here,        // and not at the Properties level!  This is important        // because we don't want to modify the default properties.        // NB: If fixupPropertyString ends up changing the property        // name or value, we need to remove the old key and re-add        // with the new key and value.  However, then our Enumeration        // could lose its place in the HashTable.  So, we first        // clone the HashTable and enumerate over that since the        // clone will not change.  When we migrate to Collections,        // this code should be revisited and cleaned up to use        // an Iterator which may (or may not) alleviate the need for        // the clone.  Many thanks to Padraig O'hIceadha        // <padraig@gradient.ie> for finding this problem.  Bugzilla 2000.        Enumeration keys = ((Properties) props.clone()).keys();        while (keys.hasMoreElements())        {            String key = (String) keys.nextElement();            // Now check if the given key was specified as a            // System property. If so, the system property            // overides the default value in the propery file.            String value = null;            try            {                value = System.getProperty(key);            }            catch (SecurityException se)            {                // No-op for sandbox/applet case, leave null -sc            }            if (value == null)                value = (String) props.get(key);            String newKey = fixupPropertyString(key, true);            String newValue = null;            try            {                newValue = System.getProperty(newKey);            }            catch (SecurityException se)            {                // No-op for sandbox/applet case, leave null -sc            }            if (newValue == null)                newValue = fixupPropertyString(value, false);            else                newValue = fixupPropertyString(newValue, false);            if (key != newKey || value != newValue)            {                props.remove(key);                props.put(newKey, newValue);            }        }        return props;    }