Class MetamaskLoginService

java.lang.Object
io.meeds.tenant.metamask.service.MetamaskLoginService
All Implemented Interfaces:
org.picocontainer.Startable

public class MetamaskLoginService extends Object implements org.picocontainer.Startable
  • Field Details

    • LOGIN_MESSAGE_ATTRIBUTE_NAME

      public static final String LOGIN_MESSAGE_ATTRIBUTE_NAME
      See Also:
    • SECURE_ROOT_ACCESS_WITH_METAMASK_PARAM

      public static final String SECURE_ROOT_ACCESS_WITH_METAMASK_PARAM
      See Also:
    • ALLOWED_ROOT_ACCESS_WALLETS_PARAM

      public static final String ALLOWED_ROOT_ACCESS_WALLETS_PARAM
      See Also:
    • LOG

      protected static final org.exoplatform.services.log.Log LOG
  • Constructor Details

    • MetamaskLoginService

      public MetamaskLoginService(org.exoplatform.services.organization.OrganizationService organizationService, org.exoplatform.portal.config.UserACL userACL, org.exoplatform.web.security.security.SecureRandomService secureRandomService, TenantManagerService tenantManagerService, org.exoplatform.account.setup.web.AccountSetupService accountSetupService, io.meeds.portal.security.service.SecuritySettingService securitySettingService, org.exoplatform.container.xml.InitParams params)
  • Method Details

    • start

      public void start()
      Specified by:
      start in interface org.picocontainer.Startable
    • stop

      public void stop()
      Specified by:
      stop in interface org.picocontainer.Startable
    • 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.
    • isTenantManager

      public boolean isTenantManager(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(javax.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(javax.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(javax.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
    • isDeedTenant

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

      public long getDeedId()
      Returns:
      DEED NFT identifier