• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java CanonicalGrantee类的典型用法和代码示例

java 1次浏览

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

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

示例1: grantAcl

点赞 3

import org.jets3t.service.acl.CanonicalGrantee; //导入依赖的package包/类
public boolean grantAcl(S3Object object) throws ServiceException, InterruptedException {
    if(Strings.isNullOrEmpty(s3Acl)){
        return true;
    }

    for (int i = 0; i < s3AclRetries; ++i) {
        try {
            AccessControlList acl = s3Service.getObjectAcl(object.getBucketName(), object.getKey());
            for (String id : s3Acl.split(",")) {
                acl.grantPermission(new CanonicalGrantee(id), Permission.PERMISSION_READ);
            }
            s3Service.putObjectAcl(object.getBucketName(), object.getKey(), acl);
            return true;
        } catch (Exception e) {
            log.error("Exception while granting ACL: " + e.getMessage(), e);
            Thread.sleep(1000 * (i + 1));
        }
    }

    return false;

}
 

开发者ID:Netflix,
项目名称:suro,
代码行数:23,
代码来源:GrantAcl.java

示例2: test

点赞 3

import org.jets3t.service.acl.CanonicalGrantee; //导入依赖的package包/类
@Test
public void test() throws Exception {
    RestS3Service s3Service = mock(RestS3Service.class);
    AccessControlList acl = new AccessControlList();
    doReturn(acl).when(s3Service).getObjectAcl("bucket", "key");
    doNothing().when(s3Service).putObjectAcl("bucket", "key", acl);

    GrantAcl grantAcl = new GrantAcl(s3Service, "1,2,3", 1);
    S3Object obj = new S3Object("key");
    obj.setBucketName("bucket");
    obj.setAcl(GSAccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL);
    assertTrue(grantAcl.grantAcl(obj));

    Set<GrantAndPermission> grants = new HashSet<GrantAndPermission>(Arrays.asList(acl.getGrantAndPermissions()));
    assertEquals(grants.size(), 3);
    Set<GrantAndPermission> grantSet = new HashSet<GrantAndPermission>();
    for (int i = 1; i <= 3; ++i) {
        grantSet.add(new GrantAndPermission(new CanonicalGrantee(Integer.toString(i)), Permission.PERMISSION_READ));
    }
}
 

开发者ID:Netflix,
项目名称:suro,
代码行数:21,
代码来源:TestGrantAcl.java

示例3: convert

点赞 2

import org.jets3t.service.acl.CanonicalGrantee; //导入依赖的package包/类
/**
 * @param list ACL from server
 * @return Editable ACL
 */
protected Acl convert(final AccessControlList list) {
    if(log.isDebugEnabled()) {
        try {
            log.debug(list.toXml());
        }
        catch(ServiceException e) {
            log.error(e.getMessage());
        }
    }
    Acl acl = new Acl();
    acl.setOwner(new Acl.CanonicalUser(list.getOwner().getId(), list.getOwner().getDisplayName()));
    for(GrantAndPermission grant : list.getGrantAndPermissions()) {
        Acl.Role role = new Acl.Role(grant.getPermission().toString());
        if(grant.getGrantee() instanceof CanonicalGrantee) {
            acl.addAll(new Acl.CanonicalUser(grant.getGrantee().getIdentifier(),
                    ((CanonicalGrantee) grant.getGrantee()).getDisplayName(), false), role);
        }
        else if(grant.getGrantee() instanceof EmailAddressGrantee) {
            acl.addAll(new Acl.EmailUser(grant.getGrantee().getIdentifier()), role);
        }
        else if(grant.getGrantee() instanceof GroupGrantee) {
            acl.addAll(new Acl.GroupUser(grant.getGrantee().getIdentifier()), role);
        }
    }
    return acl;
}
 

开发者ID:iterate-ch,
项目名称:cyberduck,
代码行数:31,
代码来源:S3AccessControlListFeature.java

示例4: initData

点赞 2

import org.jets3t.service.acl.CanonicalGrantee; //导入依赖的package包/类
/**
 * Initialises the dialog with access control information for the given S3 items (bucket or objects)
 *
 * @param s3Items   May be a single <code>S3Bucket</code>, or one or more <code>S3Object</code>s
 * @param accessControlList the initial ACL settings to represent in the dialog.
 */
