Skip to content

Commit 943f502

Browse files
committed
initial commit
1 parent 9bc9adc commit 943f502

File tree

33 files changed

+1618
-0
lines changed

33 files changed

+1618
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cordaReleaseGroup=net.corda
2+
cordaCoreReleaseGroup=net.corda
3+
cordaVersion=4.7
4+
cordaCoreVersion=4.7
5+
gradlePluginsVersion=5.0.12
6+
kotlinVersion=1.2.71
7+
junitVersion=4.12
8+
quasarVersion=0.7.10
9+
log4jVersion =2.11.2
10+
platformVersion=9
11+
slf4jVersion=1.7.25
12+
nettyVersion=4.1.22.Final
13+
corda_bn_extension_version=1.1-RC03
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2016, R3 Limited.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Membership Attestation
2+
3+
4+
In this sample, we will showcase the use of business network extension in a mock insurance constorsium cordapp
5+
6+
Concept:
7+
In this app, we will have a global insurance network, where participants are either insurance companies or different kind of health care providers.
8+
With the help of business network extension, we can further breakdown the global network into smaller pieces as groups, such as APAC_Insurance_Alliance.
9+
10+
In our sample, we will have three nodes, named as:
11+
NetworkProvider
12+
Insurer
13+
CarePro
14+
15+
The NetworkProvider will be create and primarily manage the network. As introduced in the SDK docs, NetworkManager will be the default authorized user of this global network. And the other two nodes will fill the roles which can be easily tell by its name.
16+
17+
The corDapp will run with the following steps:
18+
1. Network creations by NetworkProvider
19+
2. The rest of the nodes request join the network
20+
3. The network provider will query all the request and active the membership status for the other nodes.
21+
4. The NetworkProvider will then create a sub group out of the global insurance network called APAC_Insurance_Alliance, and include the two other nodes in the network.
22+
5. The networkmanager will then assign custom network identity to the nodes. The insurer node will get an insurance identity, the carePro node will get a health care provider identity.
23+
6. Custom network identity comes with custom roles. We will give the insurer node a policy.
24+
As of now, the network setup is done. The very last step is to run a transaction between the insurer and the carePro node
25+
26+
27+
28+
29+
//Step1: Create the network
30+
flow start CreateNetwork
31+
32+
//Step2: 2 non-member makes the request to join the network.
33+
flow start RequestMembership authorisedParty: NetworkOperator, networkId: 603ec1c1-8b4f-4d4a-968a-8893ba9fdc00
34+
35+
//Step3: go back to the admin node, and query all the membership requests.
36+
flow start QueryAllMembers
37+
38+
//Step4: Admin active membership, two times, ONLY the membership activation
39+
Insurance:
40+
flow start ActiveMembers membershipId: c80bfa2c-d6c4-4376-8244-56d5cd27f050
41+
42+
CarePro:
43+
flow start ActiveMembers membershipId: 54e6d7af-2c9e-4267-adf0-872f70b7c800
44+
45+
---------------------
46+
flow start CreateNetworkSubGroup networkId: 603ec1c1-8b4f-4d4a-968a-8893ba9fdc00, groupName: APAC_Insurance_Alliance, groupParticipants: [baefb1ed-250a-4d27-b3db-6b8914151a45, c80bfa2c-d6c4-4376-8244-56d5cd27f050, 54e6d7af-2c9e-4267-adf0-872f70b7c800]
47+
48+
flow start AssignBNIdentity firmType: InsuranceFirm, membershipId: c80bfa2c-d6c4-4376-8244-56d5cd27f050, bnIdentity: APACIN76CZX
49+
50+
flow start AssignPolicyIssuerRole membershipId: c80bfa2c-d6c4-4376-8244-56d5cd27f050, networkId: 603ec1c1-8b4f-4d4a-968a-8893ba9fdc00
51+
52+
flow start AssignBNIdentity firmType: CareProvider, membershipId: 54e6d7af-2c9e-4267-adf0-872f70b7c800, bnIdentity: APACCP44OJS
53+
54+
55+
//Query to check
56+
run vaultQuery contractStateType: net.corda.core.contracts.ContractState
57+
58+
-------------------Network setup is done, and business flow begins--------------------------
59+
60+
/* Step9: The insurance Company will issue a policy to insuree.
61+
* The flow initiator (the insurance company) has to be a member of the Business network, has to have a insuranceIdentity, and has to have issuer Role, and has to have issuance permission.
62+
*/
63+
flow start IssuePolicyInitiator networkId: 603ec1c1-8b4f-4d4a-968a-8893ba9fdc00, careProvider: CarePro, insuree: PeterLi
64+
//Step10: Query the state in the CarePro node.
65+
run vaultQuery contractStateType: net.corda.samples.businessmembership.states.InsuranceState
66+
run vaultQuery contractStateType: net.corda.bn.states.MembershipState
67+
68+
69+
//flow start AssignBNIdentity firmType: CareProvider, membershipId: 9cc6abf7-e20e-4404-be8c-4bcec1a668e0, bnIdentity: APACCP44OJS
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Corda and the Corda logo are trademarks of R3CEV LLC and its affiliates. All rights reserved.
2+
3+
For R3CEV LLC's trademark and logo usage information, please consult our Trademark Usage Policy at
4+
https://www.r3.com/trademark-policy/.
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
buildscript {//properties that you need to build the project
2+
Properties constants = new Properties()
3+
file("$projectDir/../constants.properties").withInputStream { constants.load(it) }
4+
5+
ext {
6+
corda_release_group = constants.getProperty("cordaReleaseGroup")
7+
corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup")
8+
corda_release_version = constants.getProperty("cordaVersion")
9+
corda_core_release_version = constants.getProperty("cordaCoreVersion")
10+
corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion")
11+
kotlin_version = constants.getProperty("kotlinVersion")
12+
junit_version = constants.getProperty("junitVersion")
13+
quasar_version = constants.getProperty("quasarVersion")
14+
log4j_version = constants.getProperty("log4jVersion")
15+
slf4j_version = constants.getProperty("slf4jVersion")
16+
corda_platform_version = constants.getProperty("platformVersion").toInteger()
17+
//springboot
18+
spring_boot_version = '2.0.2.RELEASE'
19+
spring_boot_gradle_plugin_version = '2.0.2.RELEASE'
20+
//Membership Attestation
21+
corda_bn_extension_version=constants.getProperty("corda_bn_extension_version")
22+
}
23+
24+
repositories {
25+
mavenLocal()
26+
mavenCentral()
27+
jcenter()
28+
maven { url 'https://software.r3.com/artifactory/corda-releases' }
29+
}
30+
31+
dependencies {
32+
classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version"
33+
classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version"
34+
classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version"
35+
classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version"
36+
}
37+
}
38+
39+
allprojects {//Properties that you need to compile your project (The application)
40+
apply from: "${rootProject.projectDir}/repositories.gradle"
41+
apply plugin: 'java'
42+
43+
repositories {
44+
mavenLocal()
45+
jcenter()
46+
mavenCentral()
47+
maven { url 'https://software.r3.com/artifactory/corda' }
48+
maven { url 'https://jitpack.io' }
49+
}
50+
51+
tasks.withType(JavaCompile) {
52+
options.compilerArgs << "-parameters" // Required by Corda's serialisation framework.
53+
}
54+
55+
jar {
56+
// This makes the JAR's SHA-256 hash repeatable.
57+
preserveFileTimestamps = false
58+
reproducibleFileOrder = true
59+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
60+
}
61+
}
62+
63+
apply plugin: 'net.corda.plugins.cordapp'
64+
apply plugin: 'net.corda.plugins.cordformation'
65+
apply plugin: 'net.corda.plugins.quasar-utils'
66+
67+
sourceSets {
68+
main {
69+
resources {
70+
srcDir rootProject.file("config/dev")
71+
}
72+
}
73+
}
74+
//Module dependencis
75+
dependencies {
76+
// Corda dependencies.
77+
cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version"
78+
cordaCompile "$corda_release_group:corda-node-api:$corda_release_version"
79+
cordaRuntime "$corda_release_group:corda:$corda_release_version"
80+
81+
// CorDapp dependencies.
82+
cordapp project(":workflows")
83+
cordapp project(":contracts")
84+
cordapp("net.corda.bn:business-networks-contracts:$corda_bn_extension_version")
85+
cordapp("net.corda.bn:business-networks-workflows:$corda_bn_extension_version")
86+
87+
cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}"
88+
cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}"
89+
cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version"
90+
}
91+
92+
93+
//Task to deploy the nodes in order to bootstrap a network
94+
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
95+
96+
/* This property will load the CorDapps to each of the node by default, including the Notary. You can find them
97+
* in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand
98+
* the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load
99+
* the Corda network bootstrapper.
100+
*/
101+
nodeDefaults {
102+
projectCordapp {
103+
deploy = false
104+
}
105+
cordapp project(':contracts')
106+
cordapp project(':workflows')
107+
cordapp("net.corda.bn:business-networks-contracts:$corda_bn_extension_version")
108+
cordapp("net.corda.bn:business-networks-workflows:$corda_bn_extension_version")
109+
runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid
110+
//problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change
111+
//it to false for quicker project compiling time.
112+
}
113+
node {
114+
name "O=Notary,L=London,C=GB"
115+
notary = [validating : false]
116+
p2pPort 10002
117+
rpcSettings {
118+
address("localhost:10003")
119+
adminAddress("localhost:10043")
120+
}
121+
}
122+
node {
123+
name "O=NetworkOperator,L=London,C=GB"
124+
p2pPort 10005
125+
rpcSettings {
126+
address("localhost:10006")
127+
adminAddress("localhost:10046")
128+
}
129+
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
130+
}
131+
node {
132+
name "O=Insurance,L=New York,C=US"
133+
p2pPort 10008
134+
rpcSettings {
135+
address("localhost:10009")
136+
adminAddress("localhost:10049")
137+
}
138+
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
139+
}
140+
node {
141+
name "O=CarePro,L=New York,C=US"
142+
p2pPort 10011
143+
rpcSettings {
144+
address("localhost:10012")
145+
adminAddress("localhost:10052")
146+
}
147+
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
148+
}
149+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Configuration status="info">
3+
4+
<Properties>
5+
<Property name="log-path">logs</Property>
6+
<Property name="log-name">node-${hostName}</Property>
7+
<Property name="archive">${log-path}/archive</Property>
8+
</Properties>
9+
10+
<ThresholdFilter level="trace"/>
11+
12+
<Appenders>
13+
<Console name="Console-Appender" target="SYSTEM_OUT">
14+
<PatternLayout>
15+
<pattern>
16+
%highlight{%level{length=1} %d{HH:mm:ss} %T %c{1}.%M - %msg%n}{INFO=white,WARN=red,FATAL=bright red blink}
17+
</pattern>>
18+
</PatternLayout>
19+
</Console>
20+
21+
<!-- Will generate up to 10 log files for a given day. During every rollover it will delete
22+
those that are older than 60 days, but keep the most recent 10 GB -->
23+
<RollingFile name="RollingFile-Appender"
24+
fileName="${log-path}/${log-name}.log"
25+
filePattern="${archive}/${log-name}.%d{yyyy-MM-dd}-%i.log.gz">
26+
27+
<PatternLayout pattern="[%-5level] %d{ISO8601}{GMT+0} [%t] %c{1} - %msg%n"/>
28+
29+
<Policies>
30+
<TimeBasedTriggeringPolicy/>
31+
<SizeBasedTriggeringPolicy size="10MB"/>
32+
</Policies>
33+
34+
<DefaultRolloverStrategy min="1" max="10">
35+
<Delete basePath="${archive}" maxDepth="1">
36+
<IfFileName glob="${log-name}*.log.gz"/>
37+
<IfLastModified age="60d">
38+
<IfAny>
39+
<IfAccumulatedFileSize exceeds="10 GB"/>
40+
</IfAny>
41+
</IfLastModified>
42+
</Delete>
43+
</DefaultRolloverStrategy>
44+
45+
</RollingFile>
46+
</Appenders>
47+
48+
<Loggers>
49+
<Root level="info">
50+
<AppenderRef ref="Console-Appender"/>
51+
<AppenderRef ref="RollingFile-Appender"/>
52+
</Root>
53+
<Logger name="net.corda" level="info" additivity="false">
54+
<AppenderRef ref="Console-Appender"/>
55+
<AppenderRef ref="RollingFile-Appender"/>
56+
</Logger>
57+
</Loggers>
58+
59+
</Configuration>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Configuration status="info">
3+
<Appenders>
4+
<Console name="Console-Appender" target="SYSTEM_OUT">
5+
<PatternLayout>
6+
<pattern>
7+
[%-5level] %d{HH:mm:ss.SSS} [%t] %c{1}.%M - %msg%n
8+
</pattern>>
9+
</PatternLayout>
10+
</Console>
11+
</Appenders>
12+
<Loggers>
13+
<Root level="info">
14+
<AppenderRef ref="Console-Appender"/>
15+
</Root>
16+
<Logger name="net.corda" level="info" additivity="false">
17+
<AppenderRef ref="Console-Appender"/>
18+
</Logger>
19+
</Loggers>
20+
</Configuration>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apply plugin: 'net.corda.plugins.cordapp'
2+
apply plugin: 'net.corda.plugins.cordformation'
3+
4+
cordapp {
5+
targetPlatformVersion corda_platform_version
6+
minimumPlatformVersion corda_platform_version
7+
contract {
8+
name "Membership Attestation Contracts"
9+
vendor "Corda Open Source"
10+
licence "Apache License, Version 2.0"
11+
versionId 1
12+
}
13+
}
14+
15+
sourceSets {
16+
main{
17+
java {
18+
srcDir 'src/main/java'
19+
java.outputDir = file('bin/main')
20+
}
21+
}
22+
test{
23+
java{
24+
srcDir 'src/test/java'
25+
java.outputDir = file('bin/test')
26+
}
27+
}
28+
}
29+
30+
dependencies {
31+
// Corda dependencies.
32+
cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version"
33+
cordaRuntime "$corda_release_group:corda:$corda_release_version"
34+
testCompile "$corda_release_group:corda-node-driver:$corda_release_version"
35+
cordapp("net.corda.bn:business-networks-contracts:$corda_bn_extension_version")
36+
}

0 commit comments

Comments
 (0)