public void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException { checkValidity(date.getTime()); }
/** * Builds the instance of X509CertPathImpl on the base of the list of * ASN.1 encodings of X.509 certificates provided via PkiPath structure. * This method participates in decoding process. */ public Object getDecodedObject(BerInputStream in) throws IOException { // retrieve the decoded content final List<byte[]> encodedCerts = (List<byte[]>) in.content; final int size = encodedCerts.size(); final List<X509Certificate> certificates = new ArrayList<X509Certificate>(size); for (int i = size - 1; i >= 0; i--) { // create the X.509 certificate on the base of its encoded form // and add it to the list. certificates.add(new X509CertImpl((Certificate) Certificate.ASN1 .decode(encodedCerts.get(i)))); } // create and return the resulting object return new X509CertPathImpl(certificates, Encoding.PKI_PATH); }
@Override public byte[] getEncoded() throws CertificateEncodingException { return getEncodedInternal().clone(); } private byte[] getEncodedInternal() throws CertificateEncodingException {
private void checkValidity(long time) throws CertificateExpiredException, CertificateNotYetValidException { if (time < getNotBeforeInternal()) { throw new CertificateNotYetValidException("current time: " + new Date(time) + ", validation time: " + new Date(getNotBeforeInternal())); } if (time > getNotAfterInternal()) { throw new CertificateExpiredException("current time: " + new Date(time) + ", expiration time: " + new Date(getNotAfterInternal())); } }
@Override public void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException { Signature signature = Signature.getInstance(getSigAlgName(), sigProvider); signature.initVerify(key); // retrieve the encoding of the TBSCertificate structure byte[] tbsCertificateLocal = getTbsCertificateInternal(); // compute and verify the signature signature.update(tbsCertificateLocal, 0, tbsCertificateLocal.length); if (!signature.verify(certificate.getSignatureValue())) { throw new SignatureException("Signature was not verified"); } }
public Date getNotAfter() { return new Date(getNotAfterInternal()); }
public Date getNotBefore() { return new Date(getNotBeforeInternal()); }
public String getSigAlgName() { String result = sigAlgName; if (result == null) { String sigAlgOIDLocal = getSigAlgOID(); // retrieve the name of the signing algorithm result = AlgNameMapper.map2AlgName(sigAlgOIDLocal); if (result == null) { // if could not be found, use OID as a name result = sigAlgOIDLocal; } sigAlgName = result; } return result; }
public Principal getIssuerDN() { return getIssuerX500Principal(); }
public Principal getSubjectDN() { return getSubjectX500Principal(); }
public byte[] getSignature() { return getSignatureInternal().clone(); }
@Override public void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException { Signature signature = Signature.getInstance(getSigAlgName()); signature.initVerify(key); // retrieve the encoding of the TBSCertificate structure byte[] tbsCertificateLocal = getTbsCertificateInternal(); // compute and verify the signature signature.update(tbsCertificateLocal, 0, tbsCertificateLocal.length); if (!signature.verify(certificate.getSignatureValue())) { throw new SignatureException("Signature was not verified"); } }
private void checkValidity(long time) throws CertificateExpiredException, CertificateNotYetValidException { if (time < getNotBeforeInternal()) { throw new CertificateNotYetValidException("current time: " + new Date(time) + ", validation time: " + new Date(getNotBeforeInternal())); } if (time > getNotAfterInternal()) { throw new CertificateExpiredException("current time: " + new Date(time) + ", expiration time: " + new Date(getNotAfterInternal())); } }
public Date getNotAfter() { return new Date(getNotAfterInternal()); }
public Date getNotBefore() { return new Date(getNotBeforeInternal()); }
public String getSigAlgName() { String result = sigAlgName; if (result == null) { String sigAlgOIDLocal = getSigAlgOID(); // retrieve the name of the signing algorithm result = AlgNameMapper.map2AlgName(sigAlgOIDLocal); if (result == null) { // if could not be found, use OID as a name result = sigAlgOIDLocal; } sigAlgName = result; } return result; }
public Principal getIssuerDN() { return getIssuerX500Principal(); }
public Principal getSubjectDN() { return getSubjectX500Principal(); }
public byte[] getSignature() { return getSignatureInternal().clone(); }
@Override public void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException { Signature signature = Signature.getInstance(getSigAlgName(), sigProvider); signature.initVerify(key); // retrieve the encoding of the TBSCertificate structure byte[] tbsCertificateLocal = getTbsCertificateInternal(); // compute and verify the signature signature.update(tbsCertificateLocal, 0, tbsCertificateLocal.length); if (!signature.verify(certificate.getSignatureValue())) { throw new SignatureException("Signature was not verified"); } }