本文整理汇总了Java中org.alfresco.service.cmr.security.AccessPermission类的典型用法代码示例。如果您正苦于以下问题:Java AccessPermission类的具体用法?Java AccessPermission怎么用?Java AccessPermission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AccessPermission类属于org.alfresco.service.cmr.security包,在下文中一共展示了AccessPermission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllPermissionsImpl
import org.alfresco.service.cmr.security.AccessPermission; //导入依赖的package包/类
protected Set<AccessPermission> getAllPermissionsImpl(NodeRef nodeRef, boolean includeTrue, boolean includeFalse)
{
String userName = AuthenticationUtil.getRunAsUser();
HashSet<AccessPermission> accessPermissions = new HashSet<AccessPermission>();
for (PermissionReference pr : getSettablePermissionReferences(nodeRef))
{
if (hasPermission(nodeRef, pr) == AccessStatus.ALLOWED)
{
accessPermissions.add(new AccessPermissionImpl(getPermission(pr), AccessStatus.ALLOWED, userName, -1));
}
else
{
if (includeFalse)
{
accessPermissions.add(new AccessPermissionImpl(getPermission(pr), AccessStatus.DENIED, userName, -1));
}
}
}
return accessPermissions;
}
示例2: getPermissions
import org.alfresco.service.cmr.security.AccessPermission; //导入依赖的package包/类
@Override
public Set<AccessPermission> getPermissions(NodeRef nodeRef)
{
PermissionServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference == null)
{
return theTrait.getPermissions(nodeRef);
}
else
{
Set<AccessPermission> virtualSetPermissions = smartStore.getAllSetPermissions(reference);
NodeRef nodeToAdhereTo = establishPermisisonAdherence(reference);
Set<AccessPermission> mergedEntries = new HashSet<>(virtualSetPermissions);
if (nodeToAdhereTo != null)
{
Set<AccessPermission> actualSetPermissions = theTrait.getPermissions(nodeToAdhereTo);
mergedEntries.addAll(actualSetPermissions);
}
return mergedEntries;
}
}
示例3: execute
import org.alfresco.service.cmr.security.AccessPermission; //导入依赖的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);
}
示例4: getSortedACLs
import org.alfresco.service.cmr.security.AccessPermission; //导入依赖的package包/类
/**
* @return Sorted list of <code>AccessPermission</code> based on <code>CMISConnector.AccessPermissionComparator</code>
* and <code>AccessStatus</code> of the permission for an authority.
*/
public static List<AccessPermission> getSortedACLs(Set<AccessPermission> acls)
{
ArrayList<AccessPermission> ordered = new ArrayList<AccessPermission>(acls);
Map<String, AccessPermission> deDuplicatedPermissions = new HashMap<String, AccessPermission>(acls.size());
Collections.sort(ordered, new CMISConnector.AccessPermissionComparator());
for (AccessPermission current : ordered)
{
String composedKey = current.getAuthority() + current.getPermission();
if (current.getAccessStatus() == AccessStatus.ALLOWED)
{
deDuplicatedPermissions.put(composedKey, current);
}
else if (current.getAccessStatus() == AccessStatus.DENIED)
{
deDuplicatedPermissions.remove(composedKey);
}
}
return new ArrayList<AccessPermission>(deDuplicatedPermissions.values());
}
示例5: retrieveAllSetPermissions
import org.alfresco.service.cmr.security.AccessPermission; //导入依赖的package包/类
/**
* Helper to construct the response object for the various getPermissions() calls.
*
* @param direct True to only retrieve direct permissions, false to get inherited also
* @param full True to retrieve full data string with [INHERITED|DIRECT] element
* This exists to maintain backward compatibility with existing permission APIs.
*
* @return Object[] of packed permission strings.
*/
protected Object[] retrieveAllSetPermissions(boolean direct, boolean full)
{
Set<AccessPermission> acls = this.services.getPermissionService().getAllSetPermissions(getNodeRef());
List<Object> permissions = new ArrayList<Object>(acls.size());
List<AccessPermission> ordered = getSortedACLs(acls);
for (AccessPermission permission : ordered)
{
if (!direct || permission.isSetDirectly())
{
StringBuilder buf = new StringBuilder(64);
buf.append(permission.getAccessStatus())
.append(';')
.append(permission.getAuthority())
.append(';')
.append(permission.getPermission());
if (full)
{
buf.append(';').append(permission.isSetDirectly() ? "DIRECT" : "INHERITED");
}
permissions.add(buf.toString());
}
}
return (Object[])permissions.toArray(new Object[permissions.size()]);
}
示例6: allSetPermissionsToJSON
import org.alfresco.service.cmr.security.AccessPermission; //导入依赖的package包/类
/**
* Handles the work of converting all set permissions to JSON.
*
* @param nodeRef NodeRef
* @return JSONArray
*/
@SuppressWarnings("unchecked")
protected JSONArray allSetPermissionsToJSON(NodeRef nodeRef)
{
Set<AccessPermission> acls = permissionService.getAllSetPermissions(nodeRef);
JSONArray permissions = new JSONArray();
List<AccessPermission> ordered = ScriptNode.getSortedACLs(acls);
for (AccessPermission permission : ordered)
{
StringBuilder buf = new StringBuilder(64);
buf.append(permission.getAccessStatus())
.append(';')
.append(permission.getAuthority())
.append(';')
.append(permission.getPermission())
.append(';').append(permission.isSetDirectly() ? "DIRECT" : "INHERITED");
permissions.add(buf.toString());
}
return permissions;
}
示例7: getAllowedPermissionsMap
import org.alfresco.service.cmr.security.AccessPermission; //导入依赖的package包/类
/**
* Gets the authorities and their allowed permissions for a node
*/
private Map<String, Set<String>> getAllowedPermissionsMap(NodeRef nodeRef)
{
Map<String,Set<String>> perms = new HashMap<String, Set<String>>();
for (AccessPermission ap : permissionService.getAllSetPermissions(nodeRef))
{
if (ap.getAccessStatus() == AccessStatus.ALLOWED)
{
Set<String> permsValue = perms.get(ap.getAuthority());
if (permsValue == null)
{
permsValue = new HashSet<String>();
}
permsValue.add(ap.getPermission());
perms.put(ap.getAuthority(), permsValue);
}
}
return perms;
}
示例8: mapAccessPermissionsByName
import org.alfresco.service.cmr.security.AccessPermission; //导入依赖的package包/类
private Map<String, List<AccessPermission>> mapAccessPermissionsByName(Set<AccessPermission> accessPermissions)
{
Map<String, List<AccessPermission>> nameMap = new HashMap<>();
for (AccessPermission accessPermission : accessPermissions)
{
String name = accessPermission.getPermission();
List<AccessPermission> permissions = (List<AccessPermission>) nameMap.get(name);
if (permissions == null)
{
permissions = new ArrayList<>();
nameMap.put(name,
permissions);
}
permissions.add(accessPermission);
}
return nameMap;
}
示例9: assertUniqueAccessPermission
import org.alfresco.service.cmr.security.AccessPermission; //导入依赖的package包/类
/**
* Asserts that the permission with the given name uniquely found in the
* given permission entries list has the given access status for the given
* authority.
*
* @param permissionName
* @param accessStatus
* @param authority
* @param permissionEntries
*/
protected void assertUniqueAccessPermission(String permissionName, AccessStatus accessStatus, String authority,
Set<AccessPermission> accessPermissions)
{
Map<String, List<AccessPermission>> apByName = mapAccessPermissionsByName(accessPermissions);
assertNotNull("Not null permission " + permissionName + " expected.",
apByName.get(permissionName));
List<AccessPermission> oneAccessPermission = apByName.get(permissionName);
assertEquals("Expected single AccessPermission but found " + oneAccessPermission,
1,
oneAccessPermission.size());
AccessPermission permission = apByName.get(permissionName).get(0);
assertEquals(accessStatus,
permission.getAccessStatus());
assertEquals(authority,
permission.getAuthority());
}
示例10: getPermissions
import org.alfresco.service.cmr.security.AccessPermission; //导入依赖的package包/类
/**
* Gets the current node permissions
*
* @return the permissions
*/
public List<Permission> getPermissions(NodeRef nodeRef)
{
List<Permission> permissions = null;
AccessStatus readPermissions = this.getPermissionService().hasPermission(nodeRef, PermissionService.READ_PERMISSIONS);
if (readPermissions.equals(AccessStatus.ALLOWED))
{
List<Permission> nodePermissions = new ArrayList<Permission>();
for (Iterator<AccessPermission> iterator = getPermissionService().getAllSetPermissions(nodeRef).iterator(); iterator
.hasNext();)
{
AccessPermission ap = iterator.next();
nodePermissions.add(new Permission(ap.getPermission(), ap.getAuthority(), ap.getAccessStatus().toString()));
}
permissions = nodePermissions;
}
else
{
List<Permission> noReadPermissions = new ArrayList<Permission>(1);
noReadPermissions.add(new NoReadPermissionGranted());
permissions = noReadPermissions;
}
return permissions;
}
示例11: checkPermissions
import org.alfresco.service.cmr.security.AccessPermission; //导入依赖的package包/类
private void checkPermissions(NodeRef nodeRef, String necessatyAuth, String expectedPermission, String actionInfo)
{
Set<AccessPermission> allSetPermissions = permissionService.getAllSetPermissions(nodeRef);
for (AccessPermission perm : allSetPermissions)
{
String authority = perm.getAuthority();
if (necessatyAuth.equals(authority))
{
if (expectedPermission.equals(perm.getPermission()))
{
return;
}
fail("Expected permissions for authority \"" + necessatyAuth + "\" are incorrect. Expected: " + expectedPermission + ", but actual permission: "
+ perm.getPermission() + ". Check position: " + actionInfo);
}
}
fail("Expected authority \"" + necessatyAuth + "\" wasn't found. Check position: " + actionInfo);
}
示例12: getPermissions
import org.alfresco.service.cmr.security.AccessPermission; //导入依赖的package包/类
@Override
public Set<AccessPermission> getPermissions(NodeRef nodeRef)
{
PermissionServiceTrait theTrait = getTrait();
if (!Reference.isReference(nodeRef))
{
return theTrait.getPermissions(nodeRef);
}
else
{
Reference reference = Reference.fromNodeRef(nodeRef);
Set<AccessPermission> virtualSetPermissions = smartStore.getAllSetPermissions(reference);
NodeRef nodeToAdhereTo = establishPermisisonAdherence(reference);
Set<AccessPermission> mergedEntries = new HashSet<>(virtualSetPermissions);
if (nodeToAdhereTo != null)
{
Set<AccessPermission> actualSetPermissions = theTrait.getPermissions(nodeToAdhereTo);
mergedEntries.addAll(actualSetPermissions);
}
return mergedEntries;
}
}
示例13: getCapabilitiesImpl
import org.alfresco.service.cmr.security.AccessPermission; //导入依赖的package包/类
/**
*
* @param rmRootNode
* @param roleAuthority
* @return
*/
private Set<Capability> getCapabilitiesImpl(NodeRef rmRootNode, String roleAuthority)
{
Set<AccessPermission> permissions = permissionService.getAllSetPermissions(rmRootNode);
Set<Capability> capabilities = new HashSet<Capability>(52);
for (AccessPermission permission : permissions)
{
if (permission.getAuthority().equals(roleAuthority))
{
String capabilityName = permission.getPermission();
Capability capability = capabilityService.getCapability(capabilityName);
if (capability != null && !capability.isPrivate())
{
capabilities.add(capability);
}
}
}
return capabilities;
}
示例14: assertExistenceOfSpecialRolesAndPermissions
import org.alfresco.service.cmr.security.AccessPermission; //导入依赖的package包/类
private void assertExistenceOfSpecialRolesAndPermissions(NodeRef node)
{
Map<String, String> accessPermissions = new HashMap<String, String>();
Set<AccessPermission> permissions = permissionService.getAllSetPermissions(node);
// FIXME!!!
//assertEquals(3, permissions.size());
for (AccessPermission permission : permissions)
{
accessPermissions.put(permission.getAuthority(), permission.getPermission());
}
assertTrue(accessPermissions.containsKey(ExtendedReaderDynamicAuthority.EXTENDED_READER));
assertEquals(RMPermissionModel.READ_RECORDS, accessPermissions.get(ExtendedReaderDynamicAuthority.EXTENDED_READER));
assertTrue(accessPermissions.containsKey(ExtendedWriterDynamicAuthority.EXTENDED_WRITER));
assertEquals(RMPermissionModel.FILING, accessPermissions.get(ExtendedWriterDynamicAuthority.EXTENDED_WRITER));
String adminRole = authorityService.getName(AuthorityType.GROUP, FilePlanRoleService.ROLE_ADMIN + filePlan.getId());
assertTrue(accessPermissions.containsKey(adminRole));
assertEquals(RMPermissionModel.FILING, accessPermissions.get(adminRole));
}
示例15: getAllSetPermissions
import org.alfresco.service.cmr.security.AccessPermission; //导入依赖的package包/类
@Override
@Extend(traitAPI = PermissionServiceTrait.class, extensionAPI = PermissionServiceExtension.class)
public Set<AccessPermission> getAllSetPermissions(NodeRef nodeRef)
{
HashSet<AccessPermission> accessPermissions = new HashSet<AccessPermission>();
NodePermissionEntry nodePremissionEntry = getSetPermissions(nodeRef);
for (PermissionEntry pe : nodePremissionEntry.getPermissionEntries())
{
accessPermissions.add(new AccessPermissionImpl(getPermission(pe.getPermissionReference()), pe.getAccessStatus(), pe.getAuthority(), pe.getPosition()));
}
return accessPermissions;
}