use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider in project jackrabbit-oak by apache.
the class PrincipalConfigurationImplTest method testGetPrincipalProvider2.
@Test
public void testGetPrincipalProvider2() {
pc1.setSecurityProvider(getSecurityProvider());
PrincipalProvider pp = pc1.getPrincipalProvider(root, NamePathMapper.DEFAULT);
assertNotNull(pp);
assertEquals(getUserConfiguration().getUserPrincipalProvider(root, NamePathMapper.DEFAULT).getClass(), pp.getClass());
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider in project jackrabbit-oak by apache.
the class PrincipalConfigurationImplTest method testGetPrincipalProvider3.
@Test
public void testGetPrincipalProvider3() {
PrincipalProvider pp = pc2.getPrincipalProvider(root, NamePathMapper.DEFAULT);
assertNotNull(pp);
assertEquals(getUserConfiguration().getUserPrincipalProvider(root, NamePathMapper.DEFAULT).getClass(), pp.getClass());
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider in project jackrabbit-oak by apache.
the class PrincipalConfigurationImplTest method testGetPrincipalProvider4.
@Test
public void testGetPrincipalProvider4() {
PrincipalConfigurationImpl pc3 = new PrincipalConfigurationImpl();
final SecurityProvider sp = new SecurityProvider() {
@Nonnull
@Override
public ConfigurationParameters getParameters(@Nullable String name) {
return ConfigurationParameters.EMPTY;
}
@Nonnull
@Override
public Iterable<? extends SecurityConfiguration> getConfigurations() {
return ImmutableList.of();
}
@Nonnull
@Override
public <T> T getConfiguration(@Nonnull Class<T> configClass) {
if (configClass.equals(UserConfiguration.class)) {
return (T) new UserConfigurationImpl(this) {
@Nullable
@Override
public PrincipalProvider getUserPrincipalProvider(@Nonnull Root root, @Nonnull NamePathMapper namePathMapper) {
return null;
}
};
} else {
throw new IllegalArgumentException();
}
}
};
pc3.setSecurityProvider(sp);
PrincipalProvider pp = pc3.getPrincipalProvider(root, NamePathMapper.DEFAULT);
assertTrue(pp instanceof PrincipalProviderImpl);
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider in project jackrabbit-oak by apache.
the class UserPrincipalProviderWithCacheTest method testLongOverflow.
@Test
public void testLongOverflow() throws Exception {
long[] maxCache = new long[] { Long.MAX_VALUE, Long.MAX_VALUE - 1, Long.MAX_VALUE - 10000 };
Root systemRoot = getSystemSession().getLatestRoot();
for (long exp : maxCache) {
changeUserConfiguration(ConfigurationParameters.of(UserPrincipalProvider.PARAM_CACHE_EXPIRATION, exp));
PrincipalProvider pp = createPrincipalProvider(systemRoot);
pp.getPrincipals(userId);
Tree userTree = systemRoot.getTree(getTestUser().getPath());
Tree cache = userTree.getChild(CacheConstants.REP_CACHE);
assertTrue(cache.exists());
PropertyState propertyState = cache.getProperty(CacheConstants.REP_EXPIRATION);
assertNotNull(propertyState);
assertEquals(Long.MAX_VALUE, propertyState.getValue(Type.LONG).longValue());
cache.remove();
systemRoot.commit();
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider in project jackrabbit-oak by apache.
the class UserPrincipalProviderWithCacheTest method testGetGroupMembershipForGroups.
@Test
public void testGetGroupMembershipForGroups() throws Exception {
PrincipalProvider pp = createPrincipalProvider(systemRoot);
Set<? extends Principal> principals = pp.getGroupMembership(testGroup.getPrincipal());
assertPrincipals(principals, EveryonePrincipal.getInstance());
principals = pp.getGroupMembership(testGroup2.getPrincipal());
assertPrincipals(principals, EveryonePrincipal.getInstance(), testGroup.getPrincipal());
root.refresh();
Tree principalCache = getCacheTree(root, testGroup.getPath());
assertFalse(principalCache.exists());
principalCache = getCacheTree(root, testGroup2.getPath());
assertFalse(principalCache.exists());
}
Aggregations