当前位置: 首页>>代码示例>>Java>>正文


Java UserManager.createGroup方法代码示例

本文整理汇总了Java中org.apache.jackrabbit.api.security.user.UserManager.createGroup方法的典型用法代码示例。如果您正苦于以下问题:Java UserManager.createGroup方法的具体用法?Java UserManager.createGroup怎么用?Java UserManager.createGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jackrabbit.api.security.user.UserManager的用法示例。


在下文中一共展示了UserManager.createGroup方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testEveryone

import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
@Test
public void testEveryone() throws Exception {
    Principal everyone = principalProvider.getPrincipal(EveryonePrincipal.NAME);
    assertTrue(everyone instanceof EveryonePrincipal);

    Group everyoneGroup = null;
    try {
        UserManager userMgr = getUserManager(root);
        everyoneGroup = userMgr.createGroup(EveryonePrincipal.NAME);
        root.commit();

        Principal ep = principalProvider.getPrincipal(EveryonePrincipal.NAME);
        assertFalse(ep instanceof EveryonePrincipal);
    } finally {
        if (everyoneGroup != null) {
            everyoneGroup.remove();
            root.commit();
        }
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:21,代码来源:PrincipalProviderImplTest.java

示例2: testAccessControlAction

import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
@Test
public void testAccessControlAction() throws Exception {
    UserManager userMgr = getUserManager(root);
    Group gr = null;
    try {
        gr = userMgr.createGroup("actionTestGroup");
        root.commit();

        assertAcAction(gr, PrivilegeConstants.JCR_READ);
    } finally {
        root.refresh();
        if (gr != null) {
            gr.remove();
        }
        root.commit();
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:18,代码来源:AccessControlActionTest.java

示例3: createGroups

import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
/**
 * Create user groups for authors and testers.
 *
 * @param bundleContext The bundle context provided by the component.
 */
private void createGroups(BundleContext bundleContext){
    ServiceReference SlingRepositoryFactoryReference = bundleContext.getServiceReference(SlingRepository.class.getName());
    SlingRepository repository = (SlingRepository)bundleContext.getService(SlingRepositoryFactoryReference);

    Session session = null;

    if (repository != null) {
        try {
            session = repository.loginAdministrative(null);

            if (session != null && session instanceof JackrabbitSession) {
                UserManager userManager = ((JackrabbitSession)session).getUserManager();
                ValueFactory valueFactory = session.getValueFactory();

                Authorizable authors = userManager.getAuthorizable(PublickConstants.GROUP_ID_AUTHORS);

                if (authors == null) {
                    authors = userManager.createGroup(PublickConstants.GROUP_ID_AUTHORS);
                    authors.setProperty(GROUP_DISPLAY_NAME, valueFactory.createValue(PublickConstants.GROUP_DISPLAY_AUTHORS));
                }

                Authorizable testers = userManager.getAuthorizable(PublickConstants.GROUP_ID_TESTERS);

                if (testers == null) {
                    testers = userManager.createGroup(PublickConstants.GROUP_ID_TESTERS);
                    testers.setProperty(GROUP_DISPLAY_NAME, valueFactory.createValue(PublickConstants.GROUP_DISPLAY_TESTERS));
                }
            }
        } catch (RepositoryException e) {
            LOGGER.error("Could not get session", e);
        } finally {
            if (session != null && session.isLive()) {
                session.logout();
                session = null;
            }
        }
    }
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:44,代码来源:Activator.java

示例4: before

import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
@Override
public void before() throws Exception {
    super.before();

    UserManager userMgr = getUserManager(root);
    everyoneGroup = userMgr.createGroup(EveryonePrincipal.getInstance());

    authorizables = new HashSet<Authorizable>(2);
    authorizables.add(userMgr.createGroup("testGroup"));
    authorizables.add(userMgr.createUser("testUser", "pw"));
    root.commit();
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:13,代码来源:EveryoneGroupTest.java

示例5: testDetectCyclicMembership

import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
/**
 * @since oak 1.0 cyclic group membership added in a single set of transient
 *        modifications must be detected upon save.
 */
@Test
public void testDetectCyclicMembership() throws Exception {
    Group group1 = null;
    Group group2 = null;
    Group group3 = null;
    
    UserManager userMgr = getUserManager(root);
    try {
        group1 = userMgr.createGroup("group1");
        group2 = userMgr.createGroup("group2");
        group3 = userMgr.createGroup("group3");

        group1.addMember(group2);
        group2.addMember(group3);
        
        assertFalse(group3.addMember(group1));
        
        Tree group3Tree = root.getTree(group3.getPath());
        Set<String> values = Collections.singleton(root.getTree(group1.getPath()).getProperty(JcrConstants.JCR_UUID).getValue(Type.STRING));
        PropertyState prop = PropertyStates.createProperty(REP_MEMBERS, values, Type.WEAKREFERENCES);
        group3Tree.setProperty(prop);
        root.commit();
        fail("Cyclic group membership must be detected");
    } catch (CommitFailedException e) {
        // success
    } finally {
        if (group1 != null) group1.remove();
        if (group2 != null) group2.remove();
        if (group3 != null) group3.remove();
        root.commit();
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:37,代码来源:UserValidatorTest.java

示例6: testEveryoneMembers

import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
@Test
public void testEveryoneMembers() throws Exception {
    Principal everyone = principalProvider.getPrincipal(EveryonePrincipal.NAME);
    assertTrue(everyone instanceof EveryonePrincipal);

    Group everyoneGroup = null;
    try {
        UserManager userMgr = getUserManager(root);
        everyoneGroup = userMgr.createGroup(EveryonePrincipal.NAME);
        root.commit();

        Principal ep = principalProvider.getPrincipal(EveryonePrincipal.NAME);
        Set<? extends Principal> everyoneMembers = ImmutableSet.copyOf(Collections.list(((java.security.acl.Group) ep).members()));

        Iterator<? extends Principal> all = principalProvider.findPrincipals(PrincipalManager.SEARCH_TYPE_ALL);
        while (all.hasNext()) {
            Principal p = all.next();
            if (everyone.equals(p)) {
                assertFalse(everyoneMembers.contains(p));
            } else {
                assertTrue(everyoneMembers.contains(p));
            }
        }

    } finally {
        if (everyoneGroup != null) {
            everyoneGroup.remove();
            root.commit();
        }
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:32,代码来源:PrincipalProviderImplTest.java

示例7: testFindGroupPrincipal

import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
@Test
public void testFindGroupPrincipal() throws Exception {
    Group testGroup = null;
    try {
        UserManager userMgr = getUserManager(root);
        testGroup = userMgr.createGroup("TestGroup");
        root.commit();

        String principalName = testGroup.getPrincipal().getName();
        assertNotNull(principalProvider.getPrincipal(principalName));

        List<String> nameHints = new ArrayList<String>();
        nameHints.add("TestGroup");
        nameHints.add("Test");
        nameHints.add("Group");
        nameHints.add("stGr");

        assertResult(principalProvider, nameHints, principalName, PrincipalManager.SEARCH_TYPE_GROUP, true);
        assertResult(principalProvider, nameHints, principalName, PrincipalManager.SEARCH_TYPE_ALL, true);
        assertResult(principalProvider, nameHints, principalName, PrincipalManager.SEARCH_TYPE_NOT_GROUP, false);
    } finally {
        if (testGroup != null) {
            testGroup.remove();
            root.commit();
        }
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:28,代码来源:PrincipalProviderImplTest.java

示例8: 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();
    }
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:32,代码来源:PrincipalProviderImplTest.java

示例9: before

import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
@Override
public void before() throws Exception {
    super.before();

    new NodeUtil(root.getTree("/")).addChild("test", JcrConstants.NT_UNSTRUCTURED);
    UserManager uMgr = getUserManager(root);
    adminstrators = uMgr.createGroup(ADMINISTRATOR_GROUP);
    root.commit();
    config = getSecurityProvider().getConfiguration(AuthorizationConfiguration.class);
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:11,代码来源:PermissionProviderImplTest.java

示例10: getUnderlyingGroup

import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
protected static Group getUnderlyingGroup(final JackrabbitSession session)
    throws RepositoryException {
  final UserManager um = session.getUserManager();
  try {
    // Create group
    return um.createGroup(GROUP_ID);
  } catch (AuthorizableExistsException e) {
    // Great! Find it instead
    return findAdminGroup(um);
  }
}
 
开发者ID:uq-eresearch,项目名称:aorra,代码行数:12,代码来源:Admin.java

示例11: createUserGroup

import org.apache.jackrabbit.api.security.user.UserManager; //导入方法依赖的package包/类
/**
 * Create a new user group.
 *
 * If the group already exists, the function will return null so that a calling function
 * can determine whether or not the group was actually created (vs. preexisting) by the
 * call to this function.
 *
 * @param groupName The name of the group to create.
 * @param intermediatePath The intermediate path in the JCR under which to save the group.
 *                         This can be used to organize multiple groups into a single folder.
 * @return Group if created, else null.
 * @throws RepositoryException
 */
protected Group createUserGroup(String groupName, String intermediatePath) throws RepositoryException {
    UserManager userManager = AccessControlUtil.getUserManager(session);
    Group existingGroup = (Group) userManager.getAuthorizable(groupName);
    if (existingGroup == null) {
        logger.info("Creating user group '{}'", groupName);
        return userManager.createGroup(new PrincipalImpl(groupName), intermediatePath);
    } else {
        logger.info("'{}' group already exists", groupName);
        return null;
    }
}
 
开发者ID:HS2-SOLUTIONS,项目名称:hs2-aem-commons,代码行数:25,代码来源:OnDeployScriptBase.java


注:本文中的org.apache.jackrabbit.api.security.user.UserManager.createGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。