public final class TenantAccessor extends Object
Constructor and Description |
---|
TenantAccessor() |
Modifier and Type | Method and Description |
---|---|
static Tenant |
getCurrentTenant()
Returns the current
Tenant . |
static Optional<Tenant> |
getCurrentTenantIfAvailable()
Returns the current
Tenant , if available. |
static TenantFacade |
getTenantFacade()
The
TenantFacade instance. |
static void |
setTenantFacade(TenantFacade tenantFacade)
Replaces the default
TenantFacade instance. |
public static void setTenantFacade(@Nonnull TenantFacade tenantFacade)
TenantFacade
instance. This method is for internal use only.@Nonnull public static Tenant getCurrentTenant() throws TenantNotAvailableException, TenantAccessException
Tenant
.Tenant
.TenantNotAvailableException
- If there is currently no Tenant
available. This typically occurs when trying to access the
tenant within code that is running outside any tenant context, e.g., within a background task. For
more details on the availability of a tenant, refer to getCurrentTenantIfAvailable()
.TenantAccessException
- If there is an issue while accessing the Tenant
.@Nonnull public static Optional<Tenant> getCurrentTenantIfAvailable() throws TenantAccessException
Tenant
, if available.
The availability of the tenant is defined as follows:
Tenant available | Tenant not available | |
---|---|---|
SAP Cloud Platform Cloud Foundry | A request is present with an "Authorization" header that contains a valid JWT bearer with field "zid". | A request is not available, no "Authorization" header is present in the current request, or the JWT bearer does not hold a field "zid". |
SAP Cloud Platform Neo | Successful JNDI lookup of TenantContext. | Never. If correctly configured, a TenantContext is always available. If not, a TenantAccessException
is thrown. |
Optional
of the current Tenant
.TenantAccessException
- If there is an issue while accessing the Tenant
.@Nullable public static TenantFacade getTenantFacade()
TenantFacade
instance. For internal use only.Copyright © 2018 SAP SE. All rights reserved.