@Test public void badRevoke() throws Exception { Contract c = Contract.fromDslFile(rootPath + "simple_root_contract.yml"); c.addSignerKeyFromFile(rootPath+"_xer0yfe2nn1xthc.private.unikey"); c.seal(); PrivateKey issuer = TestKeys.privateKey(2); Contract tc = c.createRevocation(issuer); boolean result = tc.check(); assertFalse(result); assertEquals(1, tc.getErrors().size()); assertEquals(Errors.FORBIDDEN, tc.getErrors().get(0).getError()); }
public synchronized static Contract createRevocation(Contract c, PrivateKey... keys) { Contract tc = new Contract(); Contract.Definition cd = tc.getDefinition(); cd.setExpiresAt(tc.getCreatedAt().plusDays(30)); SimpleRole issuerRole = new SimpleRole("issuer",tc); for (PrivateKey k : keys) { KeyRecord kr = new KeyRecord(k.getPublicKey()); issuerRole.addKeyRecord(kr); tc.addSignerKey(k); } tc.addRole(issuerRole); tc.addRole("owner", issuerRole); tc.addRole("creator", issuerRole); if (!tc.getRevokingItems().contains(c)) { Binder data = tc.getDefinition().getData(); List<Binder> actions = data.getOrCreateList("actions"); tc.getRevokingItems().add(c); actions.add(Binder.fromKeysValues("action", "remove", "id", c.getId())); } tc.seal(); return tc; }
ContractsService { public synchronized static Contract createRevocation(Contract c, PrivateKey... keys) { Contract tc = new Contract(); Contract.Definition cd = tc.getDefinition(); cd.setExpiresAt(tc.getCreatedAt().plusDays(30)); SimpleRole issuerRole = new SimpleRole("issuer",tc); for (PrivateKey k : keys) { KeyRecord kr = new KeyRecord(k.getPublicKey()); issuerRole.addKeyRecord(kr); tc.addSignerKey(k); } tc.addRole(issuerRole); tc.addRole("owner", issuerRole); tc.addRole("creator", issuerRole); if (!tc.getRevokingItems().contains(c)) { Binder data = tc.getDefinition().getData(); List<Binder> actions = data.getOrCreateList("actions"); tc.getRevokingItems().add(c); actions.add(Binder.fromKeysValues("action", "remove", "id", c.getId())); } tc.seal(); return tc; } }
ContractsService { public synchronized static Contract createRevocation(Contract c, PrivateKey... keys) { Contract tc = new Contract(); Contract.Definition cd = tc.getDefinition(); cd.setExpiresAt(tc.getCreatedAt().plusDays(30)); SimpleRole issuerRole = new SimpleRole("issuer",tc); for (PrivateKey k : keys) { KeyRecord kr = new KeyRecord(k.getPublicKey()); issuerRole.addKeyRecord(kr); tc.addSignerKey(k); } tc.addRole(issuerRole); tc.addRole("owner", issuerRole); tc.addRole("creator", issuerRole); if (!tc.getRevokingItems().contains(c)) { Binder data = tc.getDefinition().getData(); List<Binder> actions = data.getOrCreateList("actions"); tc.getRevokingItems().add(c); actions.add(Binder.fromKeysValues("action", "remove", "id", c.getId())); } tc.seal(); return tc; }  }
ContractsService { public synchronized static Contract createRevocation(Contract c, PrivateKey... keys) { Contract tc = new Contract(); Contract.Definition cd = tc.getDefinition(); cd.setExpiresAt(tc.getCreatedAt().plusDays(30)); SimpleRole issuerRole = new SimpleRole("issuer",tc); for (PrivateKey k : keys) { KeyRecord kr = new KeyRecord(k.getPublicKey()); issuerRole.addKeyRecord(kr); tc.addSignerKey(k); } tc.addRole(issuerRole); tc.addRole("owner", issuerRole); tc.addRole("creator", issuerRole); if (!tc.getRevokingItems().contains(c)) { Binder data = tc.getDefinition().getData(); List<Binder> actions = data.getOrCreateList("actions"); tc.getRevokingItems().add(c); actions.add(Binder.fromKeysValues("action", "remove", "id", c.getId())); } tc.seal(); return tc; }  synchronized static Contract createRevocation(Contract c, PrivateKey... keys); @Deprecated synchronized static Contract createSplit(Contract c, String amount, String fieldName, Set<PrivateKey> keys); @Deprecated synchronized static Contract createSplit(Contract c, String amount, String fieldName, Set<PrivateKey> keys, boolean andSetCreator); synchronized static Contract createSplit(Contract c, BigDecimal amount, String fieldName, Set<PrivateKey> keys); synchronized static Contract createSplit(Contract c, BigDecimal amount, String fieldName, Set<PrivateKey> keys, boolean andSetCreator); synchronized static Contract createJoin(Contract contract1, Contract contract2, String fieldName, Set<PrivateKey> keys); static List<Contract> createSplitJoin(Collection<Contract> contractsToJoin, List<String> amountsToSplit, List<KeyAddress> addressesToSplit,Set<PrivateKey> ownerKeys, String fieldName); synchronized static Contract startSwap(Contract contract1, Contract contract2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys); synchronized static Contract startSwap(List<Contract> contracts1, List<Contract> contracts2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys); synchronized static Contract startSwap(Contract contract1, Contract contract2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys, boolean createNewRevision); synchronized static Contract startSwap(List<Contract> contracts1, List<Contract> contracts2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys, boolean createNewRevision); @Deprecated synchronized static Contract signPresentedSwap(Contract swapContract, Set<PrivateKey> keys); @Deprecated synchronized static Contract finishSwap(Contract swapContract, Set<PrivateKey> keys); synchronized static Contract createTwoSignedContract(Contract baseContract, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys, boolean createNewRevision); @Deprecated synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue, String currency, String name, String description); @Deprecated synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue); @Deprecated synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount); synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue, String currency, String name, String description); synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue); synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); @Deprecated synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue, String currency, String name, String description); @Deprecated synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue); synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue, String currency, String name, String description); synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue); synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, String amount, Set<PrivateKey> keys, String fieldName); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, String amount, Set<PrivateKey> keys); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, BigDecimal amount, Set<PrivateKey> keys, String fieldName); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, BigDecimal amount, Set<PrivateKey> keys); @Deprecated synchronized static Contract createShareContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount); synchronized static Contract createShareContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); synchronized static Contract createNotaryContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys); synchronized static Contract createNotaryContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys,
                                                             List<String> filePaths); synchronized static Contract createNotaryContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys,
                                                             List<String> filePaths, List<String> fileDescriptions); synchronized static boolean checkAttachNotaryContract(Contract notaryContract, String filePaths); synchronized static SlotContract createSlotContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider); synchronized static UnsContract createUnsContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider); synchronized static UnsContract createUnsContractForRegisterContractName(
            Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider,
            String name, String description, String URL, Contract namedContract); synchronized static UnsContract createUnsContractForRegisterKeyName(
            Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider,
            String name, String description, String URL, AbstractKey namedKey); synchronized static FollowerContract createFollowerContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider); synchronized static Contract addReferenceToContract(
            Contract baseContract, Contract refContract, String refName, int refType, Binder conditions); synchronized static Contract addReferenceToContract(
            Contract baseContract, Contract refContract, String refName, int refType, List<String> listConditions, boolean isAllOfConditions); synchronized static Parcel createParcel(Contract payload, Contract payment, int amount, Set<PrivateKey> keys); synchronized static Parcel createParcel(Contract payload, Contract payment, int amount, Set<PrivateKey> keys,
                                                   boolean withTestPayment); synchronized static Parcel createParcel(TransactionPack payload, Contract payment, int amount, Set<PrivateKey> keys); synchronized static Parcel createParcel(TransactionPack payload, Contract payment, int amount, Set<PrivateKey> keys,
                                                   boolean withTestPayment); synchronized static Parcel createPayingParcel(TransactionPack payload, Contract payment, int amount, int amountSecond,
                                                         Set<PrivateKey> keys, boolean withTestPayment); static Contract createBatch(Collection<PrivateKey> keys, Contract... contracts); static Contract addConsent(Contract source, KeyAddress... consentKeyAddresses); static Contract createEscrowContract(
            Collection<PrivateKey> issuerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys,
            Collection<PublicKey> arbitratorKeys); static Contract createInternalEscrowContract(
            Collection<PrivateKey> issuerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys,
            Collection<PublicKey> arbitratorKeys); static Contract createExternalEscrowContract(Contract internalEscrow, Collection<PrivateKey> issuerKeys); static Contract modifyPaymentForEscrowContract(
            Contract escrow,
            Contract payment,
            Collection<PrivateKey> paymentOwnerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys); static Contract modifyPaymentForEscrowContract(
            String escrowOrigin,
            Contract payment,
            Collection<PrivateKey> paymentOwnerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys); static boolean addPaymentToEscrowContract(
            Contract escrow,
            Contract payment,
            Collection<PrivateKey> paymentOwnerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys); static Contract completeEscrowContract(Contract escrow); static Contract cancelEscrowContract(Contract escrow); static Contract takeEscrowPayment(Collection<PrivateKey> newOwnerKeys, Contract payment); synchronized static Contract createRateLimitDisablingContract(PublicKey key, Contract payment, int amount, Set<PrivateKey> keys); }
