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

x33g5p2x  于2022-01-19 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(112)

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

Extension.getParsedValue介绍

暂无

代码示例

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

/**
 * Constructor which will take an extension
 *
 * @param extension a X509Extension object containing an AuthorityKeyIdentifier.
 */
public AuthorityKeyIdentifierStructure(
  Extension extension)
{
  super((ASN1Sequence)extension.getParsedValue());
}

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

/**
 * return the parsed value of the extension represented by the object identifier
 * passed in.
 *
 * @return the parsed value of the extension if it's present, null otherwise.
 */
public ASN1Encodable getExtensionParsedValue(ASN1ObjectIdentifier oid)
{
  Extension ext = this.getExtension(oid);
  if (ext != null)
  {
    return ext.getParsedValue();
  }
  return null;
}

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

/**
 * return the parsed value of the extension represented by the object identifier
 * passed in.
 *
 * @return the parsed value of the extension if it's present, null otherwise.
 */
public ASN1Encodable getExtensionParsedValue(ASN1ObjectIdentifier oid)
{
  Extension ext = this.getExtension(oid);
  if (ext != null)
  {
    return ext.getParsedValue();
  }
  return null;
}

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

private void extractArchiveCutOff(SingleResp bestSingleResp) {
  Extension extension = bestSingleResp.getExtension(OCSPObjectIdentifiers.id_pkix_ocsp_archive_cutoff);
  if (extension != null) {
    ASN1GeneralizedTime archiveCutOffAsn1 = (ASN1GeneralizedTime) extension.getParsedValue();
    try {
      archiveCutOff = archiveCutOffAsn1.getDate();
    } catch (ParseException e) {
      LOG.warn("Unable to extract id_pkix_ocsp_archive_cutoff : " + e.getMessage());
    }
  }
}

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

private Set loadCRLEntries()
{
  Set entrySet = new HashSet();
  Enumeration certs = c.getRevokedCertificateEnumeration();
  X500Name previousCertificateIssuer = null; // the issuer
  while (certs.hasMoreElements())
  {
    TBSCertList.CRLEntry entry = (TBSCertList.CRLEntry)certs.nextElement();
    X509CRLEntryObject crlEntry = new X509CRLEntryObject(entry, isIndirect, previousCertificateIssuer);
    entrySet.add(crlEntry);
    if (isIndirect && entry.hasExtensions())
    {
      Extension currentCaName = entry.getExtensions().getExtension(Extension.certificateIssuer);
      if (currentCaName != null)
      {
        previousCertificateIssuer = X500Name.getInstance(GeneralNames.getInstance(currentCaName.getParsedValue()).getNames()[0].getName());
      }
    }
  }
  return entrySet;
}

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

private Set loadCRLEntries()
{
  Set entrySet = new HashSet();
  Enumeration certs = c.getRevokedCertificateEnumeration();
  X500Name previousCertificateIssuer = null; // the issuer
  while (certs.hasMoreElements())
  {
    TBSCertList.CRLEntry entry = (TBSCertList.CRLEntry)certs.nextElement();
    X509CRLEntryObject crlEntry = new X509CRLEntryObject(entry, isIndirect, previousCertificateIssuer);
    entrySet.add(crlEntry);
    if (isIndirect && entry.hasExtensions())
    {
      Extension currentCaName = entry.getExtensions().getExtension(Extension.certificateIssuer);
      if (currentCaName != null)
      {
        previousCertificateIssuer = X500Name.getInstance(GeneralNames.getInstance(currentCaName.getParsedValue()).getNames()[0].getName());
      }
    }
  }
  return entrySet;
}

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

public static byte[] extractSki(org.bouncycastle.asn1.x509.Certificate cert)
  throws CertificateEncodingException {
 Args.notNull(cert, "cert");
 Extension encodedSkiValue = cert.getTBSCertificate().getExtensions().getExtension(
   Extension.subjectKeyIdentifier);
 if (encodedSkiValue == null) {
  return null;
 }
 try {
  return ASN1OctetString.getInstance(encodedSkiValue.getParsedValue()).getOctets();
 } catch (IllegalArgumentException ex) {
  throw new CertificateEncodingException("invalid extension SubjectKeyIdentifier: "
    + ex.getMessage());
 }
}

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

