From 0d7abe2b1b0c1ad881479a2d507eb80c7c3fc238 Mon Sep 17 00:00:00 2001 From: "U-BASIS\\tshahi" Date: Mon, 3 Feb 2014 10:19:19 -0500 Subject: [PATCH 1/4] changed timezone and times to UTC for display --- Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java b/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java index 190aa2a7d5..3aeaf07cdb 100644 --- a/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java +++ b/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java @@ -41,6 +41,7 @@ import java.util.List; import java.util.Locale; import java.util.Scanner; import java.util.Stack; +import java.util.TimeZone; import java.util.logging.Level; import javafx.application.Platform; import javafx.beans.value.ChangeListener; @@ -75,7 +76,6 @@ import org.openide.awt.ActionReference; import org.openide.awt.ActionReferences; import org.openide.awt.ActionRegistration; import org.openide.modules.InstalledFileLocator; -import org.openide.modules.ModuleInstall; import org.openide.nodes.Children; import org.openide.nodes.Node; import org.openide.util.HelpCtx; @@ -112,7 +112,7 @@ import org.sleuthkit.datamodel.TskCoreException; * */ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, PropertyChangeListener { - + private static final Logger logger = Logger.getLogger(Timeline.class.getName()); private final java.io.File macRoot = InstalledFileLocator.getDefault().locate("mactime", Timeline.class.getPackage().getName(), false); private TimelineFrame mainFrame; //frame for holding all the elements @@ -147,7 +147,7 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, super(); fxInited = Installer.isJavaFxInited(); - + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); //sets the default timezone to UTC unless otherwise stated } //Swing components and JavafX components don't play super well together From 4ded0acbf3ea5e534ee6510f187c5d106338b664 Mon Sep 17 00:00:00 2001 From: "U-BASIS\\tshahi" Date: Wed, 5 Feb 2014 16:58:45 -0500 Subject: [PATCH 2/4] Timeline bargraph now same as user timezone or GMT --- .../sleuthkit/autopsy/timeline/Timeline.java | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java b/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java index db32c74fdc..f223d547bd 100644 --- a/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java +++ b/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java @@ -43,6 +43,7 @@ import java.util.Scanner; import java.util.Stack; import java.util.TimeZone; import java.util.logging.Level; +import java.util.prefs.Preferences; import javafx.application.Platform; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; @@ -80,6 +81,7 @@ import org.openide.nodes.Children; import org.openide.nodes.Node; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; +import org.openide.util.NbPreferences; import org.openide.util.actions.CallableSystemAction; import org.openide.util.actions.Presenter; import org.openide.util.lookup.Lookups; @@ -100,7 +102,8 @@ import org.sleuthkit.autopsy.coreutils.ExecUtil; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TskCoreException; - +import org.sleuthkit.autopsy.datamodel.ArtifactStringContent; +import org.sleuthkit.datamodel.Content; @ActionID(category = "Tools", id = "org.sleuthkit.autopsy.timeline.Timeline") @ActionRegistration(displayName = "#CTL_MakeTimeline", lazy = false) @ActionReferences(value = { @@ -147,7 +150,7 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, super(); fxInited = Installer.isJavaFxInited(); - TimeZone.setDefault(TimeZone.getTimeZone("UTC")); //sets the default timezone to UTC unless otherwise stated + // TimeZone.setDefault(TimeZone.getTimeZone("UTC")); //sets the default timezone to UTC unless otherwise stated } //Swing components and JavafX components don't play super well together @@ -914,17 +917,36 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, int prevYear = -1; YearEpoch ye = null; + while (scan.hasNextLine()) { String[] s = scan.nextLine().split(","); //1999-02-08T11:08:08Z, 78706, m..b, rrwxrwxrwx, 0, 0, 8355, /img... - // break the date into mon, day and year: Note that the ISO times are in GMT - String[] datetime = s[0].split("T"); //{1999-02-08, 11:08:08Z} - String[] date = datetime[0].split("-"); // {1999, 02, 08} + // break the date into year,month,day,hour,minute, and second: Note that the ISO times are in GMT + String delims = "[T:Z\\-]+"; + String[] date = s[0].split(delims); //{1999,02,08,11,08,08,...} + int year = Integer.valueOf(date[0]); int month = Integer.valueOf(date[1]) - 1; //Months are zero indexed: 1 = February, 6 = July, 11 = December int day = Integer.valueOf(date[2]); //Days are 1 indexed + int hour=Integer.valueOf(date[3]); + int minute=Integer.valueOf(date[4]); + int second=Integer.valueOf(date[5]); + + Preferences generalPanelPrefs = NbPreferences.root().node("/org/sleuthkit/autopsy/core"); //access Use GMT? checkbox + boolean useLocalTime = generalPanelPrefs.getBoolean("useLocalTime", true); - // get the object id out of the modified outpu + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); //set calendar to GMT due to ISO format + calendar.set(year, month, day, hour, minute, second); + day=calendar.get(Calendar.DAY_OF_MONTH); // this is needed or else timezone change wont work for some reason + //conversion to GMT + if (!useLocalTime) + { + calendar.setTimeZone(TimeZone.getTimeZone("GMT")); + } + else calendar.setTimeZone(TimeZone.getDefault());// local timezone OF the user. should be what the user SETS at startup + + day=calendar.get(Calendar.DAY_OF_MONTH);//get the day which may be affected by timezone change + long ObjId = Long.valueOf(s[4]); // when the year changes, create and add a new YearEpoch object to the list @@ -961,7 +983,6 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, // Get report path String bodyFilePath = moduleDir.getAbsolutePath() + java.io.File.separator + currentCase.getName() + "-" + datenotime + ".txt"; - // Run query to get all files final String filesAndDirs = "name != '.' " + "AND name != '..'"; From e64efe3587939aba827b86f57da257454349984b Mon Sep 17 00:00:00 2001 From: "U-BASIS\\tshahi" Date: Thu, 6 Feb 2014 11:17:39 -0500 Subject: [PATCH 3/4] created methods to call localtime --- .../autopsy/corecomponents/GeneralPanel.form | 3 ++ .../autopsy/corecomponents/GeneralPanel.java | 11 ++++++ .../autopsy/datamodel/ContentUtils.java | 23 ++++++++--- .../sleuthkit/autopsy/timeline/Timeline.java | 39 ++++++++++++------- 4 files changed, 58 insertions(+), 18 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.form b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.form index a2c34ea3f8..432bd9b5c3 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.form +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.form @@ -148,6 +148,9 @@ + + + diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.java b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.java index 2b702bef4b..3b3c77a876 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.java @@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.corecomponents; import java.util.prefs.Preferences; import org.openide.util.NbPreferences; +import org.sleuthkit.autopsy.datamodel.ContentUtils; final class GeneralPanel extends javax.swing.JPanel { @@ -33,6 +34,7 @@ final class GeneralPanel extends javax.swing.JPanel { GeneralPanel(GeneralOptionsPanelController controller) { this.controller = controller; initComponents(); + ContentUtils.setLocalTime(useLocalTimeRB.isSelected()); // TODO listen to changes in form fields and call controller.changed() } @@ -80,6 +82,11 @@ final class GeneralPanel extends javax.swing.JPanel { buttonGroup3.add(useGMTTimeRB); org.openide.awt.Mnemonics.setLocalizedText(useGMTTimeRB, org.openide.util.NbBundle.getMessage(GeneralPanel.class, "GeneralPanel.useGMTTimeRB.text")); // NOI18N + useGMTTimeRB.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + useGMTTimeRBActionPerformed(evt); + } + }); org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(GeneralPanel.class, "GeneralPanel.jLabel3.text")); // NOI18N @@ -144,6 +151,10 @@ final class GeneralPanel extends javax.swing.JPanel { // TODO add your handling code here: }//GEN-LAST:event_useBestViewerRBActionPerformed + private void useGMTTimeRBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useGMTTimeRBActionPerformed + ContentUtils.setLocalTime(useLocalTimeRB.isSelected()); + }//GEN-LAST:event_useGMTTimeRBActionPerformed + void load() { boolean keepPreferredViewer = prefs.getBoolean(KEEP_PREFERRED_VIEWER, false); keepCurrentViewerRB.setSelected(keepPreferredViewer); diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/ContentUtils.java b/Core/src/org/sleuthkit/autopsy/datamodel/ContentUtils.java index 121b5a1cfa..3dee14bff4 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/ContentUtils.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/ContentUtils.java @@ -50,7 +50,7 @@ public final class ContentUtils { private final static Logger logger = Logger.getLogger(ContentUtils.class.getName()); private static final SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); private static final SimpleDateFormat dateFormatterISO8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); - + private static boolean localTime; // don't instantiate private ContentUtils() { throw new AssertionError(); @@ -104,12 +104,11 @@ public final class ContentUtils { public static String getStringTimeISO8601(long epochSeconds, Content c) { return getStringTimeISO8601(epochSeconds, getTimeZone(c)); } - + public static TimeZone getTimeZone(Content c) { - Preferences generalPanelPrefs = NbPreferences.root().node("/org/sleuthkit/autopsy/core"); - boolean useLocalTime = generalPanelPrefs.getBoolean("useLocalTime", true); + try { - if (!useLocalTime) { + if (!localTime()) { return TimeZone.getTimeZone("GMT"); } else { @@ -360,4 +359,18 @@ public final class ContentUtils { + cntnt.getClass().getSimpleName()); } } + /**sets localTime value based on button in GeneralPanel.java + * + * @param flag + */ + public static void setLocalTime(boolean flag) { + localTime = flag; + } + /** returns true if local time is selected. + * returns false if GMT is selected. + * @return + */ + public static boolean localTime(){ + return localTime; + } } diff --git a/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java b/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java index f223d547bd..952e907562 100644 --- a/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java +++ b/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java @@ -99,11 +99,11 @@ import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor; import org.sleuthkit.autopsy.datamodel.FileNode; import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.coreutils.ExecUtil; +import org.sleuthkit.autopsy.datamodel.ContentUtils; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TskCoreException; -import org.sleuthkit.autopsy.datamodel.ArtifactStringContent; -import org.sleuthkit.datamodel.Content; + @ActionID(category = "Tools", id = "org.sleuthkit.autopsy.timeline.Timeline") @ActionRegistration(displayName = "#CTL_MakeTimeline", lazy = false) @ActionReferences(value = { @@ -145,7 +145,7 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, private EventHandler fxMouseExitedListener; private SleuthkitCase skCase; private boolean fxInited = false; - + private static boolean localTime = true; public Timeline() { super(); @@ -922,7 +922,7 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, String[] s = scan.nextLine().split(","); //1999-02-08T11:08:08Z, 78706, m..b, rrwxrwxrwx, 0, 0, 8355, /img... // break the date into year,month,day,hour,minute, and second: Note that the ISO times are in GMT - String delims = "[T:Z\\-]+"; + String delims = "[T:Z\\-]+"; //split by the delimiters String[] date = s[0].split(delims); //{1999,02,08,11,08,08,...} int year = Integer.valueOf(date[0]); @@ -932,21 +932,20 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, int minute=Integer.valueOf(date[4]); int second=Integer.valueOf(date[5]); - Preferences generalPanelPrefs = NbPreferences.root().node("/org/sleuthkit/autopsy/core"); //access Use GMT? checkbox - boolean useLocalTime = generalPanelPrefs.getBoolean("useLocalTime", true); - + setLocalTime(localTime); Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); //set calendar to GMT due to ISO format calendar.set(year, month, day, hour, minute, second); - day=calendar.get(Calendar.DAY_OF_MONTH); // this is needed or else timezone change wont work for some reason + day=calendar.get(Calendar.DAY_OF_MONTH); // this is needed or else timezone change wont work. probably incorrect optimization by compiler + //conversion to GMT - if (!useLocalTime) - { + if (!localTime()) { calendar.setTimeZone(TimeZone.getTimeZone("GMT")); } - else calendar.setTimeZone(TimeZone.getDefault());// local timezone OF the user. should be what the user SETS at startup + else{ + calendar.setTimeZone(TimeZone.getDefault());// local timezone OF the user. should be what the user SETS at startup + } day=calendar.get(Calendar.DAY_OF_MONTH);//get the day which may be affected by timezone change - long ObjId = Long.valueOf(s[4]); // when the year changes, create and add a new YearEpoch object to the list @@ -1128,7 +1127,21 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, public void performAction() { initTimeline(); } - + + /**set localTime by getting it from ContentUtils class + * + * @param flag + */ + public static void setLocalTime(boolean flag) { + localTime = ContentUtils.localTime(); + } + /**returns whether user has set localTime settings, or GMT if false + * + * @return + */ + public static boolean localTime() { + return localTime; + } private void initTimeline() { if (!Case.existsCurrentCase()) { return; From e16ef6082cbb31e7e6a25bd732cd0b891799f4d6 Mon Sep 17 00:00:00 2001 From: "U-BASIS\\tshahi" Date: Fri, 7 Feb 2014 13:26:17 -0500 Subject: [PATCH 4/4] renamed variables and functions for timezone check --- .../autopsy/corecomponents/GeneralPanel.java | 4 ++-- .../autopsy/datamodel/ContentUtils.java | 18 +++++++++--------- .../sleuthkit/autopsy/timeline/Timeline.java | 19 ++----------------- 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.java b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.java index 3b3c77a876..3d697b07ab 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/GeneralPanel.java @@ -34,7 +34,7 @@ final class GeneralPanel extends javax.swing.JPanel { GeneralPanel(GeneralOptionsPanelController controller) { this.controller = controller; initComponents(); - ContentUtils.setLocalTime(useLocalTimeRB.isSelected()); + ContentUtils.setDisplayInLocalTime(useLocalTimeRB.isSelected()); // TODO listen to changes in form fields and call controller.changed() } @@ -152,7 +152,7 @@ final class GeneralPanel extends javax.swing.JPanel { }//GEN-LAST:event_useBestViewerRBActionPerformed private void useGMTTimeRBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useGMTTimeRBActionPerformed - ContentUtils.setLocalTime(useLocalTimeRB.isSelected()); + ContentUtils.setDisplayInLocalTime(useLocalTimeRB.isSelected()); }//GEN-LAST:event_useGMTTimeRBActionPerformed void load() { diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/ContentUtils.java b/Core/src/org/sleuthkit/autopsy/datamodel/ContentUtils.java index 3dee14bff4..9cc844cae6 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/ContentUtils.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/ContentUtils.java @@ -50,7 +50,7 @@ public final class ContentUtils { private final static Logger logger = Logger.getLogger(ContentUtils.class.getName()); private static final SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); private static final SimpleDateFormat dateFormatterISO8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); - private static boolean localTime; + private static boolean displayInLocalTime; // don't instantiate private ContentUtils() { throw new AssertionError(); @@ -108,7 +108,7 @@ public final class ContentUtils { public static TimeZone getTimeZone(Content c) { try { - if (!localTime()) { + if (!getDisplayInLocalTime()) { return TimeZone.getTimeZone("GMT"); } else { @@ -359,18 +359,18 @@ public final class ContentUtils { + cntnt.getClass().getSimpleName()); } } - /**sets localTime value based on button in GeneralPanel.java + /**sets displayInlocalTime value based on button in GeneralPanel.java * * @param flag */ - public static void setLocalTime(boolean flag) { - localTime = flag; + public static void setDisplayInLocalTime(boolean flag) { + displayInLocalTime = flag; } - /** returns true if local time is selected. - * returns false if GMT is selected. + /** get global timezone setting for displaying time values + * * @return */ - public static boolean localTime(){ - return localTime; + public static boolean getDisplayInLocalTime(){ + return displayInLocalTime; } } diff --git a/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java b/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java index 952e907562..675bfc318f 100644 --- a/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java +++ b/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java @@ -145,7 +145,6 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, private EventHandler fxMouseExitedListener; private SleuthkitCase skCase; private boolean fxInited = false; - private static boolean localTime = true; public Timeline() { super(); @@ -932,13 +931,13 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, int minute=Integer.valueOf(date[4]); int second=Integer.valueOf(date[5]); - setLocalTime(localTime); Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); //set calendar to GMT due to ISO format calendar.set(year, month, day, hour, minute, second); day=calendar.get(Calendar.DAY_OF_MONTH); // this is needed or else timezone change wont work. probably incorrect optimization by compiler //conversion to GMT - if (!localTime()) { + + if (!ContentUtils.getDisplayInLocalTime()) { calendar.setTimeZone(TimeZone.getTimeZone("GMT")); } else{ @@ -1128,20 +1127,6 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, initTimeline(); } - /**set localTime by getting it from ContentUtils class - * - * @param flag - */ - public static void setLocalTime(boolean flag) { - localTime = ContentUtils.localTime(); - } - /**returns whether user has set localTime settings, or GMT if false - * - * @return - */ - public static boolean localTime() { - return localTime; - } private void initTimeline() { if (!Case.existsCurrentCase()) { return;