java.security.Principal
public class KafkaPrincipal
extends java.lang.Object
implements java.security.Principal
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:
1. To be compatible with the ACL APIs provided by Kafka (including the command line tool), each ACL
can only represent a permission granted to a single principal (consisting of a principal type and name).
It is possible to use richer ACL semantics, but you must implement your own mechanisms for adding
and removing ACLs.
2. In general, 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 | Description |
---|---|---|
static KafkaPrincipal |
ANONYMOUS |
|
static java.lang.String |
USER_TYPE |
Constructor | Description |
---|---|
KafkaPrincipal(java.lang.String principalType,
java.lang.String name) |
Modifier and Type | Method | 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.Principal
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in interface java.security.Principal
equals
in class java.lang.Object
public int hashCode()
hashCode
in interface java.security.Principal
hashCode
in class java.lang.Object
public java.lang.String getName()
getName
in interface java.security.Principal
public java.lang.String getPrincipalType()
public void tokenAuthenticated(boolean tokenAuthenticated)
public boolean tokenAuthenticated()