本文整理汇总了Java中org.apache.jackrabbit.api.security.user.UserManager.createUser方法的典型用法代码示例。如果您正苦于以下问题:Java UserManager.createUser方法的具体用法?Java UserManager.createUser怎么用?Java UserManager.createUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jackrabbit.api.security.user.UserManager
的用法示例。
在下文中一共展示了UserManager.createUser方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createUser
import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
public boolean createUser(String name, String pass) throws AuthorizableExistsException, RepositoryException {
// usual entry point into the Jackrabbit API
JackrabbitSession js = (JackrabbitSession) session;
UserManager um = js.getUserManager();
PrincipalImpl p = new PrincipalImpl(name);
String usersPath = "/" + name;
User u = um.createUser(name, pass, p, null);
u.setProperty("homeFolder", session.getValueFactory().createValue(usersPath));
// "HOME" folder for the brand new user
// createUsersFolder(name, session);
// Assign permissions to the "HOME" folder of the just created user
// assignInitialPermissions(u, u.getPrincipal(), usersPath, session);
session.save();
return true;
}
示例2: testRemoveAdminUser
import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
@Test
public void testRemoveAdminUser() throws Exception {
try {
String adminId = getConfig().getConfigValue(PARAM_ADMIN_ID, DEFAULT_ADMIN_ID);
UserManager userMgr = getUserManager(root);
Authorizable admin = userMgr.getAuthorizable(adminId);
if (admin == null) {
admin = userMgr.createUser(adminId, adminId);
root.commit();
}
root.getTree(admin.getPath()).remove();
root.commit();
fail("Admin user cannot be removed");
} catch (CommitFailedException e) {
// success
} finally {
root.refresh();
}
}
示例3: testRemoveAdminUserFolder
import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
@Test
public void testRemoveAdminUserFolder() throws Exception {
try {
String adminId = getConfig().getConfigValue(PARAM_ADMIN_ID, DEFAULT_ADMIN_ID);
UserManager userMgr = getUserManager(root);
Authorizable admin = userMgr.getAuthorizable(adminId);
if (admin == null) {
admin = userMgr.createUser(adminId, adminId);
root.commit();
}
root.getTree(admin.getPath()).getParent().remove();
root.commit();
fail("Admin user cannot be removed");
} catch (CommitFailedException e) {
// success
} finally {
root.refresh();
}
}
示例4: testDisableAdminUser
import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
@Test
public void testDisableAdminUser() throws Exception {
try {
String adminId = getConfig().getConfigValue(PARAM_ADMIN_ID, DEFAULT_ADMIN_ID);
UserManager userMgr = getUserManager(root);
Authorizable admin = userMgr.getAuthorizable(adminId);
if (admin == null) {
admin = userMgr.createUser(adminId, adminId);
root.commit();
}
root.getTree(admin.getPath()).setProperty(REP_DISABLED, "disabled");
root.commit();
fail("Admin user cannot be disabled");
} catch (CommitFailedException e) {
// success
} finally {
root.refresh();
}
}
示例5: testUserManagementPermissionWithJr2Flag
import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
@Test
public void testUserManagementPermissionWithJr2Flag() throws Exception {
Root testRoot = getTestRoot();
testRoot.refresh();
UserManager testUserMgr = getUserConfiguration().getUserManager(testRoot, NamePathMapper.DEFAULT);
try {
User u = testUserMgr.createUser("a", "b");
testRoot.commit();
u.changePassword("c");
testRoot.commit();
u.remove();
testRoot.commit();
} finally {
root.refresh();
Authorizable user = getUserManager(root).getAuthorizable("a");
if (user != null) {
user.remove();
root.commit();
}
}
}
示例6: testAccessControlActionForUser
import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
@Test
public void testAccessControlActionForUser() throws Exception {
UserManager userMgr = getUserManager(root);
User u = null;
try {
String uid = "actionTestUser";
u = userMgr.createUser(uid, uid);
root.commit();
assertAcAction(u, PrivilegeConstants.JCR_ALL);
} finally {
root.refresh();
if (u != null) {
u.remove();
}
root.commit();
}
}
示例7: createTestUser
import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
private User createTestUser() throws RepositoryException, CommitFailedException {
if (user == null) {
UserManager userManager = getUserManager(root);
user = userManager.createUser(USER_ID, USER_PW);
root.commit();
}
return user;
}
示例8: testFindUserPrincipal
import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
@Test
public void testFindUserPrincipal() throws Exception {
User testUser = null;
try {
UserManager userMgr = getUserManager(root);
testUser = userMgr.createUser("TestUser", "pw");
root.commit();
String principalName = testUser.getPrincipal().getName();
assertNotNull(principalProvider.getPrincipal(principalName));
List<String> nameHints = new ArrayList<String>();
nameHints.add("TestUser");
nameHints.add("Test");
nameHints.add("User");
nameHints.add("stUs");
assertResult(principalProvider, nameHints, principalName, PrincipalManager.SEARCH_TYPE_NOT_GROUP, true);
assertResult(principalProvider, nameHints, principalName, PrincipalManager.SEARCH_TYPE_ALL, true);
assertResult(principalProvider, nameHints, principalName, PrincipalManager.SEARCH_TYPE_GROUP, false);
} finally {
if (testUser != null) {
testUser.remove();
root.commit();
}
}
}
示例9: testFindWithoutHint
import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
@Test
public void testFindWithoutHint() throws Exception {
User testUser = null;
Group testGroup = null;
try {
UserManager userMgr = getUserManager(root);
testUser = userMgr.createUser("TestUser", "pw");
testGroup = userMgr.createGroup("TestGroup");
root.commit();
Set<String> resultNames = new HashSet<String>();
Iterator<? extends Principal> principals = principalProvider.findPrincipals(PrincipalManager.SEARCH_TYPE_ALL);
while (principals.hasNext()) {
resultNames.add(principals.next().getName());
}
assertTrue(resultNames.contains(EveryonePrincipal.NAME));
assertTrue(resultNames.contains("TestUser"));
assertTrue(resultNames.contains("TestGroup"));
} finally {
if (testUser != null) {
testUser.remove();
}
if (testGroup != null) {
testGroup.remove();
}
root.commit();
}
}
示例10: testCreateUser
import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
@Test
public void testCreateUser() throws Exception {
OakContext context = injector.getInstance(OakContext.class);
ContentSession session = context.login("admin", "admin");
Root root = session.getLatestRoot();
SecurityManagerImpl securityManager= new SecurityManagerImpl(config);
UserManager userManager = securityManager.getUserManager(session);
User user = userManager.createUser("test", "pass");
}