• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AclEntryPermission类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: makeFileNonReadable

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
private static void makeFileNonReadable(String file) throws IOException {
    Path filePath = Paths.get(file);
    Set<String> supportedAttr = filePath.getFileSystem().supportedFileAttributeViews();

    if (supportedAttr.contains("posix")) {
        Files.setPosixFilePermissions(filePath, PosixFilePermissions.fromString("-w--w----"));
    } else if (supportedAttr.contains("acl")) {
        UserPrincipal fileOwner = Files.getOwner(filePath);

        AclFileAttributeView view = Files.getFileAttributeView(filePath, AclFileAttributeView.class);

        AclEntry entry = AclEntry.newBuilder()
                .setType(AclEntryType.DENY)
                .setPrincipal(fileOwner)
                .setPermissions(AclEntryPermission.READ_DATA)
                .build();

        List<AclEntry> acl = view.getAcl();
        acl.add(0, entry);
        view.setAcl(acl);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:TestVMOptionsFile.java


示例2: checkAccessAllowed

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
@Override
public boolean checkAccessAllowed(CloudPath path, UserPrincipal userOrGroup,
		Set<AclEntryPermission> checkPermissions) {
	// Get the view for the path
	CloudFileAttributesView cloudFileAttributeView = Files.getFileAttributeView(path, CloudFileAttributesView.class);
	
	if (cloudFileAttributeView == null) {
		LOG.warn("Could not get {} attribute view from path {}", CloudFileAttributesView.class, path);
		return false;
	}

	CloudAclFileAttributes aclFileAttributes;
	try {
		aclFileAttributes = cloudFileAttributeView.readAttributes();
	} catch (IOException e) {
		LOG.warn("Could not read ACL file attributes for {}", path);
		return false;
	}
	
	return checkAccessAllowed(aclFileAttributes.getAclSet(), userOrGroup, checkPermissions);
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:22,代码来源:DefaultAclCheckingSecurityManager.java


示例3: newByteChannel

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
/**
 * File access is checked using {@link #checkAccess(BlobStoreContext, CloudPath, Set)}
 * always with {@link AclEntryPermission#WRITE_DATA} and {@link AclEntryPermission#ADD_FILE},
 * and optionally with {@link AclEntryPermission#APPEND_DATA} if <em>options</em> contains
 * {@link StandardOpenOption#APPEND}.
 * @see	CloudFileChannel
 */
@Override
public CloudFileChannel newByteChannel(BlobStoreContext context, CloudPath path,
		Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
	EnumSet<AclEntryPermission> channelPerms = EnumSet.noneOf(AclEntryPermission.class);
	options.forEach(o -> {
		AclEntryPermission aclPerm = openOptionToAclEntryPermission(o);
		if (aclPerm != null) {
			channelPerms.add(aclPerm);
		}
	});

	// Check the parent path for file add
	if (channelPerms.remove(AclEntryPermission.ADD_FILE)) {
		checkAccess(context, path.getParent(), CREATE_NEW_FILE_PERMS);
	}

	// Check file access if the file exists
	if (path.exists()) {
		checkAccess(context, path, channelPerms);
	}
	
	// Create the channel
	return new CloudFileChannel(context, path, getCloudFileChannelTransport(), options, attrs);
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:32,代码来源:DefaultCloudFileSystemImplementation.java


示例4: openOptionToAclEntryPermission

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
/**
 * Transforms a {@link StandardOpenOption} into an {@link AclEntryPermission}. Other
 * {@link OpenOption} types are ignored.
 * @param o
 * @return The option as an ACL permission or null if this is not applicable.
 */
protected AclEntryPermission openOptionToAclEntryPermission(OpenOption o) {
	if (o instanceof StandardOpenOption) {
		switch ((StandardOpenOption)o) {
			case APPEND: return AclEntryPermission.APPEND_DATA;
			case CREATE: return AclEntryPermission.ADD_FILE;
			case CREATE_NEW: return AclEntryPermission.ADD_FILE;
			case DELETE_ON_CLOSE: return AclEntryPermission.DELETE;
			case READ: return AclEntryPermission.READ_DATA;
			case TRUNCATE_EXISTING: return AclEntryPermission.APPEND_DATA;
			case WRITE: return AclEntryPermission.WRITE_DATA;
			default: return null;
		}
	}

	return null;
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:23,代码来源:DefaultCloudFileSystemImplementation.java


示例5: CloudAclFileAttributes

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
/**
 * <p>
 * This constructor can only discern some very basic permissions. It assumes that because you have access
 * to this container then you have all CRUD operation access. This may not be true. More sophisticated
 * implementations should be able to tell the exact permissions.
 * </p>
 * <p>
 * There is a lone {@link CloudAclEntry} created which has the default permissions. It is of type
 * {@link PublicPrivateCloudPermissionsPrincipal}.
 * </p>
 * <p>
 * Subclasses may implement different permissions.
 * </p>
 */
public CloudAclFileAttributes(CloudAclEntryConflictChecker conflictChecker, BlobMetadata blobMetadata, BlobAccess blobAccess) {
	super(blobMetadata);
	aclSet = new CloudAclEntrySet(AnonymousUserPrincipal.INSTANCE, conflictChecker);
	CloudAclEntry<PublicPrivateCloudPermissionsPrincipal> entry =
		new CloudAclEntryBuilder<>(PublicPrivateCloudPermissionsPrincipal.class)
			.addPermissions(AclEntryPermission.READ_DATA, AclEntryPermission.WRITE_DATA, AclEntryPermission.APPEND_DATA,
					AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY,
					AclEntryPermission.DELETE, AclEntryPermission.DELETE_CHILD, AclEntryPermission.LIST_DIRECTORY,
					AclEntryPermission.READ_ACL, AclEntryPermission.WRITE_ACL,
					AclEntryPermission.READ_ATTRIBUTES, AclEntryPermission.READ_ATTRIBUTES)
			.setType(AclEntryType.ALLOW)
			.setPrincipal(new PublicPrivateCloudPermissionsPrincipal(blobAccess))
			.build();
	addAcl(AnonymousUserPrincipal.INSTANCE, entry);
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:30,代码来源:CloudAclFileAttributes.java


示例6: checkAccess

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
@Override
public void checkAccess(Path path, AccessMode... modes) throws IOException {
	CloudPath cloudPath = getCloudPath(path);
	CloudFileSystemImplementation sourceCloudFileSystemImplementation = getCloudFileSystemImplementation(cloudPath);

	// Work out permissions to check
	Set<AclEntryPermission> checkPermissions = EnumSet.noneOf(AclEntryPermission.class);
	Arrays.stream(modes).forEach(m ->
			{
				if (AccessMode.EXECUTE.equals(m)) {
					checkPermissions.add(AclEntryPermission.EXECUTE);
				} else if (AccessMode.READ.equals(m)) {
					checkPermissions.add(AclEntryPermission.READ_DATA);
				} else if (AccessMode.WRITE.equals(m)) {
					checkPermissions.add(AclEntryPermission.WRITE_DATA);
				}
			});

	sourceCloudFileSystemImplementation.checkAccess(getBlobStoreContext(cloudPath), cloudPath, checkPermissions);
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:21,代码来源:CloudFileSystemProviderDelegate.java


示例7: hasPermissions

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
boolean hasPermissions(EnumSet<AclEntryPermission> permissions) {
	CloudHostConfiguration cloudHostConfiguration = cloudPath.getFileSystem().getCloudHostConfiguration();
	CloudHostSecurityManager cloudHostSecurityManager = cloudHostConfiguration.getCloudHostSecurityManager();
	UserGroupLookupService<?> userPrincipalLookupService =
			cloudHostConfiguration.getUserGroupLookupService();

	if (cloudHostSecurityManager == null) {
		// No security manager, allow access
		LOG.debug("No {} found in cloud host configuration {}, default action is to allow all access",
				CloudHostSecurityManager.class, cloudHostConfiguration);
		return true;
	}

	UserPrincipal currentUser = null; // Anonymous
	if (userPrincipalLookupService != null) {
		currentUser = userPrincipalLookupService.getCurrentUser();
	} else {
		LOG.debug("Cannot find current user, no {} in cloud host configuration {}",
				UserGroupLookupService.class, cloudHostConfiguration);
		currentUser = AnonymousUserPrincipal.INSTANCE;
	}

	return cloudHostSecurityManager.checkAccessAllowed(cloudPath, currentUser, permissions);
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:25,代码来源:CloudFile.java


示例8: testDoesUserHaveAccessFailsForAUserWithAnAnonymousGroupAllowRuleButAnonymousUserDenyRule

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
@Test
public void testDoesUserHaveAccessFailsForAUserWithAnAnonymousGroupAllowRuleButAnonymousUserDenyRule() {
	UserPrincipal user = new TestUserImpl("user1");
	CloudAclEntry<GroupPrincipal> entry1 = new CloudAclEntryBuilder<GroupPrincipal>(GroupPrincipal.class)
		.addPermission(AclEntryPermission.ADD_FILE)
		.setType(AclEntryType.ALLOW)
		.setPrincipal(AnonymousGroupPrincipal.INSTANCE)
		.build();
	CloudAclEntry<UserPrincipal> entry2 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
			.addPermission(AclEntryPermission.ADD_FILE)
			.setType(AclEntryType.DENY)
			.setPrincipal(new AnonymousUserPrincipal())
			.build();
	CloudAclEntrySet assetPermissions = new CloudAclEntrySet(AnonymousUserPrincipal.INSTANCE, entry1, entry2);
	Assert.assertFalse(mgr.doesUserHaveAccess(assetPermissions, user, null, EnumSet.of(AclEntryPermission.ADD_FILE)));
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:17,代码来源:DefaultAclCheckingSecurityManagerTest.java


示例9: testDoesUserHaveAccessFailsForAUserGroupWithAnAllowRuleAndAUserWithADenyRule

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
@Test
public void testDoesUserHaveAccessFailsForAUserGroupWithAnAllowRuleAndAUserWithADenyRule() {
	UserPrincipal user = new TestUserImpl("user1");
	CloudAclEntry<UserPrincipal> entry1 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
		.addPermission(AclEntryPermission.ADD_FILE)
		.setType(AclEntryType.DENY)
		.setPrincipal(user)
		.build();
	GroupPrincipal group1 = new TestGroupImpl("group1");
	GroupPrincipal group2 = new TestGroupImpl("group2");
	Set<GroupPrincipal> userGroups = Sets.newHashSet(group1, group2);
	CloudAclEntry<GroupPrincipal> entry2 = new CloudAclEntryBuilder<GroupPrincipal>(GroupPrincipal.class)
			.addPermission(AclEntryPermission.ADD_FILE)
			.setType(AclEntryType.ALLOW)
			.setPrincipal(group2)
			.build();
	CloudAclEntrySet assetPermissions = new CloudAclEntrySet(AnonymousUserPrincipal.INSTANCE, entry1, entry2);
	Assert.assertFalse(mgr.doesUserHaveAccess(assetPermissions, user, userGroups, EnumSet.of(AclEntryPermission.ADD_FILE)));
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:20,代码来源:DefaultAclCheckingSecurityManagerTest.java


示例10: TestUserImpl

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
@Test
public void testDoesUserHaveAccessSucceedsForAUserPrincipalWithMultipleCheckPermissionsAndMultipleAssetPermissionsAllowed() {
	UserPrincipal user = new TestUserImpl("user1");
	CloudAclEntry<UserPrincipal> entry1 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
		.addPermissions(AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY, AclEntryPermission.WRITE_ACL)
		.setType(AclEntryType.ALLOW)
		.setPrincipal(user)
		.build();
	CloudAclEntrySet assetPermissions = new CloudAclEntrySet(AnonymousUserPrincipal.INSTANCE, entry1);
	Assert.assertTrue(mgr.doesUserHaveAccess(assetPermissions, user, null,
			EnumSet.of(AclEntryPermission.ADD_FILE, AclEntryPermission.WRITE_ACL)));
	Assert.assertTrue(mgr.doesUserHaveAccess(assetPermissions, user, null,
			EnumSet.of(AclEntryPermission.ADD_SUBDIRECTORY, AclEntryPermission.WRITE_ACL)));
	Assert.assertTrue(mgr.doesUserHaveAccess(assetPermissions, user, null,
			EnumSet.of(AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY, AclEntryPermission.WRITE_ACL)));
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:17,代码来源:DefaultAclCheckingSecurityManagerTest.java


示例11: testIsConflictingAclWillDetermineThatAnAllowAndDenyForTheSamePermissionsForAUserConflicts

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
@Test
public void testIsConflictingAclWillDetermineThatAnAllowAndDenyForTheSamePermissionsForAUserConflicts() {
	UserPrincipal user1 = new TestUserImpl("user1");
	UserPrincipal user2 = new TestUserImpl("user1");

	CloudAclEntry<UserPrincipal> cloudAclEntry1 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
		.setPrincipal(user1)
		.setType(AclEntryType.DENY)
		.addPermissions(AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY)
		.build();

	CloudAclEntry<UserPrincipal> cloudAclEntry2 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
			.setPrincipal(user2)
			.setType(AclEntryType.ALLOW)
			.addPermissions(AclEntryPermission.DELETE, AclEntryPermission.ADD_SUBDIRECTORY)
			.build();

	Assert.assertTrue(checker.isConflictingAcl(cloudAclEntry1, cloudAclEntry2));
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:20,代码来源:DefaultCloudAclEntryConflictCheckerTest.java


示例12: testIsConflictingAclWillDetermineThatAnAllowAndDenyForDifferentUsersDoesNotConflict

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
@Test
public void testIsConflictingAclWillDetermineThatAnAllowAndDenyForDifferentUsersDoesNotConflict() {
	UserPrincipal user1 = new TestUserImpl("user1");
	UserPrincipal user2 = new TestUserImpl("user2");

	CloudAclEntry<UserPrincipal> cloudAclEntry1 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
		.setPrincipal(user1)
		.setType(AclEntryType.DENY)
		.addPermissions(AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY)
		.build();

	CloudAclEntry<UserPrincipal> cloudAclEntry2 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
			.setPrincipal(user2)
			.setType(AclEntryType.ALLOW)
			.addPermissions(AclEntryPermission.DELETE, AclEntryPermission.ADD_SUBDIRECTORY)
			.build();

	Assert.assertFalse(checker.isConflictingAcl(cloudAclEntry1, cloudAclEntry2));
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:20,代码来源:DefaultCloudAclEntryConflictCheckerTest.java


示例13: testIsConflictingAclWillDetermineThatAnAllowAndDenyForTheSamePermissionsForAGroupConflicts

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
@Test
public void testIsConflictingAclWillDetermineThatAnAllowAndDenyForTheSamePermissionsForAGroupConflicts() {
	GroupPrincipal group1 = new TestGroupImpl("group1");
	GroupPrincipal group2 = new TestGroupImpl("group1");

	CloudAclEntry<GroupPrincipal> cloudAclEntry1 = new CloudAclEntryBuilder<GroupPrincipal>(GroupPrincipal.class)
		.setPrincipal(group1)
		.setType(AclEntryType.DENY)
		.addPermissions(AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY)
		.build();

	CloudAclEntry<GroupPrincipal> cloudAclEntry2 = new CloudAclEntryBuilder<GroupPrincipal>(GroupPrincipal.class)
			.setPrincipal(group2)
			.setType(AclEntryType.ALLOW)
			.addPermissions(AclEntryPermission.ADD_SUBDIRECTORY)
			.build();

	Assert.assertTrue(checker.isConflictingAcl(cloudAclEntry1, cloudAclEntry2));
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:20,代码来源:DefaultCloudAclEntryConflictCheckerTest.java


示例14: testIsConflictingAclWillDetermineThatAnAllowAndDenyForDifferentGroupsDoesNotConflict

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
@Test
public void testIsConflictingAclWillDetermineThatAnAllowAndDenyForDifferentGroupsDoesNotConflict() {
	GroupPrincipal group1 = new TestGroupImpl("group1");
	GroupPrincipal group2 = new TestGroupImpl("group2");

	CloudAclEntry<GroupPrincipal> cloudAclEntry1 = new CloudAclEntryBuilder<GroupPrincipal>(GroupPrincipal.class)
		.setPrincipal(group1)
		.setType(AclEntryType.DENY)
		.addPermissions(AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY)
		.build();

	CloudAclEntry<GroupPrincipal> cloudAclEntry2 = new CloudAclEntryBuilder<GroupPrincipal>(GroupPrincipal.class)
			.setPrincipal(group2)
			.setType(AclEntryType.ALLOW)
			.addPermissions(AclEntryPermission.ADD_SUBDIRECTORY)
			.build();

	Assert.assertFalse(checker.isConflictingAcl(cloudAclEntry1, cloudAclEntry2));
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:20,代码来源:DefaultCloudAclEntryConflictCheckerTest.java


示例15: testIsConflictingAclWillReturnFalseForAUserNotInAGroup

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
@Test
public void testIsConflictingAclWillReturnFalseForAUserNotInAGroup() {
	UserPrincipal user1 = new TestUserImpl("user1");
	GroupPrincipal group2 = new TestGroupImpl("group1");

	CloudAclEntry<UserPrincipal> cloudAclEntry1 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
		.setPrincipal(user1)
		.setType(AclEntryType.DENY)
		.addPermissions(AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY)
		.build();

	CloudAclEntry<GroupPrincipal> cloudAclEntry2 = new CloudAclEntryBuilder<GroupPrincipal>(GroupPrincipal.class)
			.setPrincipal(group2)
			.setType(AclEntryType.ALLOW)
			.addPermissions(AclEntryPermission.ADD_SUBDIRECTORY)
			.build();

	Assert.assertFalse(checker.isConflictingAcl(cloudAclEntry1, cloudAclEntry2));
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:20,代码来源:DefaultCloudAclEntryConflictCheckerTest.java


示例16: testIsConflictingAclWillReturnFalseByDefaultForAUserInAGroupWithConflictingPermissions

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
@Test
public void testIsConflictingAclWillReturnFalseByDefaultForAUserInAGroupWithConflictingPermissions() {
	UserPrincipal user1 = new TestUserImpl("user1");
	TestGroupImpl group2 = new TestGroupImpl("group1");
	group2.addMember(user1);
	Assert.assertTrue(group2.isMember(user1));

	CloudAclEntry<UserPrincipal> cloudAclEntry1 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
		.setPrincipal(user1)
		.setType(AclEntryType.DENY)
		.addPermissions(AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY)
		.build();

	CloudAclEntry<GroupPrincipal> cloudAclEntry2 = new CloudAclEntryBuilder<GroupPrincipal>(GroupPrincipal.class)
			.setPrincipal(group2)
			.setType(AclEntryType.ALLOW)
			.addPermissions(AclEntryPermission.ADD_SUBDIRECTORY)
			.build();

	Assert.assertFalse(checker.isConflictingAcl(cloudAclEntry1, cloudAclEntry2));
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:22,代码来源:DefaultCloudAclEntryConflictCheckerTest.java


示例17: DefaultCloudAclEntryConflictChecker

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
@Test
public void testIsConflictingAclWillReturnTrueIfTheGroupMembershipCheckIsEnabledForAUserInAGroupWithConflictingPermissions() {
	checker = new DefaultCloudAclEntryConflictChecker(true);
	UserPrincipal user1 = new TestUserImpl("user1");
	TestGroupImpl group2 = new TestGroupImpl("group1");
	group2.addMember(user1);
	Assert.assertTrue(group2.isMember(user1));

	CloudAclEntry<UserPrincipal> cloudAclEntry1 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
		.setPrincipal(user1)
		.setType(AclEntryType.DENY)
		.addPermissions(AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY)
		.build();

	CloudAclEntry<GroupPrincipal> cloudAclEntry2 = new CloudAclEntryBuilder<GroupPrincipal>(GroupPrincipal.class)
			.setPrincipal(group2)
			.setType(AclEntryType.ALLOW)
			.addPermissions(AclEntryPermission.ADD_SUBDIRECTORY)
			.build();

	Assert.assertTrue(checker.isConflictingAcl(cloudAclEntry1, cloudAclEntry2));
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:23,代码来源:DefaultCloudAclEntryConflictCheckerTest.java


示例18: testMergeAclForTwoAllowRulesWillMergeThePermissionsAndFlagsOfTwoAclsForTheSameUser

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
@Test
public void testMergeAclForTwoAllowRulesWillMergeThePermissionsAndFlagsOfTwoAclsForTheSameUser() {
	CloudAclEntry<UserPrincipal> cloudAclEntry1 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
			.setPrincipal(new TestUserImpl("user1"))
			.setType(AclEntryType.ALLOW)
			.addPermissions(AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY)
			.addFlag(AclEntryFlag.DIRECTORY_INHERIT)
			.build();

	CloudAclEntry<UserPrincipal> cloudAclEntry2 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
			.setPrincipal(new TestUserImpl("user1"))
			.setType(AclEntryType.ALLOW)
			.addPermissions(AclEntryPermission.DELETE)
			.addFlag(AclEntryFlag.FILE_INHERIT)
			.build();

	CloudAclEntry<?> mergedAcl = checker.mergeAcl(new ConflictingCloudAclEntry(cloudAclEntry1, cloudAclEntry2));
	Assert.assertEquals("user1", ((TestUserImpl)mergedAcl.getPrincipal()).getName());
	Assert.assertEquals(AclEntryType.ALLOW, mergedAcl.getType());
	Assert.assertEquals(EnumSet.of(AclEntryPermission.DELETE, AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY),
			mergedAcl.getPermissions());
	Assert.assertEquals(EnumSet.of(AclEntryFlag.DIRECTORY_INHERIT, AclEntryFlag.FILE_INHERIT), mergedAcl.getFlags());
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:24,代码来源:DefaultCloudAclEntryConflictCheckerTest.java


示例19: testMergeAclForTwoDenyRulesWillMergeThePermissionsAndFlagsOfTwoAclsForTheSameUser

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
@Test
public void testMergeAclForTwoDenyRulesWillMergeThePermissionsAndFlagsOfTwoAclsForTheSameUser() {
	CloudAclEntry<UserPrincipal> cloudAclEntry1 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
			.setPrincipal(new TestUserImpl("user1"))
			.setType(AclEntryType.DENY)
			.addPermissions(AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY)
			.addFlag(AclEntryFlag.DIRECTORY_INHERIT)
			.build();

	CloudAclEntry<UserPrincipal> cloudAclEntry2 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
			.setPrincipal(new TestUserImpl("user1"))
			.setType(AclEntryType.DENY)
			.addPermissions(AclEntryPermission.DELETE)
			.addFlag(AclEntryFlag.FILE_INHERIT)
			.build();

	CloudAclEntry<?> mergedAcl = checker.mergeAcl(new ConflictingCloudAclEntry(cloudAclEntry1, cloudAclEntry2));
	Assert.assertEquals("user1", ((TestUserImpl)mergedAcl.getPrincipal()).getName());
	Assert.assertEquals(AclEntryType.DENY, mergedAcl.getType());
	Assert.assertEquals(EnumSet.of(AclEntryPermission.DELETE, AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY),
			mergedAcl.getPermissions());
	Assert.assertEquals(EnumSet.of(AclEntryFlag.DIRECTORY_INHERIT, AclEntryFlag.FILE_INHERIT), mergedAcl.getFlags());
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:24,代码来源:DefaultCloudAclEntryConflictCheckerTest.java


示例20: testCheckAccessForADirectoryWithAnAnonymousUserWillAllowAccessIfTheSecurityManagerAllowsIt

import java.nio.file.attribute.AclEntryPermission; //导入依赖的package包/类
@Test
public void testCheckAccessForADirectoryWithAnAnonymousUserWillAllowAccessIfTheSecurityManagerAllowsIt() throws IOException {
	CloudHostSecurityManager securityManager = context.mock(CloudHostSecurityManager.class);
	EnumSet<AclEntryPermission> perms = EnumSet.of(AclEntryPermission.ADD_FILE);

	context.checking(new Expectations() {{
		allowing(config).getUserGroupLookupService();
		will(returnValue(null));

		allowing(config).getCloudHostSecurityManager();
		will(returnValue(securityManager));

		allowing(blobStore).directoryExists(TEST_CONTAINER, TEST_PATH);
		will(returnValue(true));

		exactly(1).of(securityManager).checkAccessAllowed(with(any(CloudAclEntrySet.class)),
				with(equal(AnonymousUserPrincipal.INSTANCE)), with(equal(perms)));
		will(returnValue(true));
	}});

	view.checkAccess(perms);
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:23,代码来源:CloudFileAttributesViewTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SnmpErrorHandlerAgent类代码示例发布时间:2022-05-22
下一篇:
Java RenewDelegationTokenRequestPBImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap