From fc8f6eca0c93cb43973a7b042f624d4de754b68e Mon Sep 17 00:00:00 2001 From: Zoltan Haindrich Date: Wed, 11 Mar 2020 11:22:53 +0100 Subject: [PATCH] add jceks-decode --- build.gradle | 2 +- src/main/java/hu/rxd/toolbox/Toolbox.java | 40 ++++++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 53f3183..f2a1ce6 100644 --- a/build.gradle +++ b/build.gradle @@ -81,7 +81,7 @@ compile 'org.slf4j:slf4j-simple:1.7.25' compile 'hu.rxd:lexirex:+' // https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit -compile group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '4.11.0.201803080745-r' +compile group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '5.6.1.202002131546-r' compile 'org.rauschig:jarchivelib:0.7.1' // https://mvnrepository.com/artifact/org.codehaus.plexus/plexus-utils diff --git a/src/main/java/hu/rxd/toolbox/Toolbox.java b/src/main/java/hu/rxd/toolbox/Toolbox.java index b5cab7f..9044538 100644 --- a/src/main/java/hu/rxd/toolbox/Toolbox.java +++ b/src/main/java/hu/rxd/toolbox/Toolbox.java @@ -19,34 +19,64 @@ package hu.rxd.toolbox; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.PrintStream; +import java.math.BigInteger; import java.net.URL; +import java.security.Key; +import java.security.KeyStore; import java.util.ArrayList; import java.util.Arrays; +import java.util.Enumeration; import java.util.List; import java.util.Random; -import org.apache.commons.io.FileUtils; +import javax.crypto.SecretKey; + +import org.apache.commons.collections.EnumerationUtils; +import org.apache.xerces.impl.dv.util.Base64; import com.google.common.base.Joiner; +import com.google.common.collect.Iterables; import hu.rxd.toolbox.jenkins.TestEntries; import hu.rxd.toolbox.jira.HiveTicket; -import hu.rxd.toolbox.jira.ToolboxSettings; import hu.rxd.toolbox.qtest.IInputStreamDispatcher; import hu.rxd.toolbox.qtest.LastQAReportInputStreamDispatcher; import hu.rxd.toolbox.qtest.LocalFileDispatcher; import hu.rxd.toolbox.qtest.LocalizedArchiveDispatcher; import hu.rxd.toolbox.qtest.QTDiffRunner; -import hu.rxd.toolbox.qtest.diff.CachedURL; -import net.rcarz.jiraclient.Attachment; -import net.rcarz.jiraclient.Comment; public class Toolbox { public static void main(String[] args) throws FileNotFoundException, Exception { + if (args[0].equals("jceks-decode")) { + String fileName = args[1]; + char[] password = "none".toCharArray(); + // String alias = args[2]; + + KeyStore ks = KeyStore.getInstance("JCEKS"); + try (FileInputStream fis = new FileInputStream(fileName)) { + ks.load(fis, password); + Enumeration aa = ks.aliases(); + for (String alias : (List) EnumerationUtils.toList(aa)) { + SecretKey secretKey = (SecretKey) ks.getKey(alias, password); + String secret = new String(secretKey.getEncoded()); + + System.out.println("alias: " + alias); + System.out.println("secret: " + secret); + // System.out.println(Base64.decode(secret)); +// System.out.println(new BigInteger(1, secretKey.getEncoded()).toString(16)); +// System.out.println(secretKey.getEncoded()); +// Key key = secretKey; + + } + } + return; + } + if (args[0].equals("reattach")) { TicketUtils.reattach(args[1]); return;