-
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 delete certificate action and enhance export functionality
Introduced a new 'Delete' action for certificates in the plugin. Enhanced the export functionality to allow saving the certificate to a specified file location, and added logging for better error tracking.
- Loading branch information
Showing
6 changed files
with
125 additions
and
19 deletions.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
src/main/java/com/jmpeax/ssltoolbox/jks/actions/DeletetCert.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,47 @@ | ||
package com.jmpeax.ssltoolbox.jks.actions; | ||
|
||
|
||
import com.intellij.openapi.actionSystem.AnAction; | ||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import com.intellij.openapi.actionSystem.CommonDataKeys; | ||
import com.intellij.openapi.actionSystem.PlatformDataKeys; | ||
import com.intellij.openapi.application.ApplicationManager; | ||
import com.intellij.openapi.ui.Messages; | ||
import com.jmpeax.ssltoolbox.jks.JKSView; | ||
import com.jmpeax.ssltoolbox.svc.CertificateHelper; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class DeletetCert extends AnAction { | ||
|
||
@Override | ||
public void actionPerformed(@NotNull AnActionEvent e) { | ||
|
||
var certificateHelper = ApplicationManager.getApplication().getService(CertificateHelper.class); | ||
var ksVirtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE); | ||
var view = getViewComponent(e); | ||
if (view == null) { | ||
Messages.showErrorDialog("No JKS view found", "No JKS View"); | ||
return; | ||
} | ||
var selectedAlias = view.getSelectedCertificate(); | ||
if (selectedAlias == null) { | ||
Messages.showErrorDialog("No certificate selected", "No Certificate Selected"); | ||
return; | ||
} | ||
var pwd = Messages.showPasswordDialog("Keystore password", "KeyStore Password"); | ||
if (pwd != null && !pwd.isBlank()) { | ||
certificateHelper.removeCertificate(ksVirtualFile, selectedAlias,pwd.toCharArray()); | ||
view.removeCertificate(selectedAlias); | ||
Messages.showInfoMessage("Certificate removed", "Certificate Removed"); | ||
} | ||
} | ||
|
||
|
||
|
||
private JKSView getViewComponent(@NotNull AnActionEvent e) { | ||
// Retrieve your view component from context, e.g., using the data context from the event | ||
return e.getData(PlatformDataKeys.CONTEXT_COMPONENT) instanceof JKSView | ||
? (JKSView) e.getData(PlatformDataKeys.CONTEXT_COMPONENT) | ||
: null; | ||
} | ||
} |
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
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