Exemple #1
0
            /*
             * Parse the provider-configuration file as specified
             * @see <a href="http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#Provider Configuration File">JAR File Specification</a>
             */
            private java.util.Set <String> parse(java.net.URL u)
            {
                java.io.InputStream    input  = null;
                java.io.BufferedReader reader = null;
                java.util.Set <String> names  = new java.util.HashSet <String>();
                try
                {
                    input  = u.openStream();
                    reader = new java.io.BufferedReader(new java.io.InputStreamReader(input, "utf-8")); //$NON-NLS-1$

                    String line;
                    while ((line = reader.readLine()) != null)
                    {
                        // The comment character is '#' (0x23)
                        // on each line all characters following the first comment character are ignored
                        int sharpIndex = line.indexOf('#');
                        if (sharpIndex >= 0)
                        {
                            line = line.substring(0, sharpIndex);
                        }

                        // Whitespaces are ignored
                        line = line.trim();

                        if (line.length() > 0)
                        {
                            // a java class name, check if identifier correct
                            char[] namechars = line.toCharArray();
                            for (int i = 0; i < namechars.Length; i++)
                            {
                                if (!(java.lang.Character.isJavaIdentifierPart(namechars[i]) || namechars[i] == '.'))
                                {
                                    throw new ServiceConfigurationError(Messages.getString("imageio.99", line));
                                }
                            }
                            names.add(line);
                        }
                    }
                }
                catch (java.io.IOException e)
                {
                    throw new ServiceConfigurationError(e.toString());
                }
                finally
                {
                    try
                    {
                        if (reader != null)
                        {
                            reader.close();
                        }
                        if (input != null)
                        {
                            input.close();
                        }
                    }
                    catch (java.io.IOException e)
                    {
                        throw new ServiceConfigurationError(e.toString());
                    }
                }

                return(names);
            }
Exemple #2
0
 public java.io.InputStream getResourceAsStream(String name)
 {
     java.net.URL url = getResource(name);
     return(url.openStream());
 }
Exemple #3
0
        // static initialization
        // - load security properties files
        // - load statically registered providers
        // - if no provider description file found then load default providers
        static Security()
        {
            bool loaded = false;
            java.io.File f = new java.io.File(java.lang.SystemJ.getProperty("java.home") //$NON-NLS-1$
                    + java.io.File.separator + "lib" + java.io.File.separator //$NON-NLS-1$
                    + "security" + java.io.File.separator + "java.security"); //$NON-NLS-1$ //$NON-NLS-2$
            if (f.exists())
            {
                try
                {
                    java.io.FileInputStream fis = new java.io.FileInputStream(f);
                    java.io.InputStreamReader isJ = new java.io.InputStreamReader(fis);
                    secprops.load(isJ);
                    loaded = true;
                    isJ.close();
                }
                catch (java.io.IOException e)
                {
                    //                        System.err.println("Could not load Security properties file: "
                    //                                        + e);
                }
            }

            if (Util.equalsIgnoreCase("true", secprops.getProperty("security.allowCustomPropertiesFile", "true")))
            { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                String securityFile = java.lang.SystemJ.getProperty("java.security.properties"); //$NON-NLS-1$
                if (securityFile != null)
                {
                    if (securityFile.startsWith("="))
                    { // overwrite //$NON-NLS-1$
                        secprops = new java.util.Properties();
                        loaded = false;
                        securityFile = securityFile.substring(1);
                    }
                    try
                    {
                        securityFile = PolicyUtils.expand(securityFile, java.lang.SystemJ.getProperties());
                    }
                    catch (PolicyUtils.ExpansionFailedException e)
                    {
                        //                            System.err.println("Could not load custom Security properties file "
                        //                                    + securityFile +": " + e);
                    }
                    f = new java.io.File(securityFile);
                    java.io.InputStreamReader isj;
                    try
                    {
                        if (f.exists())
                        {
                            java.io.FileInputStream fis = new java.io.FileInputStream(f);
                            isj = new java.io.InputStreamReader(fis);
                        }
                        else
                        {
                            java.net.URL url = new java.net.URL(securityFile);
                            isj = new java.io.InputStreamReader(url.openStream());
                        }
                        secprops.load(isj);
                        loaded = true;
                        isj.close();
                    }
                    catch (java.io.IOException e)
                    {
                        //                           System.err.println("Could not load custom Security properties file "
                        //                                   + securityFile +": " + e);
                    }
                }
            }
            if (!loaded)
            {
                registerDefaultProviders();
            }
            Engine.door = new SecurityDoor();
        }
Exemple #4
0
        // static initialization
        // - load security properties files
        // - load statically registered providers
        // - if no provider description file found then load default providers
        static Security()
        {
            bool loaded = false;

            java.io.File f = new java.io.File(java.lang.SystemJ.getProperty("java.home")                //$NON-NLS-1$
                                              + java.io.File.separator + "lib" + java.io.File.separator //$NON-NLS-1$
                                              + "security" + java.io.File.separator + "java.security"); //$NON-NLS-1$ //$NON-NLS-2$
            if (f.exists())
            {
                try
                {
                    java.io.FileInputStream   fis = new java.io.FileInputStream(f);
                    java.io.InputStreamReader isJ = new java.io.InputStreamReader(fis);
                    secprops.load(isJ);
                    loaded = true;
                    isJ.close();
                }
                catch (java.io.IOException)
                {
                    //                        System.err.println("Could not load Security properties file: "
                    //                                        + e);
                }
            }

            if (Util.equalsIgnoreCase("true", secprops.getProperty("security.allowCustomPropertiesFile", "true")))
            {                                                                                    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                String securityFile = java.lang.SystemJ.getProperty("java.security.properties"); //$NON-NLS-1$
                if (securityFile != null)
                {
                    if (securityFile.startsWith("="))
                    { // overwrite //$NON-NLS-1$
                        secprops     = new java.util.Properties();
                        loaded       = false;
                        securityFile = securityFile.substring(1);
                    }
                    try
                    {
                        securityFile = PolicyUtils.expand(securityFile, java.lang.SystemJ.getProperties());
                    }
                    catch (PolicyUtils.ExpansionFailedException)
                    {
                        //                            System.err.println("Could not load custom Security properties file "
                        //                                    + securityFile +": " + e);
                    }
                    f = new java.io.File(securityFile);
                    java.io.InputStreamReader isj;
                    try
                    {
                        if (f.exists())
                        {
                            java.io.FileInputStream fis = new java.io.FileInputStream(f);
                            isj = new java.io.InputStreamReader(fis);
                        }
                        else
                        {
                            java.net.URL url = new java.net.URL(securityFile);
                            isj = new java.io.InputStreamReader(url.openStream());
                        }
                        secprops.load(isj);
                        loaded = true;
                        isj.close();
                    }
                    catch (java.io.IOException)
                    {
                        //                           System.err.println("Could not load custom Security properties file "
                        //                                   + securityFile +": " + e);
                    }
                }
            }
            if (!loaded)
            {
                registerDefaultProviders();
            }
            Engine.door = new SecurityDoor();
        }