Class MetamaskLoginService

java.lang.Object
io.meeds.tenant.metamask.service.MetamaskLoginService

@Service public class MetamaskLoginService extends Object
  • Field Details

  • Constructor Details

    • MetamaskLoginService

      public MetamaskLoginService()
  • Method Details

    • init

      @PostConstruct public void init()
    • isAllowUserRegistration

      public boolean isAllowUserRegistration()
      Returns:
      allowUserRegistration parameter value
    • isAllowUserRegistration

      public boolean isAllowUserRegistration(String walletAddress)
      Parameters:
      walletAddress - wallet address that attempts to register
      Returns:
      allowUserRegistration parameter value, else, it will checks whether the Tenant Manager has been registered to the tenant or not. If not regitered, allow to display the register form, else return false.
    • isDeedManager

      public boolean isDeedManager(String walletAddress)
      Parameters:
      walletAddress - to check if it's of Tenant Manager
      Returns:
      true is wallet address is of the Tenant Manager else return false.
    • isSuperUser

      public boolean isSuperUser(String walletAddress)
      Parameters:
      walletAddress - wallet address
      Returns:
      true if secure root access is allowed and designated wallet is allowed to access using root account
    • getUserWithWalletAddress

      public String getUserWithWalletAddress(String walletAddress)
      Retrieves User name with associated wallet Address
      Parameters:
      walletAddress - Ethereum Wallet Address
      Returns:
      username
    • validateSignedMessage

      public boolean validateSignedMessage(String walletAddress, String rawMessage, String signedMessage)
      Validates signed message by a wallet using Metamask
      Parameters:
      walletAddress - wallet Address (wallet public key)
      rawMessage - raw signed message
      signedMessage - encrypted message
      Returns:
      true if the message has been decrypted successfully, else false
    • generateLoginMessage

      public String generateLoginMessage(jakarta.servlet.http.HttpSession session, boolean renew)
      Generates a new Login Message to sign by current user and store it in HttpSession. If renew = true, a new Token will be generated even if alread exists in HttpSession, else the token already generated will be returned
      Parameters:
      session - HttpSession
      renew - boolean
      Returns:
      already existing token in HttpSession or a newly generated one
    • generateLoginMessage

      public String generateLoginMessage(jakarta.servlet.http.HttpSession session)
      Generates a new Login Message to sign by current user and store it in HttpSession. If a token already exists in session, it will be returned else a newly generated token will be returned
      Parameters:
      session - HttpSession
      Returns:
      already existing token in HttpSession or a newly generated one
    • getLoginMessage

      public String getLoginMessage(jakarta.servlet.http.HttpSession session)
      Retrieves Login Message to Sign with Metamask Generated and stored in HTTP Session
      Parameters:
      session - HttpSession of current user
      Returns:
      Login Message
    • isDeedHub

      public boolean isDeedHub()
      Returns:
      true if current instance if the one of a Tenant Management
    • getDeedId

      public long getDeedId()
      Returns:
      DEED NFT identifier