org.wildfly.security.credential.X509CertificateChainPublicCredential.<init>()方法的使用及代码示例

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

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

X509CertificateChainPublicCredential.<init>介绍

[英]Construct a new instance.
[中]构造一个新实例。

代码示例

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

private void parseCertificate(final List<Credential> credentials, final XMLStreamReader streamReader) throws RealmUnavailableException, XMLStreamException {
  parseCredential(streamReader, (algorithm, format, text) -> {
    if (algorithm == null) algorithm = "X.509";
    if (format == null) format = X509_FORMAT;
    try {
      final CertificateFactory certificateFactory = CertificateFactory.getInstance(algorithm);
      credentials.add(new X509CertificateChainPublicCredential((X509Certificate) certificateFactory.generateCertificate(
        CodePointIterator.ofString(text).base64Decode().asInputStream())));
    } catch (CertificateException | ClassCastException e) {
      throw ElytronMessages.log.fileSystemRealmCertificateReadError(format, path, streamReader.getLocation().getLineNumber(), name);
    }
  });
}

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

credential = new X509CertificateChainPrivateCredential(privateKey, certificateChain);
} else if (credentialType.isAssignableFrom(X509CertificateChainPublicCredential.class)) {
  credential = new X509CertificateChainPublicCredential(certificateChain);
} else if (credentialType.isAssignableFrom(PublicKeyCredential.class)) {
  credential = new PublicKeyCredential(firstCert.getPublicKey());

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

private static IdentityCredentials getSingleCredential(Object rawCredential) {
  if (rawCredential == null) {
    return IdentityCredentials.NONE;
  } else if (rawCredential instanceof Credential) {
    return IdentityCredentials.NONE.withCredential((Credential) rawCredential);
  } else if (rawCredential instanceof GSSCredential) {
    return IdentityCredentials.NONE.withCredential(new GSSKerberosCredential((GSSCredential) rawCredential));
  } else if (rawCredential instanceof Password) {
    return IdentityCredentials.NONE.withCredential(new PasswordCredential((Password) rawCredential));
  } else if (rawCredential instanceof X509Certificate) {
    return IdentityCredentials.NONE.withCredential(new X509CertificateChainPublicCredential((X509Certificate) rawCredential));
  } else if (rawCredential instanceof X509Certificate[]) {
    return IdentityCredentials.NONE.withCredential(new X509CertificateChainPublicCredential((X509Certificate[]) rawCredential));
  } else if (rawCredential instanceof X500PrivateCredential) {
    final X500PrivateCredential credential = (X500PrivateCredential) rawCredential;
    return IdentityCredentials.NONE.withCredential(new X509CertificateChainPrivateCredential(credential.getPrivateKey(), credential.getCertificate()));
  } else if (rawCredential instanceof String) {
    return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, ((String) rawCredential).toCharArray())));
  } else if (rawCredential instanceof char[]) {
    // todo: automatically decode to other credential types
    return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, (char[]) rawCredential)));
  } else if (rawCredential instanceof byte[]) {
    // todo: automatically decode to other credential types
    return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, new String((byte[]) rawCredential, StandardCharsets.UTF_8).toCharArray())));
  } else {
    return IdentityCredentials.NONE;
  }
}

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

return credentialType.cast(new X509CertificateChainPublicCredential(array));
} catch (ASN1Exception | CertificateException | ArrayIndexOutOfBoundsException e) {
  throw log.cannotAcquireCredentialFromStore(e);

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

/**
   * Convert a key store entry into a credential object.
   *
   * @param keyStoreEntry the key store entry to convert (must not be {@code null})
   * @return the corresponding credential, or {@code null} if the entry type is unrecognized
   */
  static Credential fromKeyStoreEntry(KeyStore.Entry keyStoreEntry) {
    Assert.checkNotNullParam("keyStoreEntry", keyStoreEntry);
    if (keyStoreEntry instanceof PasswordEntry) {
      return new PasswordCredential(((PasswordEntry) keyStoreEntry).getPassword());
    } else if (keyStoreEntry instanceof KeyStore.PrivateKeyEntry) {
      return new X509CertificateChainPrivateCredential(((KeyStore.PrivateKeyEntry) keyStoreEntry).getPrivateKey(), X500.asX509CertificateArray(((KeyStore.PrivateKeyEntry) keyStoreEntry).getCertificateChain()));
    } else if (keyStoreEntry instanceof KeyStore.TrustedCertificateEntry) {
      return new X509CertificateChainPublicCredential((X509Certificate) ((KeyStore.TrustedCertificateEntry) keyStoreEntry).getTrustedCertificate());
    } else if (keyStoreEntry instanceof KeyStore.SecretKeyEntry) {
      return new SecretKeyCredential(((KeyStore.SecretKeyEntry) keyStoreEntry).getSecretKey());
    } else {
      return null;
    }
  }
}

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

