org.spongycastle.asn1.x509.V3TBSCertificateGenerator类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(89)

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

V3TBSCertificateGenerator介绍

[英]Generator for Version 3 TBSCertificateStructures.

TBSCertificate ::= SEQUENCE { 
version          [ 0 ]  Version DEFAULT v1(0), 
serialNumber            CertificateSerialNumber, 
signature               AlgorithmIdentifier, 
issuer                  Name, 
validity                Validity, 
subject                 Name, 
subjectPublicKeyInfo    SubjectPublicKeyInfo, 
issuerUniqueID    [ 1 ] IMPLICIT UniqueIdentifier OPTIONAL, 
subjectUniqueID   [ 2 ] IMPLICIT UniqueIdentifier OPTIONAL, 
extensions        [ 3 ] Extensions OPTIONAL 
}

[中]用于版本3 TBSCertificateStructures的生成器

TBSCertificate ::= SEQUENCE { 
version          [ 0 ]  Version DEFAULT v1(0), 
serialNumber            CertificateSerialNumber, 
signature               AlgorithmIdentifier, 
issuer                  Name, 
validity                Validity, 
subject                 Name, 
subjectPublicKeyInfo    SubjectPublicKeyInfo, 
issuerUniqueID    [ 1 ] IMPLICIT UniqueIdentifier OPTIONAL, 
subjectUniqueID   [ 2 ] IMPLICIT UniqueIdentifier OPTIONAL, 
extensions        [ 3 ] Extensions OPTIONAL 
}

代码示例

代码示例来源:origin: com.madgag.spongycastle/bcpkix-jdk15on

/**
 * Create a builder for a version 3 certificate.
 *
 * @param issuer the certificate issuer
 * @param serial the certificate serial number
 * @param notBefore the Time before which the certificate is not valid
 * @param notAfter the Time after which the certificate is not valid
 * @param subject the certificate subject
 * @param publicKeyInfo the info structure for the public key to be associated with this certificate.
 */
public X509v3CertificateBuilder(X500Name issuer, BigInteger serial, Time notBefore, Time notAfter, X500Name subject, SubjectPublicKeyInfo publicKeyInfo)
{
  tbsGen = new V3TBSCertificateGenerator();
  tbsGen.setSerialNumber(new ASN1Integer(serial));
  tbsGen.setIssuer(issuer);
  tbsGen.setStartDate(notBefore);
  tbsGen.setEndDate(notAfter);
  tbsGen.setSubject(subject);
  tbsGen.setSubjectPublicKeyInfo(publicKeyInfo);
  extGenerator = new ExtensionsGenerator();
}

代码示例来源:origin: stackoverflow.com

V3TBSCertificateGenerator tbsGen = new V3TBSCertificateGenerator();
tbsGen.setSerialNumber(new ASN1Integer(serialNum));
tbsGen.setIssuer(issuer);
tbsGen.setStartDate(new Time(new Date(startDate)));
tbsGen.setEndDate(new Time(new Date(endDate)));
tbsGen.setSubject(new X500Name(dn));
tbsGen.setSubjectPublicKeyInfo(SubjectPublicKeyInfo.getInstance(certPubKey.getEncoded()));
tbsGen.setSignature(sigGen.getAlgorithmIdentifier());
tbsGen.setExtensions(new Extensions(extArray));
TBSCertificate tbsCert = tbsGen.generateTBSCertificate();

代码示例来源:origin: com.madgag.spongycastle/pkix

/**
   * Generate an X.509 certificate, based on the current issuer and subject
   * using the passed in signer.
   *
   * @param signer the content signer to be used to generate the signature validating the certificate.
   * @return a holder containing the resulting signed certificate.
   */
  public X509CertificateHolder build(
    ContentSigner signer)
  {
    tbsGen.setSignature(signer.getAlgorithmIdentifier());

    if (!extGenerator.isEmpty())
    {
      tbsGen.setExtensions(extGenerator.generate());
    }

    return CertUtils.generateFullCert(signer, tbsGen.generateTBSCertificate());
  }
}

代码示例来源:origin: com.madgag.spongycastle/prov

private TBSCertificate generateTbsCert()
{
  if (!extGenerator.isEmpty())
  {
    tbsGen.setExtensions(extGenerator.generate());
  }
  return tbsGen.generateTBSCertificate();
}

代码示例来源:origin: com.madgag.spongycastle/prov

/**
 * Set the subject distinguished name. The subject describes the entity associated with the public key.
 */
public void setSubjectDN(
  X509Name   subject)
{
  tbsGen.setSubject(subject);
}

代码示例来源:origin: com.madgag/scprov-jdk15on

/**
 * Set the issuer distinguished name - the issuer is the entity whose private key is used to sign the
 * certificate.
 */
public void setIssuerDN(
  X509Name   issuer)
{
  tbsGen.setIssuer(issuer);
}

