Skip to content

Commit 76885d7

Browse files
Preparation for major version 4.0.0 release.
1 parent c4538b2 commit 76885d7

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/Extensions.CordaRPCOps.kt

+29
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,38 @@ import net.corda.core.identity.CordaX500Name
2525
import net.corda.core.messaging.CordaRPCOps
2626
import net.corda.core.utilities.parsePublicKeyBase58
2727

28+
/**
29+
* Determines whether the current Corda node owns the specified party identity.
30+
*
31+
* @param party The identity to determine is owned by the current Corda node.
32+
* @return Returns true if the current Corda node owns the specified party identity; otherwise, false.
33+
*/
2834
fun CordaRPCOps.ownsLegalIdentity(party: AbstractParty): Boolean {
2935
val partyToResolve = if (party is AccountParty) party.owner else party
3036
val wellKnownParty = wellKnownPartyFromAnonymous(partyToResolve)
3137

3238
return wellKnownParty in nodeInfo().legalIdentities
3339
}
3440

41+
/**
42+
* Resolves the specified value to an [AbstractParty].
43+
*
44+
* @param value The value to resolve to an [AbstractParty].
45+
* @param type The type of account to resolve, if the value represents an [AccountParty].
46+
* @return Returns an [AbstractParty] resolved from the specified value.
47+
* @throws IllegalArgumentException if the specified value cannot be resolved to an [AbstractParty].
48+
*/
3549
fun CordaRPCOps.resolveParty(value: String, type: Class<out Account> = Account::class.java): AbstractParty {
3650
return if (AccountParty.DELIMITER in value) resolveAccountParty(value, type) else resolveAbstractParty(value)
3751
}
3852

