class BrokerAccessTokenProvider implements AccessTokenProvider {

    @Override
    public void refresh() {
        // Retrieve the current and login users from the ambient context
        UserGroupInformation currentUser;
        UserGroupInformation loginUser;
        try {
            currentUser = UserGroupInformation.getCurrentUser();
            loginUser = UserGroupInformation.getLoginUser();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        // Instantiate the proper credentials class based on the type of authentication (direct or delegated)
        BrokerServerInfo serverInfo = Utils.getBrokerDetailsFromConfig(config);
        BrokerBaseCredentials credentials;
        if (tokenIdentifier == null) {
            // Use direct authentication
            credentials = new BrokerKerberosCredentials(
                serverInfo,
                currentUser.getUserName(),
                Collections.singleton(BrokerTokenIdentifier.GCS_SCOPE),
                Utils.getTarget(config, service));
        }
        else {
            // Use delegated authentication
            credentials = new BrokerSessionCredentials(serverInfo, tokenIdentifier.getSessionToken());
        }

        // Generate the access token
        loginUser.doAs((PrivilegedAction<Void>) () -> {
            try {
                credentials.refresh();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return null;
        });
        com.google.auth.oauth2.AccessToken token = credentials.getAccessToken();
        accessToken = new AccessToken(token.getTokenValue(), token.getExpirationTime().getTime());
    }

    public  BrokerAccessTokenProvider(Text service);
    public  BrokerAccessTokenProvider(Text service, BrokerTokenIdentifier bti);

}