mirror of
https://github.com/corda/corda.git
synced 2025-06-01 23:20:54 +00:00
[NOTICK] Expose type in CryptoService (#5416)
This commit is contained in:
parent
07b96aea18
commit
3023e3ab87
@ -59,6 +59,11 @@ interface CryptoService : SignOnlyCryptoService {
|
|||||||
* Returns the [PublicKey] of the generated [KeyPair].
|
* Returns the [PublicKey] of the generated [KeyPair].
|
||||||
*/
|
*/
|
||||||
fun generateKeyPair(alias: String, scheme: SignatureScheme): PublicKey
|
fun generateKeyPair(alias: String, scheme: SignatureScheme): PublicKey
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the type of the service.
|
||||||
|
*/
|
||||||
|
fun getType(): SupportedCryptoServices
|
||||||
}
|
}
|
||||||
|
|
||||||
open class CryptoServiceException(message: String?, cause: Throwable? = null) : Exception(message, cause)
|
open class CryptoServiceException(message: String?, cause: Throwable? = null) : Exception(message, cause)
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package net.corda.nodeapi.internal.cryptoservice
|
package net.corda.nodeapi.internal.cryptoservice
|
||||||
|
|
||||||
enum class SupportedCryptoServices {
|
enum class SupportedCryptoServices(val userFriendlyName: String) {
|
||||||
/** Identifier for [BCCryptoService]. */
|
/** Identifier for [BCCryptoService]. */
|
||||||
BC_SIMPLE
|
BC_SIMPLE("file-based keystore")
|
||||||
// UTIMACO, // Utimaco HSM.
|
|
||||||
// GEMALTO_LUNA, // Gemalto Luna HSM.
|
|
||||||
// AZURE_KV // Azure key Vault.
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import net.corda.nodeapi.internal.crypto.ContentSignerBuilder
|
|||||||
import net.corda.nodeapi.internal.crypto.X509Utilities
|
import net.corda.nodeapi.internal.crypto.X509Utilities
|
||||||
import net.corda.nodeapi.internal.cryptoservice.CryptoService
|
import net.corda.nodeapi.internal.cryptoservice.CryptoService
|
||||||
import net.corda.nodeapi.internal.cryptoservice.CryptoServiceException
|
import net.corda.nodeapi.internal.cryptoservice.CryptoServiceException
|
||||||
|
import net.corda.nodeapi.internal.cryptoservice.SupportedCryptoServices
|
||||||
import org.bouncycastle.operator.ContentSigner
|
import org.bouncycastle.operator.ContentSigner
|
||||||
import java.security.KeyPair
|
import java.security.KeyPair
|
||||||
import java.security.KeyStore
|
import java.security.KeyStore
|
||||||
@ -25,6 +26,8 @@ import javax.security.auth.x500.X500Principal
|
|||||||
*/
|
*/
|
||||||
class BCCryptoService(private val legalName: X500Principal, private val certificateStoreSupplier: CertificateStoreSupplier) : CryptoService {
|
class BCCryptoService(private val legalName: X500Principal, private val certificateStoreSupplier: CertificateStoreSupplier) : CryptoService {
|
||||||
|
|
||||||
|
override fun getType(): SupportedCryptoServices = SupportedCryptoServices.BC_SIMPLE
|
||||||
|
|
||||||
// TODO check if keyStore exists.
|
// TODO check if keyStore exists.
|
||||||
// TODO make it private when E2ETestKeyManagementService does not require direct access to the private key.
|
// TODO make it private when E2ETestKeyManagementService does not require direct access to the private key.
|
||||||
var certificateStore: CertificateStore = certificateStoreSupplier.get(true)
|
var certificateStore: CertificateStore = certificateStoreSupplier.get(true)
|
||||||
|
@ -8,6 +8,7 @@ import net.corda.core.crypto.sha256
|
|||||||
import net.corda.nodeapi.internal.crypto.ContentSignerBuilder
|
import net.corda.nodeapi.internal.crypto.ContentSignerBuilder
|
||||||
import net.corda.nodeapi.internal.cryptoservice.CryptoService
|
import net.corda.nodeapi.internal.cryptoservice.CryptoService
|
||||||
import net.corda.nodeapi.internal.cryptoservice.CryptoServiceException
|
import net.corda.nodeapi.internal.cryptoservice.CryptoServiceException
|
||||||
|
import net.corda.nodeapi.internal.cryptoservice.SupportedCryptoServices
|
||||||
import org.bouncycastle.operator.ContentSigner
|
import org.bouncycastle.operator.ContentSigner
|
||||||
import java.security.KeyPair
|
import java.security.KeyPair
|
||||||
import java.security.PublicKey
|
import java.security.PublicKey
|
||||||
@ -15,6 +16,8 @@ import java.security.Signature
|
|||||||
|
|
||||||
class MockCryptoService(initialKeyPairs: Map<String, KeyPair>) : CryptoService {
|
class MockCryptoService(initialKeyPairs: Map<String, KeyPair>) : CryptoService {
|
||||||
|
|
||||||
|
override fun getType(): SupportedCryptoServices = SupportedCryptoServices.BC_SIMPLE
|
||||||
|
|
||||||
private val aliasToKey: MutableMap<String, KeyPair> = mutableMapOf()
|
private val aliasToKey: MutableMap<String, KeyPair> = mutableMapOf()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user