diff --git a/backend/framework/sdk/pom.xml b/backend/framework/sdk/pom.xml
index 51f9c3180f..b1b225e032 100644
--- a/backend/framework/sdk/pom.xml
+++ b/backend/framework/sdk/pom.xml
@@ -418,8 +418,13 @@
org.eclipse.jgit
${jgit.version}
+
+
+ com.github.bastiaanjansen
+ otp-java
+ ${otp-java.version}
+
-
diff --git a/backend/framework/sdk/src/test/java/TestTotp.java b/backend/framework/sdk/src/test/java/TestTotp.java
new file mode 100644
index 0000000000..eac62cd31f
--- /dev/null
+++ b/backend/framework/sdk/src/test/java/TestTotp.java
@@ -0,0 +1,90 @@
+import com.bastiaanjansen.otp.HMACAlgorithm;
+import com.bastiaanjansen.otp.HOTPGenerator;
+import com.bastiaanjansen.otp.SecretGenerator;
+import com.bastiaanjansen.otp.TOTPGenerator;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+import java.time.Duration;
+import java.util.UUID;
+
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+public class TestTotp {
+ public static String code;
+ // Generate a secret (or use your own secret)
+// private static final byte[] secret = SecretGenerator.generate(256);
+ private static final byte[] secret = UUID.randomUUID().toString().getBytes();
+
+ @Test
+ @Order(1)
+ public void testGenerateTotp() {
+
+
+ TOTPGenerator totpGenerator = new TOTPGenerator.Builder(secret)
+ .withHOTPGenerator(builder -> {
+ builder.withPasswordLength(6);
+ builder.withAlgorithm(HMACAlgorithm.SHA256); // SHA256 and SHA512 are also supported
+ })
+ .withPeriod(Duration.ofSeconds(60))
+ .build();
+
+
+ try {
+ code = totpGenerator.now();
+ System.out.println(code);
+
+ } catch (IllegalStateException e) {
+ // Handle error
+ }
+ }
+
+ @Test
+ @Order(2)
+ public void testVerifyTotp() {
+
+ TOTPGenerator totpGenerator = new TOTPGenerator.Builder(secret)
+ .withHOTPGenerator(builder -> {
+ builder.withPasswordLength(6);
+ builder.withAlgorithm(HMACAlgorithm.SHA256); // SHA256 and SHA512 are also supported
+ })
+ .withPeriod(Duration.ofSeconds(60))
+ .build();
+
+
+ try {
+
+ // To verify a token:
+ boolean isValid = totpGenerator.verify(code);
+ System.out.println(isValid);
+ } catch (IllegalStateException e) {
+ // Handle error
+ }
+ }
+
+ @Test
+ @Order(3)
+ public void testGenerateHotp() {
+
+ HOTPGenerator hotp = new HOTPGenerator.Builder(secret)
+ .withAlgorithm(HMACAlgorithm.SHA256) // SHA256 and SHA512 are also supported
+ .withPasswordLength(6)
+ .build();
+ code = hotp.generate(1);// 1 is the counter value
+ System.out.println(code);
+ }
+
+ @Test
+ @Order(4)
+ public void testVerifyHotp() {
+
+ HOTPGenerator hotp = new HOTPGenerator.Builder(secret)
+ .withAlgorithm(HMACAlgorithm.SHA256) // SHA256 and SHA512 are also supported
+ .withPasswordLength(6)
+ .build();
+
+ boolean verify = hotp.verify(code, 1);
+ System.out.println(verify);
+ }
+}
diff --git a/pom.xml b/pom.xml
index c38aa0d08a..523a272f7a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,6 +86,7 @@
5.4.0
22.3.1
3.0.0-RC5
+ 2.0.1
1.12.1
v16.10.0