use of org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl in project jackrabbit-oak by apache.
the class SecurityProviderRegistrationTest method testAuthorizationContext.
@Test
public void testAuthorizationContext() throws Exception {
Tree t = root.getTree("/");
Field f = registration.getClass().getDeclaredField("authorizationConfiguration");
f.setAccessible(true);
AuthorizationConfiguration ac = new AuthorizationConfigurationImpl();
registration.bindAuthorizationConfiguration(ac, PROPS);
CompositeAuthorizationConfiguration cac = (CompositeAuthorizationConfiguration) f.get(registration);
Context ctx = cac.getContext();
assertContext(ctx, 1, t, false);
AuthorizationConfiguration ac1 = mockConfiguration(AuthorizationConfiguration.class);
registration.bindAuthorizationConfiguration(ac1, PROPS);
cac = (CompositeAuthorizationConfiguration) f.get(registration);
ctx = cac.getContext();
assertContext(ctx, 2, t, true);
AuthorizationConfiguration ac2 = mockConfiguration(AuthorizationConfiguration.class);
registration.bindAuthorizationConfiguration(ac2, PROPS);
cac = (CompositeAuthorizationConfiguration) f.get(registration);
ctx = cac.getContext();
assertContext(ctx, 3, t, true);
// unbind again:
registration.unbindAuthorizationConfiguration(ac1, PROPS);
cac = (CompositeAuthorizationConfiguration) f.get(registration);
ctx = cac.getContext();
assertContext(ctx, 2, t, true);
registration.unbindAuthorizationConfiguration(ac, PROPS);
cac = (CompositeAuthorizationConfiguration) f.get(registration);
ctx = cac.getContext();
assertContext(ctx, 1, t, true);
registration.unbindAuthorizationConfiguration(ac2, PROPS);
cac = (CompositeAuthorizationConfiguration) f.get(registration);
ctx = cac.getContext();
assertContext(ctx, 0, t, false);
}
use of org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl in project jackrabbit-oak by apache.
the class SecurityProviderRegistrationTest method testAuthorizationRanking.
@Test
public void testAuthorizationRanking() throws Exception {
Field f = registration.getClass().getDeclaredField("authorizationConfiguration");
f.setAccessible(true);
AuthorizationConfiguration testAc = mockConfiguration(AuthorizationConfiguration.class);
registration.bindAuthorizationConfiguration(testAc, ConfigurationParameters.EMPTY);
AuthorizationConfigurationImpl ac = new AuthorizationConfigurationImpl();
ac.setParameters(ConfigurationParameters.of(CompositeConfiguration.PARAM_RANKING, 500));
registration.bindAuthorizationConfiguration(ac, PROPS);
AuthorizationConfiguration testAc2 = mockConfiguration(AuthorizationConfiguration.class);
Map<String, Object> props = ImmutableMap.<String, Object>of(Constants.SERVICE_RANKING, new Integer(100));
registration.bindAuthorizationConfiguration(testAc2, props);
CompositeAuthorizationConfiguration cac = (CompositeAuthorizationConfiguration) f.get(registration);
List<AuthorizationConfiguration> list = cac.getConfigurations();
assertEquals(3, list.size());
assertSame(ac, list.get(0));
assertSame(testAc2, list.get(1));
assertSame(testAc, list.get(2));
}
use of org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl in project jackrabbit-oak by apache.
the class SecurityProviderRegistrationTest method testActivate.
@Test
public void testActivate() {
registration.activate(context.bundleContext(), requiredServiceIdMap("serviceA", "serviceB"));
SecurityProvider service = context.getService(SecurityProvider.class);
assertNull(service);
RestrictionProvider mockRp = Mockito.mock(RestrictionProvider.class);
registration.bindRestrictionProvider(mockRp, ImmutableMap.of(Constants.SERVICE_PID, "serviceA"));
service = context.getService(SecurityProvider.class);
assertNull(service);
registration.bindAuthorizationConfiguration(new AuthorizationConfigurationImpl(), ImmutableMap.of(Constants.SERVICE_PID, "serviceB"));
service = context.getService(SecurityProvider.class);
assertNotNull(service);
}
use of org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl in project jackrabbit-oak by apache.
the class CompositeAuthorizationConfigurationTest method testSingleGetAccessControlManager.
@Test
public void testSingleGetAccessControlManager() {
CompositeAuthorizationConfiguration cc = getCompositeConfiguration(new AuthorizationConfigurationImpl(getSecurityProvider()));
AccessControlManager accessControlManager = cc.getAccessControlManager(root, NamePathMapper.DEFAULT);
assertFalse(accessControlManager instanceof CompositeAccessControlManager);
}
use of org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl in project jackrabbit-oak by apache.
the class CompositeAuthorizationConfigurationTest method testMultipleGetPermissionProvider2.
@Test
public void testMultipleGetPermissionProvider2() {
CompositeAuthorizationConfiguration cc = getCompositeConfiguration(new AuthorizationConfigurationImpl(getSecurityProvider()), new AuthorizationConfigurationImpl(getSecurityProvider()));
PermissionProvider pp = cc.getPermissionProvider(root, root.getContentSession().getWorkspaceName(), Collections.<Principal>emptySet());
assertTrue(pp instanceof CompositePermissionProvider);
}
Aggregations