19 package org.sleuthkit.autopsy.datamodel;
21 import java.text.SimpleDateFormat;
22 import java.util.Arrays;
23 import java.util.TimeZone;
24 import java.util.logging.Level;
26 import org.openide.util.NbBundle;
30 import org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
43 BlackboardArtifact artifact;
46 private static SimpleDateFormat
dateFormatter =
new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
53 @SuppressWarnings(
"deprecation")
55 if (stringContent.isEmpty()) {
57 StringBuilder buffer =
new StringBuilder();
58 buffer.append(
"<html>\n");
59 buffer.append(
"<body>\n");
62 buffer.append(
"<h4>");
63 buffer.append(artifact.getDisplayName());
64 buffer.append(
"</h4>\n");
67 buffer.append(
"<table border='0'>");
68 buffer.append(
"<tr>");
69 buffer.append(
"</tr>\n");
72 for (BlackboardAttribute attr : artifact.getAttributes()) {
75 buffer.append(
"<tr><td>");
76 buffer.append(attr.getAttributeType().getDisplayName());
77 buffer.append(
"</td>");
80 buffer.append(
"<td>");
81 if (attr.getAttributeType().getTypeID() == ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID()
82 || attr.getAttributeType().getTypeID() == ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED.getTypeID()
83 || attr.getAttributeType().getTypeID() == ATTRIBUTE_TYPE.TSK_DATETIME_CREATED.getTypeID()
84 || attr.getAttributeType().getTypeID() == ATTRIBUTE_TYPE.TSK_DATETIME_MODIFIED.getTypeID()
85 || attr.getAttributeType().getTypeID() == ATTRIBUTE_TYPE.TSK_DATETIME_RCVD.getTypeID()
86 || attr.getAttributeType().getTypeID() == ATTRIBUTE_TYPE.TSK_DATETIME_SENT.getTypeID()
87 || attr.getAttributeType().getTypeID() == ATTRIBUTE_TYPE.TSK_DATETIME_START.getTypeID()
88 || attr.getAttributeType().getTypeID() == ATTRIBUTE_TYPE.TSK_DATETIME_END.getTypeID()) {
89 long epoch = attr.getValueLong();
90 String time =
"0000-00-00 00:00:00";
93 time = dateFormatter.format(
new java.util.Date(epoch * 1000));
97 switch (attr.getAttributeType().getValueType()) {
99 String str = attr.getValueString();
100 str = str.replaceAll(
" ",
" ");
101 str = str.replaceAll(
"<",
"<");
102 str = str.replaceAll(
">",
">");
103 str = str.replaceAll(
"(\r\n|\n)",
"<br />");
107 buffer.append(attr.getValueInt());
110 buffer.append(attr.getValueLong());
113 buffer.append(attr.getValueDouble());
116 buffer.append(Arrays.toString(attr.getValueBytes()));
119 buffer.append(attr.getValueLong());
124 if (!
"".equals(attr.getContext())) {
126 buffer.append(attr.getContext());
129 buffer.append(
"</td>");
130 buffer.append(
"</tr>\n");
137 path = content.getUniquePath();
138 }
catch (TskCoreException ex) {
139 logger.log(Level.SEVERE,
"Exception while calling Content.getUniquePath() on {0} : {1}",
new Object[]{content, ex.getLocalizedMessage()});
143 buffer.append(
"<tr>");
144 buffer.append(
"<td>");
145 buffer.append(NbBundle.getMessage(
this.getClass(),
"ArtifactStringContent.getStr.srcFilePath.text"));
146 buffer.append(
"</td>");
147 buffer.append(
"<td>");
149 buffer.append(
"</td>");
150 buffer.append(
"</tr>\n");
153 buffer.append(
"<tr><td>");
154 buffer.append(NbBundle.getMessage(
this.getClass(),
"ArtifactStringContent.getStr.artifactId.text"));
155 buffer.append(
"</td><td>");
156 buffer.append(artifact.getArtifactID());
157 buffer.append(
"</td>");
158 buffer.append(
"</tr>\n");
160 buffer.append(
"</table>");
161 buffer.append(
"</html>\n");
163 stringContent = buffer.toString();
164 }
catch (TskException ex) {
165 stringContent = NbBundle.getMessage(this.getClass(),
"ArtifactStringContent.getStr.err");
174 return artifact.getSleuthkitCase().getContentById(artifact.getObjectID());
175 }
catch (TskException ex) {
176 logger.log(Level.WARNING,
"Getting file failed", ex);
178 throw new IllegalArgumentException(NbBundle.getMessage(
ArtifactStringContent.class,
"ArtifactStringContent.exception.msg"));
181 private static TimeZone
getTimeZone(BlackboardArtifact artifact) {
static SimpleDateFormat dateFormatter
static Content getAssociatedContent(BlackboardArtifact artifact)
static TimeZone getTimeZone(BlackboardArtifact artifact)
synchronized static Logger getLogger(String name)
static TimeZone getTimeZone(Content c)
ArtifactStringContent(BlackboardArtifact art)