Search in sources :

Example 1 with SecurityProvider

use of io.helidon.security.spi.SecurityProvider in project helidon by oracle.

the class CompositePolicyConfigTest method initClass.

@BeforeAll
public static void initClass() {
    Config config = Config.create();
    security = Security.create(config.get("security"));
    PathBasedProvider pbp = new PathBasedProvider();
    ResourceBasedProvider rbp = new ResourceBasedProvider();
    psp = CompositeProviderSelectionPolicy.create(config.get("unit.test")).apply(new ProviderSelectionPolicy.Providers() {

        @Override
        public <T extends SecurityProvider> List<NamedProvider<T>> getProviders(Class<T> providerType) {
            List<NamedProvider<T>> result = new ArrayList<>();
            result.add(new NamedProvider<>("first", providerType.cast(pbp)));
            result.add(new NamedProvider<>("second", providerType.cast(rbp)));
            return result;
        }
    });
}
Also used : Config(io.helidon.config.Config) PathBasedProvider(io.helidon.security.providers.PathBasedProvider) SecurityProvider(io.helidon.security.spi.SecurityProvider) ArrayList(java.util.ArrayList) ResourceBasedProvider(io.helidon.security.providers.ResourceBasedProvider) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with SecurityProvider

use of io.helidon.security.spi.SecurityProvider in project helidon by oracle.

the class CompositePolicyBuilderTest method initClass.

@BeforeAll
public static void initClass() {
    PathBasedProvider pbp = new PathBasedProvider();
    ResourceBasedProvider rbp = new ResourceBasedProvider();
    psp = CompositeProviderSelectionPolicy.builder().addOutboundProvider("first").addOutboundProvider("second").addAuthenticationProvider("first").addAuthenticationProvider("second").addAuthorizationProvider("first", CompositeProviderFlag.OPTIONAL).addAuthorizationProvider("second").build().apply(new ProviderSelectionPolicy.Providers() {

        @Override
        public <T extends SecurityProvider> List<NamedProvider<T>> getProviders(Class<T> providerType) {
            List<NamedProvider<T>> result = new ArrayList<>();
            result.add(new NamedProvider<>("first", providerType.cast(pbp)));
            result.add(new NamedProvider<>("second", providerType.cast(rbp)));
            return result;
        }
    });
    security = Security.builder().addProvider(new PathBasedProvider(), "first").addProvider(new ResourceBasedProvider(), "second").providerSelectionPolicy(CompositeProviderSelectionPolicy.builder().name("composite").isDefault(true).addAuthenticationProvider("first", CompositeProviderFlag.REQUIRED).addAuthenticationProvider("second").addOutboundProvider("first").addOutboundProvider("second").addAuthorizationProvider("first").addAuthorizationProvider("second").build()).build();
}
Also used : PathBasedProvider(io.helidon.security.providers.PathBasedProvider) SecurityProvider(io.helidon.security.spi.SecurityProvider) ArrayList(java.util.ArrayList) ResourceBasedProvider(io.helidon.security.providers.ResourceBasedProvider) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

PathBasedProvider (io.helidon.security.providers.PathBasedProvider)2 ResourceBasedProvider (io.helidon.security.providers.ResourceBasedProvider)2 SecurityProvider (io.helidon.security.spi.SecurityProvider)2 ArrayList (java.util.ArrayList)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 Config (io.helidon.config.Config)1