use of org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration in project jackrabbit-oak by apache.
the class InternalSecurityProviderTest method testSetAuthorizationConfiguration.
@Test
public void testSetAuthorizationConfiguration() {
AuthorizationConfiguration ac = Mockito.mock(AuthorizationConfiguration.class);
when(ac.getParameters()).thenReturn(PARAMS);
securityProvider.setAuthorizationConfiguration(ac);
assertSame(ac, securityProvider.getConfiguration(AuthorizationConfiguration.class));
for (SecurityConfiguration sc : securityProvider.getConfigurations()) {
if (sc instanceof AuthorizationConfiguration) {
assertSame(ac, sc);
}
}
assertEquals(PARAMS, securityProvider.getParameters(AuthorizationConfiguration.NAME));
}
use of org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration 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.spi.security.authorization.AuthorizationConfiguration 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.spi.security.authorization.AuthorizationConfiguration in project jackrabbit-oak by apache.
the class AbstractCompositeProviderTest method createPermissionProvider.
CompositePermissionProvider createPermissionProvider(Set<Principal> principals) {
String workspaceName = root.getContentSession().getWorkspaceName();
AuthorizationConfiguration config = getConfig(AuthorizationConfiguration.class);
return new CompositePermissionProvider(root, getAggregatedProviders(workspaceName, config, principals), config.getContext(), CompositionType.AND, getRootProvider());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration in project jackrabbit-oak by apache.
the class CompositeAuthorizationConfigurationTest method getCompositeConfiguration.
private CompositeAuthorizationConfiguration getCompositeConfiguration(AuthorizationConfiguration... entries) {
CompositeAuthorizationConfiguration compositeConfiguration = new CompositeAuthorizationConfiguration(getSecurityProvider());
compositeConfiguration.setRootProvider(getRootProvider());
compositeConfiguration.setTreeProvider(getTreeProvider());
for (AuthorizationConfiguration ac : entries) {
compositeConfiguration.addConfiguration(ac);
}
return compositeConfiguration;
}
Aggregations