summaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authormark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-07 18:38:09 +0000
committermark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-07 18:38:09 +0000
commitb6929d5321816a2f2d29676e6dffe3e54c1feee3 (patch)
tree60d65600b34dd9363ea5415428632baf37aac957 /libjava
parent6ec1f4e023b5e2ec844a490e0a9364bacdab0c05 (diff)
downloadgcc-b6929d5321816a2f2d29676e6dffe3e54c1feee3.tar.gz
* java/security/Security.java (secprops): Initialize.
(loadProviders): Return boolean. (static): Check result of loadProvider calls. If necessary display WARNING and fallback to Gnu provider. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@67597 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog7
-rw-r--r--libjava/java/security/Security.java49
2 files changed, 43 insertions, 13 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 10e54f5f7de..d4c8e4099a0 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,10 @@
+2003-06-06 Mark Wielaard <mark@klomp.org>
+
+ * java/security/Security.java (secprops): Initialize.
+ (loadProviders): Return boolean.
+ (static): Check result of loadProvider calls. If necessary
+ display WARNING and fallback to Gnu provider.
+
2002-06-06 James Clark <jjc@jclark.com>
Fix for PR libgcj/8738:
diff --git a/libjava/java/security/Security.java b/libjava/java/security/Security.java
index 0f1827ea02c..56335bf85c3 100644
--- a/libjava/java/security/Security.java
+++ b/libjava/java/security/Security.java
@@ -64,12 +64,29 @@ public final class Security extends Object
private static final String ALG_ALIAS = "Alg.Alias.";
private static Vector providers = new Vector();
- private static Properties secprops;
+ private static Properties secprops = new Properties();
static
{
String base = System.getProperty("gnu.classpath.home.url");
- loadProviders(base, System.getProperty("gnu.classpath.vm.shortname"));
- loadProviders(base, "classpath");
+ String vendor = System.getProperty("gnu.classpath.vm.shortname");
+
+ // Try VM specific security file
+ boolean loaded = loadProviders(base, vendor);
+
+ // Append classpath standard provider if possible
+ if (!loadProviders(base, "classpath") && !loaded && providers.size() == 0)
+ {
+ // No providers found and both security files failed to load properly.
+ System.err.println
+ ("WARNING: could not properly read security provider files:");
+ System.err.println
+ (" " + base + "/security/" + vendor + ".security");
+ System.err.println
+ (" " + base + "/security/" + "classpath" + ".security");
+ System.err.println
+ (" Falling back to standard GNU security provider");
+ providers.addElement(new gnu.java.security.provider.Gnu());
+ }
}
// This class can't be instantiated.
@@ -77,16 +94,21 @@ public final class Security extends Object
{
}
- private static void loadProviders(String baseUrl, String vendor)
+ /**
+ * Tries to load the vender specific security providers from the given
+ * base URL. Returns true if the resource could be read and completely
+ * parsed successfully, false otherwise.
+ */
+ private static boolean loadProviders(String baseUrl, String vendor)
{
if (baseUrl == null || vendor == null)
- return;
+ return false;
+ boolean result = true;
String secfilestr = baseUrl + "/security/" + vendor + ".security";
try
{
InputStream fin = new URL(secfilestr).openStream();
- secprops = new Properties();
secprops.load(fin);
int i = 1;
@@ -112,19 +134,20 @@ public final class Security extends Object
}
if (exception != null)
- System.err.println (
- "Error loading security provider " + name + ": " + exception);
+ {
+ System.err.println ("WARNING: Error loading security provider "
+ + name + ": " + exception);
+ result = false;
+ }
i++;
}
}
- catch (FileNotFoundException ignored)
- {
- // Actually we probably shouldn't ignore these, once the security
- // properties file is actually installed somewhere.
- }
catch (IOException ignored)
{
+ result = false;
}
+
+ return false;
}
/**