Simplify InputStreamSerializer, make NODE_USER role explicit

This commit is contained in:
Andras Slemmer
2016-12-06 14:02:28 +00:00
parent a601f0abf5
commit 9117ec9860
4 changed files with 21 additions and 44 deletions

View File

@ -5,6 +5,7 @@ import net.corda.core.contracts.StateAndRef
import net.corda.core.crypto.CompositeKey
import net.corda.core.crypto.SecureHash
import net.corda.core.flows.FlowLogic
import net.corda.core.flows.StateMachineRunId
import net.corda.core.messaging.CordaRPCOps
import net.corda.core.messaging.FlowHandle
import net.corda.core.messaging.StateMachineInfo
@ -64,8 +65,8 @@ class CordaRPCOpsImpl(
override fun stateMachinesAndUpdates(): Pair<List<StateMachineInfo>, Observable<StateMachineUpdate>> {
val (allStateMachines, changes) = smm.track()
return Pair(
allStateMachines.map { stateMachineInfoFromFlowStateMachineImpl(it) },
changes.map { stateMachineUpdateFromStateMachineChange(it) }
allStateMachines.map { stateMachineInfoFromFlowLogic(it.id, it.logic) },
changes.map { stateMachineUpdateFromStateMachineChange(it) }
)
}
@ -110,27 +111,14 @@ class CordaRPCOpsImpl(
override fun partyFromName(name: String) = services.identityService.partyFromName(name)
companion object {
fun stateMachineInfoFromFlowStateMachineImpl(stateMachine: FlowStateMachineImpl<*>): StateMachineInfo {
return StateMachineInfo(
id = stateMachine.id,
flowLogicClassName = stateMachine.logic.javaClass.name,
progressTrackerStepAndUpdates = stateMachine.logic.track()
)
private fun stateMachineInfoFromFlowLogic(id: StateMachineRunId, flowLogic: FlowLogic<*>): StateMachineInfo {
return StateMachineInfo(id, flowLogic.javaClass.name, flowLogic.track())
}
fun stateMachineUpdateFromStateMachineChange(change: StateMachineManager.Change): StateMachineUpdate {
private fun stateMachineUpdateFromStateMachineChange(change: StateMachineManager.Change): StateMachineUpdate {
return when (change.addOrRemove) {
AddOrRemove.ADD -> {
val stateMachineInfo = StateMachineInfo(
id = change.id,
flowLogicClassName = change.logic.javaClass.name,
progressTrackerStepAndUpdates = change.logic.track()
)
StateMachineUpdate.Added(stateMachineInfo)
}
AddOrRemove.REMOVE -> {
StateMachineUpdate.Removed(change.id)
}
AddOrRemove.ADD -> StateMachineUpdate.Added(stateMachineInfoFromFlowLogic(change.id, change.logic))
AddOrRemove.REMOVE -> StateMachineUpdate.Removed(change.id)
}
}
}

View File

@ -184,9 +184,9 @@ class ArtemisMessagingServer(override val config: NodeConfiguration,
securityRoles["$INTERNAL_PREFIX#"] = setOf(nodeInternalRole) // Do not add any other roles here as it's only for the node
securityRoles[P2P_QUEUE] = setOf(nodeInternalRole, restrictedRole(PEER_ROLE, send = true))
securityRoles[RPC_REQUESTS_QUEUE] = setOf(nodeInternalRole, restrictedRole(RPC_ROLE, send = true))
// TODO remove NODE_USER once webserver doesn't need it
val possibleClientUserNames = userService.users.map { it.username } + listOf(NODE_USER)
for (username in possibleClientUserNames) {
// TODO remove the NODE_USER role once the webserver doesn't need it
securityRoles["$CLIENTS_PREFIX$NODE_USER.rpc.*"] = setOf(nodeInternalRole)
for ((username) in userService.users) {
securityRoles["$CLIENTS_PREFIX$username.rpc.*"] = setOf(
nodeInternalRole,
restrictedRole("$CLIENTS_PREFIX$username", consume = true, createNonDurableQueue = true, deleteNonDurableQueue = true))

View File

@ -161,7 +161,7 @@ abstract class RPCDispatcher(val ops: RPCOps, val userService: RPCUserService, v
}
// TODO remove this User once webserver doesn't need it
val nodeUser = User(NODE_USER, NODE_USER, setOf())
private val nodeUser = User(NODE_USER, NODE_USER, setOf())
@VisibleForTesting
protected open fun getUser(message: ClientMessage): User {
val validatedUser = message.requiredString(Message.HDR_VALIDATED_USER.toString())