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

Java SQSActions类代码示例

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

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



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

示例1: subscribeQueueToTopic

import com.amazonaws.auth.policy.actions.SQSActions; //导入依赖的package包/类
public String subscribeQueueToTopic(String snsTopicArn, String sqsQueueUrl){		
       Map<String, String> queueAttributes = sqsClient.getQueueAttributes(new GetQueueAttributesRequest(sqsQueueUrl)
               .withAttributeNames(QueueAttributeName.QueueArn.toString())).getAttributes();
       String sqsQueueArn = queueAttributes.get(QueueAttributeName.QueueArn.toString());

       Policy policy = new Policy().withStatements(
               new Statement(Effect.Allow)
                   .withId("topic-subscription-" + snsTopicArn)
                   .withPrincipals(Principal.AllUsers)
                   .withActions(SQSActions.SendMessage)
                   .withResources(new Resource(sqsQueueArn))
                   .withConditions(ConditionFactory.newSourceArnCondition(snsTopicArn)));

       logger.debug("Policy: " + policy.toJson());

       queueAttributes = new HashMap<String, String>();
       queueAttributes.put(QueueAttributeName.Policy.toString(), policy.toJson());
       sqsClient.setQueueAttributes(new SetQueueAttributesRequest(sqsQueueUrl, queueAttributes));

       SubscribeResult subscribeResult =
               snsClient.subscribe(new SubscribeRequest()
                   .withEndpoint(sqsQueueArn)
                   .withProtocol("sqs")
                   .withTopicArn(snsTopicArn));
       return subscribeResult.getSubscriptionArn();
}
 
开发者ID:TimShi,项目名称:s3_video,代码行数:27,代码来源:AWSAdapter.java


示例2: setQueuePolicy

import com.amazonaws.auth.policy.actions.SQSActions; //导入依赖的package包/类
private void setQueuePolicy(String topicSnsArn, String queueArn, String queueURL) {
	logger.info("Set up policy for queue to allow SNS to publish to it");
	Policy sqsPolicy = new Policy()
       .withStatements(new Statement(Statement.Effect.Allow)
                           .withPrincipals(Principal.AllUsers)
                           .withResources(new Resource(queueArn))
                           .withConditions(ConditionFactory.newSourceArnCondition(topicSnsArn))
                           .withActions(SQSActions.SendMessage));
	
       Map<String, String> attributes = new HashMap<String,String>();
       attributes.put("Policy", sqsPolicy.toJson());
       
       SetQueueAttributesRequest setQueueAttributesRequest = new SetQueueAttributesRequest();
       setQueueAttributesRequest.setQueueUrl(queueURL);
       setQueueAttributesRequest.setAttributes(attributes);
       sqsClient.setQueueAttributes(setQueueAttributesRequest);		
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:18,代码来源:QueuePolicyManager.java


示例3: getPolicy

import com.amazonaws.auth.policy.actions.SQSActions; //导入依赖的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


示例4: allowQueuePublish

import com.amazonaws.auth.policy.actions.SQSActions; //导入依赖的package包/类
private boolean allowQueuePublish(Statement statement) {
	if (statement.getEffect().equals(Statement.Effect.Allow)) {
		List<Action> actions = statement.getActions();

		for(Action action : actions) { // .equals not properly defined on actions
			if (action.getActionName().equals("sqs:"+SQSActions.SendMessage.toString())) {
				return true;
			}
		}
	}	
	return false;
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:13,代码来源:QueuePolicyManager.java


示例5: allowSQSQueueToReceiveMessagesFromSNSTopic

import com.amazonaws.auth.policy.actions.SQSActions; //导入依赖的package包/类
private static void allowSQSQueueToReceiveMessagesFromSNSTopic(
    AmazonSQS amazonSQS,
    String queueURL,
    String queueARN,
    String topicARN
) {
    GetQueueAttributesResult queueAttributesResult =
        amazonSQS.getQueueAttributes(
            new GetQueueAttributesRequest().withQueueUrl(queueURL).withAttributeNames(
                QueueAttributeName.Policy
            )
        );

    String policyJson = queueAttributesResult.getAttributes().get(QueueAttributeName.Policy.name());

    final List<Statement> statements;
    if (policyJson != null) {
        statements = new ArrayList<>(Policy.fromJson(policyJson).getStatements());
    } else {
        // no policies yet exist
        statements = new ArrayList<>();
    }

    statements.add(
        new Statement(Statement.Effect.Allow)
            .withPrincipals(Principal.AllUsers)
            .withResources(new Resource(queueARN))
            .withActions(SQSActions.SendMessage)
            .withConditions(ConditionFactory.newSourceArnCondition(topicARN))
    );

    Policy policy = new Policy();
    policy.setStatements(statements);
    Map<String, String> queueAttributes = new HashMap<>();
    queueAttributes.put(QueueAttributeName.Policy.name(), policy.toJson());

    // Note that if the queue already has this policy, this will do nothing.
    amazonSQS.setQueueAttributes(
        new SetQueueAttributesRequest()
            .withQueueUrl(queueURL)
            .withAttributes(queueAttributes)
    );
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:44,代码来源:AmazonSNSSubscriptionSetup.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java PaymentRequestException类代码示例发布时间:2022-05-23
下一篇:
Java InspectionProfileEntry类代码示例发布时间: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