public abstract class PulsarWebResource extends Object
| Modifier and Type | Field and Description |
|---|---|
protected javax.servlet.http.HttpServletRequest |
httpRequest |
protected static int |
NOT_IMPLEMENTED |
protected javax.servlet.ServletContext |
servletContext |
protected javax.ws.rs.core.UriInfo |
uri |
| Constructor and Description |
|---|
PulsarWebResource() |
| Modifier and Type | Method and Description |
|---|---|
protected static void |
checkAuthorization(PulsarService pulsarService,
org.apache.pulsar.common.naming.TopicName topicName,
String role,
AuthenticationDataSource authenticationData) |
protected void |
checkConnect(org.apache.pulsar.common.naming.TopicName topicName) |
static CompletableFuture<org.apache.pulsar.common.policies.data.ClusterData> |
checkLocalOrGetPeerReplicationCluster(PulsarService pulsarService,
org.apache.pulsar.common.naming.NamespaceName namespace) |
String |
clientAppId()
Gets a caller id (IP + role)
|
AuthenticationDataHttps |
clientAuthData() |
protected ServiceConfiguration |
config() |
protected static CompletableFuture<org.apache.pulsar.common.policies.data.ClusterData> |
getClusterDataIfDifferentCluster(PulsarService pulsar,
String cluster,
String clientAppId) |
protected boolean |
hasSuperUserAccess() |
protected CompletableFuture<Boolean> |
isBundleOwnedByAnyBroker(org.apache.pulsar.common.naming.NamespaceName fqnn,
org.apache.pulsar.common.policies.data.BundlesData bundles,
String bundleRange)
Checks whether a given bundle is currently loaded by any broker
|
static boolean |
isClientAuthenticated(String appId) |
protected boolean |
isLeaderBroker() |
protected static boolean |
isLeaderBroker(PulsarService pulsar) |
boolean |
isRequestHttps() |
static String |
joinPath(String... parts) |
String |
originalPrincipal() |
static String |
path(String... parts) |
protected PulsarService |
pulsar() |
void |
setPulsar(PulsarService pulsar) |
static String |
splitPath(String source,
int slice) |
protected static void |
validateAdminAccessForTenant(PulsarService pulsar,
String clientAppId,
String originalPrincipal,
String tenant,
AuthenticationDataSource authenticationData) |
protected void |
validateAdminAccessForTenant(String tenant)
Checks that the http client role has admin access to the specified tenant.
|
void |
validateBundleOwnership(NamespaceBundle bundle,
boolean authoritative,
boolean readOnly) |
protected void |
validateBundleOwnership(String tenant,
String cluster,
String namespace,
boolean authoritative,
boolean readOnly,
NamespaceBundle bundle) |
protected void |
validateClusterForTenant(String tenant,
String cluster) |
protected void |
validateClusterOwnership(String cluster)
Check if the cluster exists and redirect the call to the owning cluster
|
protected void |
validateGlobalNamespaceOwnership(org.apache.pulsar.common.naming.NamespaceName namespace)
If the namespace is global, validate the following - 1.
|
protected NamespaceBundle |
validateNamespaceBundleOwnership(org.apache.pulsar.common.naming.NamespaceName fqnn,
org.apache.pulsar.common.policies.data.BundlesData bundles,
String bundleRange,
boolean authoritative,
boolean readOnly) |
protected NamespaceBundle |
validateNamespaceBundleRange(org.apache.pulsar.common.naming.NamespaceName fqnn,
org.apache.pulsar.common.policies.data.BundlesData bundles,
String bundleRange) |
void |
validateNamespaceOperation(org.apache.pulsar.common.naming.NamespaceName namespaceName,
org.apache.pulsar.common.policies.data.NamespaceOperation operation) |
protected void |
validateNamespaceOwnershipWithBundles(String tenant,
String cluster,
String namespace,
boolean authoritative,
boolean readOnly,
org.apache.pulsar.common.policies.data.BundlesData bundleData)
Checks whether the broker is the owner of all the namespace bundles.
|
void |
validateNamespacePolicyOperation(org.apache.pulsar.common.naming.NamespaceName namespaceName,
org.apache.pulsar.common.policies.data.PolicyName policy,
org.apache.pulsar.common.policies.data.PolicyOperation operation) |
protected void |
validateSuperUserAccess()
Checks whether the user has Pulsar Super-User access to the system.
|
void |
validateTenantOperation(String tenant,
org.apache.pulsar.common.policies.data.TenantOperation operation) |
protected void |
validateTopicOwnership(org.apache.pulsar.common.naming.TopicName topicName,
boolean authoritative)
Checks whether the broker is the owner of the namespace.
|
@Context protected javax.servlet.ServletContext servletContext
@Context protected javax.servlet.http.HttpServletRequest httpRequest
@Context protected javax.ws.rs.core.UriInfo uri
protected static final int NOT_IMPLEMENTED
protected PulsarService pulsar()
protected ServiceConfiguration config()
public String clientAppId()
public String originalPrincipal()
public AuthenticationDataHttps clientAuthData()
public boolean isRequestHttps()
public static boolean isClientAuthenticated(String appId)
protected boolean hasSuperUserAccess()
protected void validateSuperUserAccess()
javax.ws.rs.WebApplicationException - if not authorizedprotected void validateAdminAccessForTenant(String tenant)
tenant - the tenant idjavax.ws.rs.WebApplicationException - if not authorizedprotected static void validateAdminAccessForTenant(PulsarService pulsar, String clientAppId, String originalPrincipal, String tenant, AuthenticationDataSource authenticationData) throws RestException, Exception
RestExceptionExceptionprotected void validateClusterOwnership(String cluster) throws javax.ws.rs.WebApplicationException
cluster - Cluster nameException - In case the redirect happensjavax.ws.rs.WebApplicationExceptionprotected static CompletableFuture<org.apache.pulsar.common.policies.data.ClusterData> getClusterDataIfDifferentCluster(PulsarService pulsar, String cluster, String clientAppId)
protected void validateNamespaceOwnershipWithBundles(String tenant, String cluster, String namespace, boolean authoritative, boolean readOnly, org.apache.pulsar.common.policies.data.BundlesData bundleData)
tenant - tenant namecluster - cluster namenamespace - namespace nameauthoritative - if it is an authoritative requestreadOnly - if the request is read-onlybundleData - bundle dataprotected void validateBundleOwnership(String tenant, String cluster, String namespace, boolean authoritative, boolean readOnly, NamespaceBundle bundle)
protected NamespaceBundle validateNamespaceBundleRange(org.apache.pulsar.common.naming.NamespaceName fqnn, org.apache.pulsar.common.policies.data.BundlesData bundles, String bundleRange)
protected CompletableFuture<Boolean> isBundleOwnedByAnyBroker(org.apache.pulsar.common.naming.NamespaceName fqnn, org.apache.pulsar.common.policies.data.BundlesData bundles, String bundleRange)
protected NamespaceBundle validateNamespaceBundleOwnership(org.apache.pulsar.common.naming.NamespaceName fqnn, org.apache.pulsar.common.policies.data.BundlesData bundles, String bundleRange, boolean authoritative, boolean readOnly)
public void validateBundleOwnership(NamespaceBundle bundle, boolean authoritative, boolean readOnly) throws Exception
Exceptionprotected void validateTopicOwnership(org.apache.pulsar.common.naming.TopicName topicName,
boolean authoritative)
topicName - topic nameauthoritative - protected void validateGlobalNamespaceOwnership(org.apache.pulsar.common.naming.NamespaceName namespace)
namespace - Exceptionpublic static CompletableFuture<org.apache.pulsar.common.policies.data.ClusterData> checkLocalOrGetPeerReplicationCluster(PulsarService pulsarService, org.apache.pulsar.common.naming.NamespaceName namespace)
protected void checkConnect(org.apache.pulsar.common.naming.TopicName topicName)
throws RestException,
Exception
RestExceptionExceptionprotected static void checkAuthorization(PulsarService pulsarService, org.apache.pulsar.common.naming.TopicName topicName, String role, AuthenticationDataSource authenticationData) throws RestException, Exception
RestExceptionExceptionpublic void setPulsar(PulsarService pulsar)
protected boolean isLeaderBroker()
protected static boolean isLeaderBroker(PulsarService pulsar)
public void validateTenantOperation(String tenant, org.apache.pulsar.common.policies.data.TenantOperation operation)
public void validateNamespaceOperation(org.apache.pulsar.common.naming.NamespaceName namespaceName,
org.apache.pulsar.common.policies.data.NamespaceOperation operation)
public void validateNamespacePolicyOperation(org.apache.pulsar.common.naming.NamespaceName namespaceName,
org.apache.pulsar.common.policies.data.PolicyName policy,
org.apache.pulsar.common.policies.data.PolicyOperation operation)
Copyright © 2017–2021 Apache Software Foundation. All rights reserved.