Search in sources :

Example 1 with GroupProvider

use of io.trino.spi.security.GroupProvider in project trino by trinodb.

the class TestFileGroupProvider method testGroupProviderFactory.

@Test
public void testGroupProviderFactory() throws Exception {
    File groupFile = new File(Resources.getResource("group.txt").toURI().getPath());
    GroupProvider groupProvider = new FileGroupProviderFactory().create(ImmutableMap.of("file.group-file", groupFile.getAbsolutePath()));
    assertGroupProvider(groupProvider);
}
Also used : GroupProvider(io.trino.spi.security.GroupProvider) File(java.io.File) Test(org.testng.annotations.Test)

Example 2 with GroupProvider

use of io.trino.spi.security.GroupProvider in project trino by trinodb.

the class GroupProviderManager method setConfiguredGroupProvider.

private void setConfiguredGroupProvider(String name, Map<String, String> properties) {
    requireNonNull(name, "name is null");
    requireNonNull(properties, "properties is null");
    log.info("-- Loading group provider %s --", name);
    GroupProviderFactory factory = groupProviderFactories.get(name);
    checkState(factory != null, "Group provider %s is not registered", name);
    GroupProvider groupProvider;
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(factory.getClass().getClassLoader())) {
        groupProvider = factory.create(ImmutableMap.copyOf(properties));
    }
    checkState(configuredGroupProvider.compareAndSet(Optional.empty(), Optional.of(groupProvider)), "groupProvider is already set");
    log.info("-- Loaded group provider %s --", name);
}
Also used : GroupProvider(io.trino.spi.security.GroupProvider) ThreadContextClassLoader(io.trino.spi.classloader.ThreadContextClassLoader) GroupProviderFactory(io.trino.spi.security.GroupProviderFactory)

Example 3 with GroupProvider

use of io.trino.spi.security.GroupProvider in project trino by trinodb.

the class TestFileGroupProvider method test.

@Test
public void test() throws Exception {
    File groupFile = new File(Resources.getResource("group.txt").toURI().getPath());
    GroupProvider groupProvider = new FileGroupProvider(new FileGroupConfig().setGroupFile(groupFile));
    assertGroupProvider(groupProvider);
}
Also used : GroupProvider(io.trino.spi.security.GroupProvider) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

GroupProvider (io.trino.spi.security.GroupProvider)3 File (java.io.File)2 Test (org.testng.annotations.Test)2 ThreadContextClassLoader (io.trino.spi.classloader.ThreadContextClassLoader)1 GroupProviderFactory (io.trino.spi.security.GroupProviderFactory)1