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


Java PermissionService类代码示例

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


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

示例1: findServices

import org.alfresco.service.cmr.security.PermissionService; //导入依赖的package包/类
private static void findServices()
{
    ApplicationContext ctx = testContext.getApplicationContext();
    
    copyService = ctx.getBean("CopyService", CopyService.class);
    nodeService = ctx.getBean("NodeService", NodeService.class);
    directQuickShareService = ctx.getBean("quickShareService", QuickShareService.class);
    quickShareService = ctx.getBean("QuickShareService", QuickShareService.class);
    repository = ctx.getBean("repositoryHelper", Repository.class);
    attributeService = ctx.getBean("AttributeService", AttributeService.class);
    permissionService = ctx.getBean("PermissionService", PermissionService.class);
    nodeArchiveService = ctx.getBean("nodeArchiveService", NodeArchiveService.class);
    scheduledPersistedActionService = ctx.getBean("scheduledPersistedActionService", ScheduledPersistedActionService.class);
    quickShareLinkExpiryActionPersister = ctx.getBean("quickShareLinkExpiryActionPersister", QuickShareLinkExpiryActionPersister.class);
    transactionHelper = ctx.getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
    globalProperties = ctx.getBean("global-properties", Properties.class);
    siteService = (SiteService) ctx.getBean("SiteService");
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:QuickShareServiceIntegrationTest.java

示例2: validateNodeRefIsWritableSpace

import org.alfresco.service.cmr.security.PermissionService; //导入依赖的package包/类
protected final void validateNodeRefIsWritableSpace(NodeRef target)
{
    if (target == null)
    {
        throw new IllegalArgumentException("target must not be null.");
    }
    
    if (!fileFolderService.exists(target))
    {
        throw new IllegalArgumentException("Target '" + target.toString() + "' doesn't exist.");
    }
    
    if (AccessStatus.DENIED.equals(permissionService.hasPermission(target, PermissionService.ADD_CHILDREN)))
    {
        throw new IllegalArgumentException("Target '" + target.toString() + "' is not writeable.");
    }
    
    if (!fileFolderService.getFileInfo(target).isFolder())
    {
        throw new IllegalArgumentException("Target '" + target.toString() + "' is not a space.");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:AbstractBulkFilesystemImporter.java

示例3: testSetFlag

import org.alfresco.service.cmr.security.PermissionService; //导入依赖的package包/类
public void testSetFlag() throws Exception
{
    NavigableMap<Long, FileInfo> fis = imapService.getFolderStatus(authenticationService.getCurrentUserName(), testImapFolderNodeRef, ImapViewMode.ARCHIVE).search;
    if (fis != null && fis.size() > 0)
    {
        FileInfo messageFileInfo = fis.firstEntry().getValue();
        
        reauthenticate(USER_NAME, USER_PASSWORD);
        
        permissionService.setPermission(testImapFolderNodeRef, anotherUserName, PermissionService.WRITE, true);
        
        reauthenticate(anotherUserName, anotherUserName);
        
        imapService.setFlag(messageFileInfo, Flags.Flag.RECENT, true);
        
        Serializable prop = nodeService.getProperty(messageFileInfo.getNodeRef(), ImapModel.PROP_FLAG_RECENT);
        assertNotNull("Can't set RECENT flag", prop);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:ImapServiceImplTest.java

示例4: testBasicAllowNodePair

import org.alfresco.service.cmr.security.PermissionService; //导入依赖的package包/类
public void testBasicAllowNodePair() throws Exception
{
    runAs("andy");

    Object o = new ClassWithMethods();
    Method method = o.getClass().getMethod("echoNodePair", new Class[] { NodeRef.class });

    AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("AFTER_ACL_NODE.sys:base.Read")));
    proxyFactory.setTargetSource(new SingletonTargetSource(o));
    Object proxy = proxyFactory.getProxy();

    permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ), "andy", AccessStatus.ALLOWED));

    Pair<Long, NodeRef> rootNodePair = new Pair<Long, NodeRef>(Long.valueOf(1), rootNodeRef);
    Object answer = method.invoke(proxy, new Object[] { rootNodeRef });
    assertEquals(rootNodePair, answer);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:ACLEntryAfterInvocationTest.java

示例5: testAuthorities

import org.alfresco.service.cmr.security.PermissionService; //导入依赖的package包/类
public void testAuthorities()
{
    assertEquals(1, getAllAuthorities(AuthorityType.ADMIN).size());
    assertTrue(getAllAuthorities(AuthorityType.ADMIN).contains(PermissionService.ADMINISTRATOR_AUTHORITY));
    assertEquals(1, getAllAuthorities(AuthorityType.EVERYONE).size());
    assertTrue(getAllAuthorities(AuthorityType.EVERYONE).contains(PermissionService.ALL_AUTHORITIES));
    // groups added for email and admin
    assertEquals(GRP_CNT, getAllAuthorities(AuthorityType.GROUP).size());
    assertFalse(getAllAuthorities(AuthorityType.GROUP).contains(PermissionService.ALL_AUTHORITIES));
    assertEquals(1, getAllAuthorities(AuthorityType.GUEST).size());
    assertTrue(getAllAuthorities(AuthorityType.GUEST).contains(PermissionService.GUEST_AUTHORITY));
    assertEquals(0, getAllAuthorities(AuthorityType.OWNER).size());
    assertEquals(0, getAllAuthorities(AuthorityType.ROLE).size());
    
    int peopleCnt = personService.getPeople(null, null, null, new PagingRequest(0, Integer.MAX_VALUE, null)).getPage().size();
    assertEquals(peopleCnt, getAllAuthorities(AuthorityType.USER).size());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:AuthorityServiceTest.java

示例6: getPersonIfAllowed

import org.alfresco.service.cmr.security.PermissionService; //导入依赖的package包/类
private TemplateNode getPersonIfAllowed(final String userName)
{
    final PersonService personService = serviceRegistry.getPersonService();
    NodeRef inviterRef = AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
    {
        public NodeRef doWork() throws Exception
        {
            if (!personService.personExists(userName))
            {
                return null;
            }
            return personService.getPerson(userName, false);
        }
    }, AuthenticationUtil.getSystemUserName());
    if (inviterRef != null
            && serviceRegistry.getPermissionService().hasPermission(inviterRef, PermissionService.READ_PROPERTIES)
                    .equals(AccessStatus.ALLOWED))
    {
        return new TemplateNode(inviterRef, serviceRegistry, null);
    }
    return null;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:23,代码来源:Invites.java

示例7: testRuleServicePermissionsConsumer

import org.alfresco.service.cmr.security.PermissionService; //导入依赖的package包/类
public void testRuleServicePermissionsConsumer()
{
    this.authenticationService.createAuthentication("conUser", "password".toCharArray());
    this.permissionService.setPermission(this.nodeRef, "conUser", PermissionService.CONSUMER, true);
    this.permissionService.setInheritParentPermissions(this.nodeRef, true);        
    
    this.authenticationService.authenticate("conUser", "password".toCharArray());        
    Rule rule = createTestRule();
    try
    {
        this.ruleService.saveRule(this.nodeRef, rule);
        // Fail
        fail("Consumers cannot create rules.");
    }
    catch (Exception exception)
    {
        // Ok
    }

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:RuleServiceImplTest.java

示例8: setUp

import org.alfresco.service.cmr.security.PermissionService; //导入依赖的package包/类
@Override
public void setUp() throws Exception
{
    ctx = ApplicationContextHelper.getApplicationContext();
    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    txnHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper();
    fileFolderService = serviceRegistry.getFileFolderService();
    repository = (Repository) ctx.getBean("repositoryHelper");
    fixedAclUpdater = (FixedAclUpdater) ctx.getBean("fixedAclUpdater");
    permissionsDaoComponent = (PermissionsDaoComponent) ctx.getBean("admPermissionsDaoComponent");
    permissionService = (PermissionService) ctx.getBean("permissionService");
    nodeDAO = (NodeDAO) ctx.getBean("nodeDAO");

    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());

    NodeRef home = repository.getCompanyHome();
    // create a folder hierarchy for which will change permission inheritance
    int[] filesPerLevel = { 5, 5, 10 };
    RetryingTransactionCallback<NodeRef> cb = createFolderHierchyCallback(home, fileFolderService, "ROOT", filesPerLevel);
    folderNodeRef = txnHelper.doInTransaction(cb);

    // change setFixedAclMaxTransactionTime to lower value so setInheritParentPermissions on created folder hierarchy require async call
    setFixedAclMaxTransactionTime(permissionsDaoComponent, home, 50);

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:26,代码来源:FixedAclUpdaterTest.java

示例9: createTestFolder

import org.alfresco.service.cmr.security.PermissionService; //导入依赖的package包/类
@Before public void createTestFolder()
{
    initContextAndCreateUser();
    AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
    final NodeRef companyHome = repositoryHelper.getCompanyHome();
    
    Map<QName, Serializable> props = new HashMap<QName, Serializable>();
    props.put(ContentModel.PROP_NAME, this.getClass() + "_testFolder");
    testFolder = nodeService.createNode(companyHome, 
                                            ContentModel.ASSOC_CONTAINS, 
                                            ContentModel.ASSOC_CONTAINS, 
                                            ContentModel.TYPE_FOLDER,
                                            props).getChildRef();
    // Let anyone (meaning non-admin) do anything (meaning create new content)
    permissionService.setPermission(testFolder, PermissionService.ALL_AUTHORITIES, PermissionService.ALL_PERMISSIONS, true);
    this.nodesToBeTidiedUp.add(testFolder);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:MultiUserRenditionTest.java

示例10: testAclInsertionPerformanceMixed

import org.alfresco.service.cmr.security.PermissionService; //导入依赖的package包/类
@Category(PerformanceTests.class)
public void testAclInsertionPerformanceMixed()
{
    NodeRef parent = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}one"), ContentModel.TYPE_FOLDER).getChildRef();
    for(int i = 0; i < 1000; i++)
    {
        NodeRef created = nodeService.createNode(parent, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}child"+i), ContentModel.TYPE_FOLDER).getChildRef();
        if(i % 2 == 0)
        {
            permissionService.setPermission(new SimplePermissionEntry(created, getPermission(PermissionService.CONSUMER), "bob", AccessStatus.ALLOWED));
        }
    }
    long start = System.nanoTime();
    permissionService.setPermission(new SimplePermissionEntry(parent, getPermission(PermissionService.CONSUMER), "andy", AccessStatus.ALLOWED));
    long end = System.nanoTime();

    //assertTrue("Time was "+(end - start)/1000000000.0f, end == start);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:PermissionServiceTest.java

示例11: testGetTranslationContainerPermissions

import org.alfresco.service.cmr.security.PermissionService; //导入依赖的package包/类
public void testGetTranslationContainerPermissions() throws Exception
{
    // Grant the guest user rights to our working folder
    PermissionService permissionService = serviceRegistry.getPermissionService();
    AuthenticationComponent authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    permissionService.setPermission(
            folderNodeRef,
            AuthenticationUtil.getGuestUserName(),
            PermissionService.ALL_PERMISSIONS,
            true);
    // Get the current authentication
    AuthenticationUtil.pushAuthentication();
    try
    {
        authenticationComponent.setGuestUserAsCurrentUser();
        // Create some documents
        NodeRef chineseContentNodeRef = createContent();
        // Make a translation
        multilingualContentService.makeTranslation(chineseContentNodeRef, Locale.CHINESE);
        multilingualContentService.getTranslationContainer(chineseContentNodeRef);
    }
    finally
    {
        AuthenticationUtil.popAuthentication();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:MultilingualContentServiceImplTest.java

示例12: makePackageContainer

import org.alfresco.service.cmr.security.PermissionService; //导入依赖的package包/类
private NodeRef makePackageContainer()
{
    NodeRef packages = findOrCreatePackagesFolder();
    String packageId = "pkg_" + GUID.generate();
    QName packageName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, packageId);
    
    try {
    	policyBehaviourFilter.disableBehaviour(packages, ContentModel.ASPECT_AUDITABLE); 
    	ChildAssociationRef packageAssoc = nodeService.createNode(packages, ContentModel.ASSOC_CONTAINS, packageName,
    			WorkflowModel.TYPE_PACKAGE);
    	NodeRef packageContainer = packageAssoc.getChildRef();
    	// TODO: For now, grant full access to everyone
    	permissionService.setPermission(packageContainer, PermissionService.ALL_AUTHORITIES,
    			PermissionService.ALL_PERMISSIONS, true);
    	return packageContainer;
    }
    finally
    {
    	 policyBehaviourFilter.enableBehaviour(packages, ContentModel.ASPECT_AUDITABLE); 
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:WorkflowPackageImpl.java

示例13: getAuthorityInfo

import org.alfresco.service.cmr.security.PermissionService; //导入依赖的package包/类
/**
 * Retrieve authority info by name. <b>Node id field isn't used at this time
 * and it is set to null.</b>
 *
 * @param id
 *            The authority name.
 * @param defaultDisplayNameIfNull
 *            True if we would like to get a default value (e.g. shortName of the authority) if the authority display name is null.
 * @return The authority info.
 */
private AuthorityInfo getAuthorityInfo(String id, boolean defaultDisplayNameIfNull)
{
    if (id == null || id.isEmpty())
    {
        throw new InvalidArgumentException("id is null or empty");
    }

    // authorityService.authorityExists(ALL_AUTHORITIES) returns false!
    if (!id.equals(PermissionService.ALL_AUTHORITIES) && !authorityService.authorityExists(id))
    {
        throw new EntityNotFoundException(id);
    }

    String authorityDisplayName = getAuthorityDisplayName(id, defaultDisplayNameIfNull);

    return new AuthorityInfo(null, authorityDisplayName, id);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:28,代码来源:GroupsImpl.java

示例14: test_AR_2055

import org.alfresco.service.cmr.security.PermissionService; //导入依赖的package包/类
public void test_AR_2055()
{
    runAs(AuthenticationUtil.getAdminUserName());
    NodeRef folder = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}one"), ContentModel.TYPE_FOLDER).getChildRef();

    runAs("andy");
    List<String> pathElements = new ArrayList<String>();
    pathElements.add("monkey");
    try
    {
        FileFolderServiceImpl.makeFolders(serviceRegistry.getFileFolderService(), folder, pathElements, ContentModel.TYPE_FOLDER);
        fail();
    }
    catch (AccessDeniedException ade)
    {

    }

    runAs(AuthenticationUtil.getAdminUserName());
    permissionService.setPermission(folder, "andy", PermissionService.ALL_PERMISSIONS, true);

    FileFolderServiceImpl.makeFolders(serviceRegistry.getFileFolderService(), folder, pathElements, ContentModel.TYPE_FOLDER);

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:PermissionServiceTest.java

示例15: execute

import org.alfresco.service.cmr.security.PermissionService; //导入依赖的package包/类
@Override
public Set<AccessPermission> execute(VirtualProtocol virtualProtocol, Reference reference)
            throws ProtocolMethodException
{
    Set<String> toAllow = userPermissions.getAllowSmartNodes();
    Set<String> toDeny = userPermissions.getDenySmartNodes();

    VirtualFolderDefinition definition = resolver.resolveVirtualFolderDefinition(reference);
    FilingRule filingRule = definition.getFilingRule();
    boolean readonly = filingRule.isNullFilingRule()
                || filingRule.filingNodeRefFor(new FilingParameters(reference)) == null;
    if (readonly)
    {
        Set<String> deniedPermissions = userPermissions.getDenyReadonlySmartNodes();
        toDeny = new HashSet<>(toDeny);
        toDeny.addAll(deniedPermissions);
        toAllow.add(PermissionService.READ);
    }
    

    return execute(reference,
                   toAllow,
                   toDeny);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:GetAllSetPermissionsMethod.java


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