@ApiAudience.Private @ApiStability.Unstable public class KeyStoreTemplate extends java.lang.Object implements KeyStoreOperation, ChannelInjectable, ContextProviderInjectable
Modifier and Type | Field and Description |
---|---|
protected ContextProvider |
contextProvider |
protected ExceptionConverter<RpcException> |
exceptionConverter |
protected KeyStoreBaseTemplate |
keyStoreBaseTemplate |
Constructor and Description |
---|
KeyStoreTemplate() |
Modifier and Type | Method and Description |
---|---|
AccountAddress |
create(java.lang.String password)
Create an account with a password.
|
EncryptedPrivateKey |
exportKey(Authentication authentication)
Export an encrypted private key of account which is stored in a server key store.
|
AccountAddress |
importKey(EncryptedPrivateKey encryptedKey,
java.lang.String oldPassword,
java.lang.String newPassword)
Import an encrypted private key to a server key store.
|
java.util.List<AccountAddress> |
list()
Get account list on a key store.
|
boolean |
lock(Authentication authentication)
Lock a private key of account which is stored in a server key store.
|
void |
setChannel(io.grpc.ManagedChannel channel) |
void |
setContextProvider(ContextProvider contextProvider) |
Transaction |
sign(RawTransaction rawTransaction)
Sign for transaction.
|
boolean |
unlock(Authentication authentication)
Unlock a private key of account which is stored in a server key store.
|
protected final ExceptionConverter<RpcException> exceptionConverter
protected KeyStoreBaseTemplate keyStoreBaseTemplate
protected ContextProvider contextProvider
public void setChannel(io.grpc.ManagedChannel channel)
setChannel
in interface ChannelInjectable
public void setContextProvider(ContextProvider contextProvider)
setContextProvider
in interface ContextProviderInjectable
public java.util.List<AccountAddress> list()
KeyStoreOperation
list
in interface KeyStoreOperation
public AccountAddress create(java.lang.String password)
KeyStoreOperation
create
in interface KeyStoreOperation
password
- a password to encrypt private keypublic boolean lock(Authentication authentication)
KeyStoreOperation
lock
in interface KeyStoreOperation
authentication
- an authentication to lockpublic boolean unlock(Authentication authentication)
KeyStoreOperation
unlock
in interface KeyStoreOperation
authentication
- an authentication to unlockpublic Transaction sign(RawTransaction rawTransaction)
KeyStoreOperation
sign
in interface KeyStoreOperation
rawTransaction
- raw transaction to signpublic AccountAddress importKey(EncryptedPrivateKey encryptedKey, java.lang.String oldPassword, java.lang.String newPassword)
KeyStoreOperation
oldPassword
is used to
decrypt passed private key. An newPassword
is used to store private key as encrypted
state in a server.importKey
in interface KeyStoreOperation
encryptedKey
- an encrypted private keyoldPassword
- an old password to decrypt encrypted private keynewPassword
- an new password to encrypt passed private key in a server keystorepublic EncryptedPrivateKey exportKey(Authentication authentication)
KeyStoreOperation
exportKey
in interface KeyStoreOperation
authentication
- an authentication of stored account