Search in sources :

Example 1 with WhiteboardRestrictionProvider

use of org.apache.jackrabbit.oak.security.authorization.restriction.WhiteboardRestrictionProvider in project jackrabbit-oak by apache.

the class SecurityProviderRegistrationTest method testActivateWithMixedServicePiAnddOakServiceName.

@Test
public void testActivateWithMixedServicePiAnddOakServiceName() {
    registration.activate(context.bundleContext(), configWithRequiredServiceIds("rpId", "authorizationId"));
    RestrictionProvider mockRp = Mockito.mock(RestrictionProvider.class);
    registration.bindRestrictionProvider(mockRp, ImmutableMap.of(Constants.SERVICE_PID, "rpId"));
    registration.bindAuthorizationConfiguration(new AuthorizationConfigurationImpl(), ImmutableMap.of(RegistrationConstants.OAK_SECURITY_NAME, "authorizationId"));
    SecurityProvider service = context.getService(SecurityProvider.class);
    RestrictionProvider rp = service.getConfiguration(AuthorizationConfiguration.class).getRestrictionProvider();
    assertTrue(rp instanceof WhiteboardRestrictionProvider);
}
Also used : WhiteboardRestrictionProvider(org.apache.jackrabbit.oak.security.authorization.restriction.WhiteboardRestrictionProvider) CompositeAuthorizationConfiguration(org.apache.jackrabbit.oak.security.authorization.composite.CompositeAuthorizationConfiguration) AuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration) RestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider) WhiteboardRestrictionProvider(org.apache.jackrabbit.oak.security.authorization.restriction.WhiteboardRestrictionProvider) AuthorizationConfigurationImpl(org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 2 with WhiteboardRestrictionProvider

use of org.apache.jackrabbit.oak.security.authorization.restriction.WhiteboardRestrictionProvider in project jackrabbit-oak by apache.

the class SecurityProviderRegistrationTest method testModified.

@Test
public void testModified() {
    registration.activate(context.bundleContext(), configWithRequiredServiceIds("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(configWithRequiredServiceIds("authorizationId"));
    SecurityProvider service = context.getService(SecurityProvider.class);
    assertNotNull(service);
    RestrictionProvider rp = service.getConfiguration(AuthorizationConfiguration.class).getRestrictionProvider();
    assertTrue(rp instanceof WhiteboardRestrictionProvider);
}
Also used : WhiteboardRestrictionProvider(org.apache.jackrabbit.oak.security.authorization.restriction.WhiteboardRestrictionProvider) CompositeAuthorizationConfiguration(org.apache.jackrabbit.oak.security.authorization.composite.CompositeAuthorizationConfiguration) AuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration) AuthorizationConfigurationImpl(org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl) RestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider) WhiteboardRestrictionProvider(org.apache.jackrabbit.oak.security.authorization.restriction.WhiteboardRestrictionProvider) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 3 with WhiteboardRestrictionProvider

use of org.apache.jackrabbit.oak.security.authorization.restriction.WhiteboardRestrictionProvider in project jackrabbit-oak by apache.

the class SecurityProviderRegistrationTest method testBindRestrictionProviderWithAuthorizationConfig.

@Test
public void testBindRestrictionProviderWithAuthorizationConfig() {
    registration.activate(context.bundleContext(), configWithRequiredServiceIds("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);
}
Also used : WhiteboardRestrictionProvider(org.apache.jackrabbit.oak.security.authorization.restriction.WhiteboardRestrictionProvider) CompositeAuthorizationConfiguration(org.apache.jackrabbit.oak.security.authorization.composite.CompositeAuthorizationConfiguration) AuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration) RestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider) WhiteboardRestrictionProvider(org.apache.jackrabbit.oak.security.authorization.restriction.WhiteboardRestrictionProvider) AuthorizationConfigurationImpl(org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)3 AuthorizationConfigurationImpl (org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl)3 CompositeAuthorizationConfiguration (org.apache.jackrabbit.oak.security.authorization.composite.CompositeAuthorizationConfiguration)3 WhiteboardRestrictionProvider (org.apache.jackrabbit.oak.security.authorization.restriction.WhiteboardRestrictionProvider)3 SecurityProvider (org.apache.jackrabbit.oak.spi.security.SecurityProvider)3 AuthorizationConfiguration (org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration)3 RestrictionProvider (org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider)3 Test (org.junit.Test)3