当前位置: 首页>>代码示例>>Java>>正文


Java Policy.getStatements方法代码示例

本文整理汇总了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();
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:15,代码来源:KmsPolicyService.java

示例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);
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:9,代码来源:KmsPolicyService.java

示例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");
    }
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:8,代码来源:InstanceProfileHelper.java

示例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;
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:12,代码来源:InstanceProfileHelper.java

示例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();

}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:56,代码来源:JsonPolicyWriter.java


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