Skip to content

Commit 87ee66f

Browse files
ENT-14766- Sample to support the key rotation.
1 parent e7853c6 commit 87ee66f

3 files changed

Lines changed: 35 additions & 5 deletions

File tree

Advanced/negotiation-cordapp/repositories.gradle

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,28 @@ repositories {
44
maven { url 'https://jitpack.io' }
55
maven { url 'https://download.corda.net/maven/corda-dependencies' }
66
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
7+
8+
// Repository where the user-reported artifact resides
9+
maven {
10+
url "https://software.r3.com/artifactory/r3-corda-releases"
11+
credentials {
12+
username = findProperty('cordaArtifactoryUsername') ?: System.getenv('CORDA_ARTIFACTORY_USERNAME')
13+
password = findProperty('cordaArtifactoryPassword') ?: System.getenv('CORDA_ARTIFACTORY_PASSWORD')
14+
}
15+
content {
16+
includeGroupByRegex 'com\\.r3(\\..*)?'
17+
}
18+
}
19+
20+
// Repository for corda-dev artifacts (contains net.corda SNAPSHOTs like corda-shell 4.14-SNAPSHOT)
21+
maven {
22+
url "https://software.r3.com/artifactory/corda-dev"
23+
credentials {
24+
username = findProperty('cordaArtifactoryUsername') ?: System.getenv('CORDA_ARTIFACTORY_USERNAME')
25+
password = findProperty('cordaArtifactoryPassword') ?: System.getenv('CORDA_ARTIFACTORY_PASSWORD')
26+
}
27+
content {
28+
includeGroupByRegex 'net\\.corda(\\..*)?'
29+
}
30+
}
731
}

Advanced/negotiation-cordapp/workflows/src/main/java/net/corda/samples/negotiation/flows/ModificationFlow.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import co.paralleluniverse.fibers.Suspendable;
44
import com.google.common.collect.ImmutableList;
5+
import net.corda.core.crypto.keyrotation.crossprovider.PartyIdentityResolved;
6+
import net.corda.core.crypto.keyrotation.crossprovider.PartyIdentityResolver;
57
import net.corda.samples.negotiation.contracts.ProposalAndTradeContract;
68
import net.corda.samples.negotiation.states.ProposalState;
79
import net.corda.core.contracts.Command;
@@ -42,10 +44,12 @@ public SignedTransaction call() throws FlowException {
4244
QueryCriteria.LinearStateQueryCriteria inputCriteria = new QueryCriteria.LinearStateQueryCriteria(null, ImmutableList.of(proposalId), Vault.StateStatus.UNCONSUMED, null);
4345
StateAndRef inputStateAndRef = getServiceHub().getVaultService().queryBy(ProposalState.class, inputCriteria).getStates().get(0);
4446
ProposalState input = (ProposalState) inputStateAndRef.getState().getData();
47+
Party proposerParty = PartyIdentityResolver.Companion.resolveToCurrentParty(input.getProposer(), getServiceHub().getIdentityService());
4548

4649
//Creating the output
47-
Party counterparty = (getOurIdentity().equals(input.getProposer()))? input.getProposee() : input.getProposer();
48-
ProposalState output = new ProposalState(newAmount, input.getBuyer(),input.getSeller(), getOurIdentity(), counterparty, input.getLinearId());
50+
Party myPartyFromInput = (getOurIdentity().equals(proposerParty)) ? input.getProposer() : input.getProposee();
51+
Party counterpartyFromInput = (myPartyFromInput.equals(input.getProposer()))? input.getProposee() : input.getProposer();
52+
ProposalState output = new ProposalState(newAmount, input.getBuyer(),input.getSeller(), myPartyFromInput, counterpartyFromInput, input.getLinearId());
4953

5054
//Creating the command
5155
List<PublicKey> requiredSigners = ImmutableList.of(input.getProposee().getOwningKey(), input.getProposer().getOwningKey());
@@ -62,7 +66,8 @@ public SignedTransaction call() throws FlowException {
6266
SignedTransaction partStx = getServiceHub().signInitialTransaction(txBuilder);
6367

6468
//Gathering the counterparty's signatures
65-
FlowSession counterpartySession = initiateFlow(counterparty);
69+
Party counterParty = PartyIdentityResolver.Companion.resolveToCurrentParty(counterpartyFromInput, getServiceHub().getIdentityService());
70+
FlowSession counterpartySession = initiateFlow(counterParty);
6671
SignedTransaction fullyStx = subFlow(new CollectSignaturesFlow(partStx, ImmutableList.of(counterpartySession)));
6772

6873
//Finalising the transaction
@@ -88,7 +93,8 @@ public SignedTransaction call() throws FlowException {
8893
protected void checkTransaction(@NotNull SignedTransaction stx) throws FlowException {
8994
try {
9095
LedgerTransaction ledgerTx = stx.toLedgerTransaction(getServiceHub(), false);
91-
Party proposee = ledgerTx.inputsOfType(ProposalState.class).get(0).getProposee();
96+
ProposalState input = ledgerTx.inputsOfType(ProposalState.class).get(0);
97+
Party proposee = PartyIdentityResolver.Companion.resolveToCurrentParty(input.getProposee(), getServiceHub().getIdentityService());
9298
if(!proposee.equals(counterpartySession.getCounterparty())){
9399
throw new FlowException("Only the proposee can modify a proposal.");
94100
}

Advanced/negotiation-cordapp/workflows/src/main/java/net/corda/samples/negotiation/flows/ProposalFlow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public UniqueIdentifier call() throws FlowException {
5353

5454
// Obtain a reference to a notary we wish to use.
5555
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
56-
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
56+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=TestNotaryService, L=London, C=GB"));
5757

5858
TransactionBuilder txBuilder = new TransactionBuilder(notary)
5959
.addOutputState(output, ProposalAndTradeContract.ID)

0 commit comments

Comments
 (0)