FileDocCategorySizeDatePackage
PrintCert.javaAPI DocExample2338Sun Oct 25 18:13:36 GMT 1998None

PrintCert

public class PrintCert extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

		try {
			FileInputStream fr = new FileInputStream("sdo.cer");
			// In 1.2 beta 4, the following method no longer exists, and
			// we have to use a certificate factory instead
			// X509Certificate c = X509Certificate.getInstance(fr);
			CertificateFactory cf = CertificateFactory.getInstance("X509");
			Certificate cert = cf.generateCertificate(fr);
			X509Certificate c = (X509Certificate) cert;
			System.out.println("Read in the following certificate:");
			System.out.println("\tCertificate for: " + c.getSubjectDN());
			System.out.println("\tCertificate issued by: " + c.getIssuerDN());
			System.out.println("\tThe certificate is valid from " +
						c.getNotBefore() + " to " + c.getNotAfter());
			System.out.println("\tCertificate SN# " + c.getSerialNumber());
			System.out.println("\tGenerated with " + c.getSigAlgName());
		} catch (Exception e) {
			e.printStackTrace();
		}