new HashSet<>(Collections.singleton(projectViewer)), StorageRoles.legacyObjectReader(), (Set<Identity>) new HashSet<>(Collections.singleton(Identity.allUsers()))); currentPolicy .toBuilder() .addIdentity(StorageRoles.legacyObjectReader(), Identity.allUsers()) .build(), bucketOptions); updatedPolicy .toBuilder() .removeIdentity(StorageRoles.legacyObjectReader(), Identity.allUsers()) .build(), bucketOptions);
Policy postCommitLibPolicy = Policy.newBuilder() .addIdentity(StorageRoles.objectViewer(), Identity.allUsers()) .addIdentity( StorageRoles.objectAdmin(),
Policy libPolicy = Policy.newBuilder() .addIdentity(StorageRoles.objectViewer(), Identity.allUsers()) .addIdentity( StorageRoles.objectAdmin(),
/** * Converts a string to an {@code Identity}. Used primarily for converting protobuf-generated * policy identities to {@code Identity} objects. */ public static Identity valueOf(String identityStr) { String[] info = identityStr.split(":"); Type type = Type.valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, info[0])); switch (type) { case ALL_USERS: return Identity.allUsers(); case ALL_AUTHENTICATED_USERS: return Identity.allAuthenticatedUsers(); case USER: return Identity.user(info[1]); case SERVICE_ACCOUNT: return Identity.serviceAccount(info[1]); case GROUP: return Identity.group(info[1]); case DOMAIN: return Identity.domain(info[1]); default: throw new IllegalStateException("Unexpected identity type " + type); } } }