Class TokenManagerService

java.lang.Object
de.joergdev.mosy.backend.security.TokenManagerService

public class TokenManagerService extends Object
  • Constructor Details

    • TokenManagerService

      public TokenManagerService()
  • Method Details

    • createToken

      public static String createToken(int hash, Integer tenantId, Integer hashForTenant, IntSupplier defaultTenantIdForNonMultiTanencySupplier)
      Creates a new token.
      Parameters:
      hash - - hashcode of secret
      tenantId - - may be null if multi-tanency is not enabled
      hashForTenant - - hashcode of secret for tenant (may be null if multi-tanency is not enabled)
      defaultTenantIdForNonMultiTanencySupplier - - IntSupplier for resolving the default-tenantId (non-multi-tanency)
      Returns:
      null on invalid credentials else valid token
    • createTokenWithoutSecretCheck

      public static String createTokenWithoutSecretCheck(Integer tenantId, IntSupplier defaultTenantIdForNonMultiTanencySupplier)
       Creates a new token WITHOUT check of secret key.
       
       !!ATTENTION!!
       This may only be used for internal use cases.
       This token should never be delivered to a client!
       
      Parameters:
      tenantId - - ID
      defaultTenantIdForNonMultiTanencySupplier - - IntSupplier for resolving the default-tenantId (non-multi-tanency)
      Returns:
      null on invalid credentials else valid token
    • validateToken

      public static boolean validateToken(String token)
    • invalidateToken

      public static boolean invalidateToken(String token)
    • getTenantId

      public static Integer getTenantId(String token)