19 package org.sleuthkit.autopsy.modules.embeddedfileextractor;
21 import java.awt.event.ActionEvent;
22 import java.nio.file.Paths;
23 import java.util.concurrent.ExecutionException;
24 import java.util.logging.Level;
25 import javax.swing.AbstractAction;
26 import javax.swing.JOptionPane;
27 import javax.swing.SwingWorker;
29 import net.sf.sevenzipjbinding.SevenZipNativeInitializationException;
30 import org.openide.util.NbBundle.Messages;
31 import org.openide.windows.WindowManager;
59 @Messages({
"ExtractArchiveWithPasswordAction.name.text=Unzip contents with password",
"ExtractArchiveWithPasswordAction.prompt.text=Enter Password",
60 "ExtractArchiveWithPasswordAction.prompt.title=Enter Password",
61 "ExtractArchiveWithPasswordAction.extractFailed.title=Failed to Unpack Files, with Password",
62 "# {0} - archiveFile",
63 "ExtractArchiveWithPasswordAction.progress.text=Unpacking contents of archive: {0}"})
65 super(Bundle.ExtractArchiveWithPasswordAction_name_text());
71 String password =
getPassword(Bundle.ExtractArchiveWithPasswordAction_prompt_title(),
"");
72 if (password != null) {
74 extractWorker.execute();
78 private String
getPassword(String title, String oldPassword) {
79 String password = null;
80 Object inputValue = JOptionPane.showInputDialog(WindowManager.getDefault().getMainWindow(), Bundle.ExtractArchiveWithPasswordAction_prompt_text(),
81 title, JOptionPane.PLAIN_MESSAGE, null, null, oldPassword);
82 if (inputValue != null) {
83 password = (String) inputValue;
112 boolean done =
false;
119 progress.
start(Bundle.ExtractArchiveWithPasswordAction_progress_text(archive.getName()));
127 SevenZipExtractor extractor =
new SevenZipExtractor(null, fileTypeDetector, moduleDirRelative, moduleDirAbsolute);
128 done = extractor.unpack(archive, password);
129 }
catch (SevenZipNativeInitializationException ex) {
131 logger.log(Level.INFO,
"Unable to extract file with password", ex);
135 logger.log(Level.SEVERE,
"Error getting open case unable to perform extraction action", ex);
144 boolean done =
false;
148 password =
getPassword(Bundle.ExtractArchiveWithPasswordAction_extractFailed_title(),
password);
149 if (password == null) {
155 }
catch (InterruptedException ex) {
156 logger.log(Level.SEVERE,
"Unable to extract archive successfully", ex);
157 }
catch (ExecutionException ex) {
158 logger.log(Level.SEVERE,
"Execution Exception: Unable to extract archive successfully", ex.getCause());
String getModuleOutputDirectoryRelativePath()
static Case getOpenCase()
synchronized void start(String message, int totalWorkUnits)
void postMessage(final IngestMessage message)
String getModuleDirectory()
void actionPerformed(ActionEvent e)
synchronized static Logger getLogger(String name)
static IngestMessage createWarningMessage(String source, String subject, String detailsHtml)
static synchronized IngestServices getInstance()
synchronized void finish()