Class PrincipalTenantResolver

java.lang.Object
io.micronaut.multitenancy.tenantresolver.PrincipalTenantResolver
All Implemented Interfaces:
HttpRequestTenantResolver, TenantResolver

@Singleton @Requires(property="micronaut.multitenancy.tenantresolver.principal.enabled", value="true", defaultValue="false") public class PrincipalTenantResolver extends Object implements TenantResolver, HttpRequestTenantResolver
A tenant resolver that resolves the tenant from the authenticated principal.
Since:
1.0.0
Author:
Sergio del Amo
  • Constructor Details

    • PrincipalTenantResolver

      public PrincipalTenantResolver()
  • Method Details

    • resolveTenantId

      @NonNull public @NonNull String resolveTenantId()
      Description copied from interface: TenantResolver

      Resolves the current tenant identifier.

      In a Multi Tenant setup where a single database is being used amongst multiple tenants this would be the object that is used as the tenantId property for each domain class.

      Specified by:
      resolveTenantId in interface TenantResolver
      Returns:
      The tenant identifier
    • resolveTenantId

      @NonNull public @NonNull String resolveTenantId(@NonNull @NonNull io.micronaut.http.HttpRequest<?> request) throws TenantNotFoundException
      Description copied from interface: HttpRequestTenantResolver
      Resolves the current tenant identifier.
      Specified by:
      resolveTenantId in interface HttpRequestTenantResolver
      Parameters:
      request - The HTTP request
      Returns:
      The tenant identifier
      Throws:
      TenantNotFoundException - if tenant not found
    • resolveTenantIdentifier

      @NonNull @Deprecated(forRemoval=true, since="5.5.0") public @NonNull Serializable resolveTenantIdentifier()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: TenantResolver

      Resolves the current tenant identifier.

      In a Multi Tenant setup where a single database is being used amongst multiple tenants this would be the object that is used as the tenantId property for each domain class.

      Specified by:
      resolveTenantIdentifier in interface TenantResolver
      Returns:
      The tenant identifier
    • resolveTenantIdentifier

      @NonNull @Deprecated(forRemoval=true, since="5.5.0") public @NonNull Serializable resolveTenantIdentifier(@NonNull @NonNull io.micronaut.http.HttpRequest<?> request) throws TenantNotFoundException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: HttpRequestTenantResolver
      Resolves the current tenant identifier.
      Specified by:
      resolveTenantIdentifier in interface HttpRequestTenantResolver
      Parameters:
      request - The HTTP request
      Returns:
      The tenant identifier
      Throws:
      TenantNotFoundException - if tenant not found