代码示例来源:origin: com.madgag.spongycastle/prov

public X509V3CertificateGenerator()
{
  tbsGen = new V3TBSCertificateGenerator();
  extGenerator = new X509ExtensionsGenerator();
}

代码示例来源:origin: com.madgag/sc-light-jdk15on

/**
 * @deprecated use method taking Extensions
 * @param extensions
 */
public void setExtensions(
  X509Extensions    extensions)
{
  setExtensions(Extensions.getInstance(extensions));
}

代码示例来源:origin: com.madgag.spongycastle/prov

/**
 * set the serial number for the certificate.
 */
public void setSerialNumber(
  BigInteger      serialNumber)
{
  if (serialNumber.compareTo(BigInteger.ZERO) <= 0)
  {
    throw new IllegalArgumentException("serial number must be a positive integer");
  }
  
  tbsGen.setSerialNumber(new ASN1Integer(serialNumber));
}

代码示例来源:origin: com.madgag.spongycastle/prov

public void setNotBefore(
  Date    date)
{
  tbsGen.setStartDate(new Time(date));
}

代码示例来源:origin: com.madgag.spongycastle/prov

public void setNotAfter(
  Date    date)
{
  tbsGen.setEndDate(new Time(date));
}

代码示例来源:origin: com.madgag.spongycastle/prov

public void setPublicKey(
  PublicKey       key)
  throws IllegalArgumentException
{
  try
  {
    tbsGen.setSubjectPublicKeyInfo(
          SubjectPublicKeyInfo.getInstance(new ASN1InputStream(key.getEncoded()).readObject()));
  }
  catch (Exception e)
  {
    throw new IllegalArgumentException("unable to process key - " + e.toString());
  }
}

代码示例来源:origin: com.madgag.spongycastle/prov

/**
 * Set the signature algorithm. This can be either a name or an OID, names
 * are treated as case insensitive.
 * 
 * @param signatureAlgorithm string representation of the algorithm name.
 */
public void setSignatureAlgorithm(
  String  signatureAlgorithm)
{
  this.signatureAlgorithm = signatureAlgorithm;
  try
  {
    sigOID = X509Util.getAlgorithmOID(signatureAlgorithm);
  }
  catch (Exception e)
  {
    throw new IllegalArgumentException("Unknown signature type requested: " + signatureAlgorithm);
  }
  sigAlgId = X509Util.getSigAlgID(sigOID, signatureAlgorithm);
  tbsGen.setSignature(sigAlgId);
}

代码示例来源:origin: com.madgag.spongycastle/bcpkix-jdk15on

/**
   * Generate an X.509 certificate, based on the current issuer and subject
   * using the passed in signer.
   *
   * @param signer the content signer to be used to generate the signature validating the certificate.
   * @return a holder containing the resulting signed certificate.
   */
  public X509CertificateHolder build(
    ContentSigner signer)
  {
    tbsGen.setSignature(signer.getAlgorithmIdentifier());

    if (!extGenerator.isEmpty())
    {
      tbsGen.setExtensions(extGenerator.generate());
    }

    return CertUtils.generateFullCert(signer, tbsGen.generateTBSCertificate());
  }
}

代码示例来源:origin: com.madgag/scprov-jdk15on

private TBSCertificate generateTbsCert()
{
  if (!extGenerator.isEmpty())
  {
    tbsGen.setExtensions(extGenerator.generate());
  }
  return tbsGen.generateTBSCertificate();
}

代码示例来源:origin: com.madgag/scprov-jdk15on

/**
 * Set the subject distinguished name. The subject describes the entity associated with the public key.
 */
public void setSubjectDN(
  X509Name   subject)
{
  tbsGen.setSubject(subject);
}

代码示例来源:origin: com.madgag.spongycastle/prov

/**
 * Set the issuer distinguished name - the issuer is the entity whose private key is used to sign the
 * certificate.
 */
public void setIssuerDN(
  X509Name   issuer)
{
  tbsGen.setIssuer(issuer);
}

代码示例来源:origin: com.madgag.spongycastle/prov

/**
 * reset the generator
 */
public void reset()
{
  tbsGen = new V3TBSCertificateGenerator();
  extGenerator.reset();
}

代码示例来源:origin: com.madgag.spongycastle/core

/**
 * @deprecated use method taking Extensions
 * @param extensions
 */
public void setExtensions(
  X509Extensions    extensions)
{
  setExtensions(Extensions.getInstance(extensions));
}

代码示例来源:origin: com.madgag/scprov-jdk15on

/**
 * set the serial number for the certificate.
 */
public void setSerialNumber(
  BigInteger      serialNumber)
{
  if (serialNumber.compareTo(BigInteger.ZERO) <= 0)
  {
    throw new IllegalArgumentException("serial number must be a positive integer");
  }
  
  tbsGen.setSerialNumber(new ASN1Integer(serialNumber));
}

相关文章