64 |
private static final String ALG_ALIAS = "Alg.Alias."; |
private static final String ALG_ALIAS = "Alg.Alias."; |
65 |
|
|
66 |
private static Vector providers = new Vector(); |
private static Vector providers = new Vector(); |
67 |
private static Properties secprops; |
private static Properties secprops = new Properties(); |
68 |
static |
static |
69 |
{ |
{ |
70 |
String base = System.getProperty("gnu.classpath.home.url"); |
String base = System.getProperty("gnu.classpath.home.url"); |
71 |
loadProviders(base, System.getProperty("gnu.classpath.vm.shortname")); |
String vendor = System.getProperty("gnu.classpath.vm.shortname"); |
72 |
loadProviders(base, "classpath"); |
|
73 |
|
// Try VM specific security file |
74 |
|
boolean loaded = loadProviders(base, vendor); |
75 |
|
|
76 |
|
// Append classpath standard provider if possible |
77 |
|
if (!loadProviders(base, "classpath") && !loaded && providers.size() == 0) |
78 |
|
{ |
79 |
|
// No providers found and both security files failed to load properly. |
80 |
|
System.err.println |
81 |
|
("WARNING: could not properly read security provider files:"); |
82 |
|
System.err.println |
83 |
|
(" " + base + "/security/" + vendor + ".security"); |
84 |
|
System.err.println |
85 |
|
(" " + base + "/security/" + "classpath" + ".security"); |
86 |
|
System.err.println |
87 |
|
(" Falling back to standard GNU security provider"); |
88 |
|
providers.addElement(new gnu.java.security.provider.Gnu()); |
89 |
|
} |
90 |
} |
} |
91 |
|
|
92 |
// This class can't be instantiated. |
// This class can't be instantiated. |
94 |
{ |
{ |
95 |
} |
} |
96 |
|
|
97 |
private static void loadProviders(String baseUrl, String vendor) |
/** |
98 |
|
* Tries to load the vender specific security providers from the given |
99 |
|
* base URL. Returns true if the resource could be read and completely |
100 |
|
* parsed successfully, false otherwise. |
101 |
|
*/ |
102 |
|
private static boolean loadProviders(String baseUrl, String vendor) |
103 |
{ |
{ |
104 |
if (baseUrl == null || vendor == null) |
if (baseUrl == null || vendor == null) |
105 |
return; |
return false; |
106 |
|
|
107 |
|
boolean result = true; |
108 |
String secfilestr = baseUrl + "/security/" + vendor + ".security"; |
String secfilestr = baseUrl + "/security/" + vendor + ".security"; |
109 |
try |
try |
110 |
{ |
{ |
111 |
InputStream fin = new URL(secfilestr).openStream(); |
InputStream fin = new URL(secfilestr).openStream(); |
|
secprops = new Properties(); |
|
112 |
secprops.load(fin); |
secprops.load(fin); |
113 |
|
|
114 |
int i = 1; |
int i = 1; |
134 |
} |
} |
135 |
|
|
136 |
if (exception != null) |
if (exception != null) |
137 |
System.err.println ( |
{ |
138 |
"Error loading security provider " + name + ": " + exception); |
System.err.println ("WARNING: Error loading security provider " |
139 |
|
+ name + ": " + exception); |
140 |
|
result = false; |
141 |
|
} |
142 |
i++; |
i++; |
143 |
} |
} |
144 |
} |
} |
|
catch (FileNotFoundException ignored) |
|
|
{ |
|
|
// Actually we probably shouldn't ignore these, once the security |
|
|
// properties file is actually installed somewhere. |
|
|
} |
|
145 |
catch (IOException ignored) |
catch (IOException ignored) |
146 |
{ |
{ |
147 |
|
result = false; |
148 |
} |
} |
149 |
|
|
150 |
|
return false; |
151 |
} |
} |
152 |
|
|
153 |
/** |
/** |