Class QualifiedSubject
java.lang.Object
io.confluent.kafka.schemaregistry.utils.QualifiedSubject
- All Implemented Interfaces:
Comparable<QualifiedSubject>
A qualified subject consists of a tenant, a context, and a subject name.
The qualification refers to the context and subject being qualified with a tenant.
The qualified subject string has the following format:
[tenant_][:.context:]subject
where tenant is optional and defaults to "default", context is optional and defaults to ".", and subject is required and may be empty.
The special context name ".__GLOBAL" is used for global configuration and mode settings. The special subject name "__GLOBAL" is used to store global permissions. The special subject name "__EMPTY" represents an empty string.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedQualifiedSubject(String tenant, String qualifiedSubject) QualifiedSubject(String tenant, String context, String subject) -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(QualifiedSubject that) static StringcontextFor(String tenant, String qualifiedSubject) Returns the context for the given qualified subject.static QualifiedSubjectCreates a QualifiedSubject from the given tenant and qualified subject.static QualifiedSubjectcreateFromUnqualified(String tenant, String unqualifiedSubject) Creates a QualifiedSubject from the given tenant and unqualified subject.booleaninthashCode()static booleanChecks if the given qualified subject represents a context (i.e., has no subject part).static booleanisDefaultContext(String tenant, String qualifiedSubject) Checks if the given qualified subject is the default context for the given tenant.static booleanisGlobalContext(String tenant, String qualifiedSubject) Checks if the given qualified subject is the global context for the given tenant.static booleanisQualified(String tenant, String qualifiedSubject) Checks if the given subject is qualified with the given tenant.static booleanisSubjectInContext(String tenant, String qualifiedSubject, QualifiedSubject qualifiedContext) Checks if the given qualified subject is a context for the given qualified subject.static booleanisValidSubject(String tenant, String qualifiedSubject) Validates the given qualified subject for the given tenant.static booleanisValidSubject(String tenant, String qualifiedSubject, boolean isConfigOrMode) Validates the given qualified subject for the given tenant.static StringNormalizes the given qualified subject name.static StringnormalizeContext(String context) Normalizes the given context name.static StringqualifiedContextFor(String tenant, String qualifiedSubject) Returns the qualified context for the given qualified subject.static QualifiedSubjectqualifySubjectWithParent(String tenant, String parent, String subjectWithoutTenant) Qualifies the given subject (which has no tenant) with the given parent context (which may have a tenant).static QualifiedSubjectqualifySubjectWithParent(String tenant, String parent, String subjectWithoutTenant, boolean prefixTenant) Qualifies the given subject (which has no tenant) with the given parent context (which may have a tenant).Returns the context and subject with the tenant prefix.toString()Returns the context without the tenant prefix.Returns the context and subject without the tenant prefix.
-
Field Details
-
DEFAULT_TENANT
- See Also:
-
DEFAULT_CONTEXT
- See Also:
-
TENANT_DELIMITER
- See Also:
-
CONTEXT_DELIMITER
- See Also:
-
CONTEXT_SEPARATOR
- See Also:
-
CONTEXT_PREFIX
- See Also:
-
WILDCARD
- See Also:
-
CONTEXT_WILDCARD
- See Also:
-
GLOBAL_CONTEXT_NAME
- See Also:
-
GLOBAL_SUBJECT_NAME
- See Also:
-
EMPTY_SUBJECT_NAME
- See Also:
-
-
Constructor Details
-
QualifiedSubject
-
QualifiedSubject
-
-
Method Details
-
getTenant
-
getContext
-
getSubject
-
equals
-
hashCode
public int hashCode() -
toString
-
toQualifiedContext
-
toUnqualifiedContext
Returns the context without the tenant prefix. -
toQualifiedSubject
Returns the context and subject with the tenant prefix. -
toUnqualifiedSubject
Returns the context and subject without the tenant prefix. -
isQualified
Checks if the given subject is qualified with the given tenant.- Parameters:
tenant- the tenantqualifiedSubject- the subject with a tenant prefix- Returns:
- true if the subject is qualified with the tenant, false otherwise
-
create
Creates a QualifiedSubject from the given tenant and qualified subject.- Parameters:
tenant- the tenantqualifiedSubject- the subject with a tenant prefix- Returns:
- the QualifiedSubject, or null if the qualified subject is null or invalid
-
createFromUnqualified
Creates a QualifiedSubject from the given tenant and unqualified subject.- Parameters:
tenant- the tenantunqualifiedSubject- the subject without a tenant prefix- Returns:
- the QualifiedSubject, or null if the unqualified subject is null or invalid
-
contextFor
Returns the context for the given qualified subject.- Parameters:
tenant- the tenantqualifiedSubject- the subject with a tenant prefix- Returns:
- the context, or DEFAULT_CONTEXT if the qualified subject is null or invalid
-
qualifiedContextFor
Returns the qualified context for the given qualified subject.- Parameters:
tenant- the tenantqualifiedSubject- the subject with a tenant prefix- Returns:
- the qualified context, or empty string if the qualified subject is null or invalid
-
isSubjectInContext
public static boolean isSubjectInContext(String tenant, String qualifiedSubject, QualifiedSubject qualifiedContext) Checks if the given qualified subject is a context for the given qualified subject.- Parameters:
tenant- the tenantqualifiedSubject- the subject with a tenant prefixqualifiedContext- the context with a tenant prefix, which must not specify a subject- Returns:
- true if the subject is in the context, false otherwise
-
qualifySubjectWithParent
public static QualifiedSubject qualifySubjectWithParent(String tenant, String parent, String subjectWithoutTenant) Qualifies the given subject (which has no tenant) with the given parent context (which may have a tenant). If the parent has a context, it is used as the context for the subject. If the parent has no context, the subject is placed in the default context.- Parameters:
tenant- the tenant to use if the parent has no tenantparent- the parent context, which may have a tenantsubjectWithoutTenant- the subject without a tenant- Returns:
- the qualified subject, or null if the subjectWithoutTenant is null or invalid
-
qualifySubjectWithParent
public static QualifiedSubject qualifySubjectWithParent(String tenant, String parent, String subjectWithoutTenant, boolean prefixTenant) Qualifies the given subject (which has no tenant) with the given parent context (which may have a tenant). If the parent has a context, it is used as the context for the subject. If the parent has no context, the subject is placed in the default context.- Parameters:
tenant- the tenant to use if the parent has no tenantparent- the parent context, which may have a tenantsubjectWithoutTenant- the subject without a tenantprefixTenant- if true, the returned qualified subject will have the tenant prefixed- Returns:
- the qualified subject, or null if the subjectWithoutTenant is null or invalid
-
normalize
Normalizes the given qualified subject name.- Parameters:
tenant- the tenantqualifiedSubject- the subject with a tenant prefix- Returns:
- the normalized subject name
-
normalizeContext
Normalizes the given context name.- Parameters:
context- the context name- Returns:
- the normalized context name, or null if the context is null
- Throws:
IllegalArgumentException- if the context name is invalid
-
isContext
Checks if the given qualified subject represents a context (i.e., has no subject part). A context has the format ":.context:" with an empty subject part, or null for default context.- Parameters:
tenant- the tenantqualifiedSubject- the subject with a tenant prefix- Returns:
- true if the qualified subject is a context, false otherwise
-
isDefaultContext
Checks if the given qualified subject is the default context for the given tenant. The default context is the context with name "." and an empty subject.- Parameters:
tenant- the tenantqualifiedSubject- the subject with a tenant prefix- Returns:
- true if the qualified subject is the default context, false otherwise
-
isGlobalContext
Checks if the given qualified subject is the global context for the given tenant. The global context is the context with name ".__GLOBAL" and an empty subject.- Parameters:
tenant- the tenantqualifiedSubject- the subject with a tenant prefix- Returns:
- true if the qualified subject is the global context, false otherwise
-
isValidSubject
Validates the given qualified subject for the given tenant. A valid subject must not be null, must not contain control characters, must not be "__GLOBAL" or "__EMPTY", and must not be in the global context unless isConfigOrMode is true.- Parameters:
tenant- the tenantqualifiedSubject- the subject with a tenant prefix- Returns:
- true if the qualified subject is valid, false otherwise
-
isValidSubject
public static boolean isValidSubject(String tenant, String qualifiedSubject, boolean isConfigOrMode) Validates the given qualified subject for the given tenant. A valid subject must not be null, must not contain control characters, must not be "__GLOBAL" or "__EMPTY", and must not be in the global context unless isConfigOrMode is true.- Parameters:
tenant- the tenantqualifiedSubject- the subject with a tenant prefixisConfigOrMode- true if the subject is for config or mode settings- Returns:
- true if the qualified subject is valid, false otherwise
-
compareTo
- Specified by:
compareToin interfaceComparable<QualifiedSubject>
-