diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index ce1c62c..bb02656 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -5,6 +5,7 @@
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 2758df8..eda6f86 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -4,7 +4,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 4f339e7..7fff9f6 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,7 +5,13 @@
+
+
+
+
+
+
@@ -34,22 +40,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -97,12 +87,13 @@
"Gradle.Keytool [signPlugin].executor": "Run",
"Gradle.Run Plugin.executor": "Run",
"Gradle.keytoolj [setupDependencies].executor": "Run",
- "Gradle.ssl-toolbox [publishPlugin].executor": "Run",
+ "Gradle.ssl-toolbox [publishPlugin].executor": "Debug",
"Gradle.ssl-toolbox [setupDependencies].executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"UI_DESIGNER_EDITOR_MODE.PaletteManager.SHOW": "true",
"git-widget-placeholder": "main",
+ "ignore.virus.scanning.warn.message": "true",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "/Users/cortiz/repos/jmpeax/ssl-toolbox/.github/workflows",
"node.js.detected.package.eslint": "true",
@@ -110,7 +101,7 @@
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
- "settings.editor.selected.configurable": "reference.settings.grazie.pro",
+ "settings.editor.selected.configurable": "reference.settingsdialog.project.gradle",
"vue.rearranger.settings.migration": "true"
}
}
@@ -197,8 +188,8 @@
-
+
@@ -237,6 +228,8 @@
+
+
diff --git a/src/main/java/com/jmpeax/ssltoolbox/jks/JKSView.java b/src/main/java/com/jmpeax/ssltoolbox/jks/JKSView.java
index f1460c4..db522f4 100644
--- a/src/main/java/com/jmpeax/ssltoolbox/jks/JKSView.java
+++ b/src/main/java/com/jmpeax/ssltoolbox/jks/JKSView.java
@@ -1,8 +1,13 @@
package com.jmpeax.ssltoolbox.jks;
import com.intellij.icons.AllIcons;
+import com.intellij.openapi.actionSystem.ActionGroup;
+import com.intellij.openapi.actionSystem.ActionManager;
+import com.intellij.openapi.actionSystem.ActionToolbar;
+import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.components.JBLabel;
@@ -152,44 +157,55 @@ private JPanel createUnlockButton() {
}
private JPanel buildToolBar() {
+ ActionGroup actionGroup = (ActionGroup) ActionManager.getInstance().getAction("JKS-Actions");
+ ActionToolbar actionToolBar = ActionManager.getInstance().createActionToolbar("JKS-Actions-Toolbar", actionGroup, true);
+ actionToolBar.setTargetComponent(this);
+
+ DataContext dataContext = dataId -> this.file;
+ actionToolBar.getComponent().putClientProperty(DataContext.class, dataContext);
+
JPanel panel = new JPanel(new GridLayout(1,1));
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = JBUI.insets(5);
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.WEST;
-
- JButton openButton = new JButton(AllIcons.ToolbarDecorator.Import);
- openButton.setToolTipText("Open");
- openButton.setPreferredSize(new Dimension(AllIcons.ToolbarDecorator.Import.getIconWidth() + 10, AllIcons.ToolbarDecorator.Import.getIconHeight() + 10));
- openButton.setBorderPainted(false);
- openButton.addActionListener(e -> {
- var descriptor = new FileChooserDescriptor(
- true, // Choose Files
- false,
- false,
- false,
- false,
- false
- );
- VirtualFile file = FileChooser.chooseFile(descriptor, null, null);
- if (file != null) {
- var str = Messages.showInputDialog("Enter Alias for " + file.getName(), "Alias for Imported Certificate", null);
- LoggerFactory.getLogger(JKSView.class).info("Selected file: alias {} {}", str, file.getPath());
- this.listModel.addElement(str);
- }
- });
gbc.gridx = 0;
gbc.gridy = 0;
- panel.add(openButton, gbc);
- JButton saveButton = new JButton(AllIcons.ToolbarDecorator.Export);
- saveButton.setPreferredSize(new Dimension(AllIcons.ToolbarDecorator.Export.getIconWidth() + 10, AllIcons.ToolbarDecorator.Export.getIconHeight() + 10));
- saveButton.setToolTipText("Save");
- saveButton.addActionListener(e -> {
- });
- gbc.gridx = 1;
- panel.add(saveButton, gbc);
-
+ panel.add(actionToolBar.getComponent(), gbc);
return panel;
+//
+// JButton openButton = new JButton(AllIcons.ToolbarDecorator.Import);
+// openButton.setToolTipText("Open");
+// openButton.setPreferredSize(new Dimension(AllIcons.ToolbarDecorator.Import.getIconWidth() + 10, AllIcons.ToolbarDecorator.Import.getIconHeight() + 10));
+// openButton.setBorderPainted(false);
+// openButton.addActionListener(e -> {
+// var descriptor = new FileChooserDescriptor(
+// true, // Choose Files
+// false,
+// false,
+// false,
+// false,
+// false
+// );
+// VirtualFile file = FileChooser.chooseFile(descriptor, null, null);
+// if (file != null) {
+// var str = Messages.showInputDialog("Enter Alias for " + file.getName(), "Alias for Imported Certificate", null);
+// LoggerFactory.getLogger(JKSView.class).info("Selected file: alias {} {}", str, file.getPath());
+// this.listModel.addElement(str);
+// }
+// });
+// gbc.gridx = 0;
+// gbc.gridy = 0;
+// panel.add(openButton, gbc);
+// JButton saveButton = new JButton(AllIcons.ToolbarDecorator.Export);
+// saveButton.setPreferredSize(new Dimension(AllIcons.ToolbarDecorator.Export.getIconWidth() + 10, AllIcons.ToolbarDecorator.Export.getIconHeight() + 10));
+// saveButton.setToolTipText("Save");
+// saveButton.addActionListener(e -> {
+// });
+// gbc.gridx = 1;
+// panel.add(saveButton, gbc);
+//
+// return panel;
}
private void updateView(Map certs) {
diff --git a/src/main/java/com/jmpeax/ssltoolbox/jks/actions/ImportCert.java b/src/main/java/com/jmpeax/ssltoolbox/jks/actions/ImportCert.java
new file mode 100644
index 0000000..b4654b9
--- /dev/null
+++ b/src/main/java/com/jmpeax/ssltoolbox/jks/actions/ImportCert.java
@@ -0,0 +1,51 @@
+package com.jmpeax.ssltoolbox.jks.actions;
+
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.CommonDataKeys;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.fileChooser.FileChooser;
+import com.intellij.openapi.fileChooser.FileChooserDescriptor;
+import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.jmpeax.ssltoolbox.svc.CertificateHelper;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.IOException;
+
+public class ImportCert extends AnAction {
+
+ private static final Logger LOGGER = Logger.getInstance(ImportCert.class);
+
+ @Override
+ public void actionPerformed(@NotNull AnActionEvent e) {
+ try {
+ var f = e.getData(CommonDataKeys.VIRTUAL_FILE);
+ if (f == null) {
+ LOGGER.warn("JKS not send to the Action");
+ return;
+ }
+ var descriptor = new FileChooserDescriptor(
+ true, // Choose Files
+ false,
+ false,
+ false,
+ false,
+ false
+ );
+ VirtualFile file = FileChooser.chooseFile(descriptor, null, null);
+ if (file == null) {
+ LOGGER.warn("User did not select a certificate");
+ return;
+ }
+ Messages.showInputDialog("Cert alias","Certificate Alias", Messages.getQuestionIcon());
+ var pwd = Messages.showPasswordDialog("Keystore password", "KeyStore Password");
+ if (pwd != null && !pwd.isBlank()) {
+ CertificateHelper.importCertificate(f.getInputStream(), file.getInputStream(), pwd.toCharArray());
+ }
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+}
diff --git a/src/main/java/com/jmpeax/ssltoolbox/svc/CertificateHelper.java b/src/main/java/com/jmpeax/ssltoolbox/svc/CertificateHelper.java
index 9f73c95..3f8cf5f 100644
--- a/src/main/java/com/jmpeax/ssltoolbox/svc/CertificateHelper.java
+++ b/src/main/java/com/jmpeax/ssltoolbox/svc/CertificateHelper.java
@@ -109,4 +109,7 @@ public static Map getKeyStoreCerts(InputStream keystoreI
return certs;
}
+ public static void importCertificate(@NotNull InputStream inputStream, @NotNull InputStream inputStream1, char[] charArray) {
+
+ }
}
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index d1b4c37..ed92e04 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -55,4 +55,17 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file