use keys.key and keys.pub as default filename
@@ -88,11 +88,14 @@ public class KeyGeneratorImpl implements KeyGenerator {
System.out.println("Enter a relative or absolute path (without extension) to save the keys to");
System.out.println("or leave blank to not save to separate file:");
- final String path = new Scanner(filenameStream).nextLine();
- final String privateKeyJson = this.privateKeyToJson(finalKeys);
+ String path = new Scanner(filenameStream).nextLine();
+
+ if (path.trim().isEmpty()) {
+ path = "keys";
+ }
- if (!path.trim().isEmpty()) {
+ final String privateKeyJson = this.privateKeyToJson(finalKeys);
final Path resolvedPath = Paths.get(path).toAbsolutePath();
final Path parentPath = resolvedPath.getParent();
@@ -103,13 +106,7 @@ public class KeyGeneratorImpl implements KeyGenerator {
IOCallback.execute(() -> Files.write(publicKeyPath, publicKeyBase64.getBytes(UTF_8)));
IOCallback.execute(() -> Files.write(privateKeyPath, privateKeyJson.getBytes(UTF_8)));
- }
- else {
- System.out.println("-----PUBLIC KEY-----");
- System.out.println(publicKeyBase64);
- System.out.println("-----PRIVATE KEY-----");
- System.out.println(privateKeyJson);
- }
+
return finalKeys;
}
