.updateWith(pemBuilder) .updateWith(keystoreBuilder) .build() .privateKey();
builder.privateKey(PkiUtil.loadPrivateKey(keyStore, keyAlias, keyPassphrase)); } catch (Exception e) { if (guessing) { builder.publicKeyCert(certChain.get(0)); builder.publicKeyCert(PkiUtil.loadCertificate(keyStore, certAlias)); PkiUtil.loadCertificates(keyStore).forEach(builder::addCert); } else { certificateAliases.forEach(it -> builder.addCert(PkiUtil.loadCertificate(keyStore, it)));
private Builder updateBuilder(Builder builder) { if (privateKeyStream.isSet()) { builder.privateKey(PemReader.readPrivateKey(privateKeyStream.stream(), pemKeyPassphrase)); } if (publicKeyStream.isSet()) { builder.publicKey(PemReader.readPublicKey(publicKeyStream.stream())); } if (certChainStream.isSet()) { List<X509Certificate> chain = PemReader.readCertificates(certChainStream.stream()); chain.forEach(builder::addCertChain); if (!chain.isEmpty()) { builder.publicKeyCert(chain.get(0)); } } return builder; }
builder.privateKey(PkiUtil.loadPrivateKey(keyStore, keyAlias, keyPassphrase)); } catch (Exception e) { if (guessing) { builder.publicKeyCert(certChain.get(0)); builder.publicKeyCert(PkiUtil.loadCertificate(keyStore, certAlias)); PkiUtil.loadCertificates(keyStore).forEach(builder::addCert); } else { certificateAliases.forEach(it -> builder.addCert(PkiUtil.loadCertificate(keyStore, it)));
.updateWith(pemBuilder) .updateWith(keystoreBuilder) .build() .privateKey();
private Builder updateBuilder(Builder builder) { if (privateKeyStream.isSet()) { builder.privateKey(PemReader.readPrivateKey(privateKeyStream.stream(), pemKeyPassphrase)); } if (publicKeyStream.isSet()) { builder.publicKey(PemReader.readPublicKey(publicKeyStream.stream())); } if (certChainStream.isSet()) { List<X509Certificate> chain = PemReader.readCertificates(certChainStream.stream()); chain.forEach(builder::addCertChain); if (!chain.isEmpty()) { builder.publicKeyCert(chain.get(0)); } } return builder; }
/** * Updated this builder instance from configuration. * Keys configured will override existing fields in this builder, others will be left intact. * If certification path is already defined, configuration based cert-path will be added. * * @param config configuration to update this builder from * @return updated builder instance */ public Builder config(Config config) { updateWith(pemBuilder().config(config)); updateWith(keystoreBuilder().config(config)); return this; } }
/** * Load key config from config. * * @param config config instance located at keys configuration (expects "keystore-path" child) * @return KeyConfig loaded from config * @throws PkiException when keys or certificates fail to load from keystore or when misconfigured */ public static KeyConfig create(Config config) throws PkiException { try { return fullBuilder().config(config).build(); } catch (ResourceException e) { throw new PkiException("Failed to load from config", e); } }
/** * Create an instance of {@link KeyConfig} based on this builder. * * @return new key config based on a keystore */ @Override public KeyConfig build() { return toFullBuilder().build(); }
/** * Creates a new builder to configure instance. * * @return builder instance */ public static Builder fullBuilder() { return new Builder(); }
/** * Build {@link KeyConfig} based on information from PEM files only. * * @return new instance configured from this builder */ @Override public KeyConfig build() { return toFullBuilder().build(); }
/** * Updated this builder instance from configuration. * Keys configured will override existing fields in this builder, others will be left intact. * If certification path is already defined, configuration based cert-path will be added. * * @param config configuration to update this builder from * @return updated builder instance */ public Builder config(Config config) { updateWith(pemBuilder().config(config)); updateWith(keystoreBuilder().config(config)); return this; } }
/** * Load key config from config. * * @param config config instance located at keys configuration (expects "keystore-path" child) * @return KeyConfig loaded from config * @throws PkiException when keys or certificates fail to load from keystore or when misconfigured */ public static KeyConfig create(Config config) throws PkiException { try { return fullBuilder().config(config).build(); } catch (ResourceException e) { throw new PkiException("Failed to load from config", e); } }
/** * Create an instance of {@link KeyConfig} based on this builder. * * @return new key config based on a keystore */ @Override public KeyConfig build() { return toFullBuilder().build(); }
/** * Creates a new builder to configure instance. * * @return builder instance */ public static Builder fullBuilder() { return new Builder(); }
/** * Build {@link KeyConfig} based on information from PEM files only. * * @return new instance configured from this builder */ @Override public KeyConfig build() { return toFullBuilder().build(); }