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

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

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

KeyStore.getType介绍

[英]Returns the type of this KeyStore.
[中]返回此密钥库的类型。

代码示例

代码示例来源: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

/**
 * 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: apache/nifi

private String getKeyPassword() {
  if (keyStore.getType().equalsIgnoreCase(KeystoreType.PKCS12.toString())) {
    tlsConfig.setKeyPassword(null);
    return null;
  } else {
    String result = tlsConfig.getKeyPassword();
    if (StringUtils.isEmpty(result)) {
      if (differentKeyAndKeyStorePassword) {
        result = passwordUtil.generatePassword();
      } else {
        result = getKeyStorePassword();
      }
      tlsConfig.setKeyPassword(result);
    }
    return result;
  }
}

代码示例来源: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

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

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

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

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

private String getKey(String inputKey) {
  if ("PKCS12".equals(keyStore.getType())) {
    // workaround for https://bugs.openjdk.java.net/browse/JDK-8079616:
    return inputKey.toLowerCase(Locale.ROOT);
  }
  return inputKey;
}

代码示例来源:origin: kaikramer/keystore-explorer

/**
 * Get KeyStore's type.
 *
 * @return KeyStore's type
 */
public KeyStoreType getType() {
  return KeyStoreType.resolveJce(keyStore.getType());
}

代码示例来源: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.renci.ahab/libtransport

@Override
  public String toString() {
    try {
      return ks.getType() + " contains alias " + keyAlias + ": " + ks.containsAlias(keyAlias);
    } catch(KeyStoreException kse) {
      return "Unable to get keystore information: " + kse;
    }
  }
}

代码示例来源: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: 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: 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: kaikramer/keystore-explorer

private void createLastModifiedNode(DefaultMutableTreeNode parentNode, String alias) throws CryptoException {
  try {
    KeyStore keyStore = currentState.getKeyStore();
    if (KeyStoreType.resolveJce(keyStore.getType()) != KeyStoreType.PKCS12) {
      String lastModified = MessageFormat.format(res.getString("DProperties.properties.LastModified"),
          StringUtils.formatDate(keyStore.getCreationDate(alias)));
      parentNode.add(new DefaultMutableTreeNode(lastModified));
    }
  } catch (ProviderException e) {
    // some keystore types do not provide creation dates for their entries => simply create no node
  } catch (KeyStoreException e) {
    throw new CryptoException(res.getString("DProperties.NoGetProperties.exception.message"), e);
  }
}

代码示例来源:origin: de.adorsys.cryptoutils/encobject-jcloud

public void saveKeyStore(KeyStore keystore, CallbackHandler storePassHandler, ObjectHandle handle) throws NoSuchAlgorithmException, CertificateException, UnknownContainerException{
  try {
    String storeType = keystore.getType();
    byte[] bs = KeyStoreService.toByteArray(keystore, handle.getName(), storePassHandler);
    KeystoreData keystoreData = KeystoreData.newBuilder().setType(storeType).setKeystore(ByteString.copyFrom(bs)).build();
    blobStoreConnection.putBlob(handle, keystoreData.toByteArray());
  } catch (IOException e) {
    throw new IllegalStateException(e);
  }
}

代码示例来源:origin: de.adorsys.cryptoutils/encobject-jcloud

public void saveKeyStoreWithAttributes(KeyStore keystore, Map<String, String> attributes, CallbackHandler storePassHandler, ObjectHandle handle) throws NoSuchAlgorithmException, CertificateException, UnknownContainerException{
  try {
    String storeType = keystore.getType();
    byte[] bs = KeyStoreService.toByteArray(keystore, handle.getName(), storePassHandler);
    KeystoreData keystoreData = KeystoreData.newBuilder()
        .setType(storeType)
        .setKeystore(ByteString.copyFrom(bs))
        .putAllAttributes(attributes)
        .build();
    blobStoreConnection.putBlob(handle, keystoreData.toByteArray());
  } catch (IOException e) {
    throw new IllegalStateException(e);
  }
}

代码示例来源:origin: de.adorsys.cryptoutils/encobject

@Override
public void saveKeyStore(KeyStore keystore, CallbackHandler storePassHandler, ObjectHandle handle) {
  String storeType = keystore.getType();
  byte[] bs = KeyStoreService.toByteArray(keystore, handle.getName(), storePassHandler);
  BucketPath bucketPath = BucketPath.fromHandle(handle);
  Payload payload = new SimplePayloadImpl(bs);
  payload.getStorageMetadata().getUserMetadata().put(KEYSTORE_TYPE_KEY, storeType);
  extendedStoreConnection.putBlob(bucketPath, payload);
}

代码示例来源:origin: de.adorsys.cryptoutils/encobject

@Override
public void saveKeyStoreWithAttributes(KeyStore keystore, UserMetaData userMetaData, CallbackHandler storePassHandler, ObjectHandle handle) {
  String storeType = keystore.getType();
  byte[] bs = KeyStoreService.toByteArray(keystore, handle.getName(), storePassHandler);
  BucketPath bucketPath = BucketPath.fromHandle(handle);
  SimpleStorageMetadataImpl simpleStorageMetadataImpl = new SimpleStorageMetadataImpl();
  simpleStorageMetadataImpl.getUserMetadata().put(KEYSTORE_TYPE_KEY, storeType);
  simpleStorageMetadataImpl.addUserMetadata(userMetaData);
  SimplePayloadImpl payload = new SimplePayloadImpl(simpleStorageMetadataImpl, bs);
  extendedStoreConnection.putBlob(bucketPath, payload);
}

代码示例来源:origin: de.adorsys.sts/sts-persistence-mongo

public void mapIntoEntity(StsKeyStore keyStore, KeyStoreEntity persistentKeyStore) {
  byte[] bytes = KeyStoreService.toByteArray(keyStore.getKeyStore(), keystoreName, keyPassHandler);
  persistentKeyStore.setName(keystoreName);
  persistentKeyStore.setKeystore(bytes);
  persistentKeyStore.setType(keyStore.getKeyStore().getType());
  persistentKeyStore.setLastUpdate(convert(keyStore.getLastUpdate()));
  Map<String, KeyEntryAttributesEntity> mappedEntryAttributes = mapToEntityMap(keyStore.getKeyEntries());
  persistentKeyStore.setEntries(mappedEntryAttributes);
}

相关文章