Class SaslRoleToken
java.lang.Object
org.apache.pulsar.broker.authentication.SaslRoleToken
- All Implemented Interfaces:
Principal
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SaslRoleTokenConstant that identifies an anonymous request. -
Constructor Summary
ConstructorsConstructorDescriptionSaslRoleToken(String userRole, String session) Creates an authentication token.SaslRoleToken(String userRole, String session, long expires) -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the expiration time of the token.getName()Returns the principal name (this method name comes from the JDKPrincipalinterface).Returns the authentication mechanism of the token.Returns the user name.booleanReturns if the token has expired.static SaslRoleTokenParses a string into an authentication token.voidsetExpires(long expires) Sets the expiration of the token.toString()Returns the string representation of the token.
-
Field Details
-
ANONYMOUS
Constant that identifies an anonymous request.
-
-
Constructor Details
-
SaslRoleToken
Creates an authentication token.- Parameters:
userRole- user name.session- the sessionId. (System.currentTimeMillis() + validityPeriod).
-
SaslRoleToken
-
-
Method Details
-
setExpires
public void setExpires(long expires) Sets the expiration of the token.- Parameters:
expires- expiration time of the token in milliseconds since the epoch.
-
getUserRole
Returns the user name.- Returns:
- the user name.
-
getName
Returns the principal name (this method name comes from the JDKPrincipalinterface). -
getSession
Returns the authentication mechanism of the token.- Returns:
- the authentication mechanism of the token.
-
getExpires
public long getExpires()Returns the expiration time of the token.- Returns:
- the expiration time of the token, in milliseconds since Epoc.
-
isExpired
public boolean isExpired()Returns if the token has expired.- Returns:
- if the token has expired.
-
toString
Returns the string representation of the token. This string representation is parseable by theparse(java.lang.String)method. -
parse
Parses a string into an authentication token.- Parameters:
tokenStr- string representation of a token.- Returns:
- the parsed authentication token.
- Throws:
AuthenticationException- thrown if the string representation could not be parsed into an authentication token.
-