-
Notifications
You must be signed in to change notification settings - Fork 34
feat: support conditional policies #110
Changes from 1 commit
67e52ce
84fcfea
145f7a0
ac1fd6e
2c8724b
c90dbb0
b0a617f
9dbfc2d
54ad076
ff49620
298b2be
aaebba4
a5f63ea
4873b73
c853a84
c64e55a
d2fab21
86cd863
085959d
174e8c4
14e1aac
fdb040a
42199d1
bbb708a
7f0e33e
108faec
79126b5
505f9bc
a89ef0c
f0b5085
9f5e600
8580f5a
9fe4358
8f48a15
615ba06
2b56641
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -59,6 +59,7 @@ public abstract static class Builder { | |||||
|
|
||||||
| public Builder addMembers(String... members) { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It wouldn't make sense to call this with no arguments, right? If you change it to the following, then that wouldn't even compile.
Suggested change
You can then use Guava's |
||||||
| for (String member : members) { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
That should work, no? |
||||||
|
|
||||||
| membersBuilder().add(member); | ||||||
| } | ||||||
| return this; | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -39,7 +39,7 @@ | |||||
|
|
||||||
| /** | ||||||
| * Class for Identity and Access Management (IAM) policies. IAM policies are used to specify access | ||||||
| * settings for Cloud Platform resources. A policy is a map of bindings. A binding assigns a set of | ||||||
| * settings for Cloud Platform resources. A policy is a list of bindings. A binding assigns a set of | ||||||
| * identities to a role, where the identities can be user accounts, Google groups, Google domains, | ||||||
| * and service accounts. A role is a named list of permissions defined by IAM. | ||||||
| * | ||||||
|
|
@@ -174,8 +174,8 @@ protected Builder(Policy policy) { | |||||
| * Replaces the builder's map of bindings with the given map of bindings. | ||||||
| * | ||||||
| * @throws NullPointerException if the given map is null or contains any null keys or values | ||||||
| * @throws IllegalArgumentException if any identities in the given map are null | ||||||
| * @throws IllegalArgumentException if policy version is equal to 3 or has conditional bindings. | ||||||
| * @throws IllegalArgumentException if any identities in the given map are null or if policy | ||||||
| * version is equal to 3 or has conditional bindings. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| */ | ||||||
| public final Builder setBindings(Map<Role, Set<Identity>> bindings) { | ||||||
| checkNotNull(bindings, "The provided map of bindings cannot be null."); | ||||||
|
|
@@ -204,7 +204,8 @@ public final Builder setBindings(Map<Role, Set<Identity>> bindings) { | |||||
| /** | ||||||
| * Replaces the builder's List of bindings with the given List of Bindings. | ||||||
| * | ||||||
| * @throws NullPointerException if the given map is null or contains any null keys or values | ||||||
| * @throws NullPointerException if the given list is null or contains any null members in | ||||||
| * bindings. | ||||||
| * @throws IllegalArgumentException if any identities in the given map are null | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems redundant/contradicts the above NullPointerException |
||||||
| */ | ||||||
| public final Builder setBindings(List<Binding> bindings) { | ||||||
|
|
@@ -256,7 +257,7 @@ public final Builder addIdentity(Role role, Identity first, Identity... others) | |||||
| checkNotNull(first, nullIdentityMessage); | ||||||
| checkNotNull(others, nullIdentityMessage); | ||||||
| checkNotNull(role, "The role cannot be null."); | ||||||
| for (int i = 0; i < bindingsList.size(); ++i) { | ||||||
| for (int i = 0; i < bindingsList.size(); i++) { | ||||||
| Binding binding = bindingsList.get(i); | ||||||
| if (binding.getRole().equals(role.getValue())) { | ||||||
| Binding.Builder bindingBuilder = binding.toBuilder().addMembers(first.strValue()); | ||||||
|
|
@@ -290,7 +291,7 @@ public final Builder removeIdentity(Role role, Identity first, Identity... other | |||||
| checkNotNull(first, nullIdentityMessage); | ||||||
| checkNotNull(others, nullIdentityMessage); | ||||||
| checkNotNull(role, "The role cannot be null."); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. Alternatively, you could have a private static method that takes a |
||||||
| for (int i = 0; i < bindingsList.size(); ++i) { | ||||||
| for (int i = 0; i < bindingsList.size(); i++) { | ||||||
| Binding binding = bindingsList.get(i); | ||||||
| if (binding.getRole().equals(role.getValue())) { | ||||||
| Binding.Builder bindingBuilder = binding.toBuilder().removeMembers(first.strValue()); | ||||||
|
|
@@ -374,7 +375,7 @@ public Map<Role, Set<Identity>> getBindings() { | |||||
| return bindingsV1Builder.build(); | ||||||
| } | ||||||
|
|
||||||
| /** Returns the map of bindings that comprises the policy for version 3. */ | ||||||
| /** Returns the list of bindings that comprises the policy for version 3. */ | ||||||
| public List<Binding> getBindingsList() { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| return bindingsList; | ||||||
| } | ||||||
|
|
@@ -428,7 +429,7 @@ public boolean equals(Object obj) { | |||||
| if (bindingsList.size() != other.getBindingsList().size()) { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whole block can be just |
||||||
| return false; | ||||||
| } | ||||||
| for (int i = 0; i < bindingsList.size(); ++i) { | ||||||
| for (int i = 0; i < bindingsList.size(); i++) { | ||||||
| bindingsList.get(i).equals(other.getBindingsList().get(i)); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, missed this. Should this be returning something?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, I missed this as well. Will fix. |
||||||
| } | ||||||
| return Objects.equals(etag, other.getEtag()) && Objects.equals(version, other.getVersion()); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.