protected void initData(BaseS3Object[] s3Items, AccessControlList accessControlList) {
	this.originalAccessControlList = accessControlList;

	// Item(s) description.
	if (s3Items.length > 1) {
		// Only objects can be updated in multiples, buckets are always single.
		itemsDescription.setText("<html><b>Object count</b>: " + s3Items.length + " objects");
	} else {
		if (s3Items[0] instanceof S3Bucket) {
			itemsDescription.setText("<html><b>Bucket</b><br>" + ((S3Bucket)s3Items[0]).getName());
		} else {
			itemsDescription.setText("<html><b>Object</b><br>" + ((S3Object)s3Items[0]).getKey());
		}
	}

	// Populate grantees tables.
	canonicalGranteeTableModel.removeAllGrantAndPermissions();
	emailGranteeTableModel.removeAllGrantAndPermissions();
	groupGranteeTableModel.removeAllGrantAndPermissions();

	Iterator grantIter = originalAccessControlList.getGrants().iterator();
	while (grantIter.hasNext()) {
		GrantAndPermission gap = (GrantAndPermission) grantIter.next();
		GranteeInterface grantee = gap.getGrantee();
		Permission permission = gap.getPermission();
		if (grantee instanceof CanonicalGrantee) {
			canonicalGranteeTableModel.addGrantee(grantee, permission);
		} else if (grantee instanceof EmailAddressGrantee) {
			emailGranteeTableModel.addGrantee(grantee, permission);
		} else if (grantee instanceof GroupGrantee) {
			groupGranteeTableModel.addGrantee(grantee, permission);
		}
	}
}
 

开发者ID:glycoinfo,
项目名称:eurocarbdb,
代码行数:41,
代码来源:AccessControlDialog.java

示例5: GranteeTableModel

点赞 2

import org.jets3t.service.acl.CanonicalGrantee; //导入依赖的package包/类
public GranteeTableModel(Class granteeClass) {
	super(
		(CanonicalGrantee.class.equals(granteeClass) ? canonicalUserTableColumnNames :
			EmailAddressGrantee.class.equals(granteeClass) ? emailTableColumnNames :
				GroupGrantee.class.equals(granteeClass) ? groupTableColumnNames :
					new String[] {}
		), 0);
	this.granteeClass = granteeClass;
       permissionColumn = (CanonicalGrantee.class.equals(granteeClass) ? 2 : 1);
}
 

开发者ID:glycoinfo,
项目名称:eurocarbdb,
代码行数:11,
代码来源:AccessControlDialog.java

示例6: addGrantee

点赞 2

import org.jets3t.service.acl.CanonicalGrantee; //导入依赖的package包/类
public int addGrantee(GranteeInterface grantee, Permission permission) {
	GrantAndPermission gap = new GrantAndPermission(grantee, permission);
	int insertRow =
		Collections.binarySearch(currentGrantees, gap, new Comparator() {
			public int compare(Object o1, Object o2) {
				GrantAndPermission g1 = (GrantAndPermission) o1;
				GrantAndPermission g2 = (GrantAndPermission) o2;
				return g1.getGrantee().getIdentifier().compareToIgnoreCase(
					g2.getGrantee().getIdentifier());
			}
		});
	if (insertRow >= 0) {
		// We already have an item with this key, but that's OK.
	} else {
		insertRow = (-insertRow) - 1;
	}
	// New object to insert.
	currentGrantees.add(insertRow, gap);
	if (grantee instanceof GroupGrantee) {
           this.insertRow(insertRow, new Object[] {grantee, permission});
       } else if (grantee instanceof CanonicalGrantee) {
           CanonicalGrantee canonicalGrantee = (CanonicalGrantee) grantee;
           this.insertRow(insertRow, new Object[] {canonicalGrantee.getIdentifier(),
               canonicalGrantee.getDisplayName(), permission});
	} else {
           this.insertRow(insertRow, new Object[] {grantee.getIdentifier(), permission});
	}
	return insertRow;
}
 

开发者ID:glycoinfo,
项目名称:eurocarbdb,
代码行数:30,
代码来源:AccessControlDialog.java

示例7: initData

点赞 2

