当前位置: 首页>>代码示例>>Java>>正文


Java JcaX509ExtensionUtils.parseExtensionValue方法代码示例

本文整理汇总了Java中org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils.parseExtensionValue方法的典型用法代码示例。如果您正苦于以下问题:Java JcaX509ExtensionUtils.parseExtensionValue方法的具体用法?Java JcaX509ExtensionUtils.parseExtensionValue怎么用?Java JcaX509ExtensionUtils.parseExtensionValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils的用法示例。


在下文中一共展示了JcaX509ExtensionUtils.parseExtensionValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAuthorityKeyIdentifier

import org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils; //导入方法依赖的package包/类
public String getAuthorityKeyIdentifier() {
	byte[] e = certificate.getExtensionValue(Extension.authorityKeyIdentifier.getId());

	if (e == null) {
		return "";
	}

	ASN1Primitive ap;
	byte[] k = {};
	try {
		ap = JcaX509ExtensionUtils.parseExtensionValue(e);
		k = ASN1Sequence.getInstance(ap.getEncoded()).getEncoded();
	} catch (IOException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}
	// Very ugly hack to extract the SHA1 Hash (59 Hex Chars) from the
	// Extension :(
	return CertificateHelper.addHexColons(CertificateHelper.byteArrayToHex(k)).substring(12, k.length * 3 - 1);
}
 
开发者ID:SAMLRaider,项目名称:SAMLRaider,代码行数:21,代码来源:BurpCertificate.java

示例2: getSubjectKeyIdentifier

import org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils; //导入方法依赖的package包/类
public String getSubjectKeyIdentifier() {
	// https://stackoverflow.com/questions/6523081/why-doesnt-my-key-identifier-match
	byte[] e = certificate.getExtensionValue(Extension.subjectKeyIdentifier.getId());

	if (e == null) {
		return "";
	}

	ASN1Primitive ap;
	byte[] k = {};
	try {
		ap = JcaX509ExtensionUtils.parseExtensionValue(e);
		k = ASN1OctetString.getInstance(ap.getEncoded()).getOctets();
	} catch (IOException e1) {
		e1.printStackTrace();
	}
	return CertificateHelper.addHexColons(CertificateHelper.byteArrayToHex(k));
}
 
开发者ID:SAMLRaider,项目名称:SAMLRaider,代码行数:19,代码来源:BurpCertificate.java

示例3: findOcspCertificate

import org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils; //导入方法依赖的package包/类
private X509Cert findOcspCertificate() {
  String rId = "";
  try {
    RespID responderId = ocspResponse.getResponderId();
    rId = responderId.toString();
    String primitiveName = getCN(responderId.toASN1Primitive().getName());
    byte[] keyHash = responderId.toASN1Primitive().getKeyHash();

    boolean isKeyHash = useKeyHashForOCSP(primitiveName, keyHash);

    if (isKeyHash) {
      logger.debug("Using keyHash {} for OCSP certificate match", keyHash);
    } else {
      logger.debug("Using ASN1Primitive {} for OCSP certificate match", primitiveName);
    }

    for (CertificateToken cert : getDssSignature().getCertificates()) {
      if (isKeyHash) {
        ASN1Primitive skiPrimitive = JcaX509ExtensionUtils.parseExtensionValue(
            cert.getCertificate().getExtensionValue(Extension.subjectKeyIdentifier.getId()));
        byte[] keyIdentifier = ASN1OctetString.getInstance(skiPrimitive.getEncoded()).getOctets();
        if (Arrays.equals(keyHash, keyIdentifier)) {
          return new X509Cert(cert.getCertificate());
        }
      } else {
        String certCn = getCN(new X500Name(cert.getSubjectX500Principal().getName()));
        if (StringUtils.equals(certCn, primitiveName)) {
          return new X509Cert(cert.getCertificate());
        }
      }
    }

  } catch (IOException e) {
    logger.error("Unable to wrap and extract SubjectKeyIdentifier from certificate - technical error. {}", e);
  }

  logger.error("OCSP certificate for " + rId + " was not found in TSL");
  throw new CertificateNotFoundException("OCSP certificate for " + rId + " was not found in TSL");
}
 
开发者ID:open-eid,项目名称:digidoc4j,代码行数:40,代码来源:TimemarkSignature.java

示例4: decode

import org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils; //导入方法依赖的package包/类
/**
 * Construct a {@code X509ExtensionData} from an encoded data stream.
 *
 * @param oid The extension OID.
 * @param critical The extension's critical flag.
 * @param data The encoded extension data.
 * @return The decoded extension data object.
 * @throws IOException if an I/O error occurs during decoding.
 */
public static X509ExtensionData decode(String oid, boolean critical, byte[] data) throws IOException {
	ASN1Primitive primitive;

	try {
		primitive = JcaX509ExtensionUtils.parseExtensionValue(data);
	} catch (IllegalArgumentException e) {
		throw new IOException(e.getLocalizedMessage(), e);
	}

	X509ExtensionData decoded;

	switch (oid) {
	case BasicConstraintsExtensionData.OID:
		decoded = BasicConstraintsExtensionData.decode(primitive, critical);
		break;
	case KeyUsageExtensionData.OID:
		decoded = KeyUsageExtensionData.decode(primitive, critical);
		break;
	case ExtendedKeyUsageExtensionData.OID:
		decoded = ExtendedKeyUsageExtensionData.decode(primitive, critical);
		break;
	case SubjectAlternativeNameExtensionData.OID:
		decoded = SubjectAlternativeNameExtensionData.decode(primitive, critical);
		break;
	case SubjectKeyIdentifierExtensionData.OID:
		decoded = SubjectKeyIdentifierExtensionData.decode(primitive, critical);
		break;
	case AuthorityKeyIdentifierExtensionData.OID:
		decoded = AuthorityKeyIdentifierExtensionData.decode(primitive, critical);
		break;
	case CRLNumberExtensionData.OID:
		decoded = CRLNumberExtensionData.decode(primitive, critical);
		break;
	case CRLDistributionPointsExtensionData.OID:
		decoded = CRLDistributionPointsExtensionData.decode(primitive, critical);
		break;
	default:
		decoded = new CustomExtensionData(oid, critical, data);
	}
	return decoded;
}
 
开发者ID:hdecarne,项目名称:certmgr,代码行数:51,代码来源:X509ExtensionData.java


注:本文中的org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils.parseExtensionValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。