org.bouncycastle.asn1.ASN1GeneralizedTime.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(196)

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

ASN1GeneralizedTime.<init>介绍

[英]The correct format for this is YYYYMMDDHHMMSS[.f]Z, or without the Z for local time, or Z+-HHMM on the end, for difference between local time and UTC time. The fractional second amount f must consist of at least one number with trailing zeroes removed.
[中]正确的格式为YYYYMMDDHHMMSS[.f]Z,或不带Z表示本地时间,或结尾处的Z+-HHMM表示本地时间和UTC时间之间的差异。小数秒数f必须至少由一个数字组成,并去掉尾随的零。

代码示例

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

public DVCSTime(Date time)
{
  this(new ASN1GeneralizedTime(time));
}

代码示例来源:origin: redfish64/TinyTravelTracker

public DVCSTime(Date time)
{
  this(new ASN1GeneralizedTime(time));
}

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

private static Extension createInvalidityDateExtension(Date invalidityDate) {
 try {
  ASN1GeneralizedTime asnTime = new ASN1GeneralizedTime(invalidityDate);
  return new Extension(Extension.invalidityDate, false, asnTime.getEncoded());
 } catch (IOException ex) {
  throw new IllegalArgumentException("error encoding reason: " + ex.getMessage(), ex);
 }
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

/**
 * Add a CRL entry with an Invalidity Date extension as well as a CRLReason extension.
 * Reason being as indicated by CRLReason, i.e. CRLReason.keyCompromise
 * or 0 if CRLReason is not to be used
 **/
public void addCRLEntry(BigInteger userCertificate, Date revocationDate, int reason, Date invalidityDate)
{
  tbsGen.addCRLEntry(new ASN1Integer(userCertificate), new Time(revocationDate), reason, new ASN1GeneralizedTime(invalidityDate));
}

代码示例来源:origin: redfish64/TinyTravelTracker

/**
 * return a Generalized Time object from a tagged object.
 *
 * @param obj      the tagged object holding the object we want
 * @param explicit true if the object is meant to be explicitly
 *                 tagged false otherwise.
 * @return an ASN1GeneralizedTime instance.
 * @throws IllegalArgumentException if the tagged object cannot
 * be converted.
 */
public static ASN1GeneralizedTime getInstance(
  ASN1TaggedObject obj,
  boolean explicit)
{
  ASN1Primitive o = obj.getObject();
  if (explicit || o instanceof ASN1GeneralizedTime)
  {
    return getInstance(o);
  }
  else
  {
    return new ASN1GeneralizedTime(((ASN1OctetString)o).getOctets());
  }
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

/**
 * return a Generalized Time object from a tagged object.
 *
 * @param obj      the tagged object holding the object we want
 * @param explicit true if the object is meant to be explicitly
 *                 tagged false otherwise.
 * @return an ASN1GeneralizedTime instance.
 * @throws IllegalArgumentException if the tagged object cannot
 * be converted.
 */
public static ASN1GeneralizedTime getInstance(
  ASN1TaggedObject obj,
  boolean explicit)
{
  ASN1Primitive o = obj.getObject();
  if (explicit || o instanceof ASN1GeneralizedTime)
  {
    return getInstance(o);
  }
  else
  {
    return new ASN1GeneralizedTime(((ASN1OctetString)o).getOctets());
  }
}

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

private void checkExtensionPrivateKeyUsagePeriod(final StringBuilder failureMsg,
    final byte[] extensionValue, final Date certNotBefore, final Date certNotAfter) {
  ASN1GeneralizedTime notBefore = new ASN1GeneralizedTime(certNotBefore);
  Date dateNotAfter;
  CertValidity privateKeyUsagePeriod = certProfile.privateKeyUsagePeriod();
  if (privateKeyUsagePeriod == null) {
    dateNotAfter = certNotAfter;
  } else {
    dateNotAfter = privateKeyUsagePeriod.add(certNotBefore);
    if (dateNotAfter.after(certNotAfter)) {
      dateNotAfter = certNotAfter;
    }
  }
  ASN1GeneralizedTime notAfter = new ASN1GeneralizedTime(dateNotAfter);
  org.bouncycastle.asn1.x509.PrivateKeyUsagePeriod extValue =
      org.bouncycastle.asn1.x509.PrivateKeyUsagePeriod.getInstance(extensionValue);
  ASN1GeneralizedTime time = extValue.getNotBefore();
  if (time == null) {
    failureMsg.append("notBefore is absent but expected present; ");
  } else if (!time.equals(notBefore)) {
    addViolation(failureMsg, "notBefore", time.getTimeString(), notBefore.getTimeString());
  }
  time = extValue.getNotAfter();
  if (time == null) {
    failureMsg.append("notAfter is absent but expected present; ");
  } else if (!time.equals(notAfter)) {
    addViolation(failureMsg, "notAfter", time.getTimeString(), notAfter.getTimeString());
  }
} // method checkExtensionPrivateKeyUsagePeriod

代码示例来源:origin: org.xipki/cmpclient

hdrBuilder.setMessageTime(new ASN1GeneralizedTime(new Date()));

代码示例来源:origin: arhs/sd-dss

final String asn1GeneralizedTimeString = new ASN1GeneralizedTime(now).getTimeString();
final long randomNumber = new Random(now.getTime()).nextLong();
contentIdentifierSuffix = asn1GeneralizedTimeString + randomNumber;

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

protected PKIMessage buildErrorPkiMessage(ASN1OctetString tid,
  PKIHeader requestHeader, int failureCode, String statusText) {
 GeneralName respRecipient = requestHeader.getSender();
 PKIHeaderBuilder respHeader = new PKIHeaderBuilder(
   requestHeader.getPvno().getValue().intValue(), getSender(), respRecipient);
 respHeader.setMessageTime(new ASN1GeneralizedTime(new Date()));
 if (tid != null) {
  respHeader.setTransactionID(tid);
 }
 ASN1OctetString senderNonce = requestHeader.getSenderNonce();
 if (senderNonce != null) {
  respHeader.setRecipNonce(senderNonce);
 }
 PKIStatusInfo status = generateRejectionStatus(failureCode, statusText);
 ErrorMsgContent error = new ErrorMsgContent(status);
 PKIBody body = new PKIBody(PKIBody.TYPE_ERROR, error);
 return new PKIMessage(respHeader.build(), body);
} // method buildErrorPkiMessage

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

} else {
 Date now = new Date();
 respHeader.setMessageTime(new ASN1GeneralizedTime(now));
 tv = new InfoTypeAndValue(CMPObjectIdentifiers.it_confirmWaitTime,
   new ASN1GeneralizedTime(new Date(System.currentTimeMillis() + confirmWaitTime)));

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

protected ASN1Encodable encodeStringValue(ASN1ObjectIdentifier oid,
    String value) {
  if (oid.equals(EmailAddress) || oid.equals(DC))
  {
    return new DERIA5String(value);
  }
  else if (oid.equals(DATE_OF_BIRTH))  // accept time string as well as # (for compatibility)
  {
    return new ASN1GeneralizedTime(value);
  }
  else if (oid.equals(C) || oid.equals(SN) || oid.equals(DN_QUALIFIER)
    || oid.equals(TELEPHONE_NUMBER))
  {
    return new DERPrintableString(value);
  }
  
  return super.encodeStringValue(oid, value);
}

代码示例来源:origin: redfish64/TinyTravelTracker

protected ASN1Encodable encodeStringValue(ASN1ObjectIdentifier oid,
    String value) {
  if (oid.equals(EmailAddress) || oid.equals(DC))
  {
    return new DERIA5String(value);
  }
  else if (oid.equals(DATE_OF_BIRTH))  // accept time string as well as # (for compatibility)
  {
    return new ASN1GeneralizedTime(value);
  }
  else if (oid.equals(C) || oid.equals(SN) || oid.equals(DN_QUALIFIER)
    || oid.equals(TELEPHONE_NUMBER))
  {
    return new DERPrintableString(value);
  }
  
  return super.encodeStringValue(oid, value);
}

代码示例来源:origin: org.xipki/cmpclient

ASN1GeneralizedTime time = new ASN1GeneralizedTime(invalidityDate);
extensions[1] = new Extension(Extension.invalidityDate, true,
    new DEROctetString(time.getEncoded()));

代码示例来源:origin: redfish64/TinyTravelTracker

return ASN1Enumerated.fromOctetString(getBuffer(defIn, tmpBuffers));
case GENERALIZED_TIME:
  return new ASN1GeneralizedTime(defIn.toByteArray());
case GENERAL_STRING:
  return new DERGeneralString(defIn.toByteArray());

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

return ASN1Enumerated.fromOctetString(getBuffer(defIn, tmpBuffers));
case GENERALIZED_TIME:
  return new ASN1GeneralizedTime(defIn.toByteArray());
case GENERAL_STRING:
  return new DERGeneralString(defIn.toByteArray());

相关文章