java.security.cert.X509Certificate.getCriticalExtensionOIDs()方法的使用及代码示例

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

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

X509Certificate.getCriticalExtensionOIDs介绍

暂无

代码示例

代码示例来源:origin: Meituan-Dianping/walle

@Override
public Set<String> getCriticalExtensionOIDs() {
  return mDelegate.getCriticalExtensionOIDs();
}

代码示例来源:origin: redisson/redisson

@Override
public Set<String> getCriticalExtensionOIDs() {
  return unwrap().getCriticalExtensionOIDs();
}

代码示例来源:origin: wildfly/wildfly

@Override
public Set<String> getCriticalExtensionOIDs() {
  return unwrap().getCriticalExtensionOIDs();
}

代码示例来源:origin: looly/hutool

/**
   * 设置{@link Certificate} 为PublicKey<br>
   * 如果Certificate是X509Certificate,我们需要检查是否有密钥扩展
   * 
   * @param certificate {@link Certificate}
   * @return this
   */
  public Sign setCertificate(Certificate certificate) {
    // If the certificate is of type X509Certificate,
    // we should check whether it has a Key Usage
    // extension marked as critical.
    if (certificate instanceof java.security.cert.X509Certificate) {
      // Check whether the cert has a key usage extension
      // marked as a critical extension.
      // The OID for KeyUsage extension is 2.5.29.15.
      final X509Certificate cert = (X509Certificate) certificate;
      final Set<String> critSet = cert.getCriticalExtensionOIDs();

      if (CollUtil.isNotEmpty(critSet) && critSet.contains("2.5.29.15")) {
        final boolean[] keyUsageInfo = cert.getKeyUsage();
        // keyUsageInfo[0] is for digitalSignature.
        if ((keyUsageInfo != null) && (keyUsageInfo[0] == false)) {
          throw new CryptoException("Wrong key usage");
        }
      }
    }
    this.publicKey = certificate.getPublicKey();
    return this;
  }
}

代码示例来源:origin: looly/hutool

/**
   * 设置{@link Certificate} 为PublicKey<br>
   * 如果Certificate是X509Certificate,我们需要检查是否有密钥扩展
   * 
   * @param certificate {@link Certificate}
   * @return this
   */
  public Sign setCertificate(Certificate certificate) {
    // If the certificate is of type X509Certificate,
    // we should check whether it has a Key Usage
    // extension marked as critical.
    if (certificate instanceof java.security.cert.X509Certificate) {
      // Check whether the cert has a key usage extension
      // marked as a critical extension.
      // The OID for KeyUsage extension is 2.5.29.15.
      final X509Certificate cert = (X509Certificate) certificate;
      final Set<String> critSet = cert.getCriticalExtensionOIDs();

      if (CollUtil.isNotEmpty(critSet) && critSet.contains("2.5.29.15")) {
        final boolean[] keyUsageInfo = cert.getKeyUsage();
        // keyUsageInfo[0] is for digitalSignature.
        if ((keyUsageInfo != null) && (keyUsageInfo[0] == false)) {
          throw new CryptoException("Wrong key usage");
        }
      }
    }
    this.publicKey = certificate.getPublicKey();
    return this;
  }
}

代码示例来源:origin: robovm/robovm

