use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider in project jackrabbit-oak by apache.
the class CompositeRestrictionProviderTest method testValidateUnsupportedRestriction.
@Test
public void testValidateUnsupportedRestriction() throws Exception {
RestrictionProvider rp = CompositeRestrictionProvider.newInstance(rp1, rp3);
NodeUtil aceNode = new NodeUtil(root.getTree("/")).addChild("test", NT_REP_GRANT_ACE);
NodeUtil rNode = aceNode.addChild(REP_RESTRICTIONS, NT_REP_RESTRICTIONS);
rNode.setString("unsupported", "value");
try {
rp.validateRestrictions("/test", aceNode.getTree());
fail("Validation must detect unsupported restriction");
} catch (AccessControlException e) {
// success
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider 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.spi.security.authorization.restriction.RestrictionProvider 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.spi.security.authorization.restriction.RestrictionProvider 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);
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider in project jackrabbit-oak by apache.
the class ImmutableACLTest method testHashCode.
@Test
public void testHashCode() throws Exception {
RestrictionProvider rp = getRestrictionProvider();
ACE ace1 = createEntry(false, PrivilegeConstants.JCR_VERSION_MANAGEMENT);
ACE ace2 = createEntry(true, PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_ADD_CHILD_NODES);
ACE ace2b = createEntry(true, PrivilegeConstants.REP_READ_NODES, PrivilegeConstants.REP_READ_PROPERTIES, PrivilegeConstants.JCR_ADD_CHILD_NODES);
JackrabbitAccessControlList acl = createACL(ace1, ace2);
JackrabbitAccessControlList repoAcl = createACL((String) null, ace1, ace2);
int hc = acl.hashCode();
assertTrue(hc == createACL(ace1, ace2).hashCode());
assertTrue(hc == createACL(ace1, ace2b).hashCode());
assertTrue(repoAcl.hashCode() == createACL((String) null, ace1, ace2b).hashCode());
assertFalse(hc == createACL(ace2, ace1).hashCode());
assertFalse(hc == repoAcl.hashCode());
assertFalse(hc == createEmptyACL().hashCode());
assertFalse(hc == createACL("/anotherPath", ace1, ace2).hashCode());
assertFalse(hc == new TestACL("/anotherPath", rp, getNamePathMapper(), ace1, ace2).hashCode());
assertFalse(hc == new TestACL("/anotherPath", rp, getNamePathMapper(), ace1, ace2).hashCode());
assertFalse(hc == new TestACL("/anotherPath", rp, getNamePathMapper()).hashCode());
assertFalse(hc == new TestACL(getTestPath(), rp, getNamePathMapper(), ace1, ace2).hashCode());
}
Aggregations