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


Java PermissionService.GROUP_PREFIX属性代码示例

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


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

示例1: applyInternal

@Override
protected String applyInternal() throws Exception
{
    StringBuilder result = new StringBuilder(I18NUtil.getMessage(MSG_START));

    String groupAuthorityName = PermissionService.GROUP_PREFIX + this.groupAuthorityDetails.groupName;
    if (!authorityService.authorityExists(groupAuthorityName))
    {
        groupAuthorityName = authorityService.createAuthority(AuthorityType.GROUP,
                    this.groupAuthorityDetails.groupName,
                    this.groupAuthorityDetails.groupDisplayName,
                    this.groupAuthorityDetails.authorityZones);

        authorityService.addAuthority(groupAuthorityName, AuthenticationUtil.getAdminUserName());

        result.append(I18NUtil.getMessage(MSG_RESULT, groupAuthorityName));
    }
    else
    {
        result.append(I18NUtil.getMessage(MSG_EXIST, groupAuthorityName));
    }
    return result.toString();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:AddGroupAuthorityPatch.java

示例2: testConfigurableSitePublicGroup

/**
 * This method tests https://issues.alfresco.com/jira/browse/ALF-3785 which allows 'public' sites
 * to be only visible to members of a configured group, by default EVERYONE.
 * 
 * <br><br/>author Neil McErlean
 * @since 3.4
 */
@SuppressWarnings("deprecation")
public void testConfigurableSitePublicGroup() throws Exception
{
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    
    // We'll be configuring a JMX managed bean (in this test method only).
    ChildApplicationContextFactory sysAdminSubsystem = (ChildApplicationContextFactory) applicationContext.getBean("sysAdmin");
    final String sitePublicGroupPropName = "site.public.group";
    final String originalSitePublicGroup = "GROUP_EVERYONE";
    
    try
    {
        // Firstly we'll ensure that the site.public.group has the correct (pristine) value.
        String groupName = sysAdminSubsystem.getProperty(sitePublicGroupPropName);
        assertEquals(sitePublicGroupPropName + " was not the pristine value",
                originalSitePublicGroup, groupName);
        
        // Create a 'normal', unconfigured site.
        SiteInfo unconfiguredSite = siteService.createSite(TEST_SITE_PRESET, "unconfigured",
                                                           TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC);
        assertTrue(containsConsumerPermission(originalSitePublicGroup, unconfiguredSite));

        
        // Now set the managed bean's visibility group to something other than GROUP_EVERYONE.
        // This is the group that will have visibility of subsequently created sites.
        //
        // We'll intentionally set it to a group that DOES NOT EXIST YET.
        String newGroupName = this.getClass().getSimpleName() + System.currentTimeMillis();
        String prefixedNewGroupName = PermissionService.GROUP_PREFIX + newGroupName;
        
        sysAdminSubsystem.stop();
        sysAdminSubsystem.setProperty(sitePublicGroupPropName, prefixedNewGroupName);
        sysAdminSubsystem.start();

        // Now create a site as before. It should fail as we're using a group that doesn't exist.
        boolean expectedExceptionThrown = false;
        try
        {
            siteService.createSite(TEST_SITE_PRESET, "thisShouldFail",
                    TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC);
        }
        catch (SiteServiceException expected)
        {
            expectedExceptionThrown = true;
        }
        if (!expectedExceptionThrown)
        {
            fail("Expected exception on createSite with non-existent group was not thrown.");
        }
        
        
        // Now we'll create the group used above.
        authorityService.createAuthority(AuthorityType.GROUP, newGroupName);
        
        
        // And create the site as before. This time it should succeed.
        SiteInfo configuredSite = siteService.createSite(TEST_SITE_PRESET, "configured",
                TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC);
        
        // And check the permissions on the site.
        assertTrue("The configured site should not have " + originalSitePublicGroup + " as SiteContributor",
                !containsConsumerPermission(originalSitePublicGroup, configuredSite));
        assertTrue("The configured site should have (newGroupName) as SiteContributor",
                containsConsumerPermission(prefixedNewGroupName, configuredSite));
    }
    finally
    {
        // Reset the JMX bean to its out-of-the-box values.
        sysAdminSubsystem.stop();
        sysAdminSubsystem.setProperty(sitePublicGroupPropName, originalSitePublicGroup);
        sysAdminSubsystem.start();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:80,代码来源:SiteServiceImplTest.java


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