public class KafkaPrincipal extends Object implements 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 String |
USER_TYPE |
Constructor and Description |
---|
KafkaPrincipal(String principalType,
String name) |
KafkaPrincipal(String principalType,
String name,
boolean tokenAuthenticated) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
static KafkaPrincipal |
fromString(String str)
Deprecated.
As of 1.0.0. This method will be removed in a future major release.
|
String |
getName() |
String |
getPrincipalType() |
int |
hashCode() |
boolean |
tokenAuthenticated() |
void |
tokenAuthenticated(boolean tokenAuthenticated) |
String |
toString() |
public static final String USER_TYPE
public static final KafkaPrincipal ANONYMOUS
@Deprecated public static KafkaPrincipal fromString(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 String toString()
public boolean equals(Object o)
public int hashCode()
public String getPrincipalType()
public void tokenAuthenticated(boolean tokenAuthenticated)
public boolean tokenAuthenticated()