public static byte[] extractSki(final org.bouncycastle.asn1.x509.Certificate cert)
    throws CertificateEncodingException {
  ParamUtil.requireNonNull("cert", cert);
  Extension encodedSkiValue = cert.getTBSCertificate().getExtensions().getExtension(
      Extension.subjectKeyIdentifier);
  if (encodedSkiValue == null) {
    return null;
  }
  try {
    return ASN1OctetString.getInstance(encodedSkiValue.getParsedValue()).getOctets();
  } catch (IllegalArgumentException ex) {
    throw new CertificateEncodingException("invalid extension SubjectKeyIdentifier: "
        + ex.getMessage());
  }
}

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

private static void addRequestedExtKeyusage(List<ASN1ObjectIdentifier> usages,
  Extensions requestedExtensions, Set<ExtKeyUsageControl> usageOccs) {
 Extension extension = requestedExtensions.getExtension(Extension.extendedKeyUsage);
 if (extension == null) {
  return;
 }
 ExtendedKeyUsage reqKeyUsage = ExtendedKeyUsage.getInstance(extension.getParsedValue());
 for (ExtKeyUsageControl k : usageOccs) {
  if (k.isRequired()) {
   continue;
  }
  if (reqKeyUsage.hasKeyPurposeId(KeyPurposeId.getInstance(k.getExtKeyUsage()))) {
   usages.add(k.getExtKeyUsage());
  }
 }
} // method addRequestedExtKeyusage

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

private static void addRequestedKeyusage(Set<KeyUsage> usages, Extensions requestedExtensions,
  Set<KeyUsageControl> usageOccs) {
 Extension extension = requestedExtensions.getExtension(Extension.keyUsage);
 if (extension == null) {
  return;
 }
 org.bouncycastle.asn1.x509.KeyUsage reqKeyUsage =
   org.bouncycastle.asn1.x509.KeyUsage.getInstance(extension.getParsedValue());
 for (KeyUsageControl k : usageOccs) {
  if (k.isRequired()) {
   continue;
  }
  if (reqKeyUsage.hasUsages(k.getKeyUsage().getBcUsage())) {
   usages.add(k.getKeyUsage());
  }
 }
} // method addRequestedKeyusage

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

public X509CRLEntry getRevokedCertificate(BigInteger serialNumber)
{
  Enumeration certs = c.getRevokedCertificateEnumeration();
  X500Name previousCertificateIssuer = null; // the issuer
  while (certs.hasMoreElements())
  {
    TBSCertList.CRLEntry entry = (TBSCertList.CRLEntry)certs.nextElement();
    if (serialNumber.equals(entry.getUserCertificate().getValue()))
    {
      return new X509CRLEntryObject(entry, isIndirect, previousCertificateIssuer);
    }
    if (isIndirect && entry.hasExtensions())
    {
      Extension currentCaName = entry.getExtensions().getExtension(Extension.certificateIssuer);
      if (currentCaName != null)
      {
        previousCertificateIssuer = X500Name.getInstance(GeneralNames.getInstance(currentCaName.getParsedValue()).getNames()[0].getName());
      }
    }
  }
  return null;
}

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_components