53+
/**
54+
* Resolves the specified value to an [AbstractParty].
55+
*
56+
* @param value The value to resolve to an [AbstractParty].
57+
* @return Returns an [AbstractParty] resolved from the specified value.
58+
* @throws IllegalArgumentException if the specified value cannot be resolved to an [AbstractParty].
59+
*/
3960
fun CordaRPCOps.resolveAbstractParty(value: String): AbstractParty {
4061
return try {
4162
val parsedCordaX500Name = CordaX500Name.parse(value)
@@ -46,6 +67,14 @@ fun CordaRPCOps.resolveAbstractParty(value: String): AbstractParty {
4667
} ?: throw IllegalArgumentException("Failed to resolve '$value' to party.")
4768
}
4869

70+
/**
71+
* Resolves the specified value to an [AccountParty].
72+
*
73+
* @param value The value to resolve to an [AccountParty].
74+
* @param type The type of account to resolve.
75+
* @return Returns an [AccountParty] resolved from the specified value.
76+
* @throws IllegalArgumentException if the specified value cannot be resolved to an [AccountParty].
77+
*/
4978
fun CordaRPCOps.resolveAccountParty(value: String, type: Class<out Account> = Account::class.java): AccountParty {
5079
val identityComponent = value.substringAfter(AccountParty.DELIMITER)
5180
val linearIdComponent = value.substringBefore(AccountParty.DELIMITER)

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/Extensions.FlowLogic.Sessions.kt

+25-1
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,54 @@ import io.onixlabs.corda.core.workflow.checkSufficientSessionsForContractStates
2121
import io.onixlabs.corda.core.workflow.checkSufficientSessionsForTransactionBuilder
2222
import io.onixlabs.corda.identityframework.contract.accounts.AccountParty
2323
import net.corda.core.contracts.ContractState
24+
import net.corda.core.flows.FlowException
2425
import net.corda.core.flows.FlowLogic
2526
import net.corda.core.flows.FlowSession
2627
import net.corda.core.identity.AbstractParty
2728
import net.corda.core.transactions.TransactionBuilder
2829

30+
/**
31+
* Checks that sufficient flow sessions have been provided for the account identities of the specified states.
32+
*
33+
* @param sessions The flow sessions that have been provided to the flow.
34+
* @param states The states that will be used as input or output states in a transaction.
35+
* @throws FlowException if a required counter-party session is missing for a state participant.
36+
*/
2937
@Suspendable
3038
fun FlowLogic<*>.checkSufficientSessionsForAccounts(
3139
sessions: Iterable<FlowSession>,
3240
states: Iterable<ContractState>
3341
) = checkSufficientSessionsForContractStates(sessions, states) { it.getAccountOwningPartyOrThis() }
3442

43+
/**
44+
* Checks that sufficient flow sessions have been provided for the account identities of the specified states.
45+
*
46+
* @param sessions The flow sessions that have been provided to the flow.
47+
* @param states The states that will be used as input or output states in a transaction.
48+
* @throws FlowException if a required counter-party session is missing for a state participant.
49+
*/
3550
@Suspendable
3651
fun FlowLogic<*>.checkSufficientSessionsForAccounts(
3752
sessions: Iterable<FlowSession>,
3853
vararg states: ContractState
3954
) = checkSufficientSessionsForContractStates(sessions, *states) { it.getAccountOwningPartyOrThis() }
4055

41-
56+
/**
57+
* Checks that sufficient flow sessions have been provided for the specified transaction.
58+
*
59+
* @param sessions The flow sessions that have been provided to the flow.
60+
* @param transaction The transaction for which to check that sufficient flow sessions exist.
61+
* @throws FlowException if a required counter-party session is missing for a state participant.
62+
*/
4263
@Suspendable
4364
fun FlowLogic<*>.checkSufficientSessionsForTransactionBuilder(
4465
sessions: Iterable<FlowSession>,
4566
transaction: TransactionBuilder
4667
) = checkSufficientSessionsForTransactionBuilder(sessions, transaction) { it.getAccountOwningPartyOrThis() }
4768

69+
/**
70+
* Gets the underlying account owner identity, or returns the current identity if it is not an [AccountParty].
71+
*/
4872
private fun AbstractParty.getAccountOwningPartyOrThis(): AbstractParty {
4973
return if (this is AccountParty) owner else this
5074
}

onixlabs-corda-identity-framework-workflow/src/main/kotlin/io/onixlabs/corda/identityframework/workflow/Extensions.ServiceHub.kt

+29
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,38 @@ import net.corda.core.identity.CordaX500Name
2525
import net.corda.core.node.ServiceHub
2626
import net.corda.core.utilities.parsePublicKeyBase58
2727

28+
/**
29+
* Determines whether the current Corda node owns the specified party identity.
30+
*
31+
* @param party The identity to determine is owned by the current Corda node.
32+
* @return Returns true if the current Corda node owns the specified party identity; otherwise, false.
33+
*/
2834
fun ServiceHub.ownsLegalIdentity(party: AbstractParty): Boolean {
2935
val partyToResolve = if (party is AccountParty) party.owner else party
3036
val wellKnownParty = identityService.wellKnownPartyFromAnonymous(partyToResolve)
3137

3238
return wellKnownParty in myInfo.legalIdentities
3339
}
3440

41+
/**
42+
* Resolves the specified value to an [AbstractParty].
43+
*
44+
* @param value The value to resolve to an [AbstractParty].
45+
* @param type The type of account to resolve, if the value represents an [AccountParty].
46+
* @return Returns an [AbstractParty] resolved from the specified value.
47+
* @throws IllegalArgumentException if the specified value cannot be resolved to an [AbstractParty].
48+
*/
3549
fun ServiceHub.resolveParty(value: String, type: Class<out Account> = Account::class.java): AbstractParty {
3650
return if (AccountParty.DELIMITER in value) resolveAccountParty(value, type) else resolveAbstractParty(value)
3751
}
3852

53+
/**
54+
* Resolves the specified value to an [AbstractParty].
55+
*
56+
* @param value The value to resolve to an [AbstractParty].
57+
* @return Returns an [AbstractParty] resolved from the specified value.
58+
* @throws IllegalArgumentException if the specified value cannot be resolved to an [AbstractParty].
59+
*/
3960
fun ServiceHub.resolveAbstractParty(value: String): AbstractParty {
4061
return try {
4162
val parsedCordaX500Name = CordaX500Name.parse(value)
@@ -46,6 +67,14 @@ fun ServiceHub.resolveAbstractParty(value: String): AbstractParty {
4667
} ?: throw IllegalArgumentException("Failed to resolve '$value' to party.")
4768
}
4869

70+
/**
71+
* Resolves the specified value to an [AccountParty].
72+
*
73+
* @param value The value to resolve to an [AccountParty].
74+
* @param type The type of account to resolve.
75+
* @return Returns an [AccountParty] resolved from the specified value.
76+
* @throws IllegalArgumentException if the specified value cannot be resolved to an [AccountParty].
77+
*/
4978
fun ServiceHub.resolveAccountParty(value: String, type: Class<out Account> = Account::class.java): AccountParty {
5079
val identityComponent = value.substringAfter(AccountParty.DELIMITER)
5180
val linearIdComponent = value.substringBefore(AccountParty.DELIMITER)

0 commit comments

Comments
 (0)