Interface WalletAccountService


public interface WalletAccountService
A service to manage wallets of different types: user, space, admin
  • Method Details

    • 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:
      Wallet wallet 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 name
      currentUser - current username saving wallet private key
      Returns:
      Wallet wallet 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:
      Wallet wallet details identified by type and remote Id
    • getAdminWallet

      Wallet getAdminWallet()
      Retrieves admin wallet from internal database
      Returns:
      Wallet of 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 name
      content - crypted private key
      currentUser - 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 name
      currentUser - 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 name
      currentUser - 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 retrieve
      currentUser - current username accessing wallet information
      Returns:
      Wallet wallet details identified by type and remote Id
    • getWalletByAddress

      Wallet getWalletByAddress(String address)
      Retrieve wallet by address
      Parameters:
      address - address of wallet to retrieve
      Returns:
      Wallet wallet 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:
      currentUser - current username saving wallet backup state
      identityId - user/space technical identty id
      backupState - true if backedUp else false
      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 - Wallet wallet details to save
      currentUser - 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
    • createWalletInstance

      Wallet createWalletInstance(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.
      Parameters:
      provider - new WalletProvider
      address - new address of Wallet of selected identity
      identityId - user/space technical identty id
      Returns:
      new Wallet instance
    • 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 - Identity unique identifier
      provider - new WalletProvider
      newAddress - new address of Wallet of selected identity
      rawMessage - Raw Message to sign by user to verify that it has the private key
      signedMessage - Signed message by user
    • switchToInternalWallet

      void switchToInternalWallet(long identityId)
      Switches the selected identity to internal wallet signer and changes the address
      Parameters:
      identityId - Identity unique identifier
    • removeWalletByAddress

      void removeWalletByAddress(String address, String currentUser) throws IllegalAccessException
      Remove User or Space wallet address association
      Parameters:
      address - wallet address association to remove
      currentUser - 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, see WalletType
      remoteId - username or space pretty name
      currentUser - 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/disable
      enable - whether enable or disable wallet
      currentUser - 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 process
      currentUser - current user making the label creation/modification/deletion
      Returns:
      WalletAddressLabel saved 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 Set of label details
    • setInitializationStatus

      void setInitializationStatus(String address, WalletState initializationState, String currentUserId) throws IllegalAccessException
      Change wallet initialization status
      Parameters:
      address - wallet address
      initializationState - wallet initialization status of type WalletState
      currentUserId - user changing wallet status
      Throws:
      IllegalAccessException - if current user is not allowed to modify wallet initialization status
    • setInitializationStatus

      void setInitializationStatus(String address, WalletState initializationState)
      Change wallet initialization status
      Parameters:
      address - wallet address
      initializationState - wallet initialization status of type WalletState
    • createAdminAccount

      void createAdminAccount(String privateKey, String currentUser) throws IllegalAccessException
      Creates admin account wallet in server side
      Parameters:
      privateKey - admin account wallet private key
      currentUser - 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