use of org.apache.jackrabbit.oak.spi.security.SecurityProvider in project jackrabbit-oak by apache.
the class SecurityProviderRegistrationTest method testDeactivate.
@Test
public void testDeactivate() throws Exception {
registration.activate(context.bundleContext(), requiredServiceIdMap("nodeName"));
AuthorizableNodeName mock = Mockito.mock(AuthorizableNodeName.class);
registration.bindAuthorizableNodeName(mock, ImmutableMap.of(Constants.SERVICE_PID, "nodeName"));
SecurityProvider service = context.getService(SecurityProvider.class);
assertNotNull(service);
registration.deactivate();
// provider must have been unregistered
assertNull(context.getService(SecurityProvider.class));
}
use of org.apache.jackrabbit.oak.spi.security.SecurityProvider in project jackrabbit-oak by apache.
the class SecurityProviderRegistrationTest method testBindOptionalCandidateAfterRegistration.
@Test
public void testBindOptionalCandidateAfterRegistration() {
registration.activate(context.bundleContext(), requiredServiceIdMap("serviceId"));
registration.bindTokenConfiguration(mockConfiguration(TokenConfiguration.class), ImmutableMap.of(Constants.SERVICE_PID, "serviceId"));
SecurityProvider service = context.getService(SecurityProvider.class);
assertNotNull(service);
// binding another (optional configuration) must not result in re-registration of the service
registration.bindPrincipalConfiguration(mockConfiguration(PrincipalConfiguration.class), ImmutableMap.of(Constants.SERVICE_PID, "optionalService"));
SecurityProvider service2 = context.getService(SecurityProvider.class);
assertSame(service, service2);
}
use of org.apache.jackrabbit.oak.spi.security.SecurityProvider in project jackrabbit-oak by apache.
the class SecurityProviderRegistrationTest method testUnbindOptionalCandidateAfterRegistration.
@Test
public void testUnbindOptionalCandidateAfterRegistration() {
registration.activate(context.bundleContext(), requiredServiceIdMap("serviceId"));
UserAuthenticationFactory uaf = Mockito.mock(UserAuthenticationFactory.class);
Map<String, Object> properties = ImmutableMap.of(Constants.SERVICE_PID, "notMandatory");
registration.bindUserAuthenticationFactory(uaf, properties);
assertNull(context.getService(SecurityProvider.class));
registration.bindAuthorizableActionProvider(Mockito.mock(AuthorizableActionProvider.class), ImmutableMap.of(Constants.SERVICE_PID, "serviceId"));
SecurityProvider service = context.getService(SecurityProvider.class);
assertNotNull(service);
// unbinding an optional configuration must not result in unrregistration of the service
registration.unbindUserAuthenticationFactory(uaf, properties);
SecurityProvider service2 = context.getService(SecurityProvider.class);
assertSame(service, service2);
}
use of org.apache.jackrabbit.oak.spi.security.SecurityProvider in project jackrabbit-oak by apache.
the class SecurityProviderRegistrationTest method testBindRestrictionProviderWithoutAuthorizationConfig.
@Test
public void testBindRestrictionProviderWithoutAuthorizationConfig() {
registration.activate(context.bundleContext(), requiredServiceIdMap("serviceId"));
RestrictionProvider mockRp = Mockito.mock(RestrictionProvider.class);
registration.bindRestrictionProvider(mockRp, ImmutableMap.of(Constants.SERVICE_PID, "serviceId"));
SecurityProvider service = context.getService(SecurityProvider.class);
assertNotNull(service);
AuthorizationConfiguration ac = service.getConfiguration(AuthorizationConfiguration.class);
assertTrue(ac instanceof CompositeAuthorizationConfiguration);
// empty composite configuration => empty rp
RestrictionProvider rp = ac.getRestrictionProvider();
assertSame(RestrictionProvider.EMPTY, rp);
}
use of org.apache.jackrabbit.oak.spi.security.SecurityProvider in project jackrabbit-oak by apache.
the class SecurityProviderRegistrationTest method testActivateWithRequiredId.
@Test
public void testActivateWithRequiredId() {
registration.activate(context.bundleContext(), requiredServiceIdMap("serviceId"));
SecurityProvider service = context.getService(SecurityProvider.class);
assertNull(service);
registration.bindAuthorizableNodeName(Mockito.mock(AuthorizableNodeName.class), ImmutableMap.of(Constants.SERVICE_PID, "serviceId"));
service = context.getService(SecurityProvider.class);
assertNotNull(service);
}
Aggregations