Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
KnownStatusSearchFilter.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011 - 2013 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.filesearch;
20 
21 import java.awt.event.ActionListener;
22 import org.openide.util.NbBundle;
23 import org.openide.util.NbBundle.Messages;
24 import org.sleuthkit.datamodel.TskData.FileKnown;
25 
29 class KnownStatusSearchFilter extends AbstractFileSearchFilter<KnownStatusSearchPanel> {
30 
31  private static final String NONE_SELECTED_MESSAGE = NbBundle
32  .getMessage(KnownStatusSearchFilter.class, "KnownStatusSearchFilter.noneSelectedMsg.text");
33 
34  KnownStatusSearchFilter(KnownStatusSearchPanel panel) {
35  super(panel);
36  }
37 
38  KnownStatusSearchFilter() {
39  this(new KnownStatusSearchPanel());
40  }
41 
42  @Override
43  public boolean isEnabled() {
44  return this.getComponent().getKnownCheckBox().isSelected();
45 
46  }
47 
48  @Override
49  public String getPredicate() throws FilterValidationException {
50  KnownStatusSearchPanel panel = this.getComponent();
51 
52  boolean unknown = panel.getUnknownOptionCheckBox().isSelected();
53  boolean known = panel.getKnownOptionCheckBox().isSelected();
54  boolean knownBad = panel.getKnownBadOptionCheckBox().isSelected();
55 
56  if (!(unknown || known || knownBad)) {
57  throw new FilterValidationException(NONE_SELECTED_MESSAGE);
58  }
59 
60  String expr = "NULL";
61  if (unknown) {
62  expr += " OR " + predicateHelper(FileKnown.UNKNOWN); //NON-NLS
63  }
64  if (known) {
65  expr += " OR " + predicateHelper(FileKnown.KNOWN); //NON-NLS
66  }
67  if (knownBad) {
68  expr += " OR " + predicateHelper(FileKnown.BAD); //NON-NLS
69  }
70  return expr;
71  }
72 
80  private String predicateHelper(FileKnown knownStatus) {
81  return "known = " + knownStatus.getFileKnownValue(); //NON-NLS
82  }
83 
84  @Override
85  public void addActionListener(ActionListener l) {
86  }
87 
88  @Override
89  @Messages ({
90  "KnownStatusSearchFilter.errorMessage.noKnownStatusCheckboxSelected=At least one known status checkbox must be selected."
91  })
92  public boolean isValid() {
93  if (!this.getComponent().isValidSearch()) {
94  setLastError(Bundle.KnownStatusSearchFilter_errorMessage_noKnownStatusCheckboxSelected());
95  return false;
96  }
97  return true;
98  }
99 }

Copyright © 2012-2022 Basis Technology. Generated on: Sat Sep 24 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.