Package org.exoplatform.wallet.service
Interface WalletAccountService
public interface WalletAccountService
A service to manage wallets of different types: user, space, admin
-
Method Summary
Modifier and TypeMethodDescriptionvoidcreateAdminAccount(String privateKey, String currentUser) Creates admin account wallet in server sidecreateWalletInstance(WalletProvider provider, String address, long identityId) Creates a transient wallet instance with pre-filled default properties of a wallet that will be ready to store.booleanenableWalletByAddress(String address, boolean enable, String currentUser) Enable/Disable User or Space walletgetAddressesLabelsVisibleBy(String currentUser) List of labels that current user can accessRetrieves admin wallet from internal databasegetPrivateKeyByTypeAndId(String type, String remoteId) Retrieve wallet private key by identity type and remoteIdgetPrivateKeyByTypeAndId(String type, String remoteId, String currentUser) Retrieve wallet private key by identity type and remoteIdgetWalletByAddress(String address) Retrieve wallet by addressgetWalletByAddress(String address, String currentUser) Retrieve wallet by address with blockchain state if current user can access wallet datagetWalletByIdentityId(long identityId) Retrieve wallet details by identity technical idgetWalletByTypeAndId(String type, String remoteId) Retrieve wallet details by identity type and remoteIdgetWalletByTypeAndId(String type, String remoteId, String currentUser) Retrieve wallet details by identity type and remoteId accessed by a userlongRetrieve wallets countbooleanbooleanisWalletOwner(Wallet wallet, String currentUser) Retrieves the list registered walletsvoidrefreshWalletFromBlockchain(Wallet wallet, ContractDetail contractDetail, Map<String, Set<String>> walletsModifications) Refreshes wallet state from blockchainvoidrefreshWalletsFromBlockchain(Map<String, Set<String>> walletsModifications) Refreshes wallets from blockchainvoidremovePrivateKeyByTypeAndId(String type, String remoteId, String currentUser) Removes wallet private key by identity type and remoteIdvoidremoveWalletByAddress(String address, String currentUser) Remove User or Space wallet address associationvoidremoveWalletByTypeAndId(String type, String remoteId, String currentUser) Remove wallet address association by type and remote idvoidretrieveWalletBlockchainState(Wallet wallet) Retrieve wallet state from internal databasesaveOrDeleteAddressLabel(WalletAddressLabel label, String currentUser) Saves label if label is not empty else, delete itvoidsavePrivateKeyByTypeAndId(String type, String remoteId, String content, String currentUser) Save wallet private key for a wallet identified by identity type and remoteIdsaveWallet(Wallet wallet, boolean isNew) Save wallet instance in internal databasevoidsaveWalletAddress(Wallet wallet, String currentUser) Save wallet address to currentUser or to a space managed by current usersaveWalletBackupState(String currentUser, long identityId, boolean backupState) Change wallet backup statevoidsaveWalletBlockchainState(Wallet wallet, String contractAddress) Save wallet state on blockchainvoidsetInitializationStatus(String address, WalletState initializationState) Change wallet initialization statusvoidsetInitializationStatus(String address, WalletState initializationState, String currentUserId) Change wallet initialization statusvoidswitchToInternalWallet(long identityId) Switches the selected identity to internal wallet signer and changes the addressvoidswitchWalletProvider(long identityId, WalletProvider provider, String newAddress, String rawMessage, String signedMessage) Switches the provider of selected identity and changes the address
-
Method Details
-
listWallets
Retrieves the list registered wallets- Returns:
- list of associated wallets to users and spaces
-
getWalletsCount
long getWalletsCount()Retrieve wallets count- Returns:
- associated wallets count
-
getWalletByIdentityId
Retrieve wallet details by identity technical id- Parameters:
identityId- User/Space identity technical id- Returns:
Walletwallet details identified by identity technical id
-
getWalletByTypeAndId
Retrieve wallet details by identity type and remoteId accessed by a user- Parameters:
type- 'user' or 'space'remoteId- username or space pretty namecurrentUser- current username saving wallet private key- Returns:
Walletwallet details identified by type and remote Id
-
getWalletByTypeAndId
Retrieve wallet details by identity type and remoteId- Parameters:
type- 'user' or 'space'remoteId- username or space pretty name- Returns:
Walletwallet details identified by type and remote Id
-
getAdminWallet
Wallet getAdminWallet()Retrieves admin wallet from internal database- Returns:
Walletof administrator
-
savePrivateKeyByTypeAndId
void savePrivateKeyByTypeAndId(String type, String remoteId, String content, String currentUser) throws IllegalAccessException Save wallet private key for a wallet identified by identity type and remoteId- Parameters:
type- 'user' or 'space'remoteId- username or space pretty namecontent- crypted private keycurrentUser- current username- Throws:
IllegalAccessException- when the current user is not allowed to save the encrypted private key of wallet
-
getPrivateKeyByTypeAndId
String getPrivateKeyByTypeAndId(String type, String remoteId, String currentUser) throws IllegalAccessException Retrieve wallet private key by identity type and remoteId- Parameters:
type- 'user' or 'space'remoteId- username or space pretty namecurrentUser- current username getting wallet private key- Returns:
- encrypted wallet private key identified by type and remote Id
- Throws:
IllegalAccessException- when the current user is not allowed to get the encrypted private key of wallet
-
getPrivateKeyByTypeAndId
Retrieve wallet private key by identity type and remoteId- Parameters:
type- 'user' or 'space'remoteId- username or space pretty name- Returns:
- encrypted wallet private key identified by type and remote Id
-
removePrivateKeyByTypeAndId
void removePrivateKeyByTypeAndId(String type, String remoteId, String currentUser) throws IllegalAccessException Removes wallet private key by identity type and remoteId- Parameters:
type- 'user' or 'space'remoteId- username or space pretty namecurrentUser- current username removing wallet private key- Throws:
IllegalAccessException- when the current user is not an owner of wallet
-
getWalletByAddress
Retrieve wallet by address with blockchain state if current user can access wallet data- Parameters:
address- address of wallet to retrievecurrentUser- current username accessing wallet information- Returns:
Walletwallet details identified by type and remote Id
-
getWalletByAddress
Retrieve wallet by address- Parameters:
address- address of wallet to retrieve- Returns:
Walletwallet details identified by type and remote Id
-
saveWalletBlockchainState
Save wallet state on blockchain- Parameters:
wallet-contractAddress-
-
saveWalletBackupState
Wallet saveWalletBackupState(String currentUser, long identityId, boolean backupState) throws IllegalAccessException Change wallet backup state- Parameters:
identityId- user/space technical identty idbackupState- true if backedUp else falsecurrentUser- current username saving wallet backup state- Returns:
- modified
Wallet - Throws:
IllegalAccessException- when currentUser is not owner of wallet
-
saveWalletAddress
Save wallet address to currentUser or to a space managed by current user- Parameters:
wallet-Walletwallet details to savecurrentUser- current username saving wallet details- Throws:
IllegalAccessException- when the current user is not able to save a new address to the wallet
-
saveWallet
Save wallet instance in internal database- Parameters:
wallet-isNew-- Returns:
- save
Wallet
-
createWalletInstance
Creates a transient wallet instance with pre-filled default properties of a wallet that will be ready to store.- Parameters:
provider- newWalletProvideraddress- new address ofWalletof selected identityidentityId- user/space technical identty id- Returns:
- new
Walletinstance
-
switchWalletProvider
void switchWalletProvider(long identityId, WalletProvider provider, String newAddress, String rawMessage, String signedMessage) Switches the provider of selected identity and changes the address- Parameters:
identityId-Identityunique identifierprovider- newWalletProvidernewAddress- new address ofWalletof selected identityrawMessage- Raw Message to sign by user to verify that it has the private keysignedMessage- Signed message by user
-
switchToInternalWallet
void switchToInternalWallet(long identityId) Switches the selected identity to internal wallet signer and changes the address- Parameters:
identityId-Identityunique identifier
-
removeWalletByAddress
Remove User or Space wallet address association- Parameters:
address- wallet address association to removecurrentUser- current username removing wallet details- Throws:
IllegalAccessException- if current user is not an administrator
-
removeWalletByTypeAndId
void removeWalletByTypeAndId(String type, String remoteId, String currentUser) throws IllegalAccessException Remove wallet address association by type and remote id- Parameters:
type- USER/SPACE/ADMIN, seeWalletTyperemoteId- username or space pretty namecurrentUser- current username saving wallet details- Throws:
IllegalAccessException
-
enableWalletByAddress
boolean enableWalletByAddress(String address, boolean enable, String currentUser) throws IllegalAccessException Enable/Disable User or Space wallet- Parameters:
address- address of wallet to enable/disableenable- whether enable or disable walletcurrentUser- username of current user making the operation- Returns:
- true if modified else false
- Throws:
IllegalAccessException- if current user is not an administrator
-
isWalletOwner
- Parameters:
wallet-currentUser-- Returns:
- true if user is accessing his wallet or is accessing a space that he manages wallet
-
saveOrDeleteAddressLabel
Saves label if label is not empty else, delete it- Parameters:
label- label details object to processcurrentUser- current user making the label creation/modification/deletion- Returns:
WalletAddressLabelsaved or deleted label details
-
getAddressesLabelsVisibleBy
List of labels that current user can access- Parameters:
currentUser- current username accessing the list of addresses labels- Returns:
- a
Setof label details
-
setInitializationStatus
void setInitializationStatus(String address, WalletState initializationState, String currentUserId) throws IllegalAccessException Change wallet initialization status- Parameters:
address- wallet addressinitializationState- wallet initialization status of typeWalletStatecurrentUserId- user changing wallet status- Throws:
IllegalAccessException- if current user is not allowed to modify wallet initialization status
-
setInitializationStatus
Change wallet initialization status- Parameters:
address- wallet addressinitializationState- wallet initialization status of typeWalletState
-
createAdminAccount
Creates admin account wallet in server side- Parameters:
privateKey- admin account wallet private keycurrentUser- current user creating wallet- Throws:
IllegalAccessException- if current user is not allowed to create admin wallet account
-
getAdminAccountPassword
String getAdminAccountPassword()- Returns:
- admin account password from configuration
-
refreshWalletsFromBlockchain
Refreshes wallets from blockchain- Parameters:
walletsModifications- modified wallets on blockchain with the set of invoked methods on contract
-
refreshWalletFromBlockchain
void refreshWalletFromBlockchain(Wallet wallet, ContractDetail contractDetail, Map<String, Set<String>> walletsModifications) Refreshes wallet state from blockchain- Parameters:
wallet-contractDetail-walletsModifications-
-
retrieveWalletBlockchainState
Retrieve wallet state from internal database- Parameters:
wallet- object to refresh
-
isAdminAccountEnabled
boolean isAdminAccountEnabled()- Returns:
- true if wallet admin is enabled on Token contract else return false
-