From d8884b82c2155aafaefe443c8cbd4ff0052fd383 Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Fri, 5 Jul 2019 15:37:11 -0400 Subject: [PATCH 1/4] Added image to contact viewer tab --- .../relationships/ContactDetailsPane.form | 5 +- .../relationships/ContactDetailsPane.java | 51 +++++++++++++++---- .../relationships/ContactNode.java | 22 ++++++++ .../relationships/ContactsViewer.java | 3 -- .../thunderbirdparser/VcardParser.java | 8 +-- 5 files changed, 67 insertions(+), 22 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.form b/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.form index 671fac333e..0536cb5b11 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.form +++ b/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.form @@ -1,10 +1,6 @@
- - - - @@ -15,6 +11,7 @@ + diff --git a/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java b/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java index ae456e0abb..3839dadfeb 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java +++ b/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java @@ -18,24 +18,36 @@ */ package org.sleuthkit.autopsy.communications.relationships; +import java.util.logging.Level; +import javax.swing.ImageIcon; import org.openide.explorer.ExplorerManager; import org.openide.nodes.Node; +import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.datamodel.AbstractFile; +import org.sleuthkit.datamodel.BlackboardArtifact; +import org.sleuthkit.datamodel.Content; +import org.sleuthkit.datamodel.TskCoreException; /** * Displays the propertied of a ContactNode in a PropertySheet. */ public final class ContactDetailsPane extends javax.swing.JPanel implements ExplorerManager.Provider { - final private ExplorerManager explorerManager = new ExplorerManager(); + private static final Logger logger = Logger.getLogger(ContactDetailsPane.class.getName()); + + private final static String DEFAULT_IMAGE_PATH = "/org/sleuthkit/autopsy/images/face.png"; + + private final ExplorerManager explorerManager = new ExplorerManager(); + private final ImageIcon defaultImage; /** * Displays the propertied of a ContactNode in a PropertySheet. */ public ContactDetailsPane() { initComponents(); - this.setEnabled(false); - nameLabel.setText(""); + + defaultImage = new ImageIcon(ContactDetailsPane.class.getResource(DEFAULT_IMAGE_PATH)); } /** @@ -46,9 +58,16 @@ public final class ContactDetailsPane extends javax.swing.JPanel implements Expl public void setNode(Node[] nodes) { if (nodes != null && nodes.length == 1) { nameLabel.setText(nodes[0].getDisplayName()); + nameLabel.setIcon(null); propertySheet.setNodes(nodes); + + BlackboardArtifact n = nodes[0].getLookup().lookup(BlackboardArtifact.class); + if(n != null) { + nameLabel.setIcon(getImageForFromArtifact(n)); + } } else { nameLabel.setText(""); + nameLabel.setIcon(null); propertySheet.setNodes(null); } } @@ -57,12 +76,24 @@ public final class ContactDetailsPane extends javax.swing.JPanel implements Expl public ExplorerManager getExplorerManager() { return explorerManager; } - - @Override - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - nameLabel.setEnabled(enabled); - propertySheet.setEnabled(enabled); + + public ImageIcon getImageForFromArtifact(BlackboardArtifact artifact){ + ImageIcon image = defaultImage; + + try { + for(Content content: artifact.getChildren()) { + if(content instanceof AbstractFile) { + AbstractFile file = (AbstractFile)content; + file.getLocalAbsPath(); + + image = new ImageIcon(file.getLocalAbsPath()); + } + } + } catch (TskCoreException ex) { + logger.log(Level.WARNING, String.format("Unable to load image for contact: %d", artifact.getId()), ex); + } + + return image; } /** @@ -75,7 +106,6 @@ public final class ContactDetailsPane extends javax.swing.JPanel implements Expl private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; - messageContentViewer1 = new org.sleuthkit.autopsy.contentviewers.MessageContentViewer(); nameLabel = new javax.swing.JLabel(); propertySheet = new org.openide.explorer.propertysheet.PropertySheet(); @@ -107,7 +137,6 @@ public final class ContactDetailsPane extends javax.swing.JPanel implements Expl // Variables declaration - do not modify//GEN-BEGIN:variables - private org.sleuthkit.autopsy.contentviewers.MessageContentViewer messageContentViewer1; private javax.swing.JLabel nameLabel; private org.openide.explorer.propertysheet.PropertySheet propertySheet; // End of variables declaration//GEN-END:variables diff --git a/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactNode.java b/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactNode.java index 9f275ec228..33b9d16724 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactNode.java +++ b/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactNode.java @@ -19,6 +19,7 @@ package org.sleuthkit.autopsy.communications.relationships; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.TimeZone; import java.util.logging.Level; @@ -36,6 +37,8 @@ import static org.sleuthkit.datamodel.BlackboardAttribute.TSK_BLACKBOARD_ATTRIBU import org.sleuthkit.datamodel.TimeUtilities; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.autopsy.communications.Utils; +import org.sleuthkit.datamodel.AbstractFile; +import org.sleuthkit.datamodel.Content; /** * Extends BlackboardArtifactNode to override createSheet to create a contact @@ -112,6 +115,25 @@ final class ContactNode extends BlackboardArtifactNode { for (BlackboardAttribute bba : otherMap.values()) { sheetSet.put(new NodeProperty<>(bba.getAttributeType().getTypeName(), bba.getAttributeType().getDisplayName(), "", bba.getDisplayString())); } + + // Don't need these values to appear in the Contact property sheet. + sheetSet.remove("S"); + sheetSet.remove("C"); + + List children = artifact.getChildren(); + if(children != null) { + int count = 0; + String imageLabelPrefix = "Image"; + for(Content child: children) { + if(child instanceof AbstractFile) { + String imageLabel = imageLabelPrefix; + if(count > 0) { + imageLabel = imageLabelPrefix + "-" + count; + } + sheetSet.put(new NodeProperty<>(imageLabel, imageLabel, imageLabel, child.getName())); + } + } + } } catch (TskCoreException ex) { logger.log(Level.WARNING, "Error getting attribute values.", ex); //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactsViewer.java b/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactsViewer.java index 4fdb400c87..33afae7251 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactsViewer.java +++ b/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactsViewer.java @@ -142,9 +142,6 @@ public final class ContactsViewer extends JPanel implements RelationshipsViewer{ @Override public void setSelectionInfo(SelectionInfo info) { - contactPane.setNode(new Node[]{new AbstractNode(Children.LEAF)}); - contactPane.setEnabled(false); - nodeFactory.refresh(info); } diff --git a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/VcardParser.java b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/VcardParser.java index 7e5a321313..a0fa8260aa 100755 --- a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/VcardParser.java +++ b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/VcardParser.java @@ -164,8 +164,6 @@ final class VcardParser { private BlackboardArtifact addContactArtifact(VCard vcard, AbstractFile abstractFile) throws NoCurrentCaseException { List attributes = new ArrayList<>(); List accountInstances = new ArrayList<>(); - - extractPhotos(vcard, abstractFile); String name = ""; if (vcard.getFormattedName() != null) { @@ -229,6 +227,8 @@ final class VcardParser { List blackboardArtifacts = new ArrayList<>(); blackboardArtifacts.add(artifact); + extractPhotos(vcard, abstractFile, artifact); + // Add account relationships. if (deviceAccountInstance != null) { try { @@ -269,7 +269,7 @@ final class VcardParser { * * @throws NoCurrentCaseException if there is no open case. */ - private void extractPhotos(VCard vcard, AbstractFile abstractFile) throws NoCurrentCaseException { + private void extractPhotos(VCard vcard, AbstractFile abstractFile, BlackboardArtifact artifact) throws NoCurrentCaseException { String parentFileName = getUniqueName(abstractFile); // Skip files that already have been extracted. try { @@ -306,7 +306,7 @@ final class VcardParser { writeExtractedImage(extractedFilePath, data); derivedFilesCreated.add(fileManager.addDerivedFile(extractedFileName, getFileRelativePath(parentFileName, extractedFileName), data.length, abstractFile.getCtime(), abstractFile.getCrtime(), abstractFile.getAtime(), abstractFile.getAtime(), - true, abstractFile, null, EmailParserModuleFactory.getModuleName(), null, null, TskData.EncodingType.NONE)); + true, artifact, null, EmailParserModuleFactory.getModuleName(), EmailParserModuleFactory.getModuleVersion(), "", TskData.EncodingType.NONE)); } catch (IOException | TskCoreException ex) { logger.log(Level.WARNING, String.format("Could not write image to '%s' (id=%d).", extractedFilePath, abstractFile.getId()), ex); //NON-NLS } From d5fa5ed363132153c7df15fe1c4c4b601b4287d8 Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Mon, 8 Jul 2019 13:20:50 -0400 Subject: [PATCH 2/4] Added default contact image --- .../communications/images/defaultContact.png | Bin 0 -> 2560 bytes .../relationships/ContactDetailsPane.java | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100755 Core/src/org/sleuthkit/autopsy/communications/images/defaultContact.png diff --git a/Core/src/org/sleuthkit/autopsy/communications/images/defaultContact.png b/Core/src/org/sleuthkit/autopsy/communications/images/defaultContact.png new file mode 100755 index 0000000000000000000000000000000000000000..80d697fac50c4808cdf7356db8d1c67f73b79682 GIT binary patch literal 2560 zcmai$S3nc#7ROlui4=)a7m!fAp%;-VTq6hygwR883I^d45s=VASfvSZi4;Kr$x=cI zk}ROaAVs7%F`%@7Q6M6)^b#ZOj&JwvKFpklnK|D#=lsv_|7AGZUl$RS5#-_F5wWqh zbOxe7aQT5w0(UELpCb>?sa_jPbJy77)#BN3@lTL+;>AXtS>Jp~us12R5kWg4k_N3T ztmYGcbV{nr+U|hY@`#^$C;&QjN(%ZV^;FO8yxVV`|1*~OF2`=$UdEqgsN{d&a`iN}D2Ubmzm=R0f&+ zv@(RVXC|SVdEyValemwz)MX;UQ8nd;v|;#kE*|`VMEX}xPmd!~!hI>Z&YQN?uR@%p zqaFAI0|T*pQ^9;Ee#;w$)FQIv1XC@z`$*3lQ|b~G>a1(zE%g5c9}S&3GkG`3g7_@i zR1w8?56zo}&}Pa-Q`5l@AHYIFLY%%PO?(V1QEE&-g6_kHsIVF%Utkeq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f)2<;Kn2F|v5L_3|A751wmFcK?|OOuF^?6K_Xg$B)S57VfvAAK1%&39AOci@;K| z(9a%OnFABi&w*ka7Llr|s?0W1CRVf@2G4@{)aj=0o)I9ym*7>w`!u|jSC5Z#LXJ)F-L0huvTcxIOt-o{M> zxI8vJZR_nV3t)8x^NNB8T;(;Es|Rr8QC3#Y$Ra5#?u9s+Jh#mS5VOPKT-4Kh_x3Fh zlNP?X@wJoCnnch#F7U^dQmKTcr4UIeDZrqzk~YzGAjOSXvxP{LGKQ)JXmm+GfwRW` z^?U0VxJxq~ICt|mZp zzt&RQl;jCfJKq^d_j|SZL|c+^#9T^w?*ucWO!a`fNPI*fL>>HyC`sI#dU70WpkWWq zEjEiAtq)vz{(wv#8XCI0{86p4veFGJfVScSwH~W-$Q@*tEJIPRs>uU@9};mt)!ZpQ zo|vgyY=1x^7lYsH!eHy)1sL{MLFT&B6^)I#{r&yv+8oF7&dyFOfR&l%=#`omD0wMG zKA;P~GTK2QuZMWq1YkF7GbT_K72=QS)||XH-uJ~Oznp!2|KKwB_+VR9O2;nIXLHac{_?OSD@pM!eGW3E)i(g6mU?Z=Oy6SF-+fLi546GwPVwv zKb-Ir&c4WMc(Gi^+wYoSZ|M9aTp93&{}+x=NZox+Bg*@|22OT7HdgkQ6pMfd{{@!m B89e|1 literal 0 HcmV?d00001 diff --git a/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java b/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java index 3839dadfeb..5dba78cd5e 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java +++ b/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java @@ -35,7 +35,7 @@ public final class ContactDetailsPane extends javax.swing.JPanel implements Expl private static final Logger logger = Logger.getLogger(ContactDetailsPane.class.getName()); - private final static String DEFAULT_IMAGE_PATH = "/org/sleuthkit/autopsy/images/face.png"; + private final static String DEFAULT_IMAGE_PATH = "/org/sleuthkit/autopsy/communications/images/defaultContact.png"; private final ExplorerManager explorerManager = new ExplorerManager(); private final ImageIcon defaultImage; From c6939887496de88d244f3022d7a7acb552e40378 Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Mon, 15 Jul 2019 14:53:57 -0400 Subject: [PATCH 3/4] addressed review comments --- .../relationships/ContactDetailsPane.java | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java b/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java index 5dba78cd5e..beec25a0e0 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java +++ b/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java @@ -18,10 +18,15 @@ */ package org.sleuthkit.autopsy.communications.relationships; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; import java.util.logging.Level; +import javax.imageio.ImageIO; import javax.swing.ImageIcon; import org.openide.explorer.ExplorerManager; import org.openide.nodes.Node; +import org.openide.util.Exceptions; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact; @@ -63,7 +68,7 @@ public final class ContactDetailsPane extends javax.swing.JPanel implements Expl BlackboardArtifact n = nodes[0].getLookup().lookup(BlackboardArtifact.class); if(n != null) { - nameLabel.setIcon(getImageForFromArtifact(n)); + nameLabel.setIcon(getImageFromArtifact(n)); } } else { nameLabel.setText(""); @@ -77,23 +82,39 @@ public final class ContactDetailsPane extends javax.swing.JPanel implements Expl return explorerManager; } - public ImageIcon getImageForFromArtifact(BlackboardArtifact artifact){ - ImageIcon image = defaultImage; + public ImageIcon getImageFromArtifact(BlackboardArtifact artifact){ + ImageIcon imageIcon = defaultImage; + + if(artifact == null) { + return imageIcon; + } + + BlackboardArtifact.ARTIFACT_TYPE artifactType = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID()); + if(artifactType != BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT) { + return imageIcon; + } try { for(Content content: artifact.getChildren()) { if(content instanceof AbstractFile) { AbstractFile file = (AbstractFile)content; - file.getLocalAbsPath(); - image = new ImageIcon(file.getLocalAbsPath()); + try { + BufferedImage image = ImageIO.read(new File(file.getLocalAbsPath())); + imageIcon = new ImageIcon(image); + break; + } catch (IOException ex) { + // ImageIO.read will through an IOException if file is not an image + // therefore we don't need to report this exception just try + // the next file. + } } } } catch (TskCoreException ex) { logger.log(Level.WARNING, String.format("Unable to load image for contact: %d", artifact.getId()), ex); } - return image; + return imageIcon; } /** From b0548c725d06e1c9a04e3b8c84e49940906c27ce Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Tue, 16 Jul 2019 11:55:15 -0400 Subject: [PATCH 4/4] removed unused import --- .../autopsy/communications/relationships/ContactDetailsPane.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java b/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java index beec25a0e0..d8592a0f1d 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java +++ b/Core/src/org/sleuthkit/autopsy/communications/relationships/ContactDetailsPane.java @@ -26,7 +26,6 @@ import javax.imageio.ImageIO; import javax.swing.ImageIcon; import org.openide.explorer.ExplorerManager; import org.openide.nodes.Node; -import org.openide.util.Exceptions; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact;