* if the certificate cannot be created or initialized.
*/
public static final X509Certificate getInstance(InputStream inStream)
throws CertificateException {
if (inStream == null) {
throw new CertificateException(Messages.getString("security.87")); //$NON-NLS-1$
}
if (constructor != null) {
try {
return (X509Certificate)
constructor.newInstance(new Object[] {inStream});
} catch (Throwable e) {
throw new CertificateException(e.getMessage());
}
}
final java.security.cert.X509Certificate cert;
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509"); //$NON-NLS-1$
cert = (java.security.cert.X509Certificate)
cf.generateCertificate(inStream);
} catch (java.security.cert.CertificateException e) {
throw new CertificateException(e.getMessage());
}
return new X509Certificate() {
public byte[] getEncoded() throws CertificateEncodingException {
try {
return cert.getEncoded();
} catch (java.security.cert.CertificateEncodingException e) {
throw new CertificateEncodingException(e.getMessage());
}
}
public void verify(PublicKey key) throws CertificateException,
NoSuchAlgorithmException, InvalidKeyException,
NoSuchProviderException, SignatureException {
try {
cert.verify(key);
} catch (java.security.cert.CertificateException e) {
throw new CertificateException(e.getMessage());
}
}
public void verify(PublicKey key, String sigProvider)
throws CertificateException,
NoSuchAlgorithmException, InvalidKeyException,
NoSuchProviderException, SignatureException {
try {
cert.verify(key, sigProvider);
} catch (java.security.cert.CertificateException e) {
throw new CertificateException(e.getMessage());
}
}
public String toString() {
return cert.toString();