We have an implementation of IAuthenticator that authenticates clients against Cassandra. The client authenticates w/ Hector by passing a token in the credentials map (the map passed via HFactory.createKeyspace) and the token passed is only valid for so many hours. The client sees an AuthenticationException when the IAuthenticator implementation attempts to authenticate with the expired token.
I had assumed once the user is authenticated, authenticate would not be called again for that user, but I've found this is not always the case. I guess one possibility for this is the client had never previously contacted the node and then fails because the client attempts to use the expired token.
So how can I update the token used to authenticate? Is it just a matter of updating the credentials map with the refreshed token (as in the code below) or do I need to recreate the Keyspace instance (or something more complicated)?
final Map<String, String> credentials = new ConcurrentHashMap<String, String>();
credentials.put("token", getNewToken());
Keyspace keyspace = HFactory.createKeyspace("name", cluster, consistencyLevel, FailoverPolicy.ON_FAIL_TRY_ALL_AVAILABLE, credentials);
and then just before expiration...
credentials.put("token", getNewToken());