if (subjectAlternativeNames != null) {
  for (GeneralName name : GeneralNames.getInstance(
      subjectAlternativeNames.getParsedValue()).getNames()) {
    if (name.getTagNo() == GeneralName.rfc822Name) {
      String email = IETFUtils.valueToString(name.getName());

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

/**
 * This method extracts the CertHash extension if present
 * 
 * Common PKI Part 4: Operational Protocols
 * 3.1.2 Common PKI Private OCSP Extensions
 * 
 * CertHash ::= SEQUENCE {
 * hashAlgorithm AlgorithmIdentifier,
 * certificateHash OCTET STRING }
 * 
 * @param bestSingleResp
 *            the related SingleResponse
 */
private void extractCertHashExtension(SingleResp bestSingleResp) {
  Extension extension = bestSingleResp.getExtension(ISISMTTObjectIdentifiers.id_isismtt_at_certHash);
  if (extension != null) {
    try {
      CertHash asn1CertHash = CertHash.getInstance(extension.getParsedValue());
      DigestAlgorithm digestAlgo = DigestAlgorithm.forOID(asn1CertHash.getHashAlgorithm().getAlgorithm().getId());
      certHash = new Digest(digestAlgo, asn1CertHash.getCertificateHash());
    } catch (Exception e) {
      LOG.warn("Unable to extract id_isismtt_at_certHash : " + e.getMessage());
    }
  }
}

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

public X509CRLEntry getRevokedCertificate(BigInteger serialNumber)
{
  Enumeration certs = c.getRevokedCertificateEnumeration();
  X500Name previousCertificateIssuer = null; // the issuer
  while (certs.hasMoreElements())
  {
    TBSCertList.CRLEntry entry = (TBSCertList.CRLEntry)certs.nextElement();
    if (serialNumber.equals(entry.getUserCertificate().getValue()))
    {
      return new X509CRLEntryObject(entry, isIndirect, previousCertificateIssuer);
    }
    if (isIndirect && entry.hasExtensions())
    {
      Extension currentCaName = entry.getExtensions().getExtension(Extension.certificateIssuer);
      if (currentCaName != null)
      {
        previousCertificateIssuer = X500Name.getInstance(GeneralNames.getInstance(currentCaName.getParsedValue()).getNames()[0].getName());
      }
    }
  }
  return null;
}

代码示例来源:origin: vmware/admiral

private static List<ExtensionHolder> getServerExtensions(X509Certificate issuerCertificate)
    throws CertificateEncodingException, NoSuchAlgorithmException, IOException {
  List<ExtensionHolder> extensions = new ArrayList<>();
  // SSO forces us to allow data encipherment
  extensions.add(new ExtensionHolder(Extension.keyUsage, true, new KeyUsage(
      KeyUsage.digitalSignature
          | KeyUsage.keyEncipherment
          | KeyUsage.dataEncipherment)));
  extensions.add(new ExtensionHolder(Extension.extendedKeyUsage, true,
      new ExtendedKeyUsage(KeyPurposeId.id_kp_serverAuth)));
  Extension authorityKeyExtension = new Extension(Extension.authorityKeyIdentifier, false,
      new DEROctetString(new JcaX509ExtensionUtils()
          .createAuthorityKeyIdentifier(issuerCertificate)));
  extensions.add(new ExtensionHolder(authorityKeyExtension.getExtnId(),
      authorityKeyExtension.isCritical(), authorityKeyExtension.getParsedValue()));
  return extensions;
}

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

extension.getParsedValue()).getContentsOfAdmissions();

代码示例来源:origin: org.italiangrid/voms-api-java

.getInstance((ASN1Sequence) targetExtension.getParsedValue());

代码示例来源:origin: org.xwiki.commons/xwiki-commons-crypto-pkix

@Override
public X509ExtensionBuilder addExtensions(X509Extensions extensionSet) throws IOException
{
  if (extensionSet == null) {
    return this;
  }
  // Optimisation
  if (extensionSet instanceof BcX509Extensions) {
    Extensions exts = ((BcX509Extensions) extensionSet).getExtensions();
    @SuppressWarnings("unchecked")
    Enumeration<ASN1ObjectIdentifier> oids = exts.oids();
    while (oids.hasMoreElements()) {
      ASN1ObjectIdentifier oid = oids.nextElement();
      Extension ext = exts.getExtension(oid);
      this.extensions.addExtension(ext.getExtnId(), ext.isCritical(), ext.getParsedValue());
    }
  } else {
    // Fallback
    for (String oid : extensionSet.getExtensionOID()) {
      this.extensions.addExtension(new ASN1ObjectIdentifier(oid), extensionSet.isCritical(oid),
        extensionSet.getExtensionValue(oid));
    }
  }
  return this;
}

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

private X500Name loadCertificateIssuer(boolean isIndirect, X500Name previousCertificateIssuer)
{
  if (!isIndirect)
  {
    return null;
  }
  Extension ext = getExtension(Extension.certificateIssuer);
  if (ext == null)
  {
    return previousCertificateIssuer;
  }
  try
  {
    GeneralName[] names = GeneralNames.getInstance(ext.getParsedValue()).getNames();
    for (int i = 0; i < names.length; i++)
    {
      if (names[i].getTagNo() == GeneralName.directoryName)
      {
        return X500Name.getInstance(names[i].getName());
      }
    }
    return null;
  }
  catch (Exception e)
  {
    return null;
  }
}

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

private X500Name loadCertificateIssuer(boolean isIndirect, X500Name previousCertificateIssuer)
{
  if (!isIndirect)
  {
    return null;
  }
  Extension ext = getExtension(Extension.certificateIssuer);
  if (ext == null)
  {
    return previousCertificateIssuer;
  }
  try
  {
    GeneralName[] names = GeneralNames.getInstance(ext.getParsedValue()).getNames();
    for (int i = 0; i < names.length; i++)
    {
      if (names[i].getTagNo() == GeneralName.directoryName)
      {
        return X500Name.getInstance(names[i].getName());
      }
    }
    return null;
  }
  catch (Exception e)
  {
    return null;
  }
}

相关文章