private void parseCertificate(final List<Credential> credentials, final XMLStreamReader streamReader) throws RealmUnavailableException, XMLStreamException {
  parseCredential(streamReader, (algorithm, format, text) -> {
    if (algorithm == null) algorithm = "X.509";
    if (format == null) format = X509_FORMAT;
    try {
      final CertificateFactory certificateFactory = CertificateFactory.getInstance(algorithm);
      credentials.add(new X509CertificateChainPublicCredential((X509Certificate) certificateFactory.generateCertificate(
        CodePointIterator.ofString(text).base64Decode().asInputStream())));
    } catch (CertificateException | ClassCastException e) {
      throw ElytronMessages.log.fileSystemRealmCertificateReadError(format, path, streamReader.getLocation().getLineNumber(), name);
    }
  });
}

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

private void parseCertificate(final List<Credential> credentials, final XMLStreamReader streamReader) throws RealmUnavailableException, XMLStreamException {
  parseCredential(streamReader, (algorithm, format, text) -> {
    if (algorithm == null) algorithm = "X.509";
    if (format == null) format = X509_FORMAT;
    try {
      final CertificateFactory certificateFactory = CertificateFactory.getInstance(algorithm);
      credentials.add(new X509CertificateChainPublicCredential((X509Certificate) certificateFactory.generateCertificate(
        CodePointIterator.ofString(text).base64Decode().asInputStream())));
    } catch (CertificateException | ClassCastException e) {
      throw ElytronMessages.log.fileSystemRealmCertificateReadError(format, path, streamReader.getLocation().getLineNumber(), name);
    }
  });
}

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

private void parseCertificate(final List<Credential> credentials, final XMLStreamReader streamReader) throws RealmUnavailableException, XMLStreamException {
  parseCredential(streamReader, (algorithm, format, text) -> {
    if (algorithm == null) algorithm = "X.509";
    if (format == null) format = X509_FORMAT;
    try {
      final CertificateFactory certificateFactory = CertificateFactory.getInstance(algorithm);
      credentials.add(new X509CertificateChainPublicCredential((X509Certificate) certificateFactory.generateCertificate(
        CodePointIterator.ofString(text).base64Decode().asInputStream())));
    } catch (CertificateException | ClassCastException e) {
      throw ElytronMessages.log.fileSystemRealmCertificateReadError(format, path, streamReader.getLocation().getLineNumber(), name);
    }
  });
}

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