ContractsService { public synchronized static Contract createRevocation(Contract c, PrivateKey... keys) { Contract tc = new Contract(); Contract.Definition cd = tc.getDefinition(); cd.setExpiresAt(tc.getCreatedAt().plusDays(30)); SimpleRole issuerRole = new SimpleRole("issuer",tc); for (PrivateKey k : keys) { KeyRecord kr = new KeyRecord(k.getPublicKey()); issuerRole.addKeyRecord(kr); tc.addSignerKey(k); } tc.addRole(issuerRole); tc.addRole("owner", issuerRole); tc.addRole("creator", issuerRole); if (!tc.getRevokingItems().contains(c)) { Binder data = tc.getDefinition().getData(); List<Binder> actions = data.getOrCreateList("actions"); tc.getRevokingItems().add(c); actions.add(Binder.fromKeysValues("action", "remove", "id", c.getId())); } tc.seal(); return tc; }  synchronized static Contract createRevocation(Contract c, PrivateKey... keys); @Deprecated synchronized static Contract createSplit(Contract c, String amount, String fieldName, Set<PrivateKey> keys); @Deprecated synchronized static Contract createSplit(Contract c, String amount, String fieldName, Set<PrivateKey> keys, boolean andSetCreator); synchronized static Contract createSplit(Contract c, BigDecimal amount, String fieldName, Set<PrivateKey> keys); synchronized static Contract createSplit(Contract c, BigDecimal amount, String fieldName, Set<PrivateKey> keys, boolean andSetCreator); synchronized static Contract createJoin(Contract contract1, Contract contract2, String fieldName, Set<PrivateKey> keys); static List<Contract> createSplitJoin(Collection<Contract> contractsToJoin, List<String> amountsToSplit, List<KeyAddress> addressesToSplit,Set<PrivateKey> ownerKeys, String fieldName); synchronized static Contract startSwap(Contract contract1, Contract contract2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys); synchronized static Contract startSwap(List<Contract> contracts1, List<Contract> contracts2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys); synchronized static Contract startSwap(Contract contract1, Contract contract2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys, boolean createNewRevision); synchronized static Contract startSwap(List<Contract> contracts1, List<Contract> contracts2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys, boolean createNewRevision); @Deprecated synchronized static Contract signPresentedSwap(Contract swapContract, Set<PrivateKey> keys); @Deprecated synchronized static Contract finishSwap(Contract swapContract, Set<PrivateKey> keys); synchronized static Contract createTwoSignedContract(Contract baseContract, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys, boolean createNewRevision); @Deprecated synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue, String currency, String name, String description); @Deprecated synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue); @Deprecated synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount); synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue, String currency, String name, String description); synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue); synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); @Deprecated synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue, String currency, String name, String description); @Deprecated synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue); synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue, String currency, String name, String description); synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue); synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, String amount, Set<PrivateKey> keys, String fieldName); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, String amount, Set<PrivateKey> keys); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, BigDecimal amount, Set<PrivateKey> keys, String fieldName); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, BigDecimal amount, Set<PrivateKey> keys); @Deprecated synchronized static Contract createShareContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount); synchronized static Contract createShareContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); synchronized static Contract createNotaryContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys); synchronized static Contract createNotaryContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys,
                                                             List<String> filePaths); synchronized static Contract createNotaryContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys,
                                                             List<String> filePaths, List<String> fileDescriptions); synchronized static boolean checkAttachNotaryContract(Contract notaryContract, String filePaths); synchronized static SlotContract createSlotContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider); synchronized static UnsContract createUnsContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider); synchronized static UnsContract createUnsContractForRegisterContractName(
            Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider,
            String name, String description, String URL, Contract namedContract); synchronized static UnsContract createUnsContractForRegisterKeyName(
            Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider,
            String name, String description, String URL, AbstractKey namedKey); synchronized static FollowerContract createFollowerContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider); synchronized static Contract addReferenceToContract(
            Contract baseContract, Contract refContract, String refName, int refType, Binder conditions); synchronized static Contract addReferenceToContract(
            Contract baseContract, Contract refContract, String refName, int refType, List<String> listConditions, boolean isAllOfConditions); synchronized static Parcel createParcel(Contract payload, Contract payment, int amount, Set<PrivateKey> keys); synchronized static Parcel createParcel(Contract payload, Contract payment, int amount, Set<PrivateKey> keys,
                                                   boolean withTestPayment); synchronized static Parcel createParcel(TransactionPack payload, Contract payment, int amount, Set<PrivateKey> keys); synchronized static Parcel createParcel(TransactionPack payload, Contract payment, int amount, Set<PrivateKey> keys,
                                                   boolean withTestPayment); synchronized static Parcel createPayingParcel(TransactionPack payload, Contract payment, int amount, int amountSecond,
                                                         Set<PrivateKey> keys, boolean withTestPayment); static Contract createBatch(Collection<PrivateKey> keys, Contract... contracts); static Contract addConsent(Contract source, KeyAddress... consentKeyAddresses); static Contract createEscrowContract(
            Collection<PrivateKey> issuerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys,
            Collection<PublicKey> arbitratorKeys); static Contract createInternalEscrowContract(
            Collection<PrivateKey> issuerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys,
            Collection<PublicKey> arbitratorKeys); static Contract createExternalEscrowContract(Contract internalEscrow, Collection<PrivateKey> issuerKeys); static Contract modifyPaymentForEscrowContract(
            Contract escrow,
            Contract payment,
            Collection<PrivateKey> paymentOwnerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys); static Contract modifyPaymentForEscrowContract(
            String escrowOrigin,
            Contract payment,
            Collection<PrivateKey> paymentOwnerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys); static boolean addPaymentToEscrowContract(
            Contract escrow,
            Contract payment,
            Collection<PrivateKey> paymentOwnerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys); static Contract completeEscrowContract(Contract escrow); static Contract cancelEscrowContract(Contract escrow); static Contract takeEscrowPayment(Collection<PrivateKey> newOwnerKeys, Contract payment); synchronized static Contract createRateLimitDisablingContract(PublicKey key, Contract payment, int amount, Set<PrivateKey> keys);  }