Method that checks the time validity. Uses the standard Certificate.checkValidity method.

@throws CertPathValidatorException If certificate has expired or is not yet valid.
495539
public void invoke(X509Certificate cert, GSIConstants.CertificateType certType) throws CertPathValidatorException {
        try {
            cert.checkValidity();
        } catch (CertificateExpiredException e) {
            throw new CertPathValidatorException(
                    "Certificate " + cert.getSubjectDN() + " expired", e);
        } catch (CertificateNotYetValidException e) {
            throw new CertPathValidatorException(
                    "Certificate " + cert.getSubjectDN() + " not yet valid.", e);
        }
    }
280814
@Override
    public void validate() {
        String target = getTargetName();
        //validate the parameters
        if (value() < 0) {
            throw new FaultToleranceDefinitionException(Tr.formatMessage(tc, "timeout.parameter.invalid.value.CWMFT5011E", value(), target));
        }

    }
351351
public static void verifyAndThrow(final String name, final X509Certificate cert) throws CertificateException{
		if (!verify(name, cert)) {
			throw new CertificateException("No name matching " + name + " found");
		}		
	}
764315
def validate_timestamps(self):
        
        conditions_nodes = self.__query_assertion('/saml:Conditions')

        for conditions_node in conditions_nodes:
            nb_attr = conditions_node.get('NotBefore')
            nooa_attr = conditions_node.get('NotOnOrAfter')
            if nb_attr and OneLogin_Saml2_Utils.parse_SAML_to_time(nb_attr) > OneLogin_Saml2_Utils.now() + OneLogin_Saml2_Constants.ALLOWED_CLOCK_DRIFT:
                raise OneLogin_Saml2_ValidationError(
                    'Could not validate timestamp: not yet valid. Check system clock.',
                    OneLogin_Saml2_ValidationError.ASSERTION_TOO_EARLY
                )
            if nooa_attr and OneLogin_Saml2_Utils.parse_SAML_to_time(nooa_attr) + OneLogin_Saml2_Constants.ALLOWED_CLOCK_DRIFT <= OneLogin_Saml2_Utils.now():
                raise OneLogin_Saml2_ValidationError(
                    'Could not validate timestamp: expired. Check system clock.',
                    OneLogin_Saml2_ValidationError.ASSERTION_EXPIRED
                )
        return True
1371569
def check_ssl_valid_date(self, url_data, cert):
        
        import ssl
        try:
            notAfter = ssl.cert_time_to_seconds(cert['notAfter'])
        except ValueError as msg:
            msg = _('Invalid SSL certficate "notAfter" value %r') % cert['notAfter']
            url_data.add_warning(msg)
            return
        curTime = time.time()
        # Calculate seconds until certifcate expires. Can be negative if
        # the certificate is already expired.
        secondsValid = notAfter - curTime
        args = dict(expire=cert['notAfter'])
        if secondsValid < 0:
            msg = _('SSL certficate is expired on %(expire)s.')
            url_data.add_warning(msg % args)
        else:
            args['valid'] = strformat.strduration_long(secondsValid)
            if secondsValid < self.warn_ssl_cert_secs_valid:
                msg = _('SSL certificate expires on %(expire)s and is only %(valid)s valid.')
                url_data.add_warning(msg % args)
            else:
                msg = _('SSL certificate expires on %(expire)s and is %(valid)s valid.')
                url_data.add_info(msg % args)
