本文整理汇总了Java中com.amazonaws.auth.policy.Statement.withId方法的典型用法代码示例。如果您正苦于以下问题:Java Statement.withId方法的具体用法?Java Statement.withId怎么用?Java Statement.withId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.auth.policy.Statement
的用法示例。
在下文中一共展示了Statement.withId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateStandardCMSPolicyStatement
import com.amazonaws.auth.policy.Statement; //导入方法依赖的package包/类
/**
* Generates the standard KMS key policy statement for the Cerberus Management Service
*/
protected Statement generateStandardCMSPolicyStatement() {
Statement cmsStatement = new Statement(Statement.Effect.Allow);
cmsStatement.withId(CERBERUS_MANAGEMENT_SERVICE_SID);
cmsStatement.withPrincipals(new Principal(AWS_PROVIDER, cmsRoleArn, false));
cmsStatement.withActions(
KMSActions.Encrypt,
KMSActions.Decrypt,
KMSActions.ReEncryptFrom,
KMSActions.ReEncryptTo,
KMSActions.GenerateDataKey,
KMSActions.GenerateDataKeyWithoutPlaintext,
KMSActions.GenerateRandom,
KMSActions.DescribeKey,
KMSActions.ScheduleKeyDeletion,
KMSActions.CancelKeyDeletion);
cmsStatement.withResources(new Resource("*"));
return cmsStatement;
}
示例2: generateStandardKmsPolicy
import com.amazonaws.auth.policy.Statement; //导入方法依赖的package包/类
public String generateStandardKmsPolicy(String iamRoleArn) {
Policy kmsPolicy = new Policy();
Statement rootUserStatement = new Statement(Statement.Effect.Allow);
rootUserStatement.withId("Root User Has All Actions");
rootUserStatement.withPrincipals(new Principal(AWS_PROVIDER, rootUserArn, false));
rootUserStatement.withActions(KMSActions.AllKMSActions);
rootUserStatement.withResources(new Resource("*"));
Statement keyAdministratorStatement = new Statement(Statement.Effect.Allow);
keyAdministratorStatement.withId("Admin Role Has All Actions");
keyAdministratorStatement.withPrincipals(new Principal(AWS_PROVIDER, adminRoleArn, false));
keyAdministratorStatement.withActions(KMSActions.AllKMSActions);
keyAdministratorStatement.withResources(new Resource("*"));
Statement instanceUsageStatement = generateStandardCMSPolicyStatement();
Statement iamRoleUsageStatement = new Statement(Statement.Effect.Allow);
iamRoleUsageStatement.withId(CERBERUS_CONSUMER_SID);
iamRoleUsageStatement.withPrincipals(
new Principal(AWS_PROVIDER, iamRoleArn, false));
iamRoleUsageStatement.withActions(KMSActions.Decrypt);
iamRoleUsageStatement.withResources(new Resource("*"));
kmsPolicy.withStatements(rootUserStatement,
keyAdministratorStatement,
instanceUsageStatement,
iamRoleUsageStatement);
return kmsPolicy.toJson();
}