/** * Returns an AWS access control policy object generated from JSON string. Allows configuring options for the JSON policy * reader (for example, to disable the stripping of dashes in the principal ID). * * @param jsonString * The JSON string representation of this AWS access control policy. * @param options * Configuration for the JSON policy reader that affects the way in which it converts the JSON configuration. * * @return An AWS access control policy object. * * @throws IllegalArgumentException * If the specified JSON string is null or invalid and cannot be * converted to an AWS policy object. */ public static Policy fromJson(String jsonString, PolicyReaderOptions options) { return new JsonPolicyReader(options).createPolicyFromJsonString(jsonString); }
final Effect effect = isNotNull(effectNode) ? Effect.valueOf(effectNode.asText()) : Effect.Deny ; if (isNotNull(id)) { statement.setId(id.asText()); if (isNotNull(actionNodes)) statement.setActions(actionsOf(actionNodes)); if (isNotNull(resourceNodes)) statement.setResources(resourcesOf(resourceNodes)); if (isNotNull(conditionNodes)) statement.setConditions(conditionsOf(conditionNodes)); if (isNotNull(principalNodes)) statement.setPrincipals(principalOf(principalNodes));
/** * Generates a list of condition from the Json node. * * @param conditionNodes * the condition Json node to be parsed. * @return the list of conditions. */ private List<Condition> conditionsOf(JsonNode conditionNodes) { List<Condition> conditionList = new LinkedList<Condition>(); Iterator<Map.Entry<String, JsonNode>> mapOfConditions = conditionNodes .fields(); Entry<String, JsonNode> condition; while (mapOfConditions.hasNext()) { condition = mapOfConditions.next(); convertConditionRecord(conditionList, condition.getKey(), condition.getValue()); } return conditionList; }
if (isNotNull(idNode)) { policy.setId(idNode.asText()); if (isNotNull(statementsNode)) { if (statementsNode.isObject()) { statements.add(statementOf(statementsNode)); } else if (statementsNode.isArray()) { for (JsonNode statementNode : statementsNode) { statements.add(statementOf(statementNode));
elements = principalNode.elements(); while (elements.hasNext()) { principals.add(createPrincipal(schema, elements.next())); principals.add(createPrincipal(schema, principalNode));
reader.beginArray(); while (reader.hasNext()) { statements.add(statementOf(reader));
elements = principalNode.elements(); while (elements.hasNext()) { principals.add(createPrincipal(schema, elements.next())); principals.add(createPrincipal(schema, principalNode));
if (isNotNull(idNode)) { policy.setId(idNode.asText()); if (isNotNull(statementsNode)) { if (statementsNode.isObject()) { statements.add(statementOf(statementsNode)); } else if (statementsNode.isArray()) { for (JsonNode statementNode : statementsNode) { statements.add(statementOf(statementNode));
reader.beginArray(); while (reader.hasNext()) { statements.add(statementOf(reader));
final Effect effect = isNotNull(effectNode) ? Effect.valueOf(effectNode.asText()) : Effect.Deny ; if (isNotNull(id)) { statement.setId(id.asText()); if (isNotNull(actionNodes)) statement.setActions(actionsOf(actionNodes)); if (isNotNull(resourceNodes)) statement.setResources(resourcesOf(resourceNodes)); if (isNotNull(conditionNodes)) statement.setConditions(conditionsOf(conditionNodes)); if (isNotNull(principalNodes)) statement.setPrincipals(principalOf(principalNodes));
/** * Returns an AWS access control policy object generated from JSON string. * * @param jsonString The JSON string representation of this AWS access * control policy. * @return An AWS access control policy object. * @throws IllegalArgumentException If the specified JSON string is null or * invalid and cannot be converted to an AWS policy object. */ public static Policy fromJson(String jsonString) { return new JsonPolicyReader().createPolicyFromJsonString(jsonString); }
/** * Generates a list of condition from the Json node. * * @param conditionNodes * the condition Json node to be parsed. * @return the list of conditions. */ private List<Condition> conditionsOf(JsonNode conditionNodes) { List<Condition> conditionList = new LinkedList<Condition>(); Iterator<Map.Entry<String, JsonNode>> mapOfConditions = conditionNodes .fields(); Entry<String, JsonNode> condition; while (mapOfConditions.hasNext()) { condition = mapOfConditions.next(); convertConditionRecord(conditionList, condition.getKey(), condition.getValue()); } return conditionList; }
reader.beginArray(); while (reader.hasNext()) { principals.add(createPrincipal(schema, reader.nextString())); principals.add(createPrincipal(schema, reader.nextString()));
if (isNotNull(idNode)) { policy.setId(idNode.asText()); if (isNotNull(statementNodes)) { for (JsonNode node : statementNodes) { statements.add(statementOf(node));
reader.beginArray(); while (reader.hasNext()) { statements.add(statementOf(reader));
statement.setId(reader.nextString()); } else if (JsonDocumentFields.ACTION.equals(name)) { statement.setActions(actionsOf(reader)); } else if (JsonDocumentFields.RESOURCE.equals(name)) { statement.setResources(resourcesOf(reader)); } else if (JsonDocumentFields.PRINCIPAL.equals(name)) { statement.setPrincipals(principalOf(reader)); } else if (JsonDocumentFields.CONDITION.equals(name)) { statement.setConditions(conditionsOf(reader)); } else { reader.skipValue();
/** * Returns an AWS access control policy object generated from JSON string. Allows configuring options for the JSON policy * reader (for example, to disable the stripping of dashes in the principal ID). * * @param jsonString * The JSON string representation of this AWS access control policy. * @param options * Configuration for the JSON policy reader that affects the way in which it converts the JSON configuration. * * @return An AWS access control policy object. * * @throws IllegalArgumentException * If the specified JSON string is null or invalid and cannot be * converted to an AWS policy object. */ public static Policy fromJson(String jsonString, PolicyReaderOptions options) { return new JsonPolicyReader(options).createPolicyFromJsonString(jsonString); }
/** * Generates a list of condition from the JSON node. * * @param conditionNodes the condition JSON node to be parsed. * @return the list of conditions. * @throws IOException */ private List<Condition> conditionsOf(AwsJsonReader reader) throws IOException { List<Condition> conditionList = new LinkedList<Condition>(); reader.beginObject(); while (reader.hasNext()) { convertConditionRecord(conditionList, reader.nextName(), reader); } reader.endObject(); return conditionList; }
elements = principalNode.elements(); while (elements.hasNext()) { principals.add(createPrincipal(schema, elements.next())); principals.add(createPrincipal(schema, principalNode));
final Effect effect = isNotNull(effectNode) ? Effect.valueOf(effectNode.asText()) : Effect.Deny ; if (isNotNull(id)) { statement.setId(id.asText()); if (isNotNull(actionNodes)) statement.setActions(actionsOf(actionNodes)); if (isNotNull(resourceNodes)) statement.setResources(resourcesOf(resourceNodes)); if (isNotNull(conditionNodes)) statement.setConditions(conditionsOf(conditionNodes)); if (isNotNull(principalNodes)) statement.setPrincipals(principalOf(principalNodes));