19 package org.sleuthkit.autopsy.modules.embeddedfileextractor;
21 import java.awt.event.ActionEvent;
22 import java.nio.file.Paths;
23 import java.util.concurrent.ConcurrentHashMap;
24 import java.util.concurrent.ExecutionException;
25 import java.util.logging.Level;
26 import javax.swing.AbstractAction;
27 import javax.swing.JOptionPane;
28 import javax.swing.SwingWorker;
30 import net.sf.sevenzipjbinding.SevenZipNativeInitializationException;
31 import org.openide.util.NbBundle.Messages;
32 import org.openide.windows.WindowManager;
60 @Messages({
"ExtractArchiveWithPasswordAction.name.text=Unzip contents with password",
"ExtractArchiveWithPasswordAction.prompt.text=Enter Password",
61 "ExtractArchiveWithPasswordAction.prompt.title=Enter Password",
62 "ExtractArchiveWithPasswordAction.extractFailed.title=Failed to Unpack Files, with Password",
63 "# {0} - archiveFile",
64 "ExtractArchiveWithPasswordAction.progress.text=Unpacking contents of archive: {0}"})
66 super(Bundle.ExtractArchiveWithPasswordAction_name_text());
72 String password =
getPassword(Bundle.ExtractArchiveWithPasswordAction_prompt_title(),
"");
73 if (password != null) {
75 extractWorker.execute();
79 private String
getPassword(String title, String oldPassword) {
80 String password = null;
81 Object inputValue = JOptionPane.showInputDialog(WindowManager.getDefault().getMainWindow(), Bundle.ExtractArchiveWithPasswordAction_prompt_text(),
82 title, JOptionPane.PLAIN_MESSAGE, null, null, oldPassword);
83 if (inputValue != null) {
84 password = (String) inputValue;
113 boolean done =
false;
120 progress.
start(Bundle.ExtractArchiveWithPasswordAction_progress_text(archive.getName()));
128 SevenZipExtractor extractor =
new SevenZipExtractor(null, fileTypeDetector, moduleDirRelative, moduleDirAbsolute,
new FileTaskExecutor(null));
129 done = extractor.unpack(archive,
new ConcurrentHashMap<>(), password);
130 }
catch (SevenZipNativeInitializationException ex) {
132 logger.log(Level.INFO,
"Unable to extract file with password", ex);
136 logger.log(Level.SEVERE,
"Error getting open case unable to perform extraction action", ex);
145 boolean done =
false;
149 password =
getPassword(Bundle.ExtractArchiveWithPasswordAction_extractFailed_title(),
password);
150 if (password == null) {
156 }
catch (InterruptedException ex) {
157 logger.log(Level.SEVERE,
"Unable to extract archive successfully", ex);
158 }
catch (ExecutionException ex) {
159 logger.log(Level.SEVERE,
"Execution Exception: Unable to extract archive successfully", ex.getCause());
String getModuleOutputDirectoryRelativePath()
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 Case getCurrentCaseThrows()
static IngestMessage createWarningMessage(String source, String subject, String detailsHtml)
static synchronized IngestServices getInstance()
synchronized void finish()