Skip to content

Commit 35ae9d4

Browse files
committed
restructure of blacklist cordapp
1 parent c434d5a commit 35ae9d4

File tree

18 files changed

+144
-145
lines changed

18 files changed

+144
-145
lines changed

Features/attachment-blacklist/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ the shell of Monogram Bank:
7171

7272
start ProposeFlow agreementTxt: "A and B agree Y", counterparty: "Hiseville Deposit Bank", untrustedPartiesAttachment: "4CEC607599723D7E0393EB5F05F24562732CD1B217DEAEDEABD4C25AFE5B333A"
7373

74-
If you now run `run vaultQuery contractStateType: net.corda.examples.attachments.states.AgreementState` on either the
74+
If you now run `run vaultQuery contractStateType: AgreementState` on either the
7575
Monogram Bank or Hiseville Deposit Bank node, you should see the agreement stored:
7676

7777
data: !<net.corda.examples.attachments.state.AgreementState>

Features/attachment-blacklist/build.gradle

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,52 @@ allprojects {
5252
tasks.withType(JavaCompile) {
5353
options.compilerArgs << "-parameters" // Required for shell commands.
5454
}
55+
}
56+
57+
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
58+
nodeDefaults {
59+
cordapp project(':workflows')
60+
cordapp project(':contracts')
61+
runSchemaMigration = true
62+
}
63+
64+
node {
65+
name "O=Notary,L=London,C=GB"
66+
notary = [validating: false]
67+
p2pPort 10002
68+
rpcSettings {
69+
address("localhost:10003")
70+
adminAddress("localhost:10043")
71+
}
72+
}
5573

56-
}
74+
node {
75+
name "O=Monogram Bank,L=London,C=GB"
76+
p2pPort 10005
77+
rpcSettings {
78+
address("localhost:10006")
79+
adminAddress("localhost:10046")
80+
}
81+
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
82+
}
83+
84+
node {
85+
name "O=Hiseville Deposit Bank,L=Sao Paulo,C=BR"
86+
p2pPort 10008
87+
rpcSettings {
88+
address("localhost:10009")
89+
adminAddress("localhost:10049")
90+
}
91+
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
92+
}
93+
94+
node {
95+
name "O=George State Bank,L=New York,C=US"
96+
p2pPort 10011
97+
rpcSettings {
98+
address("localhost:10012")
99+
adminAddress("localhost:10052")
100+
}
101+
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
102+
}
103+
}

Features/attachment-blacklist/clients/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ dependencies {
2727
}
2828

2929
springBoot {
30-
mainClassName = "net.corda.examples.attachments.webserver.Server"
30+
mainClassName = "net.corda.samples.blacklist.webserver.Server"
3131
}
3232

3333
task runWebServer(type: JavaExec, dependsOn: assemble) {
3434
classpath = sourceSets.main.runtimeClasspath
35-
main = 'net.corda.examples.attachments.webserver.Starter'
35+
main = 'net.corda.samples.blacklist.webserver.Starter'
3636
args '--server.port=10050', '--config.rpc.host=localhost', '--config.rpc.port=10006', '--config.rpc.username=user1', '--config.rpc.password=test'
3737
}
3838

3939
task uploadBlacklist(type: JavaExec, dependsOn: assemble) {
4040
classpath = sourceSets.main.runtimeClasspath
41-
main = 'net.corda.examples.attachments.client.Client'
41+
main = 'net.corda.samples.blacklist.clients.Client'
4242
args 'localhost:10006', 'localhost:10009', 'localhost:10012'
4343
}

Features/attachment-blacklist/clients/src/main/java/net/corda/examples/attachments/client/Client.java renamed to Features/attachment-blacklist/clients/src/main/java/net/corda/samples/blacklist/client/Client.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
package net.corda.examples.attachments.client;
1+
package net.corda.samples.blacklist.client;
22

33
import com.google.common.base.Charsets;
44
import net.corda.client.rpc.CordaRPCClient;
55
import net.corda.client.rpc.CordaRPCConnection;
66
import net.corda.core.crypto.SecureHash;
77
import net.corda.core.messaging.CordaRPCOps;
88
import net.corda.core.utilities.NetworkHostAndPort;
9+
import net.corda.samples.blacklist.Constants;
910
import org.slf4j.Logger;
1011
import org.slf4j.LoggerFactory;
1112

