Search in sources :

Example 1 with CertificateAuthenticator

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);
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) CertificateAuthenticator(io.trino.spi.security.CertificateAuthenticator) File(java.io.File) ThreadContextClassLoader(io.trino.spi.classloader.ThreadContextClassLoader) CertificateAuthenticatorFactory(io.trino.spi.security.CertificateAuthenticatorFactory)

Aggregations

ThreadContextClassLoader (io.trino.spi.classloader.ThreadContextClassLoader)1 CertificateAuthenticator (io.trino.spi.security.CertificateAuthenticator)1 CertificateAuthenticatorFactory (io.trino.spi.security.CertificateAuthenticatorFactory)1 File (java.io.File)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1