Package com.amazonaws.auth.policy

Examples of com.amazonaws.auth.policy.Statement


        JsonNode effect = jStatement.get(JsonDocumentFields.STATEMENT_EFFECT);
        if (!isNotNull(effect))
            return null;

        Statement statement = new Statement(Effect.valueOf(effect.asText()));

        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;
    }
View Full Code Here


        topicArn = sns.createTopic(new CreateTopicRequest(topicName)).getTopicArn();
        String queueARN = sqs.getQueueAttributes(new GetQueueAttributesRequest(queueUrl).withAttributeNames("QueueArn")).getAttributes().get("QueueArn");

        Policy sqsPolicy =
            new Policy().withStatements(
                    new Statement(Effect.Allow)
                    .withPrincipals(Principal.AllUsers)
                    .withActions(SQSActions.SendMessage)
                    .withResources(new Resource(queueARN))
                    .withConditions(ConditionFactory.newSourceArnCondition(topicArn)));
        sqs.setQueueAttributes(new SetQueueAttributesRequest(queueUrl, newAttributes("Policy", sqsPolicy.toJson())));
View Full Code Here

        topicArn = sns.createTopic(new CreateTopicRequest(topicName)).getTopicArn();
        String queueARN = sqs.getQueueAttributes(new GetQueueAttributesRequest(queueUrl).withAttributeNames("QueueArn")).getAttributes().get("QueueArn");
       
        Policy sqsPolicy =
            new Policy().withStatements(
                    new Statement(Effect.Allow)
                    .withPrincipals(Principal.AllUsers)
                    .withActions(SQSActions.SendMessage)
                    .withResources(new Resource(queueARN))
                    .withConditions(ConditionFactory.newSourceArnCondition(topicArn)));
        sqs.setQueueAttributes(new SetQueueAttributesRequest(queueUrl, newAttributes("Policy", sqsPolicy.toJson())));
View Full Code Here

        Map<String, String> queueAttributes = sqs.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)));
View Full Code Here

        JsonNode effect = jStatement.get(JsonDocumentFields.STATEMENT_EFFECT);
        if (!isNotNull(effect))
            return null;

        Statement statement = new Statement(Effect.valueOf(effect.asText()));

        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;
    }
View Full Code Here

        Map<String, String> queueAttributes = sqs.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)));
View Full Code Here

            }

            JSONArray jStatements = jPolicy.getJSONArray(JsonDocumentFields.STATEMENT);

            for (int index = 0 ; index < jStatements.length() ; index++) {
                Statement statement = convertStatement(jStatements.getJSONObject(index));
                if (statement != null) {
                statements.add(statement);
                }
            }
        } catch (Exception e) {
View Full Code Here

    private  Statement convertStatement(JSONObject jStatement) throws JSONException {
        if (!Arrays.asList(JSONObject.getNames(jStatement)).contains(JsonDocumentFields.STATEMENT_EFFECT)) {
            return null;
        }

        Statement statement;
        String jEffect = jStatement.getString(JsonDocumentFields.STATEMENT_EFFECT);
        if (JsonDocumentFields.EFFECT_VALUE_ALLOW.equals(jEffect)) {
            statement = new Statement(Effect.Allow);
        } else {
            statement = new Statement(Effect.Deny);
        }

        if (Arrays.asList(JSONObject.getNames(jStatement)).contains(JsonDocumentFields.STATEMENT_ID)) {
            statement.setId(jStatement.getString(JsonDocumentFields.STATEMENT_ID));
        }

        convertActions(statement, jStatement);
        convertResources(statement, jStatement);
        convertCondition(statement, jStatement);
View Full Code Here

        topicArn = sns.createTopic(new CreateTopicRequest(topicName)).getTopicArn();
        String queueARN = sqs.getQueueAttributes(new GetQueueAttributesRequest(queueUrl).withAttributeNames("QueueArn")).getAttributes().get("QueueArn");

        Policy sqsPolicy =
            new Policy().withStatements(
                    new Statement(Effect.Allow)
                    .withPrincipals(Principal.AllUsers)
                    .withActions(SQSActions.SendMessage)
                    .withResources(new Resource(queueARN))
                    .withConditions(ConditionFactory.newSourceArnCondition(topicArn)));
        sqs.setQueueAttributes(new SetQueueAttributesRequest(queueUrl, newAttributes("Policy", sqsPolicy.toJson())));
View Full Code Here

        log.error(e.getMessage(), e);
      }
    }

    if (policyId == null || !policyId.equals(publishPolicyKey)) {
      Statement statement = new Statement(Effect.Allow);
      statement
          .withActions(SQSActions.SendMessage)
          .withPrincipals(Principal.AllUsers)
          .withResources(new Resource(queueArn))
          .withConditions(
              new ArnCondition(ArnComparisonType.ArnEquals,
View Full Code Here

TOP

Related Classes of com.amazonaws.auth.policy.Statement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.