@@ -15,8 +16,6 @@
1516
import java.util.jar.JarInputStream;
1617
import java.util.stream.Collectors;
1718

18-
import static net.corda.examples.attachments.Constants.*;
19-
2019
public class Client {
2120

2221
private static class Companion {
@@ -37,13 +36,13 @@ public static void main(String[] args) throws IOException {
3736
CordaRPCConnection rpcConnection = new CordaRPCClient(nodeAddress).start("user1", "test");
3837
CordaRPCOps proxy = rpcConnection.getProxy();
3938

40-
SecureHash attachmentHash = BLACKLIST_JAR_HASH;
39+
SecureHash attachmentHash = Constants.BLACKLIST_JAR_HASH;
4140

4241
// take relative path using substring of constant BLACKLIST_JAR_PATH, check if node contains blacklist already
4342
if (!proxy.attachmentExists(attachmentHash)) {
4443
System.out.println("Working Directory = " +
4544
System.getProperty("user.dir"));
46-
attachmentHash = uploadAttachment(proxy, BLACKLIST_JAR_PATH);
45+
attachmentHash = uploadAttachment(proxy, Constants.BLACKLIST_JAR_PATH);
4746
Companion.logger.info("Blacklist uploaded to node at " + nodeAddress);
4847
} else {
4948
Companion.logger.info("Node already contains Blacklist, skipping upload at " + nodeAddress);
@@ -52,7 +51,7 @@ public static void main(String[] args) throws IOException {
5251
JarInputStream attachmentJar = downloadAttachment(proxy, attachmentHash);
5352
Companion.logger.info("Blacklist downloaded from node at " + nodeAddress);
5453

55-
checkAttachment(attachmentJar, ATTACTMENT_FILE_NAME, ATTACHMENT_EXPECTED_CONTENTS);
54+
checkAttachment(attachmentJar, Constants.ATTACTMENT_FILE_NAME, Constants.ATTACHMENT_EXPECTED_CONTENTS);
5655
Companion.logger.info("Attachment contents checked on node at " + nodeAddress);
5756
}
5857

@@ -83,7 +82,7 @@ private static void checkAttachment(JarInputStream attachmentJar, String expecte
8382
name = attachmentJar.getNextEntry().getName();
8483
}
8584

86-
BufferedInputStream bisAttachmentJar = new BufferedInputStream(attachmentJar, (8*1024));
85+
BufferedInputStream bisAttachmentJar = new BufferedInputStream(attachmentJar, (8 * 1024));
8786
InputStreamReader isrAttachmentJar = new InputStreamReader(bisAttachmentJar, Charsets.UTF_8);
8887
BufferedReader brAttachmentJar = new BufferedReader(isrAttachmentJar);
8988

Features/attachment-blacklist/contracts/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cordapp {
1010
targetPlatformVersion corda_platform_version.toInteger()
1111
minimumPlatformVersion corda_platform_version.toInteger()
1212
contract {
13-
name "Blacklist"
13+
name "Attachments Blacklist"
1414
vendor "Corda Open Source"
1515
licence "Apache License, Version 2.0"
1616
versionId 1
@@ -28,4 +28,4 @@ dependencies {
2828
cordaCompile "$corda_release_group:corda-rpc:$corda_release_version"
2929
cordaRuntime "$corda_release_group:corda:$corda_release_version"
3030

31-
}
31+
}

Features/attachment-blacklist/contracts/src/main/java/net/corda/examples/attachments/Constants.java renamed to Features/attachment-blacklist/contracts/src/main/java/net/corda/samples/blacklist/Constants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.corda.examples.attachments;
1+
package net.corda.samples.blacklist;
22

33
import net.corda.core.crypto.SecureHash;
44

@@ -25,4 +25,4 @@ public interface Constants {
2525
);
2626
// This jar exists, but does not meet the constraints imposed by AttachmentContract.
2727
String INCORRECT_JAR_PATH = "src/test/resources/invalid.jar";
28-
}
28+
}

Features/attachment-blacklist/contracts/src/main/java/net/corda/examples/attachments/contracts/AgreementContract.java renamed to Features/attachment-blacklist/contracts/src/main/java/net/corda/samples/blacklist/contracts/AgreementContract.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package net.corda.examples.attachments.contracts;
1+
package net.corda.samples.blacklist.contracts;
22

33
import com.google.common.base.Charsets;
44
import net.corda.core.contracts.*;
55
import net.corda.core.crypto.SecureHash;
66
import net.corda.core.identity.AbstractParty;
77
import net.corda.core.identity.Party;
88
import net.corda.core.transactions.LedgerTransaction;
9-
import net.corda.examples.attachments.states.AgreementState;
9+
import net.corda.samples.blacklist.states.AgreementState;
1010

1111
import java.io.BufferedReader;
1212
import java.io.IOException;
@@ -20,7 +20,7 @@
2020
import java.util.stream.Collectors;
2121

2222
public class AgreementContract implements Contract {
23-
public static final String AGREEMENT_CONTRACT_ID = "net.corda.examples.attachments.contracts.AgreementContract";
23+
public static final String AGREEMENT_CONTRACT_ID = "net.corda.samples.blacklist.contracts.AgreementContract";
2424
private static SecureHash BLACKLIST_JAR_HASH = SecureHash.parse("4CEC607599723D7E0393EB5F05F24562732CD1B217DEAEDEABD4C25AFE5B333A");
2525

2626
@Override
@@ -40,7 +40,7 @@ public void verify(LedgerTransaction tx) {
4040
return null;
4141
});
4242

43-
// Constraints on the included attachments.
43+
// Constraints on the included blacklist.
4444
List<Attachment> nonContractAttachments = tx.getAttachments()
4545
.stream()
4646
.filter(p -> !(p instanceof ContractAttachment))
@@ -55,7 +55,7 @@ public void verify(LedgerTransaction tx) {
5555

5656
// TODO: Switch to constraint on the jar's signer.
5757
// In the future, Corda will support singing of jars. We will then be able to restrict
58-
// the attachments used to just those signed by party X.
58+
// the blacklist used to just those signed by party X.
5959
req.using("The jar's hash should be correct", attached.getId().equals(BLACKLIST_JAR_HASH));
6060
return null;
6161
});
@@ -118,6 +118,7 @@ public void verify(LedgerTransaction tx) {
118118
}
119119

120120
public interface Commands extends CommandData {
121-
class Agree extends TypeOnlyCommandData implements Commands {}
121+
class Agree extends TypeOnlyCommandData implements Commands {
122+
}
122123
}
123124
}

Features/attachment-blacklist/contracts/src/main/java/net/corda/examples/attachments/states/AgreementState.java renamed to Features/attachment-blacklist/contracts/src/main/java/net/corda/samples/blacklist/states/AgreementState.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package net.corda.examples.attachments.states;
1+
package net.corda.samples.blacklist.states;
22

33
import net.corda.core.contracts.BelongsToContract;
44
import net.corda.core.contracts.ContractState;
55
import net.corda.core.identity.AbstractParty;
66
import net.corda.core.identity.Party;
77
import net.corda.core.serialization.ConstructorForDeserialization;
88
import net.corda.core.serialization.CordaSerializable;
9-
import net.corda.examples.attachments.contracts.AgreementContract;
9+
import net.corda.samples.blacklist.contracts.AgreementContract;
1010
import org.jetbrains.annotations.NotNull;
1111

1212
import java.util.Arrays;
@@ -22,7 +22,11 @@ public class AgreementState implements ContractState {
2222
public Party getPartyA() {
2323
return partyA;
2424
}
25-
public Party getPartyB() { return partyB; }
25+
26+
public Party getPartyB() {
27+
return partyB;
28+
}
29+
2630
public String getTxt() {
2731
return txt;
2832
}

Features/attachment-blacklist/contracts/src/test/java/net/corda/examples/attachments/contracts/ContractTests.java renamed to Features/attachment-blacklist/contracts/src/test/java/net/corda/samples/blacklist/contracts/ContractTests.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
package net.corda.examples.attachments.contracts;
1+
package net.corda.samples.blacklist.contracts;
22

33
import net.corda.core.crypto.SecureHash;
44
import net.corda.core.identity.CordaX500Name;
55
import net.corda.core.identity.Party;
6-
import net.corda.examples.attachments.states.AgreementState;
6+
import net.corda.samples.blacklist.Constants;
7+
import net.corda.samples.blacklist.states.AgreementState;
78
import net.corda.testing.core.TestIdentity;
89
import net.corda.testing.node.MockServices;
910
import org.junit.Test;
@@ -16,26 +17,24 @@
1617

1718
import static java.util.Arrays.asList;
1819
import static net.corda.core.crypto.CryptoUtils.generateKeyPair;
19-
import static net.corda.examples.attachments.Constants.BLACKLISTED_PARTIES;
20-
import static net.corda.examples.attachments.Constants.BLACKLIST_JAR_PATH;
21-
import static net.corda.examples.attachments.contracts.AgreementContract.AGREEMENT_CONTRACT_ID;
20+
import static net.corda.samples.blacklist.contracts.AgreementContract.AGREEMENT_CONTRACT_ID;
2221
import static net.corda.testing.core.TestUtils.getTestPartyAndCertificate;
2322
import static net.corda.testing.node.MockServicesKt.makeTestIdentityService;
2423
import static net.corda.testing.node.NodeTestUtils.ledger;
2524

2625

2726
public class ContractTests {
28-
static private final MockServices ledgerServices = new MockServices(asList("net.corda.examples.attachments.contracts"), new TestIdentity(new CordaX500Name("TestIdentity", "", "GB")), makeTestIdentityService());
27+
static private final MockServices ledgerServices = new MockServices(asList("net.corda.samples.blacklist.contracts"), new TestIdentity(new CordaX500Name("TestIdentity", "", "GB")), makeTestIdentityService());
2928
static private final CordaX500Name megaCorpName = new CordaX500Name("MegaCorp", "London", "GB");
3029
static private final CordaX500Name miniCorpName = new CordaX500Name("MiniCorp", "London", "GB");
3130
static private final TestIdentity megaCorp = new TestIdentity(megaCorpName);
3231
static private final TestIdentity miniCorp = new TestIdentity(miniCorpName);
3332

3433
static private final String agreementTxt = megaCorpName + " agrees with " + miniCorpName + " that...";
35-
static private final File validAttachment = new File(BLACKLIST_JAR_PATH);
34+
static private final File validAttachment = new File(Constants.BLACKLIST_JAR_PATH);
3635
static private final KeyPair blacklistedPartyKeyPair = generateKeyPair();
3736
static private final PublicKey blacklistedPartyPubKey = blacklistedPartyKeyPair.getPublic();
38-
static private final CordaX500Name blacklistedPartyName = new CordaX500Name(BLACKLISTED_PARTIES.get(0), "London", "GB");
37+
static private final CordaX500Name blacklistedPartyName = new CordaX500Name(Constants.BLACKLISTED_PARTIES.get(0), "London", "GB");
3938
static private final Party blacklistedParty = getTestPartyAndCertificate(blacklistedPartyName, blacklistedPartyPubKey).getParty();
4039

4140
@Test

Features/attachment-blacklist/contracts/src/test/java/net/corda/examples/attachments/states/StateTests.java renamed to Features/attachment-blacklist/contracts/src/test/java/net/corda/samples/blacklist/states/StateTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.corda.examples.attachments.states;
1+
package net.corda.samples.blacklist.states;
22

33
import net.corda.core.contracts.ContractState;
44
import net.corda.core.identity.CordaX500Name;
@@ -38,4 +38,4 @@ public void agreementStateHasTwoParticipantsPartyAPartyB() {
3838
assertTrue(agreementState.getParticipants().contains(alice));
3939
assertTrue(agreementState.getParticipants().contains(bob));
4040
}
41-
}
41+
}

0 commit comments

Comments
 (0)