[aerogear-dev] Generated tokens stay the same?
Philip Gillißen
guerda at freenet.de
Tue Oct 27 11:03:00 EDT 2015
Dear list,
I recently discovered your library for TOTP and would like to include it in one of my applications.
Unfortunately, I discovered a situation where the library does not do the things I expected. I want to ask if this is me using the lib in a wrong way.
If I call generator.now() repeatedly, the token does not change, even if the timebox (30 seconds) is already finished.
Here's a small demo code to show my problem:
public static void main(String[] args) {
String secret = Base32.random();
Totp generator = new Totp(secret);
for (int i = 0; i < 10; i++) {
String tmpNow = generator.now();
System.out.println(tmpNow);
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
The printed out token is always the same. It only changes if I reinitialize the generator (Totp) with
generator = new Totp(secret); each time I want to generate a token.
My question is: Is this the desired behavior to only generate new tokens when the generator is newly created?
Do I have to call any other method to check if a new token would be now applicable?
Thanks in advance for your help!
Kind regards,
Philip
---
Alle Postfächer an einem Ort. Jetzt wechseln und E-Mail-Adresse mitnehmen! http://email.freenet.de/basic/Informationen
More information about the aerogear-dev
mailing list