1159404
@AssertTrue(message = "the provided certificate passphrase does not match with the uploaded certificate")
    public boolean isCertificatePassphraseValid() {
        try {
            PKCS12.validate(certificate, passphrase);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
104978
public static void verify(X509Certificate cert, PublicKey key,
            Provider sigProvider) throws CertificateException,
            NoSuchAlgorithmException, InvalidKeyException, SignatureException {
        cert.verify(key, sigProvider);
    }
466857
def certify_time(value, required=True):
    
    if certify_required(
        value=value,
        required=required,
    ):
        return

    if not isinstance(value, time):
        raise CertifierTypeError(
            message="expected timestamp (time), but value is of type {cls!r}".format(
                cls=value.__class__.__name__),
            value=value,
            required=required,
        )
679463
private function _processCertificate(ValidatorState $state, Certificate $cert): ValidatorState
    {
        // (a.1) verify signature
        $this->_verifySignature($state, $cert);
        // (a.2) check validity period
        $this->_checkValidity($cert);
        // (a.3) check that certificate is not revoked
        $this->_checkRevocation($cert);
        // (a.4) check issuer
        $this->_checkIssuer($state, $cert);
        // (b)(c) if certificate is self-issued and it is not
        // the final certificate in the path, skip this step
        if (!($cert->isSelfIssued() && !$state->isFinal())) {
            // (b) check permitted subtrees
            $this->_checkPermittedSubtrees($state, $cert);
            // (c) check excluded subtrees
            $this->_checkExcludedSubtrees($state, $cert);
        }
        $extensions = $cert->tbsCertificate()->extensions();
        if ($extensions->hasCertificatePolicies()) {
            // (d) process policy information
            if ($state->hasValidPolicyTree()) {
                $state = $state->validPolicyTree()->processPolicies($state,
                    $cert);
            }
        } else {
            // (e) certificate policies extension not present,
            // set the valid_policy_tree to NULL
            $state = $state->withoutValidPolicyTree();
        }
        // (f) check that explicit_policy > 0 or valid_policy_tree is set
        if (!($state->explicitPolicy() > 0 || $state->hasValidPolicyTree())) {
            throw new PathValidationException("No valid policies.");
        }
        return $state;
    }
1137953
public function validate($certPath, $keyPath, array $chainPaths)
    {
        // Get the contents.
        if (!is_readable($certPath)) {
            throw new \InvalidArgumentException('The certificate file could not be read: ' . $certPath);
        }
        $sslCert = trim(file_get_contents($certPath));
        // Do a bit of validation.
        $certResource = openssl_x509_read($sslCert);
        if (!$certResource) {
            throw new \InvalidArgumentException('The certificate file is not a valid X509 certificate: ' . $certPath);
        }
        // Then the key. Does it match?
        if (!is_readable($keyPath)) {
            throw new \InvalidArgumentException('The private key file could not be read: ' . $keyPath);
        }
        $sslPrivateKey = trim(file_get_contents($keyPath));
        $keyResource = openssl_pkey_get_private($sslPrivateKey);
        if (!$keyResource) {
            throw new \InvalidArgumentException('Private key not valid, or passphrase-protected: ' . $keyPath);
        }
        $keyMatch = openssl_x509_check_private_key($certResource, $keyResource);
        if (!$keyMatch) {
            throw new \InvalidArgumentException('The provided certificate does not match the provided private key.');
        }

        // Each chain needs to contain one or more valid certificates.
        $chainFileContents = $this->readChainFiles($chainPaths);
        foreach ($chainFileContents as $filePath => $data) {
            $chainResource = openssl_x509_read($data);
            if (!$chainResource) {
                throw new \InvalidArgumentException('File contains an invalid X509 certificate: ' . $filePath);
            }
            openssl_x509_free($chainResource);
        }

        // Split up the chain file contents.
        $chain = [];
        $begin = '-----BEGIN CERTIFICATE-----';
        foreach ($chainFileContents as $data) {
            if (substr_count($data, $begin) > 1) {
                foreach (explode($begin, $data) as $cert) {
                    $chain[] = $begin . $cert;
                }
            } else {
                $chain[] = $data;
            }
        }

        return [
            'certificate' => $sslCert,
            'key' => $sslPrivateKey,
            'chain' => $chain,
        ];
    }
798300
static void check(PublicKey key, AlgorithmId algorithmId)
                        throws CertPathValidatorException {
        String sigAlgName = algorithmId.getName();
        AlgorithmParameters sigAlgParams = algorithmId.getParameters();

        if (!certPathDefaultConstraints.permits(
                SIGNATURE_PRIMITIVE_SET, sigAlgName, key, sigAlgParams)) {
            throw new CertPathValidatorException(
                "algorithm check failed: " + sigAlgName + " is disabled",
                null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
        }
    }
68994
boolean validateCertificate(byte[] certPEM) {

        if (certPEM == null) {
            return false;
        }

        try {

            X509Certificate certificate = getX509Certificate(certPEM);
            if (null == certificate) {
                throw new Exception("Certificate transformation returned null");
            }

            return validateCertificate(certificate);
        } catch (Exception e) {
            logger.error("Cannot validate certificate. Error is: " + e.getMessage() + "\r\nCertificate (PEM, hex): "
                    + DatatypeConverter.printHexBinary(certPEM));
            return false;
        }
    }
805410
private void checkValidityOptions(ProxyInfoParams params,
    X509Certificate[] proxyChain) {

    if (params.containsOption(PrintOption.PROXY_STRENGTH_VALIDITY)
      && !params.containsOption(PrintOption.ALL_OPTIONS)) {
      if (!getKeySize(proxyChain[0]).equals(params.getKeyLength()))
        throw new VOMSError("Proxy key size is not valid");
    }

    if (params.containsOption(PrintOption.PROXY_EXISTS)) {
      try {
        try {
          proxyChain[0].checkValidity();
        } catch (CertificateNotYetValidException e) {
          throw new VOMSError("Proxy not found: " + e.getMessage(), e);
        }
      } catch (CertificateExpiredException e) {
        throw new VOMSError(
          "The current proxy is not valid: " + e.getMessage(), e);
      }
    }

    if (params.containsOption(PrintOption.PROXY_TIME_VALIDITY)) {
      int period = 0;
      try {
        period = TimeUtils
          .parseLifetimeInHoursAndMinutes(params.getValidTime());
      } catch (ParseException e) {
        throw new VOMSError("Wrong validity format, required 'hh:mm': "
          + e.getMessage(), e);
      }

      if (!checkTimeValidity(
        TimeUtils.getTimeLeft(proxyChain[0].getNotAfter()), period))
        throw new VOMSError("Proxy not valid for the specified period");
    }

    if (params.containsOption(PrintOption.PROXY_HOURS_VALIDITY)) {
      int period = 0;
      try {
        period = TimeUtils.parseLifetimeInHours(params.getValidHours());
      } catch (ParseException e) {
        throw new VOMSError("Wrong validity format, required 'hh': "
          + e.getMessage(), e);
      }

      if (!checkTimeValidity(
        TimeUtils.getTimeLeft(proxyChain[0].getNotAfter()), period))
        throw new VOMSError("Proxy not valid for the specified period");
    }

  }
1283371
function validateSwipeTime() {
			var result;
			//If no time set, then return true

			if (options.maxTimeThreshold) {
				if (duration >= options.maxTimeThreshold) {
					result = false;
				} else {
					result = true;
				}
			}
			else {
				result = true;
			}

			return result;
		}
912655
def validateProxy(path):
    

    # load the proxy from path
    try:
        proxy = M2Crypto.X509.load_cert(path)
    except Exception, e:
        msg = "Unable to load proxy from path %s : %s" % (path, e)
        print >>sys.stderr, msg
        sys.exit(1)

    # make sure the proxy is RFC 3820 compliant
    # or is an end-entity X.509 certificate
    try:
        proxy.get_ext("proxyCertInfo")
    except LookupError:
        # it is not an RFC 3820 proxy so check
        # if it is an old globus legacy proxy
        subject = proxy.get_subject().as_text()
        if re.search(r'.+CN=proxy$', subject):
            # it is so print warning and exit
            RFCproxyUsage()
            sys.exit(1)

    # attempt to make sure the proxy is still good for more than 15 minutes
    try:
        expireASN1 = proxy.get_not_after().__str__()
        expireGMT  = time.strptime(expireASN1, "%b %d %H:%M:%S %Y %Z")
        expireUTC  = calendar.timegm(expireGMT)
        now = int(time.time())
        secondsLeft = expireUTC - now
    except Exception, e:
        # problem getting or parsing time so just let the client
        # continue and pass the issue along to the server
        secondsLeft = 3600

    if secondsLeft <= 0:
        msg = """\
Your proxy certificate is expired.

Please generate a new proxy certificate and
try again.
"""
        print >>sys.stderr, msg
        sys.exit(1)

    if secondsLeft < (60 * 15):
        msg = """\
Your proxy certificate expires in less than
15 minutes.

Please generate a new proxy certificate and
try again.
"""
        print >>sys.stderr, msg
        sys.exit(1)

    # return True to indicate validated proxy
    return True
145872
private void validate(QPath path) throws RepositoryException, AccessDeniedException, ReferentialIntegrityException
   {

      List<ItemState> changes = changesLog.getAllStates();
      for (ItemState itemState : changes)
      {

         if (itemState.isInternallyCreated())
         {
            // skip internally created
            if (itemState.isMixinChanged())
            {
               // ...except of check of ACL correct size for internally created
               // items.
               // If no permissions in the list throw exception.
               if (itemState.isDescendantOf(path))
               {
                  if (((NodeData)itemState.getData()).getACL().getPermissionsSize() < 1)
                  {
                     throw new RepositoryException("Node " + itemState.getData().getQPath().getAsString()
                        + " has wrong formed ACL.");
                  }
               }
               validateMandatoryItem(itemState);
            }
         }
         else
         {
            if (itemState.isDescendantOf(path))
            {
               validateAccessPermissions(itemState);
               validateMandatoryItem(itemState);
            }

            if (path.isDescendantOf(itemState.getAncestorToSave()))
            {
               throw new ConstraintViolationException(path.getAsString()
                  + " is the same or descendant of either Session.move()'s destination or source node only "
                  + path.getAsString());
            }
         }
      }
   }
909834
public void initState(List<PKIXCertPathChecker> certPathCheckers)
        throws CertPathValidatorException
    {
        subjectNamesTraversed = new HashSet<GeneralNameInterface>();
        traversedCACerts = 0;

        /*
         * Populate forwardCheckers with every user-defined checker
         * that supports forward checking and initialize the forwardCheckers
         */
        forwardCheckers = new ArrayList<PKIXCertPathChecker>();
        for (PKIXCertPathChecker checker : certPathCheckers) {
            if (checker.isForwardCheckingSupported()) {
                checker.init(true);
                forwardCheckers.add(checker);
            }
        }

        init = true;
    }