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

Java GrantAndPermission类代码示例

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

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



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

示例1: toXMLBuilder

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的package包/类
@Override
public XMLBuilder toXMLBuilder() throws ServiceException, ParserConfigurationException,
    FactoryConfigurationError, TransformerException
{
    XMLBuilder builder = XMLBuilder.create("AccessControlList");

    // Owner
    if (owner != null) {
        XMLBuilder ownerBuilder = builder.elem("Owner");
        ownerBuilder.elem("ID").text(owner.getId()).up();
        if (owner.getDisplayName() != null) {
            ownerBuilder.elem("Name").text(owner.getDisplayName());
        }
    }

    XMLBuilder accessControlList = builder.elem("Entries");
    for (GrantAndPermission gap: grants) {
        GranteeInterface grantee = gap.getGrantee();
        Permission permission = gap.getPermission();
        accessControlList
            .elem("Entry")
                .importXMLBuilder(grantee.toXMLBuilder())
                .elem("Permission").text(permission.toString());
    }
    return builder;
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:27,代码来源:GSAccessControlList.java


示例2: toXMLBuilder

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的package包/类
public XMLBuilder toXMLBuilder() throws ParserConfigurationException,
    FactoryConfigurationError, TransformerException
{
    XMLBuilder builder = XMLBuilder.create("BucketLoggingStatus")
        .attr("xmlns", Constants.XML_NAMESPACE);

    if (isLoggingEnabled()) {
        XMLBuilder enabledBuilder = builder.elem("LoggingEnabled")
            .elem("TargetBucket").text(getTargetBucketName()).up()
            .elem("TargetPrefix").text(getLogfilePrefix()).up();
        if (targetGrantsList.size() > 0) {
            Iterator<GrantAndPermission> targetGrantsIter = targetGrantsList.iterator();
            XMLBuilder grantsBuilder = enabledBuilder.elem("TargetGrants");
            while (targetGrantsIter.hasNext()) {
                GrantAndPermission gap = targetGrantsIter.next();
                grantsBuilder.elem("Grant")
                    .importXMLBuilder(gap.getGrantee().toXMLBuilder())
                    .elem("Permission").text(gap.getPermission().toString());
            }
        }
    }
    return builder;
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:24,代码来源:S3BucketLoggingStatus.java


示例3: getAclDescription

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的package包/类
public static String getAclDescription(AccessControlList acl) {
    if (acl == null) {
        return ACL_UNKNOWN_DESCRIPTION;
    }

    for (GrantAndPermission gap: acl.getGrantAndPermissions()) {
        if (GroupGrantee.ALL_USERS.equals(gap.getGrantee())
            && Permission.PERMISSION_READ.equals(gap.getPermission()))
        {
            return ACL_PUBLIC_DESCRIPTION;
        }
    }
    if (AccessControlList.REST_CANNED_PUBLIC_READ.equals(acl)) {
        return ACL_PUBLIC_DESCRIPTION;
    }
    return ACL_PRIVATE_DESCRIPTION;
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:18,代码来源:CockpitLite.java


示例4: test

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的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


示例5: convert

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的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


示例6: initData

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的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


示例7: addGrantee

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的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


示例8: getGrantee

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的package包/类
public GranteeInterface getGrantee(int index) {
	GrantAndPermission originalGAP = (GrantAndPermission) currentGrantees.get(index);
	Object updatedGrantee = super.getValueAt(index, 0);
	if (updatedGrantee instanceof GroupGrantee) {
		// We can return this as-is, because GroupGrantees are actually stored in the table.
		return (GroupGrantee) updatedGrantee;
	} else {
		// Non-group Grantees are stored as Strings in the table, so update the original's ID.
		originalGAP.getGrantee().setIdentifier((String) updatedGrantee);
		return originalGAP.getGrantee();
	}
}
 
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:13,代码来源:AccessControlDialog.java


示例9: testGetBucketAcl

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的package包/类
/**
 * Test get bucket acl.
 *
 * @throws Exception the exception
 */
@Test
public void testGetBucketAcl() throws Exception {
	s3RESTService.createBucket(AWS_S3_BUCKET);//create bucket for test
	AccessControlList acl = s3RESTService.getBucketAcl(new S3Bucket(AWS_S3_BUCKET));
	GrantAndPermission[] grantAndPermissions = acl.getGrantAndPermissions();
	assertEquals(Permission.PERMISSION_FULL_CONTROL, grantAndPermissions[0].getPermission());
}
 
开发者ID:abhinavmishra14,项目名称:aws-s3-utils,代码行数:13,代码来源:JetS3RESTServiceTest.java


示例10: initData

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的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


示例11: addGrantee

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的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


示例12: getGrantee

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的package包/类
public GranteeInterface getGrantee(int index) {
    GrantAndPermission originalGAP = (GrantAndPermission) currentGrantees.get(index);
    Object updatedGrantee = super.getValueAt(index, 0);
    if (updatedGrantee instanceof GroupGrantee) {
        // We can return this as-is, because GroupGrantees are actually stored in the table.
        return (GroupGrantee) updatedGrantee;
    } else {
        // Non-group Grantees are stored as Strings in the table, so update the original's ID.
        originalGAP.getGrantee().setIdentifier((String) updatedGrantee);
        return originalGAP.getGrantee();
    }
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:13,代码来源:AccessControlDialog.java


示例13: setBucketLoggingStatus

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的package包/类
/**
 * Applies logging settings to a bucket, optionally modifying the ACL permissions for the
 * logging target bucket to ensure log files can be written to it. Only the owner of
 * a bucket may change its logging status.
 *
 * @param bucketName
 * the name of the bucket the logging settings will apply to.
 * @param status
 * the logging status settings to apply to the bucket.
 * @param updateTargetACLifRequired
 * if true, when logging is enabled the method will check the target bucket to ensure it has the
 * necessary ACL permissions set to allow logging (that is, WRITE and READ_ACP for the group
 * <tt>http://acs.amazonaws.com/groups/s3/LogDelivery</tt>). If the target bucket does not
 * have the correct permissions the bucket's ACL will be updated to have the correct
 * permissions. If this parameter is false, no ACL checks or updates will occur.
 *
 * @throws S3ServiceException
 */
public void setBucketLoggingStatus(String bucketName, S3BucketLoggingStatus status,
    boolean updateTargetACLifRequired)
    throws S3ServiceException
{
    try {
        if (status.isLoggingEnabled() && updateTargetACLifRequired) {
            // Check whether the target bucket has the ACL permissions necessary for logging.
            if (log.isDebugEnabled()) {
                log.debug("Checking whether the target logging bucket '" +
                    status.getTargetBucketName() + "' has the appropriate ACL settings");
            }
            boolean isSetLoggingGroupWrite = false;
            boolean isSetLoggingGroupReadACP = false;
            String groupIdentifier = GroupGrantee.LOG_DELIVERY.getIdentifier();

            AccessControlList logBucketACL = getBucketAcl(status.getTargetBucketName());

            for (GrantAndPermission gap: logBucketACL.getGrantAndPermissions()) {
                if (groupIdentifier.equals(gap.getGrantee().getIdentifier())) {
                    // Found a Group Grantee.
                    if (gap.getPermission().equals(Permission.PERMISSION_WRITE)) {
                        isSetLoggingGroupWrite = true;
                        if (log.isDebugEnabled()) {
                            log.debug("Target bucket '" + status.getTargetBucketName() + "' has ACL "
                                    + "permission " + Permission.PERMISSION_WRITE + " for group " +
                                    groupIdentifier);
                        }
                    } else if (gap.getPermission().equals(Permission.PERMISSION_READ_ACP)) {
                        isSetLoggingGroupReadACP = true;
                        if (log.isDebugEnabled()) {
                            log.debug("Target bucket '" + status.getTargetBucketName() + "' has ACL "
                                + "permission " + Permission.PERMISSION_READ_ACP + " for group " +
                                groupIdentifier);
                        }
                    }
                }
            }

            // Update target bucket's ACL if necessary.
            if (!isSetLoggingGroupWrite || !isSetLoggingGroupReadACP) {
                if (log.isWarnEnabled()) {
                    log.warn("Target logging bucket '" + status.getTargetBucketName()
                        + "' does not have the necessary ACL settings, updating ACL now");
                }

                logBucketACL.grantPermission(GroupGrantee.LOG_DELIVERY, Permission.PERMISSION_WRITE);
                logBucketACL.grantPermission(GroupGrantee.LOG_DELIVERY, Permission.PERMISSION_READ_ACP);
                putBucketAcl(status.getTargetBucketName(), logBucketACL);
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("Target logging bucket '" + status.getTargetBucketName()
                        + "' has the necessary ACL settings");
                }
            }
        }

        setBucketLoggingStatusImpl(bucketName, status);
    } catch (ServiceException se) {
        throw new S3ServiceException(se);
    }
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:80,代码来源:S3Service.java


示例14: getTargetGrants

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的package包/类
public GrantAndPermission[] getTargetGrants() {
    return targetGrantsList.toArray(
        new GrantAndPermission[targetGrantsList.size()]);
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:5,代码来源:S3BucketLoggingStatus.java


示例15: setTargetGrants

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的package包/类
public void setTargetGrants(GrantAndPermission[] targetGrants) {
    targetGrantsList.clear();
    targetGrantsList.addAll(Arrays.asList(targetGrants));
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:5,代码来源:S3BucketLoggingStatus.java


示例16: addTargetGrant

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的package包/类
public void addTargetGrant(GrantAndPermission targetGrant) {
    targetGrantsList.add(targetGrant);
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:4,代码来源:S3BucketLoggingStatus.java


示例17: displayBucketProperties

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的package包/类
private void displayBucketProperties(S3Bucket bucket) {
    bucketNameTextField.setText(bucket.getName());
    String location = "Unknown";
    if (bucket.isLocationKnown()) {
        location = bucket.getLocation();
        if (location == null) {
            location = "US";
        }
    }
    bucketLocationTextField.setText(location);
    bucketCreationDateTextField.setText(String.valueOf(bucket.getCreationDate()));

    if (bucket.getOwner() != null) {
        ownerNameLabel.setVisible(true);
        ownerNameTextField.setVisible(true);
        ownerIdLabel.setVisible(true);
        ownerIdTextField.setVisible(true);
        ownerNameTextField.setText(bucket.getOwner().getDisplayName());
        ownerIdTextField.setText(bucket.getOwner().getId());
    } else {
        ownerNameLabel.setVisible(false);
        ownerNameTextField.setVisible(false);
        ownerIdLabel.setVisible(false);
        ownerIdTextField.setVisible(false);
    }

    if (bucket.getAcl() != null) {
        // Display grants table.
        grantsTable.setVisible(true);
        while (grantsTableModel.getRowCount() > 0) {
            grantsTableModel.removeRow(0);
        }
        AccessControlList acl = bucket.getAcl();
        for (GrantAndPermission gap: acl.getGrantAndPermissions()) {
            grantsTableModel.addRow(new Object[] {
                gap.getGrantee().getIdentifier(), gap.getPermission().toString()});
        }
    } else {
        grantsTable.setVisible(false);
    }

    if (bucket.isRequesterPaysKnown()) {
        bucketIsRequesterPaysLabel.setVisible(true);
        bucketIsRequesterPaysCheckBox.setVisible(true);
        bucketIsRequesterPaysCheckBox.setSelected(bucket.isRequesterPays());
    } else {
        bucketIsRequesterPaysLabel.setVisible(false);
        bucketIsRequesterPaysCheckBox.setVisible(false);
    }

    this.pack();
    this.setSize(this.getWidth(), 450);
    this.setLocationRelativeTo(this.getOwner());
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:55,代码来源:ItemPropertiesDialog.java


示例18: setBucketLoggingStatus

import org.jets3t.service.acl.GrantAndPermission; //导入依赖的package包/类
/**
 * Applies logging settings to a bucket, optionally modifying the ACL permissions for the 
 * logging target bucket to ensure log files can be written to it. Only the owner of
 * a bucket may change its logging status.
 * 
 * @param bucketName
 * the name of the bucket the logging settings will apply to.
 * @param status
 * the logging status settings to apply to the bucket.
 * @param updateTargetACLifRequired
 * if true, when logging is enabled the method will check the target bucket to ensure it has the 
 * necessary ACL permissions set to allow logging (that is, WRITE and READ_ACP for the group
 * <tt>http://acs.amazonaws.com/groups/s3/LogDelivery</tt>). If the target bucket does not
 * have the correct permissions the bucket's ACL will be updated to have the correct 
 * permissions. If this parameter is false, no ACL checks or updates will occur. 
 * 
 * @throws S3ServiceException
 */
public void setBucketLoggingStatus(String bucketName, S3BucketLoggingStatus status, 
    boolean updateTargetACLifRequired) 
    throws S3ServiceException
{
    if (status.isLoggingEnabled() && updateTargetACLifRequired) {            
        // Check whether the target bucket has the ACL permissions necessary for logging.
    	if (log.isDebugEnabled()) {
    		log.debug("Checking whether the target logging bucket '" + 
    			status.getTargetBucketName() + "' has the appropriate ACL settings");
    	}
        boolean isSetLoggingGroupWrite = false;
        boolean isSetLoggingGroupReadACP = false;
        String groupIdentifier = GroupGrantee.LOG_DELIVERY.getIdentifier();
        
        AccessControlList logBucketACL = getBucketAcl(status.getTargetBucketName());
        
        Iterator grantIter = logBucketACL.getGrants().iterator();
        while (grantIter.hasNext()) {
            GrantAndPermission gap = (GrantAndPermission) grantIter.next();
            
            if (groupIdentifier.equals(gap.getGrantee().getIdentifier())) {
                // Found a Group Grantee.                    
                if (gap.getPermission().equals(Permission.PERMISSION_WRITE)) {
                    isSetLoggingGroupWrite = true;
                    if (log.isDebugEnabled()) {
                    	log.debug("Target bucket '" + status.getTargetBucketName() + "' has ACL "
                    			+ "permission " + Permission.PERMISSION_WRITE + " for group " + 
                    			groupIdentifier);
                    }
                } else if (gap.getPermission().equals(Permission.PERMISSION_READ_ACP)) {
                    isSetLoggingGroupReadACP = true;
                    if (log.isDebugEnabled()) {
                     log.debug("Target bucket '" + status.getTargetBucketName() + "' has ACL "
                         + "permission " + Permission.PERMISSION_READ_ACP + " for group " + 
                         groupIdentifier);
                    }
                }
            }
        }
        
        // Update target bucket's ACL if necessary.
        if (!isSetLoggingGroupWrite || !isSetLoggingGroupReadACP) {
        	if (log.isWarnEnabled()) {
             log.warn("Target logging bucket '" + status.getTargetBucketName() 
                 + "' does not have the necessary ACL settings, updating ACL now");
        	}
        	
            logBucketACL.grantPermission(GroupGrantee.LOG_DELIVERY, Permission.PERMISSION_WRITE);
            logBucketACL.grantPermission(GroupGrantee.LOG_DELIVERY, Permission.PERMISSION_READ_ACP);
            putBucketAcl(status.getTargetBucketName(), logBucketACL);
        } else {
        	if (log.isDebugEnabled()) {
             log.debug("Target logging bucket '" + status.getTargetBucketName() 
                 + "' has the necessary ACL settings");
        	}
        }
    }

    setBucketLoggingStatusImpl(bucketName, status);        
}
 
开发者ID:fajoy,项目名称:jets3t,代码行数:79,代码来源:S3Service.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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