Package org.exoplatform.wallet.service
Interface WalletAccountService
-
public interface WalletAccountServiceA service to manage wallets of different types: user, space, admin
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcreateAdminAccount(String privateKey, String currentUser)Creates admin account wallet in server sidebooleanenableWalletByAddress(String address, boolean enable, String currentUser)Enable/Disable User or Space walletSet<WalletAddressLabel>getAddressesLabelsVisibleBy(String currentUser)List of labels that current user can accessStringgetAdminAccountPassword()WalletgetAdminWallet()Retrieves admin wallet from internal databaseStringgetPrivateKeyByTypeAndId(String type, String remoteId)Retrieve wallet private key by identity type and remoteIdStringgetPrivateKeyByTypeAndId(String type, String remoteId, String currentUser)Retrieve wallet private key by identity type and remoteIdWalletgetWalletByAddress(String address)Retrieve wallet by addressWalletgetWalletByAddress(String address, String currentUser)Retrieve wallet by address with blockchain state if current user can access wallet dataWalletgetWalletByIdentityId(long identityId)Retrieve wallet details by identity technical idWalletgetWalletByTypeAndId(String type, String remoteId)Retrieve wallet details by identity type and remoteIdWalletgetWalletByTypeAndId(String type, String remoteId, String currentUser)Retrieve wallet details by identity type and remoteId accessed by a userlonggetWalletsCount()Retrieve wallets countbooleanisAdminAccountEnabled()booleanisWalletOwner(Wallet wallet, String currentUser)Set<Wallet>listWallets()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 databaseWalletAddressLabelsaveOrDeleteAddressLabel(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 remoteIdWalletsaveWallet(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 userWalletsaveWalletBackupState(String currentUser, long identityId, boolean backupState)Change wallet backup statevoidsaveWalletBlockchainState(Wallet wallet, String contractAddress)Save wallet state on blockchainvoidsetInitializationStatus(String address, WalletInitializationState initializationState)Change wallet initialization statusvoidsetInitializationStatus(String address, WalletInitializationState initializationState, String currentUserId)Change wallet initialization status
-
-
-
Method Detail
-
listWallets
Set<Wallet> 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
Wallet getWalletByIdentityId(long identityId)
Retrieve wallet details by identity technical id- Parameters:
identityId- User/Space identity technical id- Returns:
Walletwallet details identified by identity technical id
-
getWalletByTypeAndId
Wallet getWalletByTypeAndId(String type, String remoteId, String currentUser)
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
Wallet getWalletByTypeAndId(String type, String remoteId)
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
String getPrivateKeyByTypeAndId(String type, String remoteId)
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
Wallet getWalletByAddress(String address, String currentUser)
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
Wallet getWalletByAddress(String address)
Retrieve wallet by address- Parameters:
address- address of wallet to retrieve- Returns:
Walletwallet details identified by type and remote Id
-
saveWalletBlockchainState
void saveWalletBlockchainState(Wallet wallet, String contractAddress)
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
void saveWalletAddress(Wallet wallet, String currentUser) throws IllegalAccessException
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
Wallet saveWallet(Wallet wallet, boolean isNew)
Save wallet instance in internal database- Parameters:
wallet-isNew-- Returns:
- save
Wallet
-
removeWalletByAddress
void removeWalletByAddress(String address, String currentUser) throws IllegalAccessException
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
boolean isWalletOwner(Wallet wallet, String currentUser)
- Parameters:
wallet-currentUser-- Returns:
- true if user is accessing his wallet or is accessing a space that he manages wallet
-
saveOrDeleteAddressLabel
WalletAddressLabel saveOrDeleteAddressLabel(WalletAddressLabel label, String currentUser)
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
Set<WalletAddressLabel> getAddressesLabelsVisibleBy(String currentUser)
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, WalletInitializationState initializationState, String currentUserId) throws IllegalAccessException
Change wallet initialization status- Parameters:
address- wallet addressinitializationState- wallet initialization status of typeWalletInitializationStatecurrentUserId- user changing wallet status- Throws:
IllegalAccessException- if current user is not allowed to modify wallet initialization status
-
setInitializationStatus
void setInitializationStatus(String address, WalletInitializationState initializationState)
Change wallet initialization status- Parameters:
address- wallet addressinitializationState- wallet initialization status of typeWalletInitializationState
-
createAdminAccount
void createAdminAccount(String privateKey, String currentUser) throws IllegalAccessException
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
void refreshWalletsFromBlockchain(Map<String,Set<String>> walletsModifications)
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
void retrieveWalletBlockchainState(Wallet wallet)
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
-
-