FileDocCategorySizeDatePackage
TestCertificate.javaAPI DocExample1812Sat Jan 13 13:24:06 GMT 2001javasec.samples.ch09

TestCertificate

public class TestCertificate extends Object

Fields Summary
Constructors Summary
Methods Summary
java.security.PublicKeygetPublicKey(java.security.Principal p)

        return null;
    
public java.security.cert.CertificateimportCertificate(byte[] data)

        X509Certificate c = null;
        try {
            CertificateFactory cf = CertificateFactory.getInstance("X509");
            ByteArrayInputStream bais = new ByteArrayInputStream(data);
            c = (X509Certificate) cf.generateCertificate(bais);
            Principal p = c.getIssuerDN();
            PublicKey pk = getPublicKey(p);
            c.verify(pk);
            InputStream crlFile = lookupCRLFile(p);
            cf = CertificateFactory.getInstance("X509CRL");
            X509CRL crl = (X509CRL) cf.generateCRL(crlFile);
            if (crl.isRevoked(c))
                    throw new CertificateException("Certificate revoked");
        } catch (NoSuchAlgorithmException nsae) {
            throw new CertificateException("Can't verify certificate");
        } catch (NoSuchProviderException nspe) {
            throw new CertificateException("Can't verify certificate");
        } catch (SignatureException se) {
            throw new CertificateException("Can't verify certificate");
        } catch (InvalidKeyException ike) {
            throw new CertificateException("Can't verify certificate");
        } catch (CRLException ce) {
            // treat as no crl
        }
        return c;
    
java.io.InputStreamlookupCRLFile(java.security.Principal p)

        return null;