keycloak-uncached
Details
testsuite/integration/pom.xml 3(+0 -3)
diff --git a/testsuite/integration/pom.xml b/testsuite/integration/pom.xml
index a246609..03fbbff 100755
--- a/testsuite/integration/pom.xml
+++ b/testsuite/integration/pom.xml
@@ -268,9 +268,6 @@
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<mainClass>org.keycloak.testutils.TotpGenerator</mainClass>
- <arguments>
- <argument>${secret}</argument>
- </arguments>
</configuration>
</plugin>
</plugins>
testsuite/integration/README.md 4(+2 -2)
diff --git a/testsuite/integration/README.md b/testsuite/integration/README.md
index 3145d38..6eb01f1 100644
--- a/testsuite/integration/README.md
+++ b/testsuite/integration/README.md
@@ -30,11 +30,11 @@ TOTP codes
To generate totp codes without Google authenticator run:
- mvn exec:java -Ptotp -Dsecret='PJBX GURY NZIT C2JX I44T S3D2 JBKD G6SB'
+ mvn exec:java -Ptotp
or run org.keycloak.testutils.TotpGenerator from your favourite IDE!
-Replace value of -Dsecret with the secret from the totp configuration page (remember quotes!)
+Once started copy/paste the totp secret and press enter. To use a new secret just copy/paste and press enter again.
Mail server
-----------
diff --git a/testsuite/integration/src/main/java/org/keycloak/testutils/TotpGenerator.java b/testsuite/integration/src/main/java/org/keycloak/testutils/TotpGenerator.java
index ff0ac20..2808057 100755
--- a/testsuite/integration/src/main/java/org/keycloak/testutils/TotpGenerator.java
+++ b/testsuite/integration/src/main/java/org/keycloak/testutils/TotpGenerator.java
@@ -3,6 +3,10 @@ package org.keycloak.testutils;
import org.keycloak.models.utils.Base32;
import org.keycloak.models.utils.TimeBasedOTP;
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;
@@ -10,23 +14,38 @@ import java.util.concurrent.TimeUnit;
public class TotpGenerator {
- public static void main(String[] args) {
- String totp = "";
- for (String a : args) {
- totp += a.trim();
- }
- totp = totp.replace(" ", "");
+ public static void main(String[] args) throws IOException {
+
+ Timer timer = new Timer();
+ TotpTask task = null;
- final String google = new String(Base32.decode(totp));
- final TimeBasedOTP otp = new TimeBasedOTP();
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- Timer t = new Timer();
- t.schedule(new TimerTask() {
- @Override
- public void run() {
- System.out.println(otp.generate(google));
+ System.out.print("Insert secret: ");
+ for (String l = br.readLine(); true; l = br.readLine()) {
+ if (task != null) {
+ task.cancel();
}
- }, 0, TimeUnit.SECONDS.toMillis(TimeBasedOTP.DEFAULT_INTERVAL_SECONDS));
+
+ System.out.println("Secret: " + l);
+ task = new TotpTask(l);
+ timer.schedule(task, 0, TimeUnit.SECONDS.toMillis(TimeBasedOTP.DEFAULT_INTERVAL_SECONDS));
+ }
+ }
+
+ private static class TotpTask extends TimerTask {
+ private String secret;
+
+ private TotpTask(String secret) {
+ this.secret = secret;
+ }
+
+ @Override
+ public void run() {
+ String google = new String(Base32.decode(secret));
+ TimeBasedOTP otp = new TimeBasedOTP();
+ System.out.println(otp.generate(google));
+ }
}
}