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

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

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

KeyStore.getProvider介绍

[英]Returns the provider associated with this KeyStore.
[中]返回与此密钥库关联的提供程序。

代码示例

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

/**
 * Create a new {@code AtomicLoadKeyStore} wrapping a {@link KeyStore} of the type specified.
 *
 * @param type the type of {@link KeyStore} to be wrapped
 * @param provider the provide to use to create the {@link KeyStore}
 * @return the new {@code AtomicLoadKeyStore} instance
 * @throws KeyStoreException If there is a problem creating the {@link KeyStore}
 * @throws NoSuchProviderException if the provider specified can not be found.
 */
public static AtomicLoadKeyStore newInstance(final String type, final String provider) throws KeyStoreException, NoSuchProviderException {
  KeyStore keyStore = provider != null ? KeyStore.getInstance(type, provider) : KeyStore.getInstance(type);
  final Provider resolvedProvider = keyStore.getProvider();
  return newInstance(type, resolvedProvider);
}

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

/**
   * Construct a new instance.
   *
   * @param delegate the delegate {@code KeyStore} (must not be {@code null})
   */
  public WrappingPasswordKeyStore(final KeyStore delegate) {
    super(new WrappingPasswordKeyStoreSpiImpl(delegate), delegate.getProvider(), delegate.getType());
  }
}

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

void init(String cryptographicAlgorithm, String keyAlias, KeyStore keyStore, char[] keyPassword, KeyStore dataKeyStore) throws CredentialStoreException {
  if (cryptographicAlgorithm == null)
    cryptographicAlgorithm = DEFAULT_CRYPTOGRAPHIC_ALGORITHM;
  storageSecretKeyStore = keyStore;
  this.dataKeyStore = dataKeyStore;
  try {
    fetchStorageSecretKey(keyAlias, keyPassword);
    Provider provider = keyStore.getProvider();
    try {
      encrypt = Cipher.getInstance(cryptographicAlgorithm, provider);
    } catch (NoSuchAlgorithmException e) {
      // fallback to any provider of desired algorithm
      encrypt = Cipher.getInstance(cryptographicAlgorithm);
    }
    try {
      decrypt = Cipher.getInstance(cryptographicAlgorithm, provider);
    } catch (NoSuchAlgorithmException e) {
      // fallback to any provider of desired algorithm
      decrypt = Cipher.getInstance(cryptographicAlgorithm);
    }
  } catch (NoSuchAlgorithmException | NoSuchPaddingException | UnrecoverableEntryException |
      KeyStoreException | IOException | CertificateException e) {
    throw new CredentialStoreException(e);
  }
}

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

/**
 * Wrap an existing initialised {@link KeyStore} with an wrapper to filter which aliases can be returned.
 *
 * @param toWrap the {@link KeyStore} to wrap.
 * @return the filtering wrapper around the {@link KeyStore}
 * @throws NoSuchAlgorithmException
 * @throws CertificateException
 * @throws IOException
 * @throws IllegalArgumentException if the {@link KeyStore} being wrapped is {@code null}
 */
public static KeyStore filteringKeyStore(final KeyStore toWrap, final Predicate<String> aliasPredicate) throws NoSuchAlgorithmException, CertificateException,
    IOException {
  Assert.checkNotNullParam("toWrap", toWrap);
  KeyStore keyStore = new FilteringKeyStore(new FilteringKeyStoreSpi(toWrap, aliasPredicate), toWrap.getProvider(), toWrap.getType());
  keyStore.load(null, null);
  return keyStore;
}

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

/**
   * Wrap an existing initialised {@link KeyStore} with an unmodifiable wrapper.
   *
   * Note: References are held to the underlying {@link KeyStore} can still be modified and changes will still be visible in
   * the representation returned here.
   *
   * @param toWrap the {@link KeyStore} to wrap.
   * @return the unmodifiable wrapper around the {@link KeyStore}
   * @throws NoSuchAlgorithmException
   * @throws CertificateException
   * @throws IOException
   * @throws IllegalArgumentException if the {@link KeyStore} being wrapped is {@code null}
   */
  public static KeyStore unmodifiableKeyStore(final KeyStore toWrap) throws NoSuchAlgorithmException, CertificateException,
      IOException {
    Assert.checkNotNullParam("toWrap", toWrap);

    KeyStore keyStore = new UnmodifiableKeyStore(new UnmodifiableKeyStoreSpi(toWrap), toWrap.getProvider(),
        toWrap.getType());
    keyStore.load(null, null);

    return keyStore;
  }
}

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

/**
 * Wrap an existing initialised {@link KeyStore} with a wrapper to track if it is modified.
 *
 * @param toWrap the {@link KeyStore} to wrap
 * @return the wrapper around the {@link KeyStore}
 * @throws NoSuchAlgorithmException if the keystore could not be loaded due to a missing algorithm
 * @throws CertificateException if the keystore could not be loaded due to a certificate problem
 * @throws IOException if the keystore could not be loaded due to an I/O problem
 * @throws IllegalArgumentException if the {@link KeyStore} being wrapped is {@code null}
 */
public static ModifyTrackingKeyStore modifyTrackingKeyStore(final KeyStore toWrap) throws NoSuchAlgorithmException, CertificateException,
    IOException {
  Assert.checkNotNullParam("toWrap", toWrap);
  ModifyTrackingKeyStore keyStore = new ModifyTrackingKeyStore(new ModifyTrackingKeyStoreSpi(toWrap), toWrap.getProvider(),
      toWrap.getType());
  keyStore.load(null, null);
  return keyStore;
}

代码示例来源:origin: camunda/camunda-bpm-platform

context.addInfo(
  "key store of type '" + keyStore.getType() 
  + "' provider '" + keyStore.getProvider()
  + "': " + getKeyStore().getLocation());

