org.bouncycastle.asn1.x509.Time.toASN1Primitive()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(1.6k)|赞(0)|评价(0)|浏览(242)

本文整理了Java中org.bouncycastle.asn1.x509.Time.toASN1Primitive()方法的一些代码示例,展示了Time.toASN1Primitive()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Time.toASN1Primitive()方法的具体详情如下:
包路径:org.bouncycastle.asn1.x509.Time
类名称:Time
方法名:toASN1Primitive

Time.toASN1Primitive介绍

[英]Produce an object suitable for an ASN1OutputStream.

Time ::= CHOICE { 
utcTime        UTCTime, 
generalTime    GeneralizedTime }

[中]生成适合ASN1OutputStream的对象

Time ::= CHOICE { 
utcTime        UTCTime, 
generalTime    GeneralizedTime }

代码示例

代码示例来源:origin: org.xipki.pki/ca-qa

private static void checkTime(Time time, ValidationIssue issue) {
  ASN1Primitive asn1Time = time.toASN1Primitive();
  if (time.getDate().getTime() / 1000 < EPOCHTIME_2050010100) {
    if (!(asn1Time instanceof ASN1UTCTime)) {
      issue.setFailureMessage("not encoded as UTCTime");
    }
  } else {
    if (!(asn1Time instanceof ASN1GeneralizedTime)) {
      issue.setFailureMessage("not encoded as GeneralizedTime");
    }
  }
}

代码示例来源:origin: esig/dss

protected void extractExpiredCertsOnCRL(CRLValidity validity, byte[] expiredCertsOnCRLBinaries) {
  if (expiredCertsOnCRLBinaries != null) {
    try {
      ASN1OctetString octetString = (ASN1OctetString) ASN1Primitive.fromByteArray(expiredCertsOnCRLBinaries);
      Time time = Time.getInstance(ASN1Primitive.fromByteArray(octetString.getOctets()));
      if (time != null && time.toASN1Primitive() instanceof ASN1GeneralizedTime) {
        validity.setExpiredCertsOnCRL(time.getDate());
      } else {
        LOG.warn("Attribute 'expiredCertsOnCRL' found but ignored (should be encoded as ASN.1 GeneralizedTime)");
      }
    } catch (Exception e) {
      LOG.error("Unable to parse expiredCertsOnCRL on CRL : " + e.getMessage(), e);
    }
  }
}

相关文章