Skip to content

Commit

Permalink
Merge pull request quarkusio#40985 from cescoffier/tls-remove-lambdas
Browse files Browse the repository at this point in the history
Remove the usage of lambdas in the TLS registry code
  • Loading branch information
geoand authored Jun 5, 2024
2 parents 59fbe75 + 357a262 commit 73f14f6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@ public void register(String name, TlsConfiguration configuration) {
}

public Supplier<TlsConfigurationRegistry> getSupplier() {
return () -> this;
return new Supplier<TlsConfigurationRegistry>() {
@Override
public TlsConfigurationRegistry get() {
return CertificateRecorder.this;
}
};
}

public void register(String name, Supplier<TlsConfiguration> supplier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import javax.net.ssl.TrustManagerFactory;

import io.quarkus.tls.TlsConfiguration;
import io.quarkus.tls.runtime.config.KeyStoreConfig;
import io.quarkus.tls.runtime.config.TlsBucketConfig;
import io.quarkus.tls.runtime.config.TlsConfigUtils;
import io.vertx.core.Vertx;
Expand Down Expand Up @@ -138,7 +137,10 @@ public Optional<String> getHostnameVerificationAlgorithm() {

@Override
public boolean usesSni() {
return config.keyStore().map(KeyStoreConfig::sni).orElse(false);
if (config.keyStore().isPresent()) {
return config.keyStore().get().sni();
}
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ private static JksOptions toOptions(JKSKeyStoreConfig config,
+ "' - the key store password is not set and cannot be retrieved from the credential provider.");
}
options.setPassword(p);
config.alias().ifPresent(options::setAlias);
if (config.alias().isPresent()) {
options.setAlias(config.alias().get());
}
String ap = CredentialProviders.getAliasPassword(config.aliasPassword(), keyStoreCredentialProviderConfig)
.orElse(null);
options.setAliasPassword(ap);
Expand All @@ -83,7 +85,9 @@ private static JksOptions toOptions(JKSTrustStoreConfig config,
+ "' - the trust store password is not set and cannot be retrieved from the credential provider.");
}
options.setPassword(password);
config.alias().ifPresent(options::setAlias);
if (config.alias().isPresent()) {
options.setAlias(config.alias().get());
}
} catch (UncheckedIOException e) {
throw new IllegalStateException("Invalid JKS trust store configuration for certificate '" + name
+ "' - cannot read the trust store file '" + config.path() + "'", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ private static PfxOptions toOptions(P12KeyStoreConfig config, KeyStoreCredential
+ "' - the key store password is not set and cannot be retrieved from the credential provider.");
}
options.setPassword(password);
config.alias().ifPresent(options::setAlias);
if (config.alias().isPresent()) {
options.setAlias(config.alias().get());
}
String ap = CredentialProviders.getAliasPassword(config.aliasPassword(), pc).orElse(null);
options.setAliasPassword(ap);
} catch (UncheckedIOException e) {
Expand All @@ -80,7 +82,9 @@ private static PfxOptions toOptions(P12TrustStoreConfig config, TrustStoreCreden
+ "' - the trust store password is not set and cannot be retrieved from the credential provider.");
}
options.setPassword(password);
config.alias().ifPresent(options::setAlias);
if (config.alias().isPresent()) {
options.setAlias(config.alias().get());
}
} catch (UncheckedIOException e) {
throw new IllegalStateException("Invalid P12 trust store configuration for certificate '" + name
+ "' - cannot read the trust store file '" + config.path() + "'", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ protected TrustManager[] engineGetTrustManagers() {

@Override
public Function<String, TrustManager[]> trustManagerMapper(Vertx vertx) {
return name -> new TrustManager[] { TRUST_ALL_MANAGER };
return new Function<String, TrustManager[]>() {
@Override
public TrustManager[] apply(String name) {
return new TrustManager[] { TRUST_ALL_MANAGER };
}
};
}
}

0 comments on commit 73f14f6

Please sign in to comment.