Search in sources :

Example 1 with UserConfigurationImpl

use of org.apache.jackrabbit.oak.security.user.UserConfigurationImpl in project jackrabbit-oak by apache.

the class PrincipalConfigurationImplTest method testGetPrincipalProvider4.

@Test
public void testGetPrincipalProvider4() {
    PrincipalConfigurationImpl pc3 = new PrincipalConfigurationImpl();
    final SecurityProvider sp = new SecurityProvider() {

        @Nonnull
        @Override
        public ConfigurationParameters getParameters(@Nullable String name) {
            return ConfigurationParameters.EMPTY;
        }

        @Nonnull
        @Override
        public Iterable<? extends SecurityConfiguration> getConfigurations() {
            return ImmutableList.of();
        }

        @Nonnull
        @Override
        public <T> T getConfiguration(@Nonnull Class<T> configClass) {
            if (configClass.equals(UserConfiguration.class)) {
                return (T) new UserConfigurationImpl(this) {

                    @Nullable
                    @Override
                    public PrincipalProvider getUserPrincipalProvider(@Nonnull Root root, @Nonnull NamePathMapper namePathMapper) {
                        return null;
                    }
                };
            } else {
                throw new IllegalArgumentException();
            }
        }
    };
    pc3.setSecurityProvider(sp);
    PrincipalProvider pp = pc3.getPrincipalProvider(root, NamePathMapper.DEFAULT);
    assertTrue(pp instanceof PrincipalProviderImpl);
}
Also used : PrincipalProvider(org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider) Root(org.apache.jackrabbit.oak.api.Root) Nonnull(javax.annotation.Nonnull) NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) UserConfigurationImpl(org.apache.jackrabbit.oak.security.user.UserConfigurationImpl) Nullable(javax.annotation.Nullable) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)1 Root (org.apache.jackrabbit.oak.api.Root)1 NamePathMapper (org.apache.jackrabbit.oak.namepath.NamePathMapper)1 UserConfigurationImpl (org.apache.jackrabbit.oak.security.user.UserConfigurationImpl)1 SecurityProvider (org.apache.jackrabbit.oak.spi.security.SecurityProvider)1 PrincipalProvider (org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider)1 Test (org.junit.Test)1