@Test public void modifyReferencesWhiteList() throws Exception { Contract contract = new Contract(TestKeys.privateKey(0)); contract.getDefinition().getData().put("type","Good Bank"); ModifyDataPermission modifyDataPermission = new ModifyDataPermission(contract.getRole("owner"),new Binder()); Contract referencedContract = new Contract(TestKeys.privateKey(1)); referencedContract.seal(); List<String> listConditionsForDefinition = new ArrayList<>(); listConditionsForDefinition.add("ref.definition.data.type == \"Good Bank\""); Binder conditionsForDefinition = new Binder(); conditionsForDefinition.set("all_of", listConditionsForDefinition); Reference ref = new Reference(referencedContract); ref.name = "bank_certificate"; ref.type = Reference.TYPE_EXISTING_STATE; ref.setConditions(conditionsForDefinition); modifyDataPermission.addField("/references", Do.listOf(ref)); contract.addPermission(modifyDataPermission); contract.seal(); ref = Boss.load(Boss.dump(ref)); Contract changed = contract.createRevision(); changed.addSignerKey(TestKeys.privateKey(0)); ref.setContract(changed); changed.addReference(ref); changed.seal(); changed.check(); changed.traceErrors(); assertTrue(changed.isOk()); ref.name = "stepa_certificate"; changed = contract.createRevision(); changed.addSignerKey(TestKeys.privateKey(0)); ref.setContract(changed); changed.addReference(ref); changed.seal(); changed.check(); changed.traceErrors(); assertFalse(changed.isOk()); ref.name = "bank_certificate"; ref.type = Reference.TYPE_TRANSACTIONAL; changed = contract.createRevision(); changed.addSignerKey(TestKeys.privateKey(0)); ref.setContract(changed); changed.addReference(ref); changed.seal(); changed.check(); changed.traceErrors(); assertFalse(changed.isOk()); ref.type = Reference.TYPE_EXISTING_STATE; conditionsForDefinition = new Binder(); conditionsForDefinition.set("any_of", listConditionsForDefinition); ref.setConditions(conditionsForDefinition); changed = contract.createRevision(); changed.addSignerKey(TestKeys.privateKey(0)); ref.setContract(changed); changed.addReference(ref); changed.seal(); changed.check(); changed.traceErrors(); assertFalse(changed.isOk()); listConditionsForDefinition = new ArrayList<>(); listConditionsForDefinition.add("ref.definition.data.type == \"Stepa Bank\""); conditionsForDefinition = new Binder(); conditionsForDefinition.set("all_of", listConditionsForDefinition); ref.setConditions(conditionsForDefinition); changed = contract.createRevision(); changed.addSignerKey(TestKeys.privateKey(0)); ref.setContract(changed); changed.addReference(ref); changed.seal(); changed.check(); changed.traceErrors(); assertFalse(changed.isOk()); listConditionsForDefinition = new ArrayList<>(); listConditionsForDefinition.add("ref.definition.data.type == \"Good Bank\""); conditionsForDefinition = new Binder(); conditionsForDefinition.set("all_of", listConditionsForDefinition); ref.setConditions(conditionsForDefinition); changed = contract.createRevision(); changed.addSignerKey(TestKeys.privateKey(0)); ref.setContract(changed); changed.addReference(ref); changed.seal(); changed.check(); changed.traceErrors(); assertTrue(changed.isOk()); }
public ModifyDataPermission addField(String fieldName, List<String> values) { this.fields.put(fieldName, values); return this; }
ModifyDataPermission extends Permission { public ModifyDataPermission addField(String fieldName, List<String> values) { this.fields.put(fieldName, values); return this; } }
ModifyDataPermission extends Permission { public ModifyDataPermission addField(String fieldName, List<String> values) { this.fields.put(fieldName, values); return this; } ModifyDataPermission();  ModifyDataPermission(Role role, Binder params); }
ModifyDataPermission extends Permission { public ModifyDataPermission addField(String fieldName, List<String> values) { this.fields.put(fieldName, values); return this; } ModifyDataPermission();  ModifyDataPermission(Role role, Binder params); ModifyDataPermission addField(String fieldName, List<String> values); void addAllFields(Map<String, List<String>> fields); @Override void checkChangesQuantized(Contract contract, Contract changedContract, Map<String, Delta> stateChanges, Set<Contract> revokingItems, Collection<PublicKey> keys); Map<String, List<String>> getFields(); @Override Binder serialize(BiSerializer serializer); @Override void deserialize(Binder data, BiDeserializer deserializer); }
ModifyDataPermission extends Permission { public ModifyDataPermission addField(String fieldName, List<String> values) { this.fields.put(fieldName, values); return this; } ModifyDataPermission();  ModifyDataPermission(Role role, Binder params); ModifyDataPermission addField(String fieldName, List<String> values); void addAllFields(Map<String, List<String>> fields); @Override void checkChangesQuantized(Contract contract, Contract changedContract, Map<String, Delta> stateChanges, Set<Contract> revokingItems, Collection<PublicKey> keys); Map<String, List<String>> getFields(); @Override Binder serialize(BiSerializer serializer); @Override void deserialize(Binder data, BiDeserializer deserializer); static final String FIELD_NAME; }