1 |
/* KeyStore.java --- Key Store Class |
/* KeyStore.java --- Key Store Class |
2 |
Copyright (C) 1999 Free Software Foundation, Inc. |
Copyright (C) 1999, 2002 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
92 |
/** |
/** |
93 |
Gets an instance of the KeyStore class representing |
Gets an instance of the KeyStore class representing |
94 |
the specified keystore. If the type is not |
the specified keystore. If the type is not |
95 |
found then, it throws CertificateException. |
found then, it throws KeyStoreException. |
96 |
|
|
97 |
@param type the type of certificate to choose |
@param type the type of keystore to choose |
98 |
|
|
99 |
@return a KeyStore repesenting the desired type |
@return a KeyStore repesenting the desired type |
100 |
|
|
117 |
/** |
/** |
118 |
Gets an instance of the KeyStore class representing |
Gets an instance of the KeyStore class representing |
119 |
the specified key store from the specified provider. |
the specified key store from the specified provider. |
120 |
If the type is not found then, it throws CertificateException. |
If the type is not found then, it throws KeyStoreException. |
121 |
If the provider is not found, then it throws |
If the provider is not found, then it throws |
122 |
NoSuchProviderException. |
NoSuchProviderException. |
123 |
|
|
124 |
@param type the type of certificate to choose |
@param type the type of keystore to choose |
125 |
|
@param provider the provider name |
126 |
|
|
127 |
@return a KeyStore repesenting the desired type |
@return a KeyStore repesenting the desired type |
128 |
|
|
129 |
@throws KeyStoreException if the type of keystore is not implemented by providers |
@throws KeyStoreException if the type of keystore is not |
130 |
|
implemented by the given provider |
131 |
@throws NoSuchProviderException if the provider is not found |
@throws NoSuchProviderException if the provider is not found |
132 |
|
@throws IllegalArgumentException if the provider string is |
133 |
|
null or empty |
134 |
*/ |
*/ |
135 |
public static KeyStore getInstance(String type, String provider) |
public static KeyStore getInstance(String type, String provider) |
136 |
throws KeyStoreException, NoSuchProviderException |
throws KeyStoreException, NoSuchProviderException |
137 |
{ |
{ |
138 |
|
if (provider == null || provider.length() == 0) |
139 |
|
throw new IllegalArgumentException("Illegal provider"); |
140 |
Provider p = Security.getProvider(provider); |
Provider p = Security.getProvider(provider); |
141 |
if (p == null) |
if (p == null) |
142 |
throw new NoSuchProviderException(); |
throw new NoSuchProviderException(); |
144 |
return getInstance(p.getProperty("KeyStore." + type), type, p); |
return getInstance(p.getProperty("KeyStore." + type), type, p); |
145 |
} |
} |
146 |
|
|
147 |
|
/** |
148 |
|
Gets an instance of the KeyStore class representing |
149 |
|
the specified key store from the specified provider. |
150 |
|
If the type is not found then, it throws KeyStoreException. |
151 |
|
If the provider is not found, then it throws |
152 |
|
NoSuchProviderException. |
153 |
|
|
154 |
|
@param type the type of keystore to choose |
155 |
|
@param provider the keystore provider |
156 |
|
|
157 |
|
@return a KeyStore repesenting the desired type |
158 |
|
|
159 |
|
@throws KeyStoreException if the type of keystore is not |
160 |
|
implemented by the given provider |
161 |
|
@throws IllegalArgumentException if the provider object is null |
162 |
|
@since 1.4 |
163 |
|
*/ |
164 |
|
public static KeyStore getInstance(String type, Provider provider) |
165 |
|
throws KeyStoreException |
166 |
|
{ |
167 |
|
if (provider == null) |
168 |
|
throw new IllegalArgumentException("Illegal provider"); |
169 |
|
|
170 |
|
return getInstance(provider.getProperty("KeyStore." + type), |
171 |
|
type, provider); |
172 |
|
} |
173 |
|
|
174 |
private static KeyStore getInstance(String classname, |
private static KeyStore getInstance(String classname, |
175 |
String type, |
String type, |
176 |
Provider provider) |
Provider provider) |