Fix BankOfCorda demo after services removal (#1584)

* Fix BankOfCorda demo after services removal

* Add CashConfigDataFlow permission to BankOfCorda

* Address comments

* Add permission
This commit is contained in:
Katarzyna Streich 2017-09-21 14:50:20 +01:00 committed by josecoll
parent b0e9183850
commit d72d887224
6 changed files with 14 additions and 14 deletions

View File

@ -192,11 +192,6 @@ To run from the command line in Windows:
.. note:: To verify that the Bank of Corda node is alive and running, navigate to the following URL:
http://localhost:10007/api/bank/date
.. note:: The Bank of Corda node explicitly advertises with a node service type as follows:
``advertisedServices = ["corda.issuer.USD"]``
This allows for 3rd party applications to perform actions based on Node Type.
For example, the Explorer tool only allows nodes of this type to issue and exit cash.
In the window you run the command you should see (in case of Web, RPC is simmilar):
- Requesting Cash via Web ...

View File

@ -71,7 +71,8 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
'permissions': ["StartFlow.net.corda.finance.flows.CashPaymentFlow",
"StartFlow.net.corda.finance.flows.CashConfigDataFlow",
"StartFlow.net.corda.finance.flows.CashExitFlow",
"StartFlow.net.corda.finance.flows.CashIssueAndPaymentFlow"]]
"StartFlow.net.corda.finance.flows.CashIssueAndPaymentFlow",
"StartFlow.net.corda.finance.flows.CashConfigDataFlow"]]
]
}
node {
@ -84,7 +85,8 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
rpcUsers = [
['username' : "bigCorpUser",
'password' : "test",
'permissions': ["StartFlow.net.corda.flows.CashPaymentFlow"]]
'permissions': ["StartFlow.net.corda.finance.flows.CashPaymentFlow",
"StartFlow.net.corda.finance.flows.CashConfigDataFlow"]]
]
}
}

View File

@ -7,6 +7,7 @@ import net.corda.nodeapi.ServiceInfo
import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.testing.BOC
import net.corda.testing.driver.driver
import net.corda.testing.notary
import org.junit.Test
import kotlin.test.assertTrue
@ -18,7 +19,8 @@ class BankOfCordaHttpAPITest {
val nodeBankOfCordaFuture = startNode(providedName = BOC.name, advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type)))
val (nodeBankOfCorda) = listOf(nodeBankOfCordaFuture, bigCorpNodeFuture).map { it.getOrThrow() }
val nodeBankOfCordaApiAddr = startWebserver(nodeBankOfCorda).getOrThrow().listenAddress
assertTrue(BankOfCordaClientApi(nodeBankOfCordaApiAddr).requestWebIssue(IssueRequestParams(1000, "USD", BIGCORP_LEGAL_NAME, "1", BOC.name, BOC.name)))
val notaryName = notary().node.nodeInfo.legalIdentities[1].name
assertTrue(BankOfCordaClientApi(nodeBankOfCordaApiAddr).requestWebIssue(IssueRequestParams(1000, "USD", BIGCORP_LEGAL_NAME, "1", BOC.name, notaryName)))
}, isDebug = true)
}
}

View File

@ -54,7 +54,8 @@ private class BankOfCordaDriver {
// The ISSUE_CASH will request some Cash from the ISSUER on behalf of Big Corporation node
val role = options.valueOf(roleArg)!!
val requestParams = IssueRequestParams(options.valueOf(quantity), options.valueOf(currency), BIGCORP_LEGAL_NAME, "1", BOC.name, DUMMY_NOTARY.name)
val requestParams = IssueRequestParams(options.valueOf(quantity), options.valueOf(currency), BIGCORP_LEGAL_NAME,
"1", BOC.name, DUMMY_NOTARY.name.copy(commonName = "corda.notary.validating"))
try {
when (role) {

View File

@ -40,9 +40,9 @@ class BankOfCordaClientApi(val hostAndPort: NetworkHostAndPort) {
// Resolve parties via RPC
val issueToParty = rpc.partyFromX500Name(params.issueToPartyName)
?: throw Exception("Unable to locate ${params.issueToPartyName} in Network Map Service")
val notaryLegalIdentity = rpc.partyFromX500Name(params.notaryName)
?: throw IllegalStateException("Unable to locate ${params.notaryName} in Network Map Service")
?: throw IllegalStateException("Unable to locate ${params.issueToPartyName} in Network Map Service")
val notaryLegalIdentity = rpc.notaryIdentities().firstOrNull { it.name == params.notaryName } ?:
throw IllegalStateException("Couldn't locate notary ${params.notaryName} in NetworkMapCache")
val amount = Amount(params.amount, Currency.getInstance(params.currency))
val anonymous = true

View File

@ -44,8 +44,8 @@ class BankOfCordaWebApi(val rpc: CordaRPCOps) {
val issueToParty = rpc.partyFromX500Name(params.issueToPartyName)
?: return Response.status(Response.Status.FORBIDDEN).entity("Unable to locate ${params.issueToPartyName} in identity service").build()
rpc.partyFromX500Name(params.issuerBankName) ?: return Response.status(Response.Status.FORBIDDEN).entity("Unable to locate ${params.issuerBankName} in identity service").build()
val notaryParty = rpc.partyFromX500Name(params.notaryName)
?: return Response.status(Response.Status.FORBIDDEN).entity("Unable to locate ${params.notaryName} in identity service").build()
val notaryParty = rpc.notaryIdentities().firstOrNull { it.name == params.notaryName }
?: return Response.status(Response.Status.FORBIDDEN).entity("Unable to locate notary ${params.notaryName} in network map").build()
val amount = Amount(params.amount, Currency.getInstance(params.currency))
val anonymous = true