java.security.KeyStore.isCertificateEntry()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(145)

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

KeyStore.isCertificateEntry介绍

[英]Indicates whether the specified alias is associated with a TrustedCertificateEntry.
[中]指示指定的别名是否与TrustedCertificateEntry关联。

代码示例

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

public boolean engineIsCertificateEntry(final String alias) {
  try {
    return delegate.isCertificateEntry(alias);
  } catch (KeyStoreException e) {
    return false;
  }
}

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

@Override
public boolean engineIsCertificateEntry(String alias) {
  try {
    return getKeyStore().isCertificateEntry(alias);
  } catch (KeyStoreException e) {
    throw new IllegalStateException(e);
  }
}

代码示例来源:origin: igniterealtime/Openfire

public OpenfireX509TrustManager( KeyStore trustStore, boolean acceptSelfSigned, boolean checkValidity ) throws NoSuchAlgorithmException, KeyStoreException
{
  this.acceptSelfSigned = acceptSelfSigned;
  this.checkValidity = checkValidity;
  // Retrieve all trusted certificates from the store, but don't validate them just yet!
  final Set<X509Certificate> trusted = new HashSet<>();
  final Enumeration<String> aliases = trustStore.aliases();
  while ( aliases.hasMoreElements() )
  {
    final String alias = aliases.nextElement();
    if ( trustStore.isCertificateEntry( alias ) )
    {
      final Certificate certificate = trustStore.getCertificate( alias );
      if ( certificate instanceof X509Certificate )
      {
        trusted.add( (X509Certificate) certificate );
      }
    }
  }
  trustedIssuers = Collections.unmodifiableSet( trusted );
  Log.debug( "Constructed trust manager. Number of trusted issuers: {}, accepts self-signed: {}, checks validity: {}", trustedIssuers.size(), acceptSelfSigned, checkValidity );
}

代码示例来源:origin: oracle/helidon

static List<X509Certificate> loadCertificates(KeyStore keyStore) {
    List<X509Certificate> certs = new LinkedList<>();
    try {
      Enumeration<String> aliases = keyStore.aliases();
      while (aliases.hasMoreElements()) {
        String alias = aliases.nextElement();
        if (keyStore.isCertificateEntry(alias)) {
          X509Certificate cert = (X509Certificate) keyStore.getCertificate(alias);
          certs.add(cert);

          LOGGER.finest(() -> "Added certificate under alis " + alias + " for " + cert
              .getSubjectDN() + " to list of certificates");
        }
      }
    } catch (KeyStoreException e) {
      throw new PkiException("Failed to load certificates from keystore: " + keyStore, e);
    }

    return certs;
  }
}

代码示例来源:origin: eclipse-vertx/vert.x

