use of io.trino.spi.security.CertificateAuthenticator in project trino by trinodb.
the class CertificateAuthenticatorManager method loadCertificateAuthenticator.
public void loadCertificateAuthenticator() throws Exception {
if (!required.get()) {
return;
}
File configFile = CONFIG_FILE.getAbsoluteFile();
if (!configFile.exists()) {
useDefaultAuthenticator();
return;
}
Map<String, String> properties = new HashMap<>(loadPropertiesFrom(configFile.getPath()));
String name = properties.remove(NAME_PROPERTY);
checkState(!isNullOrEmpty(name), "Certificate authenticator configuration %s does not contain '%s'", configFile, NAME_PROPERTY);
log.info("-- Loading certificate authenticator --");
CertificateAuthenticatorFactory factory = factories.get(name);
checkState(factory != null, "Certificate authenticator '%s' is not registered", name);
CertificateAuthenticator authenticator;
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(factory.getClass().getClassLoader())) {
authenticator = factory.create(ImmutableMap.copyOf(properties));
}
this.authenticator.set(requireNonNull(authenticator, "authenticator is null"));
log.info("-- Loaded certificate authenticator %s --", name);
}
Aggregations