Class TenantIdResolver


  • @ApplicationScoped
    public class TenantIdResolver
    extends Object
    This class centralizes the logic to resolve the tenantId from an http request.
    Author:
    Fabian Martinez
    • Constructor Detail

      • TenantIdResolver

        public TenantIdResolver()
    • Method Detail

      • resolveTenantId

        public boolean resolveTenantId​(String uri,
                                       Function<String,​String> headerProvider,
                                       Supplier<String> serverNameProvider,
                                       Consumer<String> afterSuccessfullUrlResolution)
        Resolves the tenant ID from the inbound HTTP request. The tenantId can potentially be located in one of the following locations: 1) In the context path: https://registry.example.org/t/{tenantId}/apis/registry/v2/search/artifacts 2) In a request header: https://registry.example.org/apis/registry/v2/search/artifacts + header X-Registry-Tenant-Id: {tenantId} 3) In a subdomain: https://{tenantId}.registry.example.org/apis/registry/v2/search/artifacts Configuration options exist to enable/disable checking each of these locations. Additional configuration options exist to modify the specific behavior of each approach. For example, for (2) it is possible to configure the name of the request header.
        Parameters:
        uri -
        headerProvider -
        serverNameProvider -
        afterSuccessfullUrlResolution -
      • tenantPrefixLength

        public int tenantPrefixLength​(String tenantId)