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 CompletableFuture<Void> |
canUpdateCluster(String tenant,
Set<String> oldClusters,
Set<String> newClusters) |
protected static void |
checkAuthorization(PulsarService pulsarService,
org.apache.pulsar.common.naming.TopicName topicName,
String role,
AuthenticationDataSource authenticationData) |
static CompletableFuture<org.apache.pulsar.common.policies.data.ClusterDataImpl> |
checkLocalOrGetPeerReplicationCluster(PulsarService pulsarService,
org.apache.pulsar.common.naming.NamespaceName namespace) |
String |
clientAppId()
Gets a caller id (IP + role).
|
AuthenticationDataHttps |
clientAuthData() |
protected ClusterResources |
clusterResources() |
protected ServiceConfiguration |
config() |
static void |
deleteRecursive(BaseResources resources,
String pathRoot) |
protected DynamicConfigurationResources |
dynamicConfigurationResources() |
protected static CompletableFuture<org.apache.pulsar.common.policies.data.ClusterDataImpl> |
getClusterDataIfDifferentCluster(PulsarService pulsar,
String cluster,
String clientAppId) |
protected List<String> |
getListOfNamespaces(String tenant) |
protected List<String> |
getListOfResourcegroups(String property)
Get the list of resourcegroups.
|
protected LocalPoliciesResources |
getLocalPolicies() |
protected PulsarResources |
getPulsarResources() |
protected CompletableFuture<Void> |
hasActiveNamespace(String tenant) |
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) |
static com.fasterxml.jackson.databind.ObjectMapper |
jsonMapper() |
static List<String> |
listSubTreeBFS(BaseResources resources,
String pathRoot) |
protected NamespaceResources.IsolationPolicyResources |
namespaceIsolationPolicies() |
protected NamespaceResources |
namespaceResources() |
String |
originalPrincipal() |
static String |
path(String... parts) |
protected PulsarService |
pulsar() |
protected ResourceGroupResources |
resourceGroupResources() |
void |
setPulsar(PulsarService pulsar) |
static String |
splitPath(String source,
int slice) |
protected TenantResources |
tenantResources() |
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.
|
protected void |
validateBrokerName(String broker)
Redirect the call to the specified broker.
|
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 |
validateClusterExists(String cluster) |
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 CompletableFuture<Void> |
validateGlobalNamespaceOwnershipAsync(org.apache.pulsar.common.naming.NamespaceName namespace) |
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) |
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) |
void |
validatePoliciesReadOnlyAccess() |
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) |
void |
validateTopicOperation(org.apache.pulsar.common.naming.TopicName topicName,
org.apache.pulsar.common.policies.data.TopicOperation operation) |
void |
validateTopicOperation(org.apache.pulsar.common.naming.TopicName topicName,
org.apache.pulsar.common.policies.data.TopicOperation operation,
String subscription) |
protected void |
validateTopicOwnership(org.apache.pulsar.common.naming.TopicName topicName,
boolean authoritative)
Checks whether the broker is the owner of the namespace.
|
protected CompletableFuture<Void> |
validateTopicOwnershipAsync(org.apache.pulsar.common.naming.TopicName topicName,
boolean authoritative) |
void |
validateTopicPolicyOperation(org.apache.pulsar.common.naming.TopicName topicName,
org.apache.pulsar.common.policies.data.PolicyName policy,
org.apache.pulsar.common.policies.data.PolicyOperation operation) |
@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()
public 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 Exception
Exceptionprotected 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.ClusterDataImpl> getClusterDataIfDifferentCluster(PulsarService pulsar, String cluster, String clientAppId)
protected 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 CompletableFuture<Void> validateTopicOwnershipAsync(org.apache.pulsar.common.naming.TopicName topicName, boolean authoritative)
protected void validateGlobalNamespaceOwnership(org.apache.pulsar.common.naming.NamespaceName namespace)
namespace - Exceptionprotected CompletableFuture<Void> validateGlobalNamespaceOwnershipAsync(org.apache.pulsar.common.naming.NamespaceName namespace)
public static CompletableFuture<org.apache.pulsar.common.policies.data.ClusterDataImpl> checkLocalOrGetPeerReplicationCluster(PulsarService pulsarService, org.apache.pulsar.common.naming.NamespaceName namespace)
protected static void checkAuthorization(PulsarService pulsarService, org.apache.pulsar.common.naming.TopicName topicName, String role, AuthenticationDataSource authenticationData) throws Exception
Exceptionpublic 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)
protected PulsarResources getPulsarResources()
protected TenantResources tenantResources()
protected ClusterResources clusterResources()
protected NamespaceResources namespaceResources()
protected ResourceGroupResources resourceGroupResources()
protected LocalPoliciesResources getLocalPolicies()
protected NamespaceResources.IsolationPolicyResources namespaceIsolationPolicies()
protected DynamicConfigurationResources dynamicConfigurationResources()
public static com.fasterxml.jackson.databind.ObjectMapper jsonMapper()
public void validatePoliciesReadOnlyAccess()
protected CompletableFuture<Void> hasActiveNamespace(String tenant)
protected void validateClusterExists(String cluster)
protected CompletableFuture<Void> canUpdateCluster(String tenant, Set<String> oldClusters, Set<String> newClusters)
protected void validateBrokerName(String broker)
broker - Broker namepublic void validateTopicPolicyOperation(org.apache.pulsar.common.naming.TopicName topicName,
org.apache.pulsar.common.policies.data.PolicyName policy,
org.apache.pulsar.common.policies.data.PolicyOperation operation)
public void validateTopicOperation(org.apache.pulsar.common.naming.TopicName topicName,
org.apache.pulsar.common.policies.data.TopicOperation operation)
public void validateTopicOperation(org.apache.pulsar.common.naming.TopicName topicName,
org.apache.pulsar.common.policies.data.TopicOperation operation,
String subscription)
protected List<String> getListOfNamespaces(String tenant) throws Exception
Exceptionprotected List<String> getListOfResourcegroups(String property) throws Exception
Exceptionpublic static void deleteRecursive(BaseResources resources, String pathRoot) throws org.apache.pulsar.metadata.api.MetadataStoreException
org.apache.pulsar.metadata.api.MetadataStoreExceptionpublic static List<String> listSubTreeBFS(BaseResources resources, String pathRoot) throws org.apache.pulsar.metadata.api.MetadataStoreException
org.apache.pulsar.metadata.api.MetadataStoreExceptionCopyright © 2017–2021 Apache Software Foundation. All rights reserved.