-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add import certificate action and toolbar enhancement
Introduced a new toolbar action for importing certificates into JKS files. Updated `CertificateHelper` and related UI components to support the new import functionality. Adjusted project settings to use JDK 20.
- Loading branch information
Showing
7 changed files
with
128 additions
and
50 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/com/jmpeax/ssltoolbox/jks/actions/ImportCert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters