public class Policy extends Object
By default, all requests to use your resource coming from anyone but you are denied. Access control polices can override that by allowing different types of access to your resources, or by explicitly denying different types of access.
Each statement in an AWS access control policy takes the form: "A has permission to do B to C where D applies".
Note that an AWS access control policy should not be confused with the similarly named "POST form policy" concept used in Amazon S3.
Constructor and Description |
---|
Policy()
Constructs an empty AWS access control policy ready to be populated with
statements.
|
Policy(String id)
Constructs a new AWS access control policy with the specified policy ID.
|
Policy(String id,
Collection<Statement> statements)
Constructs a new AWS access control policy with the specified policy ID
and collection of statements.
|
Modifier and Type | Method and Description |
---|---|
static Policy |
fromJson(String jsonString)
Returns an AWS access control policy object generated from JSON string.
|
static Policy |
fromJson(String jsonString,
PolicyReaderOptions options)
Returns an AWS access control policy object generated from JSON string.
|
String |
getId()
Returns the policy ID for this policy.
|
Collection<Statement> |
getStatements()
Returns the collection of statements contained by this policy.
|
String |
getVersion()
Returns the version of this AWS policy.
|
void |
setId(String id)
Sets the policy ID for this policy.
|
void |
setStatements(Collection<Statement> statements)
Sets the collection of statements contained by this policy.
|
String |
toJson()
Returns a JSON string representation of this AWS access control policy,
suitable to be sent to an AWS service as part of a request to set an
access control policy.
|
Policy |
withId(String id)
Sets the policy ID for this policy and returns the updated policy so that
multiple calls can be chained together.
|
Policy |
withStatements(Statement... statements)
Sets the collection of statements contained by this policy and returns
this policy object so that additional method calls can be chained
together.
|
public Policy()
public Policy(String id)
id
- The policy ID for the new policy object. Policy IDs serve to
help developers keep track of multiple policies, and are often
used to give the policy a meaningful, human readable name.public Policy(String id, Collection<Statement> statements)
Any statements that don't have a statement ID yet will automatically be assigned a unique ID within this policy.
id
- The policy ID for the new policy object. Policy IDs serve to
help developers keep track of multiple policies, and are often
used to give the policy a meaningful, human readable name.statements
- The statements to include in the new policy.public String getId()
public void setId(String id)
id
- The policy ID for this policy.public Policy withId(String id)
Policy IDs serve to help developers keep track of multiple policies, and are often used as human readable name for a policy.
id
- The policy ID for this policy.public String getVersion()
public Collection<Statement> getStatements()
public void setStatements(Collection<Statement> statements)
Any statements that don't have a statement ID yet will automatically be assigned a unique ID within this policy.
statements
- The collection of statements included in this policy.public Policy withStatements(Statement... statements)
Individual statements in a policy are what specify the rules that enable or disable access to your AWS resources.
Any statements that don't have a statement ID yet will automatically be assigned a unique ID within this policy.
statements
- The collection of statements included in this policy.public String toJson()
public static Policy fromJson(String jsonString)
fromJson(String, PolicyReaderOptions)
.jsonString
- The JSON string representation of this AWS access control policy.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)
jsonString
- The JSON string representation of this AWS access control policy.options
- Configuration for the JSON policy reader that affects the way in which it converts the JSON configuration.IllegalArgumentException
- If the specified JSON string is null or invalid and cannot be
converted to an AWS policy object.Copyright © 2021. All rights reserved.