代码示例来源:origin: camunda/camunda-bpm-platform

context.addInfo(
  "trust store of type '" + trustStore.getType() 
  + "' provider '" + trustStore.getProvider()
  + "': " + getTrustStore().getLocation());

代码示例来源:origin: nu.zoom/portunis

public Provider getProvider()
{
  return store.getProvider();
}

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

String alias = "Alias to my PK";
char[] pass = "MyPassword".toCharArray();

KeyStore ks = KeyStore.getInstance("Windows-MY");
ks.load(null, pass);
Provider p =  ks.getProvider();

Signature sig = Signature.getInstance("SHA1withRSA",p);
PrivateKey key = (PrivateKey) ks.getKey(alias, pass)

sig.initSign(key);
sig.update("Testing".getBytes());
sig.sign();

代码示例来源:origin: com.helger/ph-security

@Nonnull
public static KeyStore getSimiliarKeyStore (@Nonnull final KeyStore aOther) throws KeyStoreException
{
 return KeyStore.getInstance (aOther.getType (), aOther.getProvider ());
}

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

/**
 * Create a new {@code AtomicLoadKeyStore} wrapping a {@link KeyStore} of the type specified.
 *
 * @param type the type of {@link KeyStore} to be wrapped
 * @param provider the provide to use to create the {@link KeyStore}
 * @return the new {@code AtomicLoadKeyStore} instance
 * @throws KeyStoreException If there is a problem creating the {@link KeyStore}
 * @throws NoSuchProviderException if the provider specified can not be found.
 */
public static AtomicLoadKeyStore newInstance(final String type, final String provider) throws KeyStoreException, NoSuchProviderException {
  KeyStore keyStore = provider != null ? KeyStore.getInstance(type, provider) : KeyStore.getInstance(type);
  final Provider resolvedProvider = keyStore.getProvider();
  return newInstance(type, resolvedProvider);
}

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

/**
 * Create a new {@code AtomicLoadKeyStore} wrapping a {@link KeyStore} of the type specified.
 *
 * @param type the type of {@link KeyStore} to be wrapped
 * @param provider the provide to use to create the {@link KeyStore}
 * @return the new {@code AtomicLoadKeyStore} instance
 * @throws KeyStoreException If there is a problem creating the {@link KeyStore}
 * @throws NoSuchProviderException if the provider specified can not be found.
 */
public static AtomicLoadKeyStore newInstance(final String type, final String provider) throws KeyStoreException, NoSuchProviderException {
  KeyStore keyStore = provider != null ? KeyStore.getInstance(type, provider) : KeyStore.getInstance(type);
  final Provider resolvedProvider = keyStore.getProvider();
  return newInstance(type, resolvedProvider);
}

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

/**
 * Create a new {@code AtomicLoadKeyStore} wrapping a {@link KeyStore} of the type specified.
 *
 * @param type the type of {@link KeyStore} to be wrapped
 * @param provider the provide to use to create the {@link KeyStore}
 * @return the new {@code AtomicLoadKeyStore} instance
 * @throws KeyStoreException If there is a problem creating the {@link KeyStore}
 * @throws NoSuchProviderException if the provider specified can not be found.
 */
public static AtomicLoadKeyStore newInstance(final String type, final String provider) throws KeyStoreException, NoSuchProviderException {
  KeyStore keyStore = provider != null ? KeyStore.getInstance(type, provider) : KeyStore.getInstance(type);
  final Provider resolvedProvider = keyStore.getProvider();
  return newInstance(type, resolvedProvider);
}

代码示例来源:origin: org.opencadc/cadc-util

@SuppressWarnings("unchecked")
private static void printKeyStoreInfo(KeyStore keystore) 
  throws KeyStoreException
{
  log.debug("Provider : " + keystore.getProvider().getName());
  log.debug("Type : " + keystore.getType());
  log.debug("Size : " + keystore.size());
  Enumeration en = keystore.aliases();
  while (en.hasMoreElements())
  {
    System.out.println("Alias: " + en.nextElement());
  }
}

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

/**
   * Construct a new instance.
   *
   * @param delegate the delegate {@code KeyStore} (must not be {@code null})
   */
  public WrappingPasswordKeyStore(final KeyStore delegate) {
    super(new WrappingPasswordKeyStoreSpiImpl(delegate), delegate.getProvider(), delegate.getType());
  }
}

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

@Override
  protected void performRuntime(ModelNode result, ModelNode operation, KeyStoreService keyStoreService)
      throws OperationFailedException {
    populateProvider(result, keyStoreService.getValue().getProvider(), false);
  }
});

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

/**
   * Construct a new instance.
   *
   * @param delegate the delegate {@code KeyStore} (must not be {@code null})
   */
  public WrappingPasswordKeyStore(final KeyStore delegate) {
    super(new WrappingPasswordKeyStoreSpiImpl(delegate), delegate.getProvider(), delegate.getType());
  }
}

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

/**
   * Construct a new instance.
   *
   * @param delegate the delegate {@code KeyStore} (must not be {@code null})
   */
  public WrappingPasswordKeyStore(final KeyStore delegate) {
    super(new WrappingPasswordKeyStoreSpiImpl(delegate), delegate.getProvider(), delegate.getType());
  }
}

代码示例来源:origin: tony19/logback-android

@Test
public void testExplicitProvider() throws Exception {
 factoryBean.setLocation(SSLTestConstants.KEYSTORE_JKS_RESOURCE);
 KeyStore keyStore = factoryBean.createKeyStore();
 factoryBean.setProvider(keyStore.getProvider().getName());
 assertNotNull(factoryBean.createKeyStore());
}

相关文章