String alias = en.nextElement();
Certificate cert = ks.getCertificate(alias);
if (ks.isCertificateEntry(alias) && ! alias.startsWith(DUMMY_CERT_ALIAS)){
 final KeyStore keyStore = createEmptyKeyStore();
 keyStore.setCertificateEntry("cert-1", cert);

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

for (Enumeration i = keyStore.aliases(); i.hasMoreElements();) {
  String alias = (String) i.nextElement();
  if (keyStore.isCertificateEntry(alias)) {

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

while (aliases.hasMoreElements()) {
  final String alias = aliases.nextElement();
  if (keyStore.isCertificateEntry(alias)) {
    final Certificate certificate = keyStore.getCertificate(alias);
    if (certificate instanceof X509Certificate && x500Principal.equals(X500PrincipalUtil.asX500Principal(((X509Certificate) certificate).getSubjectX500Principal()))) {

代码示例来源:origin: igniterealtime/Openfire

if ( store.isCertificateEntry( alias ) )

代码示例来源:origin: i2p/i2p.i2p

/**
 *  Count all X509 Certs in a key store
 *
 *  @return number successfully added
 *  @since 0.8.2, moved from SSLEepGet in 0.9.9
 */
public static int countCerts(KeyStore ks) {
  int count = 0;
  try {
    for(Enumeration<String> e = ks.aliases(); e.hasMoreElements();) {
      String alias = e.nextElement();
      if (ks.isCertificateEntry(alias)) {
        //info("Found cert " + alias);
        count++;
      }
    }
  } catch (GeneralSecurityException e) {}
  return count;
}

代码示例来源:origin: mulesoft/mule

private static Set<TrustAnchor> getTrustAnchorsFromKeyStore(KeyStore keyStore) throws GeneralSecurityException {
 Enumeration<String> aliases = keyStore.aliases();
 HashSet<TrustAnchor> trustAnchors = new HashSet<>();
 while (aliases.hasMoreElements()) {
  String alias = aliases.nextElement();
  if (keyStore.isCertificateEntry(alias)) {
   trustAnchors.add(new TrustAnchor((X509Certificate) keyStore.getCertificate(alias), null));
  }
 }
 return trustAnchors;
}

代码示例来源:origin: io.vertx/vertx-core

String alias = en.nextElement();
Certificate cert = ks.getCertificate(alias);
if (ks.isCertificateEntry(alias) && ! alias.startsWith(DUMMY_CERT_ALIAS)){
 final KeyStore keyStore = createEmptyKeyStore();
 keyStore.setCertificateEntry("cert-1", cert);

代码示例来源:origin: i2p/i2p.i2p

for(Enumeration<String> e = ks.aliases(); e.hasMoreElements();) {
  String alias = e.nextElement();
  if (ks.isCertificateEntry(alias)) {
    Certificate c = ks.getCertificate(alias);
    if (c != null && (c instanceof X509Certificate)) {

代码示例来源:origin: mulesoft/mule

@Override
public ManagerFactoryParameters configFor(KeyStore trustStore, Set<TrustAnchor> defaultTrustAnchors) {
 checkArgument(url != null, "tls:custom-ocsp-responder requires the 'url' attribute");
 checkArgument(trustStore != null, "tls:custom-ocsp-responder requires a trust store");
 try {
  CertPathBuilder cpb = CertPathBuilder.getInstance("PKIX");
  PKIXRevocationChecker rc = (PKIXRevocationChecker) cpb.getRevocationChecker();
  rc.setOptions(EnumSet.of(PKIXRevocationChecker.Option.NO_FALLBACK));
  if (url != null) {
   rc.setOcspResponder(new URI(url));
  }
  if (certAlias != null) {
   if (trustStore.isCertificateEntry(certAlias)) {
    rc.setOcspResponderCert((X509Certificate) trustStore.getCertificate(certAlias));
   } else {
    throw new IllegalStateException("Key with alias \"" + certAlias + "\" was not found");
   }
  }
  PKIXBuilderParameters pkixParams = new PKIXBuilderParameters(trustStore, new X509CertSelector());
  pkixParams.addCertPathChecker(rc);
  return new CertPathTrustManagerParameters(pkixParams);
 } catch (GeneralSecurityException | URISyntaxException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: org.wildfly.security/wildfly-elytron-credential

public boolean engineIsCertificateEntry(final String alias) {
  try {
    return delegate.isCertificateEntry(alias);
  } catch (KeyStoreException e) {
    return false;
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public boolean engineIsCertificateEntry(final String alias) {
  try {
    return delegate.isCertificateEntry(alias);
  } catch (KeyStoreException e) {
    return false;
  }
}

代码示例来源:origin: sedmelluq/lavaplayer

private void addFromKeyStore(KeyStore keyStore) throws Exception {
  for (Enumeration<String> enumeration = keyStore.aliases(); enumeration.hasMoreElements(); ) {
   String alias = enumeration.nextElement();

   if (keyStore.isCertificateEntry(alias)) {
    certificates.add(keyStore.getCertificate(alias));
   }
  }
 }
}

代码示例来源:origin: org.wildfly.security/wildfly-elytron-credential

@Override
public boolean engineIsCertificateEntry(String alias) {
  try {
    return getKeyStore().isCertificateEntry(alias);
  } catch (KeyStoreException e) {
    throw new IllegalStateException(e);
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

@Override
public boolean engineIsCertificateEntry(String alias) {
  try {
    return getKeyStore().isCertificateEntry(alias);
  } catch (KeyStoreException e) {
    throw new IllegalStateException(e);
  }
}

代码示例来源:origin: org.mule.runtime/mule-module-tls

private static Set<TrustAnchor> getTrustAnchorsFromKeyStore(KeyStore keyStore) throws GeneralSecurityException {
 Enumeration<String> aliases = keyStore.aliases();
 HashSet<TrustAnchor> trustAnchors = new HashSet<>();
 while (aliases.hasMoreElements()) {
  String alias = aliases.nextElement();
  if (keyStore.isCertificateEntry(alias)) {
   trustAnchors.add(new TrustAnchor((X509Certificate) keyStore.getCertificate(alias), null));
  }
 }
 return trustAnchors;
}

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

@Override
public boolean engineIsCertificateEntry(String alias) {
  try {
    return getKeyStore().isCertificateEntry(alias);
  } catch (KeyStoreException e) {
    throw new IllegalStateException(e);
  }
}

相关文章