added signature checking for javafx videos

This commit is contained in:
Trilok Shahi 2014-04-11 11:14:20 -04:00
parent 48452a8a27
commit ed4e01134c
4 changed files with 50 additions and 6 deletions

View File

@ -21,7 +21,9 @@ package org.sleuthkit.autopsy.corecomponents;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
@ -33,6 +35,8 @@ import org.openide.util.lookup.ServiceProviders;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer; import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
import org.sleuthkit.autopsy.coreutils.ImageUtils; import org.sleuthkit.autopsy.coreutils.ImageUtils;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.BlackboardAttribute;
import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM; import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
/** /**
@ -50,6 +54,7 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
private final MediaViewVideoPanel videoPanel; private final MediaViewVideoPanel videoPanel;
private final String[] videoExtensions; // get them from the panel private final String[] videoExtensions; // get them from the panel
private String[] imageExtensions; // use javafx supported private String[] imageExtensions; // use javafx supported
private final List<String> supportedMimes;
private final MediaViewImagePanel imagePanel; private final MediaViewImagePanel imagePanel;
private boolean videoPanelInited; private boolean videoPanelInited;
private boolean imagePanelInited; private boolean imagePanelInited;
@ -71,7 +76,7 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
imagePanelInited = imagePanel.isInited(); imagePanelInited = imagePanel.isInited();
videoExtensions = videoPanel.getExtensions(); videoExtensions = videoPanel.getExtensions();
supportedMimes = videoPanel.getMimeTypes();
customizeComponents(); customizeComponents();
logger.log(Level.INFO, "Created MediaView instance: " + this); logger.log(Level.INFO, "Created MediaView instance: " + this);
} }
@ -141,9 +146,10 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
this.switchPanels(false); this.switchPanels(false);
} else if (videoPanelInited } else if (videoPanelInited
&& (containsExt(file.getName(), videoExtensions) || containsExt(file.getName(), AUDIO_EXTENSIONS))) { && containsMimeType(selectedNode,supportedMimes)&&(containsExt(file.getName(), videoExtensions) || containsExt(file.getName(), AUDIO_EXTENSIONS))) {
videoPanel.setupVideo(file, dims); videoPanel.setupVideo(file, dims);
switchPanels(true); switchPanels(true);
} }
} catch (Exception e) { } catch (Exception e) {
logger.log(Level.SEVERE, "Exception while setting node", e); logger.log(Level.SEVERE, "Exception while setting node", e);
@ -218,8 +224,8 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
} }
if (videoPanelInited && videoPanel.isInited()) { if (videoPanelInited && videoPanel.isInited()) {
if (containsExt(name, AUDIO_EXTENSIONS) if ((containsExt(name, AUDIO_EXTENSIONS)
|| (containsExt(name, videoExtensions))) { || containsExt(name, videoExtensions))&& containsMimeType(node,supportedMimes)) {
return true; return true;
} }
} }
@ -254,4 +260,22 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
} }
return Arrays.asList(exts).contains(ext); return Arrays.asList(exts).contains(ext);
} }
private static boolean containsMimeType(Node node, List<String> mimeTypes) {
if (mimeTypes.isEmpty()) return true; //GStreamer currently is empty. Signature detection for javafx currently
AbstractFile file = node.getLookup().lookup(AbstractFile.class);
try {
ArrayList<BlackboardAttribute> genInfoAttributes = file.getGenInfoAttributes(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_FILE_TYPE_SIG);
if (genInfoAttributes.isEmpty() == false) {
for (BlackboardAttribute batt : genInfoAttributes) {
if (mimeTypes.contains(batt.getValueString())) {
return true;
}
}
return false;
}
} catch (TskCoreException ex) {
return false;
}
return false;
}
} }

View File

@ -21,6 +21,7 @@ package org.sleuthkit.autopsy.corecomponents;
import java.awt.Dimension; import java.awt.Dimension;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
import java.util.logging.Level; import java.util.logging.Level;
@ -82,6 +83,8 @@ import org.sleuthkit.autopsy.core.Installer;
public class FXVideoPanel extends MediaViewVideoPanel { public class FXVideoPanel extends MediaViewVideoPanel {
private static final String[] EXTENSIONS = new String[]{".mov", ".m4v", ".flv", ".mp4", ".mpg", ".mpeg"}; private static final String[] EXTENSIONS = new String[]{".mov", ".m4v", ".flv", ".mp4", ".mpg", ".mpeg"};
static private final List<String> supportedMimes = Arrays.asList("audio/x-aiff", "video/x-javafx", "video/x-flv", "application/vnd.apple.mpegurl", " audio/mpegurl", "audio/mpeg", "video/mp4","audio/x-m4a","video/x-m4v","audio/x-wav");
private static final Logger logger = Logger.getLogger(MediaViewVideoPanel.class.getName()); private static final Logger logger = Logger.getLogger(MediaViewVideoPanel.class.getName());
private boolean fxInited = false; private boolean fxInited = false;
// FX Components // FX Components
@ -467,6 +470,7 @@ public class FXVideoPanel extends MediaViewVideoPanel {
case READY: case READY:
case PAUSED: case PAUSED:
case STOPPED: case STOPPED:
case UNKNOWN:
mediaPlayer.play(); mediaPlayer.play();
break; break;
default: default:
@ -798,4 +802,9 @@ public class FXVideoPanel extends MediaViewVideoPanel {
public String[] getExtensions() { public String[] getExtensions() {
return EXTENSIONS; return EXTENSIONS;
} }
@Override
public List<String> getMimeTypes(){
return supportedMimes;
}
} }

View File

@ -24,6 +24,7 @@ import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -88,7 +89,7 @@ public class GstVideoPanel extends MediaViewVideoPanel {
private final Object playbinLock = new Object(); // lock for synchronization of gstPlaybin2 player private final Object playbinLock = new Object(); // lock for synchronization of gstPlaybin2 player
private AbstractFile currentFile; private AbstractFile currentFile;
private Set<String> badVideoFiles = Collections.synchronizedSet(new HashSet<String>()); private Set<String> badVideoFiles = Collections.synchronizedSet(new HashSet<String>());
static private final List<String> supportedMimes = Arrays.asList();
/** /**
* Creates new form MediaViewVideoPanel * Creates new form MediaViewVideoPanel
*/ */
@ -802,4 +803,9 @@ public class GstVideoPanel extends MediaViewVideoPanel {
public String[] getExtensions() { public String[] getExtensions() {
return EXTENSIONS; return EXTENSIONS;
} }
@Override
public List<String> getMimeTypes(){
return supportedMimes;
}
} }

View File

@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.corecomponents;
import java.awt.Dimension; import java.awt.Dimension;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -108,4 +109,8 @@ public abstract class MediaViewVideoPanel extends JPanel implements FrameCapture
* Return the extensions supported by this video panel. * Return the extensions supported by this video panel.
*/ */
abstract public String[] getExtensions(); abstract public String[] getExtensions();
/**
* Return the extensions supported by this video panel.
*/
abstract public List<String> getMimeTypes();
} }