credential = new X509CertificateChainPrivateCredential(privateKey, certificateChain);
} else if (credentialType.isAssignableFrom(X509CertificateChainPublicCredential.class)) {
  credential = new X509CertificateChainPublicCredential(certificateChain);
} else if (credentialType.isAssignableFrom(PublicKeyCredential.class)) {
  credential = new PublicKeyCredential(firstCert.getPublicKey());

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

credential = new X509CertificateChainPrivateCredential(privateKey, certificateChain);
} else if (credentialType.isAssignableFrom(X509CertificateChainPublicCredential.class)) {
  credential = new X509CertificateChainPublicCredential(certificateChain);
} else if (credentialType.isAssignableFrom(PublicKeyCredential.class)) {
  credential = new PublicKeyCredential(firstCert.getPublicKey());

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

credential = new X509CertificateChainPrivateCredential(privateKey, certificateChain);
} else if (credentialType.isAssignableFrom(X509CertificateChainPublicCredential.class)) {
  credential = new X509CertificateChainPublicCredential(certificateChain);
} else if (credentialType.isAssignableFrom(PublicKeyCredential.class)) {
  credential = new PublicKeyCredential(firstCert.getPublicKey());

代码示例来源:origin: org.jboss.eap/wildfly-webservices-server-integration

publicCredentials = publicCredentials.withCredential(new PublicKeyCredential((PublicKey) credential));
} else if (credential instanceof X509Certificate) {
  publicCredentials = publicCredentials.withCredential(new X509CertificateChainPublicCredential(
      (X509Certificate) credential));
} else if (credential instanceof Credential) {

代码示例来源:origin: org.wildfly/wildfly-webservices-server-integration

publicCredentials = publicCredentials.withCredential(new PublicKeyCredential((PublicKey) credential));
} else if (credential instanceof X509Certificate) {
  publicCredentials = publicCredentials.withCredential(new X509CertificateChainPublicCredential(
      (X509Certificate) credential));
} else if (credential instanceof Credential) {

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

private static IdentityCredentials getSingleCredential(Object rawCredential) {
  if (rawCredential == null) {
    return IdentityCredentials.NONE;
  } else if (rawCredential instanceof Credential) {
    return IdentityCredentials.NONE.withCredential((Credential) rawCredential);
  } else if (rawCredential instanceof GSSCredential) {
    return IdentityCredentials.NONE.withCredential(new GSSKerberosCredential((GSSCredential) rawCredential));
  } else if (rawCredential instanceof Password) {
    return IdentityCredentials.NONE.withCredential(new PasswordCredential((Password) rawCredential));
  } else if (rawCredential instanceof X509Certificate) {
    return IdentityCredentials.NONE.withCredential(new X509CertificateChainPublicCredential((X509Certificate) rawCredential));
  } else if (rawCredential instanceof X509Certificate[]) {
    return IdentityCredentials.NONE.withCredential(new X509CertificateChainPublicCredential((X509Certificate[]) rawCredential));
  } else if (rawCredential instanceof X500PrivateCredential) {
    final X500PrivateCredential credential = (X500PrivateCredential) rawCredential;
    return IdentityCredentials.NONE.withCredential(new X509CertificateChainPrivateCredential(credential.getPrivateKey(), credential.getCertificate()));
  } else if (rawCredential instanceof String) {
    return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, ((String) rawCredential).toCharArray())));
  } else if (rawCredential instanceof char[]) {
    // todo: automatically decode to other credential types
    return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, (char[]) rawCredential)));
  } else if (rawCredential instanceof byte[]) {
    // todo: automatically decode to other credential types
    return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, new String((byte[]) rawCredential, StandardCharsets.UTF_8).toCharArray())));
  } else {
    return IdentityCredentials.NONE;
  }
}

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

private static IdentityCredentials getSingleCredential(Object rawCredential) {
  if (rawCredential == null) {
    return IdentityCredentials.NONE;
  } else if (rawCredential instanceof Credential) {
    return IdentityCredentials.NONE.withCredential((Credential) rawCredential);
  } else if (rawCredential instanceof GSSCredential) {
    return IdentityCredentials.NONE.withCredential(new GSSKerberosCredential((GSSCredential) rawCredential));
  } else if (rawCredential instanceof Password) {
    return IdentityCredentials.NONE.withCredential(new PasswordCredential((Password) rawCredential));
  } else if (rawCredential instanceof X509Certificate) {
    return IdentityCredentials.NONE.withCredential(new X509CertificateChainPublicCredential((X509Certificate) rawCredential));
  } else if (rawCredential instanceof X509Certificate[]) {
    return IdentityCredentials.NONE.withCredential(new X509CertificateChainPublicCredential((X509Certificate[]) rawCredential));
  } else if (rawCredential instanceof X500PrivateCredential) {
    final X500PrivateCredential credential = (X500PrivateCredential) rawCredential;
    return IdentityCredentials.NONE.withCredential(new X509CertificateChainPrivateCredential(credential.getPrivateKey(), credential.getCertificate()));
  } else if (rawCredential instanceof String) {
    return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, ((String) rawCredential).toCharArray())));
  } else if (rawCredential instanceof char[]) {
    // todo: automatically decode to other credential types
    return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, (char[]) rawCredential)));
  } else if (rawCredential instanceof byte[]) {
    // todo: automatically decode to other credential types
    return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, new String((byte[]) rawCredential, StandardCharsets.UTF_8).toCharArray())));
  } else {
    return IdentityCredentials.NONE;
  }
}

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

