contract.registerRole(new RoleLink("creator", "issuer")); RoleLink roleLink = new RoleLink("@change_owner_role","owner"); roleLink.setContract(contract); contract.addPermission(new ChangeOwnerPermission(roleLink)); contract.addSignerKeys(privateKeys);
ownerLink.setContract(escrow);
/** * Create a default empty new contract using a provided key as issuer and owner and sealer. Default expiration is * set to 90 days. * <p> * This constructor adds key as sealing signature so it is ready to {@link #seal()} just after construction, thought * it is necessary to put real data to it first. It is allowed to change owner, expiration and data fields after * creation (but before sealing). * <p> * Change owner permission is added by default * @param key is {@link PrivateKey} for creating roles "issuer", "owner", "creator" and sign contract */ public Contract(PrivateKey key) { this(); // default expiration date setExpiresAt(ZonedDateTime.now().plusDays(90)); // issuer role is a key for a new contract setIssuerKeys(key.getPublicKey()); // issuer is owner, link roles registerRole(new RoleLink("owner", "issuer")); registerRole(new RoleLink("creator", "issuer")); RoleLink roleLink = new RoleLink("@change_ower_role","owner"); roleLink.setContract(this); // owner can change permission addPermission(new ChangeOwnerPermission(roleLink)); // issuer should sign addSignerKey(key); }
ownerLink.setContract(tokenContract); ChangeOwnerPermission changeOwnerPerm = new ChangeOwnerPermission(ownerLink); tokenContract.addPermission(changeOwnerPerm);
ownerLink.setContract(tokenContract); ChangeOwnerPermission changeOwnerPerm = new ChangeOwnerPermission(ownerLink); tokenContract.addPermission(changeOwnerPerm);
@Test public void goodRevokeAnother() throws Exception { Contract c1 = new Contract(ownerKey1); RoleLink rl = new RoleLink("@revoke", "owner"); rl.setContract(c1); c1.addPermission(new RevokePermission(rl)); c1.seal(); Contract c2 = new Contract(ownerKey2); c2.seal(); Assert.assertTrue(c2.check()); Contract c3 = c2.createRevision(ownerKey2); //to prevent "state is identical" c3.setOwnerKeys(ownerKey3); c3.addSignerKey(ownerKey1); c3.addRevokingItems(c1); c3.seal(); assertTrue(c3.check()); }
@Test public void badRevokeAnother() throws Exception { Contract c1 = new Contract(ownerKey1); RoleLink rl = new RoleLink("@revoke", "owner"); rl.setContract(c1); c1.addPermission(new RevokePermission(rl)); c1.seal(); Contract c2 = new Contract(ownerKey2); c2.seal(); Assert.assertTrue(c2.check()); Contract c3 = c2.createRevision(ownerKey2); //to prevent "state is identical" c3.setOwnerKeys(ownerKey3); c3.addRevokingItems(c1); c3.seal(); assertFalse(c3.check()); }
Contract c1 = new Contract(ownerKey1); RoleLink rl = new RoleLink("@revoke", "owner"); rl.setContract(c1); c1.addPermission(new RevokePermission(rl)); c1.seal();