Search in sources :

Example 1 with OpenAuthorizationConfiguration

use of org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration in project jackrabbit-oak by apache.

the class CompositeAuthorizationConfigurationTest method testMultipleGetPermissionProvider3.

@Test
public void testMultipleGetPermissionProvider3() {
    CompositeAuthorizationConfiguration cc = getCompositeConfiguration(new OpenAuthorizationConfiguration(), new OpenAuthorizationConfiguration());
    PermissionProvider pp = cc.getPermissionProvider(root, root.getContentSession().getWorkspaceName(), Collections.<Principal>emptySet());
    assertFalse(pp instanceof CompositePermissionProvider);
    assertSame(EmptyPermissionProvider.getInstance(), pp);
}
Also used : EmptyPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) OpenAuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 2 with OpenAuthorizationConfiguration

use of org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration in project jackrabbit-oak by apache.

the class MutableRootTest method before.

@Before
public void before() {
    SecurityProvider sp = new OpenSecurityProvider() {

        @Nonnull
        @Override
        public <T> T getConfiguration(@Nonnull Class<T> configClass) {
            if (AuthorizationConfiguration.class == configClass) {
                return (T) new OpenAuthorizationConfiguration() {

                    @Nonnull
                    @Override
                    public PermissionProvider getPermissionProvider(@Nonnull Root root, @Nonnull String workspaceName, @Nonnull Set<Principal> principals) {
                        return permissionProvider;
                    }
                };
            } else {
                return super.getConfiguration(configClass);
            }
        }
    };
    ContentSessionImpl cs = Mockito.mock(ContentSessionImpl.class);
    when(cs.toString()).thenReturn("contentSession");
    when(cs.getAuthInfo()).thenReturn(AuthInfoImpl.EMPTY);
    when(cs.getWorkspaceName()).thenReturn("default");
    root = new MutableRoot(store, new EmptyHook(), "default", new Subject(), sp, null, null, cs);
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) Nonnull(javax.annotation.Nonnull) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) Subject(javax.security.auth.Subject) OpenAuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) EmptyHook(org.apache.jackrabbit.oak.spi.commit.EmptyHook) Principal(java.security.Principal) Before(org.junit.Before)

Example 3 with OpenAuthorizationConfiguration

use of org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration in project jackrabbit-oak by apache.

the class CompositeAuthorizationConfigurationTest method testOnlyEmptyRestrictionProvider.

@Test
public void testOnlyEmptyRestrictionProvider() {
    AuthorizationConfiguration ac = new OpenAuthorizationConfiguration() {

        @Nonnull
        @Override
        public RestrictionProvider getRestrictionProvider() {
            return RestrictionProvider.EMPTY;
        }
    };
    CompositeAuthorizationConfiguration cc = getCompositeConfiguration(ac, ac);
    RestrictionProvider rp = cc.getRestrictionProvider();
    assertFalse(rp instanceof CompositeRestrictionProvider);
    assertSame(RestrictionProvider.EMPTY, rp);
}
Also used : AuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration) OpenAuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration) RestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider) CompositeRestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositeRestrictionProvider) CompositeRestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositeRestrictionProvider) OpenAuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 4 with OpenAuthorizationConfiguration

use of org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration in project jackrabbit-oak by apache.

the class CompositeAuthorizationConfigurationTest method testMultipleGetPermissionProvider.

@Test
public void testMultipleGetPermissionProvider() {
    CompositeAuthorizationConfiguration cc = getCompositeConfiguration(new OpenAuthorizationConfiguration(), new AuthorizationConfigurationImpl(getSecurityProvider()));
    PermissionProvider pp = cc.getPermissionProvider(root, root.getContentSession().getWorkspaceName(), Collections.<Principal>emptySet());
    assertFalse(pp instanceof CompositePermissionProvider);
}
Also used : AuthorizationConfigurationImpl(org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl) EmptyPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) OpenAuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 5 with OpenAuthorizationConfiguration

use of org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration in project jackrabbit-oak by apache.

the class CompositeAuthorizationConfigurationTest method testMultipleWithEmptyRestrictionProvider.

@Test
public void testMultipleWithEmptyRestrictionProvider() {
    CompositeAuthorizationConfiguration cc = getCompositeConfiguration(new AuthorizationConfigurationImpl(getSecurityProvider()), new OpenAuthorizationConfiguration() {

        @Nonnull
        @Override
        public RestrictionProvider getRestrictionProvider() {
            return RestrictionProvider.EMPTY;
        }
    });
    RestrictionProvider rp = cc.getRestrictionProvider();
    assertFalse(rp instanceof CompositeRestrictionProvider);
    assertNotSame(RestrictionProvider.EMPTY, rp);
}
Also used : Nonnull(javax.annotation.Nonnull) AuthorizationConfigurationImpl(org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl) RestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider) CompositeRestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositeRestrictionProvider) CompositeRestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositeRestrictionProvider) OpenAuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

OpenAuthorizationConfiguration (org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration)5 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)4 Test (org.junit.Test)4 PermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider)3 Nonnull (javax.annotation.Nonnull)2 AuthorizationConfigurationImpl (org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl)2 EmptyPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider)2 CompositeRestrictionProvider (org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositeRestrictionProvider)2 RestrictionProvider (org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider)2 Principal (java.security.Principal)1 Subject (javax.security.auth.Subject)1 Root (org.apache.jackrabbit.oak.api.Root)1 EmptyHook (org.apache.jackrabbit.oak.spi.commit.EmptyHook)1 OpenSecurityProvider (org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider)1 SecurityProvider (org.apache.jackrabbit.oak.spi.security.SecurityProvider)1 AuthorizationConfiguration (org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration)1 Before (org.junit.Before)1