public static CMPCertificate getInstance(Object o) { if (o == null || o instanceof CMPCertificate) { return (CMPCertificate)o; } if (o instanceof byte[]) { try { o = ASN1Primitive.fromByteArray((byte[])o); } catch (IOException e) { throw new IllegalArgumentException("Invalid encoding in CMPCertificate"); } } if (o instanceof ASN1Sequence) { return new CMPCertificate(Certificate.getInstance(o)); } if (o instanceof ASN1TaggedObject) { ASN1TaggedObject taggedObject = (ASN1TaggedObject)o; return new CMPCertificate(taggedObject.getTagNo(), taggedObject.getObject()); } throw new IllegalArgumentException("Invalid object: " + o.getClass().getName()); }
public static CMPCertificate getInstance(Object o) { if (o == null || o instanceof CMPCertificate) { return (CMPCertificate)o; } if (o instanceof byte[]) { try { o = ASN1Primitive.fromByteArray((byte[])o); } catch (IOException e) { throw new IllegalArgumentException("Invalid encoding in CMPCertificate"); } } if (o instanceof ASN1Sequence) { return new CMPCertificate(Certificate.getInstance(o)); } if (o instanceof ASN1TaggedObject) { ASN1TaggedObject taggedObject = (ASN1TaggedObject)o; return new CMPCertificate(taggedObject.getTagNo(), taggedObject.getObject()); } throw new IllegalArgumentException("Invalid object: " + o.getClass().getName()); }
public CaInfo(MgmtEntry.Ca caEntry, CertStore certStore) throws OperationException { this.caEntry = Args.notNull(caEntry, "caEntry"); this.certStore = Args.notNull(certStore, "certStore"); X509Certificate cert = caEntry.getCert(); this.notBefore = cert.getNotBefore(); this.notAfter = cert.getNotAfter(); this.serialNumber = cert.getSerialNumber(); this.selfSigned = cert.getIssuerX500Principal().equals(cert.getSubjectX500Principal()); Certificate bcCert; try { byte[] encodedCert = cert.getEncoded(); bcCert = Certificate.getInstance(encodedCert); } catch (CertificateEncodingException ex) { throw new OperationException(ErrorCode.SYSTEM_FAILURE, "could not encode the CA certificate"); } this.certInCmpFormat = new CMPCertificate(bcCert); this.publicCaInfo = new PublicCaInfo(cert, caEntry.getCaUris(), caEntry.getExtraControl()); this.noNewCertificateAfter = notAfter.getTime() - MS_PER_DAY * caEntry.getExpirationPeriod(); this.randomSnGenerator = RandomSerialNumberGenerator.getInstance(); } // constructor