use of org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl 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);
}
use of org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl in project jackrabbit-oak by apache.
the class SecurityProviderRegistrationTest method testModified.
@Test
public void testModified() {
registration.activate(context.bundleContext(), requiredServiceIdMap("rpId", "authorizationId"));
registration.bindAuthorizationConfiguration(new AuthorizationConfigurationImpl(), ImmutableMap.of(Constants.SERVICE_PID, "authorizationId"));
assertNull(context.getService(SecurityProvider.class));
// modify requiredServiceIds by removing the rpId from the mandatory services
// => should re-register the security provider
registration.modified(requiredServiceIdMap("authorizationId"));
SecurityProvider service = context.getService(SecurityProvider.class);
assertNotNull(service);
RestrictionProvider rp = service.getConfiguration(AuthorizationConfiguration.class).getRestrictionProvider();
assertTrue(rp instanceof WhiteboardRestrictionProvider);
}
use of org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl in project jackrabbit-oak by apache.
the class SecurityProviderRegistrationTest method testModifiedPreconditionStillSatisfied.
@Test
public void testModifiedPreconditionStillSatisfied() {
registration.activate(context.bundleContext(), requiredServiceIdMap("rpId", "authorizationId"));
RestrictionProvider mockRp = Mockito.mock(RestrictionProvider.class);
registration.bindRestrictionProvider(mockRp, ImmutableMap.of(Constants.SERVICE_PID, "rpId"));
registration.bindAuthorizationConfiguration(new AuthorizationConfigurationImpl(), ImmutableMap.of(Constants.SERVICE_PID, "authorizationId"));
SecurityProvider service = context.getService(SecurityProvider.class);
assertNotNull(service);
registration.modified(requiredServiceIdMap("authorizationId"));
SecurityProvider service2 = context.getService(SecurityProvider.class);
assertSame(service, service2);
}
use of org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl in project jackrabbit-oak by apache.
the class SecurityProviderRegistrationTest method testBindRestrictionProviderWithAuthorizationConfig.
@Test
public void testBindRestrictionProviderWithAuthorizationConfig() {
registration.activate(context.bundleContext(), requiredServiceIdMap("rpId", "authorizationId"));
RestrictionProvider mockRp = Mockito.mock(RestrictionProvider.class);
registration.bindRestrictionProvider(mockRp, ImmutableMap.of(Constants.SERVICE_PID, "rpId"));
registration.bindAuthorizationConfiguration(new AuthorizationConfigurationImpl(), ImmutableMap.of(Constants.SERVICE_PID, "authorizationId"));
SecurityProvider service = context.getService(SecurityProvider.class);
RestrictionProvider rp = service.getConfiguration(AuthorizationConfiguration.class).getRestrictionProvider();
assertTrue(rp instanceof WhiteboardRestrictionProvider);
}
Aggregations