38 |
package java.security; |
package java.security; |
39 |
|
|
40 |
import java.security.cert.Certificate; |
import java.security.cert.Certificate; |
41 |
|
import java.security.cert.CertificateException; |
42 |
import java.security.cert.X509Certificate; |
import java.security.cert.X509Certificate; |
43 |
import java.security.spec.AlgorithmParameterSpec; |
import java.security.spec.AlgorithmParameterSpec; |
44 |
|
|
45 |
|
import gnu.java.security.Engine; |
46 |
|
|
47 |
/** |
/** |
48 |
* <p>This <code>Signature</code> class is used to provide applications the |
* <p>This <code>Signature</code> class is used to provide applications the |
49 |
* functionality of a digital signature algorithm. Digital signatures are used |
* functionality of a digital signature algorithm. Digital signatures are used |
240 |
throw new IllegalArgumentException("Illegal provider"); |
throw new IllegalArgumentException("Illegal provider"); |
241 |
|
|
242 |
Signature result = null; |
Signature result = null; |
243 |
Object o = Engine.getInstance(SIGNATURE, algorithm, provider); |
Object o = null; |
244 |
|
try |
245 |
|
{ |
246 |
|
o = Engine.getInstance(SIGNATURE, algorithm, provider); |
247 |
|
} |
248 |
|
catch (java.lang.reflect.InvocationTargetException ite) |
249 |
|
{ |
250 |
|
throw new NoSuchAlgorithmException(algorithm); |
251 |
|
} |
252 |
|
|
253 |
if (o instanceof SignatureSpi) |
if (o instanceof SignatureSpi) |
254 |
{ |
{ |
319 |
throw new InvalidKeyException( |
throw new InvalidKeyException( |
320 |
"KeyUsage of this Certificate indicates it cannot be used for digital signing"); |
"KeyUsage of this Certificate indicates it cannot be used for digital signing"); |
321 |
} |
} |
322 |
this.initVerify(certificate.getPublicKey()); |
try |
323 |
|
{ |
324 |
|
this.initVerify(certificate.getPublicKey()); |
325 |
|
} |
326 |
|
catch (SignatureException se) |
327 |
|
{ |
328 |
|
throw new InvalidKeyException(se.getMessage()); |
329 |
|
} |
330 |
|
catch (NoSuchAlgorithmException nsae) |
331 |
|
{ |
332 |
|
throw new InvalidKeyException(nsae.getMessage()); |
333 |
|
} |
334 |
|
catch (NoSuchProviderException nspe) |
335 |
|
{ |
336 |
|
throw new InvalidKeyException(nspe.getMessage()); |
337 |
|
} |
338 |
|
catch (CertificateException ce) |
339 |
|
{ |
340 |
|
throw new InvalidKeyException(ce.getMessage()); |
341 |
|
} |
342 |
} |
} |
343 |
|
|
344 |
/** |
/** |