Package java.security.cert

Examples of java.security.cert.X509Certificate.checkValidity()


        certGen.setPublicKey(pubKey);
        certGen.setSignatureAlgorithm("GOST3411withGOST3410");

        X509Certificate cert = certGen.generate(privKey, "BC");

        cert.checkValidity(new Date());

        //
        // check verifies in general
        //
        cert.verify(pubKey);
View Full Code Here


        // make sure the certificate is valid for a while more
        CertificateFactory cf = CertificateFactory.getInstance("X509");
        JSONObject signature = json.getJSONObject("signature");
        for (Object cert : signature.getJSONArray("certificates")) {
            X509Certificate c = (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(Base64.decode(cert.toString().toCharArray())));
            c.checkValidity(new Date(System.currentTimeMillis() + TimeUnit2.DAYS.toMillis(30)));
        }
    }
}
View Full Code Here

            {// load and verify certificates
                CertificateFactory cf = CertificateFactory.getInstance("X509");
                for (Object cert : signature.getJSONArray("certificates")) {
                    X509Certificate c = (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(Base64.decode(cert.toString().toCharArray())));
                    try {
                        c.checkValidity();
                    } catch (CertificateExpiredException e) { // even if the certificate isn't valid yet, we'll proceed it anyway
                        warning = FormValidation.warning(e,String.format("Certificate %s has expired in update center '%s'",cert.toString(),id));
                    } catch (CertificateNotYetValidException e) {
                        warning = FormValidation.warning(e,String.format("Certificate %s is not yet valid in update center '%s'",cert.toString(),id));
                    }
View Full Code Here

            intermediateCertificates.add((X509Certificate) factory.generateCertificate(
                new ByteArrayInputStream(intermediateCertificate.getEncoded())));
        }

        // Validate the certificate on date of signature.
        certificate.checkValidity(pkcs7.getSignDate().getTime());

        // Validate the certificate on the specified date.
        CertificateValidator.validate(
            certificate,
            intermediateCertificates,
View Full Code Here

               (X509Certificate) cf.generateCertificate(fis);

            fis.close();

            //add to ArrayList
            cert.checkValidity();
            this._certs.add(cert);

            dn = cert.getSubjectDN().getName();
            added = true;
         } catch (FileNotFoundException ex) {
View Full Code Here

  public void verifyChain(Certificate[] chain) throws GeneralSecurityException {
    // Loop over the certificates in the chain
    for (int i = 0; i < chain.length; i++) {
      X509Certificate cert = (X509Certificate) chain[i];
      // check if the certificate was/is valid
      cert.checkValidity(signDate);
      // check if the previous certificate was issued by this certificate
      if (i > 0)
        chain[i-1].verify(chain[i].getPublicKey());
    }
    LOGGER.info("All certificates are valid on " + signDate.toString());
View Full Code Here

            {
                final int numCerts = (chain == null ? 0 : chain.length) ;
                for(int count = 0 ; count < numCerts ; count++)
                {
                    final X509Certificate cert = chain[count] ;
                    cert.checkValidity() ;
                    verify(cert) ;
                }
            }
           
            private void verify(final X509Certificate cert)
View Full Code Here

   */
  public static void checkValidity(Certificate cert, Date date) throws CertificateExpiredException, CertificateNotYetValidException {
    if (cert != null) {
      if (cert instanceof X509Certificate) {
        X509Certificate xcert = (X509Certificate) cert;
        xcert.checkValidity(date);
      } else if (StringUtils.equals(cert.getType(), "CVC")) {
        CardVerifiableCertificate cvccert = (CardVerifiableCertificate)cert;
        try {
          Date start = cvccert.getCVCertificate().getCertificateBody().getValidFrom();
          Date end = cvccert.getCVCertificate().getCertificateBody().getValidTo();
View Full Code Here

              Iterator<Certificate> userCertIter = userCerts.iterator();
              while(userCertIter.hasNext() &&  retval.size() <= resSize){
                X509Certificate nextCert = (X509Certificate) userCertIter.next();                       
                try {
                  // Check that the certificate is valid
                  nextCert.checkValidity(new Date());               
                  // and not revoked 
                  CertificateInfo certInfo = certificateStoreSession.getCertificateInfo(pubAdmin, CertTools.getFingerprintAsString(nextCert));
                  if(certInfo.getRevocationReason() == RevokedCertInfo.NOT_REVOKED){
                    if(fulfillsKeyUsageAndUseKeyWith(queryKeyBindingType,nextCert)){
                      retval.add(nextCert);                     
View Full Code Here

      return "NO_CERTIFICATES";
    }
    while (iter.hasNext()) {
      X509Certificate cert = (X509Certificate)iter.next();
      try {
        cert.checkValidity(new Date(System.currentTimeMillis() + 14 * 24 * 3600 * 1000));
        return "OK";
      } catch (CertificateExpiredException e) {
        try {
          cert.checkValidity(new Date(System.currentTimeMillis()));
          return "EXPIRING";
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.