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


Java SimplePermissionReference.getPermissionReference方法代码示例

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


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

示例1: ConfigAttributeDefintion

import org.alfresco.repo.security.permissions.impl.SimplePermissionReference; //导入方法依赖的package包/类
ConfigAttributeDefintion(ConfigAttribute attr)
{

    StringTokenizer st = new StringTokenizer(attr.getAttribute(), ".", false);
    if (st.countTokens() != 3)
    {
        throw new ACLEntryVoterException("There must be three . separated tokens in each config attribute");
    }
    typeString = st.nextToken();
    String qNameString = st.nextToken();
    String permissionString = st.nextToken();

    if (!(typeString.equals(AFTER_ACL_NODE) || typeString.equals(AFTER_ACL_PARENT)))
    {
        throw new ACLEntryVoterException("Invalid type: must be ACL_NODE or ACL_PARENT");
    }

    QName qName = QName.createQName(qNameString, nspr);

    required = SimplePermissionReference.getPermissionReference(qName, permissionString);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:ACLEntryAfterInvocationProvider.java

示例2: renamePermission

import org.alfresco.repo.security.permissions.impl.SimplePermissionReference; //导入方法依赖的package包/类
/**
 * Helper method to rename (move) a permission.  This involves checking for the existence of the
 * new permission and then moving all the entries to point to the new permission.
 * 
 * @param oldTypeQName the old permission type
 * @param oldName the old permission name
 * @param newTypeQName the new permission type
 * @param newName the new permission name
 * @return Returns the number of permission entries modified
 */
protected int renamePermission(QName oldTypeQName, String oldName, QName newTypeQName, String newName)
{
    if (oldTypeQName.equals(newTypeQName) && oldName.equals(newName))
    {
        throw new IllegalArgumentException("Cannot move permission to itself: " + oldTypeQName + "-" + oldName);
    }
    
    SimplePermissionReference oldPermRef = SimplePermissionReference.getPermissionReference(oldTypeQName, oldName);
    Permission permission = aclCrudDAO.getPermission(oldPermRef);
    if (permission == null)
    {
        // create the permission
        SimplePermissionReference newPermRef = SimplePermissionReference.getPermissionReference(newTypeQName, newName);
        aclCrudDAO.createPermission(newPermRef);
    }
    else
    {
        // rename the permission
        aclCrudDAO.renamePermission(oldTypeQName, oldName, newTypeQName, newName);
    }
    // done
    return 1;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:34,代码来源:AbstractPermissionChangePatch.java

示例3: renamePermission

import org.alfresco.repo.security.permissions.impl.SimplePermissionReference; //导入方法依赖的package包/类
public void renamePermission(QName oldTypeQName, String oldName, QName newTypeQName, String newName)
{
    ParameterCheck.mandatory("oldTypeQName", oldTypeQName);
    ParameterCheck.mandatory("oldName", oldName);
    ParameterCheck.mandatory("newTypeQName", newTypeQName);
    ParameterCheck.mandatory("newName", newName);
    
    if (oldTypeQName.equals(newTypeQName) && oldName.equals(newName))
    {
        throw new IllegalArgumentException("Cannot move permission to itself: " + oldTypeQName + "-" + oldName);
    }
    
    SimplePermissionReference oldPermRef = SimplePermissionReference.getPermissionReference(oldTypeQName, oldName);
    PermissionEntity permission = getPermissionForUpdate(oldPermRef);
    if (permission != null)
    {
        Long newTypeQNameId = qnameDAO.getOrCreateQName(newTypeQName).getFirst();
        permission.setTypeQNameId(newTypeQNameId);
        permission.setName(newName);
        
        int updated = permissionEntityCache.updateValue(permission.getId(), permission);
        if (updated < 1)
        {
            aclEntityCache.removeByKey(permission.getId());
            throw new ConcurrencyFailureException("PermissionEntity with ID (" + permission.getId() + ") no longer exists or has been updated concurrently");
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:29,代码来源:AbstractAclCrudDAOImpl.java

示例4: testCreateAndDeletePermission

import org.alfresco.repo.security.permissions.impl.SimplePermissionReference; //导入方法依赖的package包/类
public void testCreateAndDeletePermission() throws Exception
{
    String name = getName() + "-" + System.currentTimeMillis();
    final SimplePermissionReference permRef = SimplePermissionReference.getPermissionReference(QName.createQName("cm:cmobject"), name);
    
    Permission createdPermEntity = createPermission(permRef);
    assertNotNull(createdPermEntity);
    
    Permission permEntity = getPermission(permRef);
    assertEquals(createdPermEntity, permEntity);
    
    deletePermission(permEntity.getId());
    
    assertNull(getPermission(permRef));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:16,代码来源:AclCrudDAOTest.java

示例5: testCreatePermissionWithRollback

import org.alfresco.repo.security.permissions.impl.SimplePermissionReference; //导入方法依赖的package包/类
public void testCreatePermissionWithRollback() throws Exception
{
    String name = getName() + "-" + System.currentTimeMillis();
    final SimplePermissionReference permRef = SimplePermissionReference.getPermissionReference(QName.createQName("cm:cmobject"), name);
    
    RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>()
    {
        public Void execute() throws Throwable
        {
            createPermission(permRef);
            // Now force a rollback
            throw new RuntimeException("Forced");
        }
    };
    
    try
    {
        txnHelper.doInTransaction(callback);
        fail("Transaction didn't roll back");
    }
    catch (RuntimeException e)
    {
        // Expected
    }
    
    // Check that it doesn't exist
    assertNull(getPermission(permRef));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:29,代码来源:AclCrudDAOTest.java

示例6: ConfigAttributeDefintion

import org.alfresco.repo.security.permissions.impl.SimplePermissionReference; //导入方法依赖的package包/类
ConfigAttributeDefintion(ConfigAttribute attr)
{
    StringTokenizer st = new StringTokenizer(attr.getAttribute(), ".", false);
    if (st.countTokens() < 1)
    {
        throw new ACLEntryVoterException("There must be at least one token in a config attribute");
    }
    typeString = st.nextToken();

    if (!(typeString.equals(ACL_NODE) || typeString.equals(ACL_ITEM) || typeString.equals(ACL_PRI_CHILD_ASSOC_ON_CHILD)
            || typeString.equals(ACL_PARENT) || typeString.equals(ACL_ALLOW) || typeString.equals(ACL_METHOD) || typeString
            .equals(ACL_DENY)))
    {
        throw new ACLEntryVoterException("Invalid type: must be ACL_NODE, ACL_ITEM, ACL_PARENT or ACL_ALLOW");
    }

    if (typeString.equals(ACL_NODE) || typeString.equals(ACL_ITEM) || typeString.equals(ACL_PRI_CHILD_ASSOC_ON_CHILD)
            || typeString.equals(ACL_PARENT))
    {
        int count = st.countTokens();
        if (typeString.equals(ACL_PRI_CHILD_ASSOC_ON_CHILD))
        {
            if (count != 3 && count != 4)
            {
                throw new ACLEntryVoterException("There must be three or four . separated tokens in each config attribute");                        
            }
        }
        else if (count != 3)
        {
            throw new ACLEntryVoterException("There must be three . separated tokens in each config attribute");
        }
        // Handle a variable number of parameters
        parameter = new int[count - 2];
        for (int i=0; i<parameter.length; i++)
        {
            parameter[i] = Integer.parseInt(st.nextToken());                    
        }
        String qNameString = st.nextToken();
        String permissionString = st.nextToken();
        QName qName = QName.createQName(qNameString, nspr);

        required = SimplePermissionReference.getPermissionReference(qName, permissionString);
    }
    else if (typeString.equals(ACL_METHOD))
    {
        if (st.countTokens() != 1)
        {
            throw new ACLEntryVoterException(
                    "There must be two . separated tokens in each group or role config attribute");
        }
        authority = st.nextToken();
    }

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

示例7: getAccessControlList

import org.alfresco.repo.security.permissions.impl.SimplePermissionReference; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public AccessControlList getAccessControlList(Long id)
{
    // Used the cached properties as our cache key
    AccessControlListProperties properties = getAccessControlListProperties(id);
    if (properties == null)
    {
        return null;
    }
    AccessControlList aclCached = aclCache.get((Serializable)properties);
    if (aclCached != null)
    {
        return aclCached;
    }

    SimpleAccessControlList acl = new SimpleAccessControlList();
    acl.setProperties(properties);

    List<Map<String, Object>> results = aclCrudDAO.getAcesAndAuthoritiesByAcl(id);

    List<AccessControlEntry> entries = new ArrayList<AccessControlEntry>(results.size());
    for (Map<String, Object> result : results)
        // for (AclMemberEntity member : members)
    {
        Boolean aceIsAllowed = (Boolean) result.get("allowed");
        Integer aceType = (Integer) result.get("applies");
        String authority = (String) result.get("authority");
        Long permissionId = (Long) result.get("permissionId");
        Integer position = (Integer) result.get("pos");
        //Long result_aclmemId = (Long) result.get("aclmemId"); // not used here

        SimpleAccessControlEntry sacEntry = new SimpleAccessControlEntry();
        sacEntry.setAccessStatus(aceIsAllowed ? AccessStatus.ALLOWED : AccessStatus.DENIED);
        sacEntry.setAceType(ACEType.getACETypeFromId(aceType));
        sacEntry.setAuthority(authority);
        // if (entry.getContext() != null)
        // {
        // SimpleAccessControlEntryContext context = new SimpleAccessControlEntryContext();
        // context.setClassContext(entry.getContext().getClassContext());
        // context.setKVPContext(entry.getContext().getKvpContext());
        // context.setPropertyContext(entry.getContext().getPropertyContext());
        // sacEntry.setContext(context);
        // }
        Permission perm = aclCrudDAO.getPermission(permissionId);
        QName permTypeQName = qnameDAO.getQName(perm.getTypeQNameId()).getSecond(); // Has an ID so must exist
        SimplePermissionReference permissionRefernce = SimplePermissionReference.getPermissionReference(permTypeQName, perm.getName());
        sacEntry.setPermission(permissionRefernce);
        sacEntry.setPosition(position);
        entries.add(sacEntry);
    }

    Collections.sort(entries);
    acl.setEntries(entries);
    
    // Cache it for next time
    aclCache.put((Serializable)properties, acl);

    return acl;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:63,代码来源:AclDAOImpl.java

示例8: disableInheritanceImpl

import org.alfresco.repo.security.permissions.impl.SimplePermissionReference; //导入方法依赖的package包/类
private List<AclChange> disableInheritanceImpl(Long id, boolean setInheritedOnAcl, AclEntity aclIn)
{
    List<AclChange> changes = new ArrayList<AclChange>();

    if (!aclIn.getInherits())
    {
        return Collections.<AclChange> emptyList();
    }

    // Manages caching
    getWritable(id, null, null, null, null, false, changes, WriteMode.COPY_ONLY);
    AclUpdateEntity acl = aclCrudDAO.getAclForUpdate(changes.get(0).getAfter());
    final Long inheritsFrom = acl.getInheritsFrom();
    acl.setInherits(Boolean.FALSE);
    acl.setAclChangeSetId(getCurrentChangeSetId());
    aclCrudDAO.updateAcl(acl);

    // Keep inherits from so we can reinstate if required
    // acl.setInheritsFrom(-1l);

    // Manages caching
    getWritable(acl.getId(), null, null, null, null, true, changes, WriteMode.TRUNCATE_INHERITED);

    // set Inherited - TODO: UNTESTED

    if ((inheritsFrom != null) && (inheritsFrom != -1) && setInheritedOnAcl)
    {
        // get aces for acl (via acl member)
        List<AclMember> members = aclCrudDAO.getAclMembersByAcl(inheritsFrom);

        for (AclMember member : members)
        {
            // TODO optimise
            Ace ace = aclCrudDAO.getAce(member.getAceId());
            Authority authority = aclCrudDAO.getAuthority(ace.getAuthorityId());

            SimpleAccessControlEntry entry = new SimpleAccessControlEntry();
            entry.setAccessStatus(ace.isAllowed() ? AccessStatus.ALLOWED : AccessStatus.DENIED);
            entry.setAceType(ace.getAceType());
            entry.setAuthority(authority.getAuthority());

            /* NOTE: currently unused - intended for possible future enhancement
            if (ace.getContextId() != null)
            {
                AceContext aceContext = aclCrudDAO.getAceContext(ace.getContextId());

                SimpleAccessControlEntryContext context = new SimpleAccessControlEntryContext();
                context.setClassContext(aceContext.getClassContext());
                context.setKVPContext(aceContext.getKvpContext());
                context.setPropertyContext(aceContext.getPropertyContext());
                entry.setContext(context);
            }
             */

            Permission perm = aclCrudDAO.getPermission(ace.getPermissionId());
            QName permTypeQName = qnameDAO.getQName(perm.getTypeQNameId()).getSecond(); // Has an ID so must exist
            SimplePermissionReference permissionRefernce = SimplePermissionReference.getPermissionReference(permTypeQName, perm.getName());
            entry.setPermission(permissionRefernce);
            entry.setPosition(Integer.valueOf(0));

            setAccessControlEntry(id, entry);
        }
    }
    return changes;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:66,代码来源:AclDAOImpl.java


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