use of org.apache.jackrabbit.oak.spi.security.ConfigurationParameters in project jackrabbit-oak by apache.
the class ConfigurationInitializerTest method testInitBaseConfigurationWithParam.
@Test
public void testInitBaseConfigurationWithParam() {
TestConfiguration sc = new TestConfiguration();
SecurityConfiguration afterInit = ConfigurationInitializer.initializeConfiguration(sp, sc, params);
assertSame(sc, afterInit);
// verify securityprovider
assertSame(sp, sc.getSecurityProvider());
// verify params
ConfigurationParameters parameters = afterInit.getParameters();
assertTrue(parameters.containsKey("key"));
assertTrue(parameters.containsKey("key2"));
assertEquals("value", parameters.get("key"));
assertEquals("initialValue", parameters.get("key2"));
}
use of org.apache.jackrabbit.oak.spi.security.ConfigurationParameters in project jackrabbit-oak by apache.
the class UserInitializerTest method testAdminConfiguration.
/**
* @since OAK 1.0 The configuration defines if the password of the
* admin user is being set.
*/
@Test
public void testAdminConfiguration() throws Exception {
Map<String, Object> userParams = new HashMap();
userParams.put(UserConstants.PARAM_ADMIN_ID, "admin");
userParams.put(UserConstants.PARAM_OMIT_ADMIN_PW, true);
ConfigurationParameters params = ConfigurationParameters.of(UserConfiguration.NAME, ConfigurationParameters.of(userParams));
SecurityProvider sp = new SecurityProviderImpl(params);
final ContentRepository repo = new Oak().with(new InitialContent()).with(new PropertyIndexEditorProvider()).with(new PropertyIndexProvider()).with(new TypeEditorProvider()).with(sp).createContentRepository();
ContentSession cs = Subject.doAs(SystemSubject.INSTANCE, new PrivilegedExceptionAction<ContentSession>() {
@Override
public ContentSession run() throws Exception {
return repo.login(null, null);
}
});
try {
Root root = cs.getLatestRoot();
UserConfiguration uc = sp.getConfiguration(UserConfiguration.class);
UserManager umgr = uc.getUserManager(root, NamePathMapper.DEFAULT);
Authorizable adminUser = umgr.getAuthorizable("admin");
assertNotNull(adminUser);
Tree adminTree = root.getTree(adminUser.getPath());
assertTrue(adminTree.exists());
assertNull(adminTree.getProperty(UserConstants.REP_PASSWORD));
} finally {
cs.close();
}
// login as admin should fail
ContentSession adminSession = null;
try {
adminSession = repo.login(new SimpleCredentials("admin", new char[0]), null);
fail();
} catch (LoginException e) {
//success
} finally {
if (adminSession != null) {
adminSession.close();
}
}
}
use of org.apache.jackrabbit.oak.spi.security.ConfigurationParameters in project jackrabbit-oak by apache.
the class AccessControlActionTest method getSecurityConfigParameters.
@Override
protected ConfigurationParameters getSecurityConfigParameters() {
ConfigurationParameters userConfig = ConfigurationParameters.of(AccessControlAction.GROUP_PRIVILEGE_NAMES, new String[] { PrivilegeConstants.JCR_READ }, AccessControlAction.USER_PRIVILEGE_NAMES, new String[] { PrivilegeConstants.JCR_ALL });
ConfigurationParameters authorizationConfig = ConfigurationParameters.of(PermissionConstants.PARAM_ADMINISTRATIVE_PRINCIPALS, new String[] { "administrativePrincipalName" });
return ConfigurationParameters.of(UserConfiguration.NAME, userConfig, AuthorizationConfiguration.NAME, authorizationConfig);
}
use of org.apache.jackrabbit.oak.spi.security.ConfigurationParameters in project jackrabbit-oak by apache.
the class QueryUtilTest method testGetSearchRootUserPathParentOfGroup.
@Test
public void testGetSearchRootUserPathParentOfGroup() {
ConfigurationParameters params = ConfigurationParameters.of(UserConstants.PARAM_USER_PATH, "/configured/users", UserConstants.PARAM_GROUP_PATH, "/configured/users/groups");
Map<AuthorizableType, String> paths = ImmutableMap.of(AuthorizableType.USER, "/configured/users", AuthorizableType.GROUP, "/configured/users/groups", AuthorizableType.AUTHORIZABLE, "/configured/users");
assertSearchRoot(paths, params);
}
use of org.apache.jackrabbit.oak.spi.security.ConfigurationParameters in project jackrabbit-oak by apache.
the class UserProviderTest method testCollisions.
@Test
public void testCollisions() throws Exception {
ConfigurationParameters config = ConfigurationParameters.of(UserConstants.PARAM_AUTHORIZABLE_NODE_NAME, new AuthorizableNodeName() {
@Nonnull
@Override
public String generateNodeName(@Nonnull String authorizableId) {
return "aaa";
}
});
UserProvider up = new UserProvider(root, config);
try {
Tree u1 = up.createUser("a", null);
assertEquals("aaa", u1.getName());
Tree u2 = up.createUser("b", null);
assertEquals("aaa1", u2.getName());
Tree u3 = up.createUser("c", null);
assertEquals("aaa2", u3.getName());
Tree u4 = up.createUser("d", null);
assertEquals("aaa3", u4.getName());
} finally {
root.refresh();
}
}
Aggregations