/** * Writes the list of <code>Action</code>s to the JSONGenerator. * * @param actions * the list of the actions to be written. */ private void writeActions(List<Action> actions) throws JsonGenerationException, IOException { List<String> actionStrings = new ArrayList<String>(); for (Action action : actions) { actionStrings.add(action.getActionName()); } writeJsonArray(JsonDocumentFields.ACTION, actionStrings); }
logger.info("statement id: {}, effect: {}, action: {}, resources:{}", statement.getId(), statement.getEffect().name(), statement.getActions().get(0).getActionName(), statement.getResources().get(0).getId()); for (Action action : statement.getActions()) { if (action.getActionName().toLowerCase().equals(SQSActions.SendMessage.getActionName().toLowerCase())) { actionFound = true; break;
/** * Writes the list of <code>Action</code>s to the JSONGenerator. * * @param actions the list of the actions to be written. */ private void writeActions(List<Action> actions) throws IOException { List<String> actionStrings = new ArrayList<String>(); for (Action action : actions) { actionStrings.add(action.getActionName()); } writeJsonArray(JsonDocumentFields.ACTION, actionStrings); }
/** * Writes the list of <code>Action</code>s to the JSONGenerator. * * @param actions * the list of the actions to be written. */ private void writeActions(List<Action> actions) throws JsonGenerationException, IOException { List<String> actionStrings = new ArrayList<String>(); for (Action action : actions) { actionStrings.add(action.getActionName()); } writeJsonArray(JsonDocumentFields.ACTION, actionStrings); }
@Test public void testCloudHSMServicePrincipal() { String jsonString = "{" + "\"Version\":\"2008-10-17\"," + "\"Statement\":[" + "{\"Sid\":\"\"," + "\"Effect\":\"Allow\"," + "\"Principal\":{\"Service\":\"cloudhsm.amazonaws.com\"}," + "\"Action\":\"sts:AssumeRole\"}" + "]" + "}"; Policy policy = Policy.fromJson(jsonString); assertEquals(POLICY_VERSION, policy.getVersion()); List<Statement> statements = new LinkedList<Statement>(policy.getStatements()); assertEquals(1, statements.size()); assertEquals(1, statements.get(0).getActions().size()); assertEquals(Effect.Allow, statements.get(0).getEffect()); assertEquals("sts:AssumeRole", statements.get(0).getActions().get(0).getActionName()); assertEquals(0, statements.get(0).getConditions().size()); assertEquals(1, statements.get(0).getPrincipals().size()); assertEquals(Services.AWSCloudHSM.getServiceId(), statements.get(0).getPrincipals().get(0) .getId()); assertEquals("Service", statements.get(0).getPrincipals().get(0).getProvider()); }
assertEquals(Effect.Allow, statements.get(0).getEffect()); assertEquals("sts:AssumeRole", statements.get(0).getActions().get(0) .getActionName()); assertEquals(0, statements.get(0).getConditions().size()); assertEquals(1, statements.get(0).getPrincipals().size());
assertEquals(1, statements.get(0).getActions().size()); assertEquals(Effect.Allow, statements.get(0).getEffect()); assertEquals("sts:AssumeRole", statements.get(0).getActions().get(0).getActionName()); assertEquals(1, statements.get(0).getConditions().size()); assertEquals("IpAddress", statements.get(0).getConditions().get(0).getType());
assertEquals(Effect.Allow, statements.get(0).getEffect()); assertEquals("sts:AssumeRoleWithSAML", statements.get(0).getActions().get(0) .getActionName()); assertEquals(1, statements.get(0).getConditions().size()); assertEquals("StringEquals", statements.get(0).getConditions().get(0).getType());
@Test public void testMultipleConditionKeysForConditionType() throws Exception { Policy policy = new Policy(); policy.withStatements(new Statement(Effect.Allow) .withResources(new Resource("arn:aws:sqs:us-east-1:987654321000:MyQueue")) .withPrincipals(Principal.AllUsers) .withActions(new TestAction("foo")) .withConditions( new StringCondition(StringComparisonType.StringNotLike, "key1", "foo"), new StringCondition(StringComparisonType.StringNotLike, "key1", "bar"))); policy = Policy.fromJson(policy.toJson()); assertEquals(1, policy.getStatements().size()); List<Statement> statements = new LinkedList<Statement>(policy.getStatements()); assertEquals(Effect.Allow, statements.get(0).getEffect()); assertEquals(1, statements.get(0).getActions().size()); assertEquals("foo", statements.get(0).getActions().get(0).getActionName()); assertEquals(1, statements.get(0).getConditions().size()); assertEquals("StringNotLike", statements.get(0).getConditions().get(0).getType()); assertEquals("key1", statements.get(0).getConditions().get(0).getConditionKey()); assertEquals(2, statements.get(0).getConditions().get(0).getValues().size()); assertEquals("foo", statements.get(0).getConditions().get(0).getValues().get(0)); assertEquals("bar", statements.get(0).getConditions().get(0).getValues().get(1)); }
assertEquals("resource", statements.get(0).getResources().get(0).getId()); assertEquals(1, statements.get(0).getActions().size()); assertEquals("action1", statements.get(0).getActions().get(0).getActionName()); assertEquals(1, statements.get(0).getConditions().size()); assertEquals("IpAddress", statements.get(0).getConditions().get(0).getType()); assertEquals("resource", statements.get(1).getResources().get(0).getId()); assertEquals(1, statements.get(1).getActions().size()); assertEquals("action2", statements.get(1).getActions().get(0).getActionName()); assertEquals(1, statements.get(1).getConditions().size()); assertEquals("IpAddress", statements.get(1).getConditions().get(0).getType()); assertEquals("resource", statements.get(2).getResources().get(0).getId()); assertEquals(1, statements.get(2).getActions().size()); assertEquals("action3", statements.get(2).getActions().get(0).getActionName()); assertEquals(1, statements.get(2).getConditions().size()); assertEquals("NotIpAddress", statements.get(2).getConditions().get(0).getType());
assertEquals("action", statements.get(0).getActions().get(0).getActionName()); assertEquals("resource", statements.get(0).getResources().get(0).getId()); assertEquals(2, statements.get(0).getPrincipals().size()); assertEquals("action", statements.get(0).getActions().get(0).getActionName()); assertEquals(2, statements.get(0).getPrincipals().size()); assertEquals("Service", statements.get(0).getPrincipals().get(0).getProvider()); assertEquals("action", statements.get(0).getActions().get(0).getActionName()); assertEquals(1, statements.get(0).getPrincipals().size()); assertEquals(Principal.All, statements.get(0).getPrincipals().get(0)); assertEquals("action", statements.get(0).getActions().get(0).getActionName()); assertEquals(3, statements.get(0).getPrincipals().size()); assertEquals(Principal.AllServices, statements.get(0).getPrincipals().get(0));
/** * Writes the list of <code>Action</code>s to the JSONGenerator. * * @param actions the list of the actions to be written. */ private void writeActions(List<Action> actions) throws IOException { List<String> actionStrings = new ArrayList<String>(); for (Action action : actions) { actionStrings.add(action.getActionName()); } writeJsonArray(JsonDocumentFields.ACTION, actionStrings); }
/** * Writes the list of <code>Action</code>s to the JSONGenerator. * * @param actions the list of the actions to be written. */ private void writeActions(List<Action> actions) throws IOException { List<String> actionStrings = new ArrayList<String>(); for (Action action : actions) { actionStrings.add(action.getActionName()); } writeJsonArray(JsonDocumentFields.ACTION, actionStrings); }
/** * Writes the list of <code>Action</code>s to the JSONGenerator. * * @param actions * the list of the actions to be written. */ private void writeActions(List<Action> actions) throws JsonGenerationException, IOException { List<String> actionStrings = new ArrayList<String>(); for (Action action : actions) { actionStrings.add(action.getActionName()); } writeJsonArray(JsonDocumentFields.ACTION, actionStrings); }