19 package org.sleuthkit.autopsy.contentviewers;
21 import java.awt.Component;
22 import org.openide.nodes.Node;
23 import org.openide.util.NbBundle;
24 import org.openide.util.NbBundle.Messages;
25 import org.openide.util.lookup.ServiceProvider;
32 import org.
sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM;
39 @ServiceProvider(service = DataContentViewer.class, position = 6)
40 @SuppressWarnings(
"PMD.SingularField")
48 customizeComponents();
56 @SuppressWarnings(
"unchecked")
58 private
void initComponents() {
60 jPopupMenu1 =
new javax.swing.JPopupMenu();
61 jScrollPane2 =
new javax.swing.JScrollPane();
62 jTextPane1 =
new javax.swing.JTextPane();
64 setPreferredSize(
new java.awt.Dimension(100, 52));
66 jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
67 jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
68 jScrollPane2.setPreferredSize(
new java.awt.Dimension(610, 52));
70 jTextPane1.setEditable(
false);
71 jTextPane1.setPreferredSize(
new java.awt.Dimension(600, 52));
72 jScrollPane2.setViewportView(jTextPane1);
74 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
75 this.setLayout(layout);
76 layout.setHorizontalGroup(
77 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
78 .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
80 layout.setVerticalGroup(
81 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
82 .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
106 jTextPane1.setText(
"<html><body>" + str +
"</body></html>");
110 sb.append(
"<table>");
114 sb.append(
"</table>");
117 private void addRow(StringBuilder sb, String key, String value) {
118 sb.append(
"<tr><td valign=\"top\">");
120 sb.append(
"</td><td>");
122 sb.append(
"</td></tr>");
126 "Metadata.tableRowTitle.mimeType=MIME Type",
127 "Metadata.nodeText.truncated=(results truncated)",
128 "Metadata.tableRowTitle.sha1=SHA1",
129 "Metadata.tableRowTitle.sha256=SHA256",
130 "Metadata.tableRowTitle.imageType=Type",
131 "Metadata.tableRowTitle.sectorSize=Sector Size",
132 "Metadata.tableRowTitle.timezone=Time Zone",
133 "Metadata.tableRowTitle.deviceId=Device ID"})
136 AbstractFile file = node.getLookup().lookup(AbstractFile.class);
137 Image image = node.getLookup().lookup((Image.class));
138 if (file == null && image == null) {
139 setText(NbBundle.getMessage(
this.getClass(),
"Metadata.nodeText.nonFilePassedIn"));
143 StringBuilder sb =
new StringBuilder();
148 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.name"), file.getUniquePath());
149 }
catch (TskCoreException ex) {
150 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.name"), file.getParentPath() +
"/" + file.getName());
153 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.type"), file.getType().getName());
154 addRow(sb, Bundle.Metadata_tableRowTitle_mimeType(), file.getMIMEType());
155 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.size"), Long.toString(file.getSize()));
156 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.fileNameAlloc"), file.getDirFlagAsString());
157 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.metadataAlloc"), file.getMetaFlagsAsString());
158 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.modified"),
ContentUtils.
getStringTime(file.getMtime(), file));
159 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.accessed"),
ContentUtils.
getStringTime(file.getAtime(), file));
160 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.created"),
ContentUtils.
getStringTime(file.getCrtime(), file));
161 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.changed"),
ContentUtils.
getStringTime(file.getCtime(), file));
164 String md5 = file.getMd5Hash();
166 md5 = NbBundle.getMessage(this.getClass(),
"Metadata.tableRowContent.md5notCalc");
168 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.md5"), md5);
169 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.hashLookupResults"), file.getKnown().toString());
171 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.internalid"), Long.toString(file.getId()));
172 if (file.getType().compareTo(TSK_DB_FILES_TYPE_ENUM.LOCAL) == 0) {
173 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.localPath"), file.getLocalAbsPath());
183 if (file instanceof FsContent) {
184 FsContent fsFile = (FsContent) file;
186 sb.append(
"<hr /><pre>\n");
187 sb.append(NbBundle.getMessage(
this.getClass(),
"Metadata.nodeText.text"));
188 sb.append(
" <br /><br />");
189 for (String str : fsFile.getMetaDataText()) {
190 sb.append(str).append(
"<br />");
196 if(sb.length() > 50000){
197 sb.append(NbBundle.getMessage(
this.getClass(),
"Metadata.nodeText.truncated"));
201 sb.append(
"</pre>\n");
203 }
catch (TskCoreException ex) {
204 sb.append(NbBundle.getMessage(
this.getClass(),
"Metadata.nodeText.exceptionNotice.text")).append(ex.getLocalizedMessage());
208 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.name"), image.getUniquePath());
209 }
catch (TskCoreException ex) {
210 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.name"), image.getName());
212 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.imageType"), image.getType().getName());
213 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.size"), Long.toString(image.getSize()));
216 String md5 = image.getMd5();
217 if (md5 == null || md5.isEmpty()) {
218 md5 = NbBundle.getMessage(this.getClass(),
"Metadata.tableRowContent.md5notCalc");
220 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.md5"), md5);
222 String sha1 = image.getSha1();
223 if (sha1 == null || sha1.isEmpty()) {
224 sha1 = NbBundle.getMessage(this.getClass(),
"Metadata.tableRowContent.md5notCalc");
226 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.sha1"), sha1);
228 String sha256 = image.getSha256();
229 if (sha256 == null || sha256.isEmpty()) {
230 sha256 = NbBundle.getMessage(this.getClass(),
"Metadata.tableRowContent.md5notCalc");
232 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.sha256"), sha256);
233 }
catch (TskCoreException ex) {
234 sb.append(NbBundle.getMessage(
this.getClass(),
"Metadata.nodeText.exceptionNotice.text")).append(ex.getLocalizedMessage());
236 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.sectorSize"), Long.toString(image.getSsize()));
237 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.timezone"), image.getTimeZone());
238 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.deviceId"), image.getDeviceId());
239 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.internalid"), Long.toString(image.getId()));
242 String[] imagePaths = image.getPaths();
243 StringBuilder pathValues =
new StringBuilder(
"<div>");
244 pathValues.append(imagePaths[0]);
245 pathValues.append(
"</div>");
246 for (
int i=1; i < imagePaths.length; i++) {
247 pathValues.append(
"<div>");
248 pathValues.append(imagePaths[i]);
249 pathValues.append(
"</div>");
251 addRow(sb, NbBundle.getMessage(
this.getClass(),
"Metadata.tableRowTitle.localPath"), pathValues.toString());
254 setText(sb.toString());
255 jTextPane1.setCaretPosition(0);
256 this.setCursor(null);
261 return NbBundle.getMessage(this.getClass(),
"Metadata.title");
266 return NbBundle.getMessage(this.getClass(),
"Metadata.toolTip");
286 Image image = node.getLookup().lookup(Image.class);
287 AbstractFile file = node.getLookup().lookup(AbstractFile.class);
288 return (file != null) || (image != null);
void endTable(StringBuilder sb)
static String getStringTime(long epochSeconds, TimeZone tzone)
void addRow(StringBuilder sb, String key, String value)
javax.swing.JTextPane jTextPane1
javax.swing.JPopupMenu jPopupMenu1
void customizeComponents()
static void configureTextPaneAsHtml(JTextPane pane)
boolean isSupported(Node node)
DataContentViewer createInstance()
int isPreferred(Node node)
javax.swing.JScrollPane jScrollPane2
void startTable(StringBuilder sb)