當前位置: 首頁>>代碼示例>>Java>>正文


Java AclEntryFlag類代碼示例

本文整理匯總了Java中java.nio.file.attribute.AclEntryFlag的典型用法代碼示例。如果您正苦於以下問題:Java AclEntryFlag類的具體用法?Java AclEntryFlag怎麽用?Java AclEntryFlag使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AclEntryFlag類屬於java.nio.file.attribute包,在下文中一共展示了AclEntryFlag類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testMergeAclForTwoAllowRulesWillMergeThePermissionsAndFlagsOfTwoAclsForTheSameUser

import java.nio.file.attribute.AclEntryFlag; //導入依賴的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

示例2: testMergeAclForTwoDenyRulesWillMergeThePermissionsAndFlagsOfTwoAclsForTheSameUser

import java.nio.file.attribute.AclEntryFlag; //導入依賴的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

示例3: createConfigurationAccessACLEntry

import java.nio.file.attribute.AclEntryFlag; //導入依賴的package包/類
private AclEntry createConfigurationAccessACLEntry(UserPrincipal user) {
    AclEntry entry = AclEntry
            .newBuilder()
            .setType(AclEntryType.ALLOW)
            .setPrincipal(user)
            .setPermissions(
                    AclEntryPermission.WRITE_NAMED_ATTRS,
                    AclEntryPermission.WRITE_DATA,
                    AclEntryPermission.WRITE_ATTRIBUTES,
                    AclEntryPermission.READ_ATTRIBUTES,
                    AclEntryPermission.APPEND_DATA,
                    AclEntryPermission.READ_DATA,
                    AclEntryPermission.READ_NAMED_ATTRS,
                    AclEntryPermission.READ_ACL,
                    AclEntryPermission.SYNCHRONIZE,
                    AclEntryPermission.DELETE)
            .setFlags(AclEntryFlag.FILE_INHERIT)
            .build();
    return entry;
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:21,代碼來源:PersistanceResourceTestCase.java

示例4: testCloneProducesAnEquivalentAclEntry

import java.nio.file.attribute.AclEntryFlag; //導入依賴的package包/類
@Test
public void testCloneProducesAnEquivalentAclEntry() {
	TestUserImpl testUser = new TestUserImpl("user1");
	CloudAclEntryBuilder<UserPrincipal> builder = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
		.addFlag(AclEntryFlag.DIRECTORY_INHERIT)
		.setPrincipal(testUser)
		.setType(AclEntryType.ALLOW);
	CloudAclEntry<UserPrincipal> unclonedEntry = builder.build();
	CloudAclEntry<UserPrincipal> clonedEntry = builder.clone().build();
	Assert.assertEquals(unclonedEntry, clonedEntry);
}
 
開發者ID:brdara,項目名稱:java-cloud-filesystem-provider,代碼行數:12,代碼來源:CloudAclEntryBuilderTest.java

示例5: getFlags

import java.nio.file.attribute.AclEntryFlag; //導入依賴的package包/類
public EnumSet<AclEntryFlag> getFlags() {
	return flags;
}
 
開發者ID:brdara,項目名稱:java-cloud-filesystem-provider,代碼行數:4,代碼來源:CloudAclEntry.java

示例6: setFlags

import java.nio.file.attribute.AclEntryFlag; //導入依賴的package包/類
public void setFlags(EnumSet<AclEntryFlag> flags) {
	this.flags = flags;
}
 
開發者ID:brdara,項目名稱:java-cloud-filesystem-provider,代碼行數:4,代碼來源:CloudAclEntry.java

示例7: addFlag

import java.nio.file.attribute.AclEntryFlag; //導入依賴的package包/類
public CloudAclEntryBuilder<T> addFlag(AclEntryFlag flag) {
	cloudAclEntry.getFlags().add(flag);
	return this;
}
 
開發者ID:brdara,項目名稱:java-cloud-filesystem-provider,代碼行數:5,代碼來源:CloudAclEntryBuilder.java

示例8: addFlags

import java.nio.file.attribute.AclEntryFlag; //導入依賴的package包/類
public CloudAclEntryBuilder<T> addFlags(AclEntryFlag... flags) {
	Arrays.stream(flags).forEach(f -> addFlag(f));
	return this;
}
 
開發者ID:brdara,項目名稱:java-cloud-filesystem-provider,代碼行數:5,代碼來源:CloudAclEntryBuilder.java

示例9: testMergeAclsWillMergeAllMergeableAclsInTheSet

import java.nio.file.attribute.AclEntryFlag; //導入依賴的package包/類
@Test
public void testMergeAclsWillMergeAllMergeableAclsInTheSet() {
	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<UserPrincipal> cloudAclEntry3 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
			.setPrincipal(new TestUserImpl("user2"))
			.setType(AclEntryType.ALLOW)
			.addPermissions(AclEntryPermission.READ_DATA, AclEntryPermission.WRITE_DATA)
			.addFlag(AclEntryFlag.FILE_INHERIT)
			.build();

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

	CloudAclEntry<UserPrincipal> cloudAclEntry5 = new CloudAclEntryBuilder<UserPrincipal>(UserPrincipal.class)
			.setPrincipal(new TestUserImpl("user3"))
			.setType(AclEntryType.ALLOW)
			.addPermissions(AclEntryPermission.READ_DATA, AclEntryPermission.WRITE_DATA)
			.addFlag(AclEntryFlag.FILE_INHERIT)
			.build();

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

	CloudAclEntrySet entrySet = checker.mergeAcls(AnonymousUserPrincipal.INSTANCE, cloudAclEntry1, cloudAclEntry2, cloudAclEntry3, cloudAclEntry4, cloudAclEntry5, cloudAclEntry6);
	Assert.assertTrue(entrySet.isOwner(AnonymousUserPrincipal.INSTANCE));
	Assert.assertEquals(3, entrySet.size());
	Iterator<CloudAclEntry<?>> iterator = entrySet.iterator();
	while (iterator.hasNext()) {
		CloudAclEntry<?> entry = iterator.next();
		String userName = ((TestUserImpl)entry.getPrincipal()).getName();

		switch (userName) {
			case "user1": 	Assert.assertEquals(AclEntryType.DENY, entry.getType());
							Assert.assertEquals(EnumSet.of(AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY,
									AclEntryPermission.DELETE, AclEntryPermission.READ_DATA, AclEntryPermission.WRITE_DATA),
									entry.getPermissions());
							break;
			case "user2": 	Assert.assertEquals(AclEntryType.ALLOW, entry.getType());
							Assert.assertEquals(EnumSet.of(AclEntryPermission.READ_DATA, AclEntryPermission.WRITE_DATA,
									AclEntryPermission.DELETE),
									entry.getPermissions());
							break;
			case "user3": 	Assert.assertEquals(AclEntryType.ALLOW, entry.getType());
							Assert.assertEquals(EnumSet.of(AclEntryPermission.READ_DATA, AclEntryPermission.WRITE_DATA),
									entry.getPermissions());
							break;
			default: Assert.fail("Unexpected user entry " + entry);
		}
	}
}
 
開發者ID:brdara,項目名稱:java-cloud-filesystem-provider,代碼行數:72,代碼來源:DefaultCloudAclEntryConflictCheckerTest.java

示例10: getLocalAclEntries

import java.nio.file.attribute.AclEntryFlag; //導入依賴的package包/類
private List<AclEntry> getLocalAclEntries(ItemType type, List<AclEntry> parentAclList, List<AclEntry> childAclList)
{
	List<AclEntry> aclList = new ArrayList<>();

	for (AclEntry childEntry : childAclList)
	{
		boolean found = false;
		for (AclEntry parentEntry : parentAclList)
		{
			if (!parentEntry.type().equals(childEntry.type())) continue;
			if (!parentEntry.principal().equals(childEntry.principal())) continue;
			if (!parentEntry.permissions().equals(childEntry.permissions())) continue;
			if (!parentEntry.flags().equals(childEntry.flags()))
			{
				if (parentEntry.flags().contains(AclEntryFlag.INHERIT_ONLY))
				{
					found = true;
					break;
				}
				else
				{
					if (type.equals(ItemType.FOLDER))
					{
						if (parentEntry.flags().contains(AclEntryFlag.DIRECTORY_INHERIT))
						{
							found = true;
							break;
						}
					}
					else
					{
						if (parentEntry.flags().contains(AclEntryFlag.FILE_INHERIT))
						{
							found = true;
							break;
						}
					}
				}
				continue;
			}
			found = true;
			break;
		}

		if (found) continue;

		// System.out.println("CHILD: "+childEntry.toString());
		/*
		 * System.out.println("\n\n");
		 * System.out.println("CHILD: "+childEntry.toString());
		 * 
		 * for(AclEntry parentEntry : parentAclList){
		 * 
		 * System.out.println("PARENT: "+parentEntry.toString()); }
		 * 
		 * System.out.println("\n\n");
		 */

		aclList.add(childEntry);
	}
	return aclList;
}
 
開發者ID:HolgerHees,項目名稱:cloudsync,代碼行數:63,代碼來源:LocalFilesystemConnector.java


注:本文中的java.nio.file.attribute.AclEntryFlag類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。