本文整理汇总了Java中com.amazonaws.auth.policy.Policy.getStatements方法的典型用法代码示例。如果您正苦于以下问题:Java Policy.getStatements方法的具体用法?Java Policy.getStatements怎么用?Java Policy.getStatements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.auth.policy.Policy
的用法示例。
在下文中一共展示了Policy.getStatements方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: overwriteCMSPolicy
import com.amazonaws.auth.policy.Policy; //导入方法依赖的package包/类
/**
* Overwrite the policy statement for CMS with the standard statement. Add the standard statement for CMS
* to the policy if it did not already exist.
*
* @param policyJson - The KMS key policy in JSON format
* @return - The updated JSON KMS policy containing a regenerated statement for CMS
*/
protected String overwriteCMSPolicy(String policyJson) {
Policy policy = policyReader.createPolicyFromJsonString(policyJson);
removeStatementFromPolicy(policy, CERBERUS_MANAGEMENT_SERVICE_SID);
Collection<Statement> statements = policy.getStatements();
statements.add(generateStandardCMSPolicyStatement());
return policy.toJson();
}
示例2: removeStatementFromPolicy
import com.amazonaws.auth.policy.Policy; //导入方法依赖的package包/类
protected void removeStatementFromPolicy(Policy policy, String statementId) {
Collection<Statement> existingStatements = policy.getStatements();
List<Statement> policyStatementsExcludingConsumer = existingStatements.stream()
.filter(statement -> ! StringUtils.equals(statement.getId(), statementId))
.collect(Collectors.toList());
policyStatementsExcludingConsumer.add(generateStandardCMSPolicyStatement());
policy.setStatements(policyStatementsExcludingConsumer);
}
示例3: validatePolicyDocument
import com.amazonaws.auth.policy.Policy; //导入方法依赖的package包/类
void validatePolicyDocument(String policyJSON) {
Policy policy = Policy.fromJson(policyJSON);
Asserts.isFalse(policy.getStatements().isEmpty(), "statement is required");
for (Statement statement : policy.getStatements()) {
Asserts.isFalse(statement.getActions().isEmpty(), "action is required");
}
}
示例4: policyChanged
import com.amazonaws.auth.policy.Policy; //导入方法依赖的package包/类
boolean policyChanged(Policy policy1, Policy policy2) {
Collection<Statement> statements1 = policy1.getStatements();
Collection<Statement> statements2 = policy2.getStatements();
if (statements1.size() != statements2.size()) return true;
for (Statement statement1 : statements1) {
if (!containStatement(statements2, statement1)) return true;
}
return false;
}
示例5: jsonStringOf
import com.amazonaws.auth.policy.Policy; //导入方法依赖的package包/类
/**
* Converts the given <code>Policy</code> into a JSON String.
*
* @param policy
* the policy to be converted.
* @return a JSON String of the specified policy object.
*/
private String jsonStringOf(Policy policy) throws JsonGenerationException,
IOException {
generator.writeStartObject();
writeJsonKeyValue(JsonDocumentFields.VERSION, policy.getVersion());
if (isNotNull(policy.getId()))
writeJsonKeyValue(JsonDocumentFields.POLICY_ID, policy.getId());
writeJsonArrayStart(JsonDocumentFields.STATEMENT);
for (Statement statement : policy.getStatements()) {
generator.writeStartObject();
if (isNotNull(statement.getId())) {
writeJsonKeyValue(JsonDocumentFields.STATEMENT_ID, statement.getId());
}
writeJsonKeyValue(JsonDocumentFields.STATEMENT_EFFECT, statement
.getEffect().toString());
List<Principal> principals = statement.getPrincipals();
if (isNotNull(principals) && !principals.isEmpty())
writePrincipals(principals);
List<Action> actions = statement.getActions();
if (isNotNull(actions) && !actions.isEmpty())
writeActions(actions);
List<Resource> resources = statement.getResources();
if (isNotNull(resources) && !resources.isEmpty())
writeResources(resources);
List<Condition> conditions = statement.getConditions();
if (isNotNull(conditions) && !conditions.isEmpty())
writeConditions(conditions);
generator.writeEndObject();
}
writeJsonArrayEnd();
generator.writeEndObject();
generator.flush();
return writer.toString();
}