return credentialType.cast(new X509CertificateChainPublicCredential(array));
} catch (ASN1Exception | CertificateException | ArrayIndexOutOfBoundsException e) {
  throw log.cannotAcquireCredentialFromStore(e);

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

return credentialType.cast(new X509CertificateChainPublicCredential(array));
} catch (ASN1Exception | CertificateException | ArrayIndexOutOfBoundsException e) {
  throw log.cannotAcquireCredentialFromStore(e);

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

/**
   * Convert a key store entry into a credential object.
   *
   * @param keyStoreEntry the key store entry to convert (must not be {@code null})
   * @return the corresponding credential, or {@code null} if the entry type is unrecognized
   */
  static Credential fromKeyStoreEntry(KeyStore.Entry keyStoreEntry) {
    Assert.checkNotNullParam("keyStoreEntry", keyStoreEntry);
    if (keyStoreEntry instanceof PasswordEntry) {
      return new PasswordCredential(((PasswordEntry) keyStoreEntry).getPassword());
    } else if (keyStoreEntry instanceof KeyStore.PrivateKeyEntry) {
      return new X509CertificateChainPrivateCredential(((KeyStore.PrivateKeyEntry) keyStoreEntry).getPrivateKey(), X500.asX509CertificateArray(((KeyStore.PrivateKeyEntry) keyStoreEntry).getCertificateChain()));
    } else if (keyStoreEntry instanceof KeyStore.TrustedCertificateEntry) {
      return new X509CertificateChainPublicCredential((X509Certificate) ((KeyStore.TrustedCertificateEntry) keyStoreEntry).getTrustedCertificate());
    } else if (keyStoreEntry instanceof KeyStore.SecretKeyEntry) {
      return new SecretKeyCredential(((KeyStore.SecretKeyEntry) keyStoreEntry).getSecretKey());
    } else {
      return null;
    }
  }
}

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

/**
   * Convert a key store entry into a credential object.
   *
   * @param keyStoreEntry the key store entry to convert (must not be {@code null})
   * @return the corresponding credential, or {@code null} if the entry type is unrecognized
   */
  static Credential fromKeyStoreEntry(KeyStore.Entry keyStoreEntry) {
    Assert.checkNotNullParam("keyStoreEntry", keyStoreEntry);
    if (keyStoreEntry instanceof PasswordEntry) {
      return new PasswordCredential(((PasswordEntry) keyStoreEntry).getPassword());
    } else if (keyStoreEntry instanceof KeyStore.PrivateKeyEntry) {
      return new X509CertificateChainPrivateCredential(((KeyStore.PrivateKeyEntry) keyStoreEntry).getPrivateKey(), X500.asX509CertificateArray(((KeyStore.PrivateKeyEntry) keyStoreEntry).getCertificateChain()));
    } else if (keyStoreEntry instanceof KeyStore.TrustedCertificateEntry) {
      return new X509CertificateChainPublicCredential((X509Certificate) ((KeyStore.TrustedCertificateEntry) keyStoreEntry).getTrustedCertificate());
    } else if (keyStoreEntry instanceof KeyStore.SecretKeyEntry) {
      return new SecretKeyCredential(((KeyStore.SecretKeyEntry) keyStoreEntry).getSecretKey());
    } else {
      return null;
    }
  }
}

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

/**
   * Convert a key store entry into a credential object.
   *
   * @param keyStoreEntry the key store entry to convert (must not be {@code null})
   * @return the corresponding credential, or {@code null} if the entry type is unrecognized
   */
  static Credential fromKeyStoreEntry(KeyStore.Entry keyStoreEntry) {
    Assert.checkNotNullParam("keyStoreEntry", keyStoreEntry);
    if (keyStoreEntry instanceof PasswordEntry) {
      return new PasswordCredential(((PasswordEntry) keyStoreEntry).getPassword());
    } else if (keyStoreEntry instanceof KeyStore.PrivateKeyEntry) {
      return new X509CertificateChainPrivateCredential(((KeyStore.PrivateKeyEntry) keyStoreEntry).getPrivateKey(), X500.asX509CertificateArray(((KeyStore.PrivateKeyEntry) keyStoreEntry).getCertificateChain()));
    } else if (keyStoreEntry instanceof KeyStore.TrustedCertificateEntry) {
      return new X509CertificateChainPublicCredential((X509Certificate) ((KeyStore.TrustedCertificateEntry) keyStoreEntry).getTrustedCertificate());
    } else if (keyStoreEntry instanceof KeyStore.SecretKeyEntry) {
      return new SecretKeyCredential(((KeyStore.SecretKeyEntry) keyStoreEntry).getSecretKey());
    } else {
      return null;
    }
  }
}

相关文章

微信公众号

最新文章

更多