public class KafkaPrincipal
extends java.lang.Object
implements java.security.Principal
Principals in Kafka are defined by a type and a name. The principal type will always be "User"
for the simple authorizer that is enabled by default, but custom authorizers can leverage different
principal types (such as to enable group or role-based ACLs). The KafkaPrincipalBuilder interface
is used when you need to derive a different principal type from the authentication context, or when
you need to represent relations between different principals. For example, you could extend
KafkaPrincipal in order to link a user principal to one or more role principals.
For custom extensions of KafkaPrincipal, there two key points to keep in mind:
KafkaPrincipal extensions are only useful when the corresponding Authorizer
is also aware of the extension. If you have a KafkaPrincipalBuilder which derives user groups
from the authentication context (e.g. from an SSL client certificate), then you need a custom
authorizer which is capable of using the additional group information.
| Modifier and Type | Field and Description |
|---|---|
static KafkaPrincipal |
ANONYMOUS |
static java.lang.String |
USER_TYPE |
| Constructor and Description |
|---|
KafkaPrincipal(java.lang.String principalType,
java.lang.String name) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o) |
static KafkaPrincipal |
fromString(java.lang.String str)
Deprecated.
As of 1.0.0. This method will be removed in a future major release.
|
java.lang.String |
getName() |
java.lang.String |
getPrincipalType() |
int |
hashCode() |
boolean |
tokenAuthenticated() |
void |
tokenAuthenticated(boolean tokenAuthenticated) |
java.lang.String |
toString() |
public static final java.lang.String USER_TYPE
public static final KafkaPrincipal ANONYMOUS
public KafkaPrincipal(java.lang.String principalType,
java.lang.String name)
@Deprecated public static KafkaPrincipal fromString(java.lang.String str)
KafkaPrincipal instance from a string. This method cannot be used for KafkaPrincipal
extensions.str - The input string formatted as "{principalType}:{principalName}"KafkaPrincipal instancepublic java.lang.String toString()
toString in interface java.security.PrincipaltoString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in interface java.security.Principalequals in class java.lang.Objectpublic int hashCode()
hashCode in interface java.security.PrincipalhashCode in class java.lang.Objectpublic java.lang.String getName()
getName in interface java.security.Principalpublic java.lang.String getPrincipalType()
public void tokenAuthenticated(boolean tokenAuthenticated)
public boolean tokenAuthenticated()