merlimat commented on a change in pull request #6074: PIP-55: Refresh
Authentication Credentials
URL: https://github.com/apache/pulsar/pull/6074#discussion_r370845931
##########
File path:
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderToken.java
##########
@@ -166,4 +179,61 @@ private SignatureAlgorithm
getPublicKeyAlgType(ServiceConfiguration conf) throws
return SignatureAlgorithm.RS256;
}
}
+
+ private static final class TokenAuthenticationState implements
AuthenticationState {
+ private final AuthenticationProviderToken provider;
+ private AuthenticationDataSource authenticationDataSource;
+ private Jwt<?, Claims> jwt;
+ private final SocketAddress remoteAddress;
+ private final SSLSession sslSession;
+ private long expiration;
+
+ TokenAuthenticationState(
+ AuthenticationProviderToken provider,
+ AuthData authData,
+ SocketAddress remoteAddress,
+ SSLSession sslSession) throws AuthenticationException {
+ this.provider = provider;
+ this.remoteAddress = remoteAddress;
+ this.sslSession = sslSession;
+ this.authenticate(authData);
+ }
+
+ @Override
+ public String getAuthRole() throws AuthenticationException {
+ return provider.getPrincipal(jwt);
+ }
+
+ @Override
+ public AuthData authenticate(AuthData authData) throws
AuthenticationException {
+ String token = new String(authData.getBytes(), UTF_8);
+
+ this.jwt = provider.authenticateToken(token);
+ this.authenticationDataSource = new
AuthenticationDataCommand(token, remoteAddress, sslSession);
+ if (jwt.getBody().getExpiration() != null) {
+ this.expiration = jwt.getBody().getExpiration().getTime();
+ } else {
+ this.expiration = 0;
Review comment:
Fixed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services