当前位置: 首页>>代码示例>>Java>>正文


Java Statement.setResources方法代码示例

本文整理汇总了Java中com.amazonaws.auth.policy.Statement.setResources方法的典型用法代码示例。如果您正苦于以下问题:Java Statement.setResources方法的具体用法?Java Statement.setResources怎么用?Java Statement.setResources使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.auth.policy.Statement的用法示例。


在下文中一共展示了Statement.setResources方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: statementOf

import com.amazonaws.auth.policy.Statement; //导入方法依赖的package包/类
/**
 * Creates a <code>Statement<code> instance from the statement node.
 *
 * A statement consists of an Effect, id (optional), principal, action, resource,
 * and conditions.
 * <p>
 * principal is the AWS account that is making a request to access or modify one of your AWS resources.
 * <p>
 * action is the way in which your AWS resource is being accessed or modified, such as sending a message to an Amazon SQS queue, or storing an object in an Amazon S3 bucket.
 * <p>
 * resource is the AWS entity that the principal wants to access, such as an Amazon SQS queue, or an object stored in Amazon S3.
 * <p>
 * conditions are the optional constraints that specify when to allow or deny access for the principal to access your resource. Many expressive conditions are available, some specific to each service. For example, you can use date conditions to allow access to your resources only after or before a specific time.
 *
 * @param jStatement
 *            JsonNode representing the statement.
 * @return a reference to the statement instance created.
 */
private Statement statementOf(JsonNode jStatement) {

    JsonNode effectNode = jStatement.get(JsonDocumentFields.STATEMENT_EFFECT);

    final Effect effect = isNotNull(effectNode)
                               ? Effect.valueOf(effectNode.asText())
                               : Effect.Deny ;

    Statement statement = new Statement(effect);

    JsonNode id = jStatement.get(JsonDocumentFields.STATEMENT_ID);
    if (isNotNull(id)) {
        statement.setId(id.asText());
    }

    JsonNode actionNodes = jStatement.get(JsonDocumentFields.ACTION);
    if (isNotNull(actionNodes))
        statement.setActions(actionsOf(actionNodes));

    JsonNode resourceNodes = jStatement.get(JsonDocumentFields.RESOURCE);
    if (isNotNull(resourceNodes))
        statement.setResources(resourcesOf(resourceNodes));

    JsonNode conditionNodes = jStatement.get(JsonDocumentFields.CONDITION);
    if (isNotNull(conditionNodes))
        statement.setConditions(conditionsOf(conditionNodes));

    JsonNode principalNodes = jStatement.get(JsonDocumentFields.PRINCIPAL);
    if (isNotNull(principalNodes))
        statement.setPrincipals(principalOf(principalNodes));

    return statement;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:52,代码来源:JsonPolicyReader.java

示例2: getPolicy

import com.amazonaws.auth.policy.Statement; //导入方法依赖的package包/类
private String getPolicy(List<String> accountIds) {
	Policy policy = new Policy("AuthorizedWorkerAccessPolicy");
	Statement stmt = new Statement(Effect.Allow);
	Action action = SQSActions.SendMessage;
	stmt.getActions().add(action);
	stmt.setResources(new LinkedList<>());
	for(String accountId : accountIds) {
		Principal principal = new Principal(accountId);
		stmt.getPrincipals().add(principal);
	}
	stmt.getResources().add(new Resource(getQueueARN()));
	policy.getStatements().add(stmt);
	return policy.toJson();
}
 
开发者ID:Netflix,项目名称:conductor,代码行数:15,代码来源:SQSObservableQueue.java

示例3: withKms

import com.amazonaws.auth.policy.Statement; //导入方法依赖的package包/类
/**
 * Adds a permission to allow the specified actions to the given KMS key id.
 *
 * @param kmsKeyId Full ARN to the kms key
 * @param actions List of actions
 *
 * @return This builder
 */
@SuppressWarnings("PMD.CloseResource")
public AwsPolicyBuilder withKms(String kmsKeyId, KmsActions... actions)
{
    Statement statement = new Statement(Effect.Allow);
    statement.setActions(Arrays.asList(actions));
    statement.setResources(Arrays.asList(new Resource(kmsKeyId)));
    policy.getStatements().add(statement);
    return this;
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:18,代码来源:AwsPolicyBuilder.java

示例4: withS3

import com.amazonaws.auth.policy.Statement; //导入方法依赖的package包/类
/**
 * Adds a permission to allow the specified actions to the given bucket and s3 object key. The permission will allow the given actions only to the specified
 * object key. If object key is null, the permission is applied to the bucket itself.
 *
 * @param bucketName S3 bucket name
 * @param objectKey S3 object key
 * @param actions List of actions to allow
 *
 * @return This builder
 */
@SuppressWarnings("PMD.CloseResource")
public AwsPolicyBuilder withS3(String bucketName, String objectKey, S3Actions... actions)
{
    Statement statement = new Statement(Effect.Allow);
    statement.setActions(Arrays.asList(actions));
    String resource = "arn:aws:s3:::" + bucketName;
    if (objectKey != null)
    {
        resource += "/" + objectKey;
    }
    statement.setResources(Arrays.asList(new Resource(resource)));
    policy.getStatements().add(statement);
    return this;
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:25,代码来源:AwsPolicyBuilder.java


注:本文中的com.amazonaws.auth.policy.Statement.setResources方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。