38
38
import java .util .Base64 ;
39
39
import java .util .Optional ;
40
40
import java .util .concurrent .ExecutionException ;
41
+ import java .util .concurrent .TimeUnit ;
42
+ import java .util .concurrent .TimeoutException ;
41
43
import javax .naming .AuthenticationException ;
42
44
import lombok .AllArgsConstructor ;
43
45
import lombok .extern .slf4j .Slf4j ;
@@ -99,8 +101,11 @@ public String authenticate(FullHttpRequest request) throws SchemaStorageExceptio
99
101
throw new SchemaStorageException ("Pulsar is not configured for Token auth" );
100
102
}
101
103
try {
104
+ AuthData authData = AuthData .of (password .getBytes (StandardCharsets .UTF_8 ));
102
105
final AuthenticationState authState = authenticationProvider
103
- .newAuthState (AuthData .of (password .getBytes (StandardCharsets .UTF_8 )), null , null );
106
+ .newAuthState (authData , null , null );
107
+ // TODO: Use the configurable timeout
108
+ authState .authenticateAsync (authData ).get (10 , TimeUnit .SECONDS );
104
109
final String role = authState .getAuthRole ();
105
110
106
111
final String tenant ;
@@ -118,7 +123,7 @@ public String authenticate(FullHttpRequest request) throws SchemaStorageExceptio
118
123
119
124
performAuthorizationValidation (username , role , tenant );
120
125
return tenant ;
121
- } catch (AuthenticationException err ) {
126
+ } catch (ExecutionException | InterruptedException | TimeoutException | AuthenticationException err ) {
122
127
throw new SchemaStorageException (err );
123
128
}
124
129
0 commit comments