import org.jets3t.service.acl.CanonicalGrantee; //导入依赖的package包/类
/**
 * Initialises the dialog with access control information for the given S3 items (bucket or objects)
 *
 * @param s3Items   May be a single <code>S3Bucket</code>, or one or more <code>S3Object</code>s
 * @param accessControlList the initial ACL settings to represent in the dialog.
 */
protected void initData(BaseStorageItem[] s3Items, AccessControlList accessControlList) {
    this.originalAccessControlList = accessControlList;

    // Item(s) description.
    if (s3Items.length > 1) {
        // Only objects can be updated in multiples, buckets are always single.
        itemsDescription.setText("<html><b>Object count</b>: " + s3Items.length + " objects");
    } else {
        if (s3Items[0] instanceof S3Bucket) {
            itemsDescription.setText("<html><b>Bucket</b><br>" + ((S3Bucket)s3Items[0]).getName());
        } else {
            itemsDescription.setText("<html><b>Object</b><br>" + ((S3Object)s3Items[0]).getKey());
        }
    }

    // Populate grantees tables.
    canonicalGranteeTableModel.removeAllGrantAndPermissions();
    emailGranteeTableModel.removeAllGrantAndPermissions();
    groupGranteeTableModel.removeAllGrantAndPermissions();

    for (GrantAndPermission gap: originalAccessControlList.getGrantAndPermissions()) {
        GranteeInterface grantee = gap.getGrantee();
        Permission permission = gap.getPermission();
        if (grantee instanceof CanonicalGrantee) {
            canonicalGranteeTableModel.addGrantee(grantee, permission);
        } else if (grantee instanceof EmailAddressGrantee) {
            emailGranteeTableModel.addGrantee(grantee, permission);
        } else if (grantee instanceof GroupGrantee) {
            groupGranteeTableModel.addGrantee(grantee, permission);
        }
    }
}
 

开发者ID:guptavishal,
项目名称:jets3t-aws-roles,
代码行数:39,
代码来源:AccessControlDialog.java

示例8: GranteeTableModel

点赞 2

import org.jets3t.service.acl.CanonicalGrantee; //导入依赖的package包/类
public GranteeTableModel(Class granteeClass) {
    super(
        (CanonicalGrantee.class.equals(granteeClass) ? canonicalUserTableColumnNames :
            EmailAddressGrantee.class.equals(granteeClass) ? emailTableColumnNames :
                GroupGrantee.class.equals(granteeClass) ? groupTableColumnNames :
                    new String[] {}
        ), 0);
    this.granteeClass = granteeClass;
    permissionColumn = (CanonicalGrantee.class.equals(granteeClass) ? 2 : 1);
}
 

开发者ID:guptavishal,
项目名称:jets3t-aws-roles,
代码行数:11,
代码来源:AccessControlDialog.java

示例9: addGrantee

点赞 2

import org.jets3t.service.acl.CanonicalGrantee; //导入依赖的package包/类
public int addGrantee(GranteeInterface grantee, Permission permission) {
    GrantAndPermission gap = new GrantAndPermission(grantee, permission);
    int insertRow =
        Collections.binarySearch(currentGrantees, gap, new Comparator() {
            public int compare(Object o1, Object o2) {
                GrantAndPermission g1 = (GrantAndPermission) o1;
                GrantAndPermission g2 = (GrantAndPermission) o2;
                return g1.getGrantee().getIdentifier().compareToIgnoreCase(
                    g2.getGrantee().getIdentifier());
            }
        });
    if (insertRow >= 0) {
        // We already have an item with this key, but that's OK.
    } else {
        insertRow = (-insertRow) - 1;
    }
    // New object to insert.
    currentGrantees.add(insertRow, gap);
    if (grantee instanceof GroupGrantee) {
        this.insertRow(insertRow, new Object[] {grantee, permission});
    } else if (grantee instanceof CanonicalGrantee) {
        CanonicalGrantee canonicalGrantee = (CanonicalGrantee) grantee;
        this.insertRow(insertRow, new Object[] {canonicalGrantee.getIdentifier(),
            canonicalGrantee.getDisplayName(), permission});
    } else {
        this.insertRow(insertRow, new Object[] {grantee.getIdentifier(), permission});
    }
    return insertRow;
}
 

开发者ID:guptavishal,
项目名称:jets3t-aws-roles,
代码行数:30,
代码来源:AccessControlDialog.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)