项目作者: sample-by-jsakamoto

项目描述 :
Two Factor Auth OTP Code generation demo by Java (powered by "aerogear-otp-java")
高级语言: Java
项目地址: git://github.com/sample-by-jsakamoto/2fa-OTPCode-generation-demo-by-Java.git
创建时间: 2018-01-17T14:01:03Z
项目社区:https://github.com/sample-by-jsakamoto/2fa-OTPCode-generation-demo-by-Java

开源协议:The Unlicense

下载


Two Factor Auth OTP Code generation demo by Java (powered by “aerogear-otp-java”)

Requirement

  • Java JDK 8
  • Maven ver.3

How to build?

Execute follow command,

  1. > mvn package

then myapp-1.0-SNAPSHOT-jar-with-dependencies.jar will be created in targets folder.

How to run?

Execute follow command,

  1. > java -jar target\myapp-1.0-SNAPSHOT-jar-with-dependencies.jar

then you can get OTP code in console.

NOTICE: secret key for OTP is hard coded in .java source file, because this is demonstration code.
The secret key comes from this sample code.

How to compute OTP code?

Powered by aerogear-otp-java.

All of the java source code of this sample is this:

  1. package com.myapp;
  2. import org.jboss.aerogear.security.otp.Totp;
  3. public class App
  4. {
  5. public static void main( String[] args )
  6. {
  7. // Sample secret key: see http://j.mp/2mOovSV
  8. String secretKey = "6jm7n6xwitpjooh7ihewyyzeux7aqmw2";
  9. Totp totp = new Totp(secretKey);
  10. System.out.println(totp.now());
  11. }
  12. }

License

The Unlicense