示例#1
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();
        }
示例#2
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();
        }