throws InvalidKeyException {
if (certificate instanceof X509Certificate) {
  Set ce = ((X509Certificate) certificate).getCriticalExtensionOIDs();
  boolean critical = false;
  if (ce != null && !ce.isEmpty()) {

代码示例来源:origin: robovm/robovm

checkMode(opmode);
if (certificate instanceof X509Certificate) {
  Set<String> ce = ((X509Certificate) certificate).getCriticalExtensionOIDs();
  boolean critical = false;
  if (ce != null && !ce.isEmpty()) {

代码示例来源:origin: io.netty/netty-handler

@Override
public Set<String> getCriticalExtensionOIDs() {
  return unwrap().getCriticalExtensionOIDs();
}

代码示例来源:origin: org.nhind/agent

/**
 * {@inheritDoc}
 */
public Set<String> getCriticalExtensionOIDs()
{
  return internalCert.getCriticalExtensionOIDs();
}

代码示例来源:origin: apache/activemq-artemis

@Override
public Set<String> getCriticalExtensionOIDs() {
  return unwrap().getCriticalExtensionOIDs();
}

代码示例来源:origin: apache/activemq-artemis

@Override
public Set<String> getCriticalExtensionOIDs() {
  return unwrap().getCriticalExtensionOIDs();
}

代码示例来源:origin: org.apache.hbase.thirdparty/hbase-shaded-netty

@Override
public Set<String> getCriticalExtensionOIDs() {
  return unwrap().getCriticalExtensionOIDs();
}

代码示例来源:origin: org.wildfly.openssl/wildfly-openssl

@Override
public Set<String> getCriticalExtensionOIDs() {
  return unwrap().getCriticalExtensionOIDs();
}

代码示例来源:origin: org.apache.ratis/ratis-proto-shaded

@Override
public Set<String> getCriticalExtensionOIDs() {
  return unwrap().getCriticalExtensionOIDs();
}

代码示例来源:origin: KostyaSha/yet-another-docker-plugin

@Override
public Set<String> getCriticalExtensionOIDs() {
  return unwrap().getCriticalExtensionOIDs();
}

代码示例来源:origin: DirectProject/nhin-d

/**
 * {@inheritDoc}
 */
@Override
public boolean isCritical() 
{
  if (this.certificate == null)
    throw new IllegalStateException("Certificate value is null");
  
  final Set<String> criticalOIDs = certificate.getCriticalExtensionOIDs();
  
  return criticalOIDs.contains(getExtentionIdentifier().getId());
}

代码示例来源:origin: org.metaeffekt.dcc/dcc-commons

protected void copyExtension(final ASN1ObjectIdentifier extensionType, X509Certificate issuerCertificate,
    List<Extension> extensions) {
  final byte[] encodedAttribute = issuerCertificate.getExtensionValue(extensionType.getId());
  ASN1OctetString data = ASN1OctetString.getInstance(encodedAttribute);
  boolean isCritical = issuerCertificate.getCriticalExtensionOIDs().contains(extensionType.getId());
  if (encodedAttribute != null) {
    extensions.add(new Extension(extensionType, isCritical, data)); 
  }
}

代码示例来源:origin: DirectProject/nhin-d

public void testIsCritical_extensionPresent_notCritical_assertFalse() throws Exception
{
  X509Certificate cert = TestUtils.loadCertificate("umesh.der");
  
  assertFalse(cert.getCriticalExtensionOIDs().contains(ExtensionIdentifier.SUBJECT_KEY_IDENTIFIER.getId()));
  
  
  final SubjectKeyIdentifierExtensionField field = new SubjectKeyIdentifierExtensionField(false);
  
  field.injectReferenceValue(cert);
  assertFalse(field.isCritical());
}

代码示例来源:origin: DirectProject/nhin-d

public void testIsCritical_extensionPresent_isCritical_assertTrue() throws Exception
{
  X509Certificate cert = TestUtils.loadCertificate("CernerDirect DevCert Provider CA.der");
  
  assertTrue(cert.getCriticalExtensionOIDs().contains(ExtensionIdentifier.BASIC_CONSTRAINTS.getId()));
  
  
  final BasicContraintsExtensionField field = new BasicContraintsExtensionField(false);
  
  field.injectReferenceValue(cert);
  assertTrue(field.isCritical());
}

代码示例来源:origin: DirectProject/nhin-d

public void testIsCritical_extensionNotPresent_assertFalse() throws Exception
{
  X509Certificate cert = TestUtils.loadCertificate("umesh.der");
  
  assertFalse(cert.getCriticalExtensionOIDs().contains(ExtensionIdentifier.EXTENDED_KEY_USAGE.getId()));
  
  
  final ExtendedKeyUsageExtensionField field = new ExtendedKeyUsageExtensionField(false);
  
  field.injectReferenceValue(cert);
  assertFalse(field.isCritical());
}

相关文章