A Java library for generating one time passwords according to RFC 4226..
This API is compatible with Google Authenticator apps available for Android and iPhone. You can follow the instructions here to install Google Authenticator.
-
add the maven dependency
<dependency> <groupId>org.jboss.aerogear</groupId> <artifactId>aerogear-otp-java</artifactId> <version>1.0.0</version> <scope>compile</scope> </dependency>
-
Time based OTP's
String secret = Base32.random(); Totp totp = new Totp(secret); totp.now(); //427773 totp.verify("427773"); //true Thread.sleep(40); totp.verify("427773"); //false
- Go to http://controller-aerogear.rhcloud.com/aerogear-controller-demo/login
- Login with username: john and password: 123. Click on Give it a try.
- Now open google authenticator application at your phone
- Go to Add account
- Then ask to Scan barcode
- After that john account might be added
- On your web browser go to Try Google authenticator
- Enter username: john and password: 123 and use the current OTP on your mobile
For more details, please refer to our documentation
<dependency>
<groupId>org.jboss.aerogear</groupId>
<artifactId>aerogear-security</artifactId>
<version>1.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>