Update OsAccountDataViewer

This commit is contained in:
Kelly Kelly 2021-03-30 16:38:09 -04:00
parent a096c6e926
commit 996cd1f0bc
2 changed files with 57 additions and 19 deletions

View File

@ -1,3 +1,4 @@
OsAccountDataPanel_administrator_title=Administrator
OsAccountDataPanel_basic_address=Address OsAccountDataPanel_basic_address=Address
OsAccountDataPanel_basic_admin=Administrator OsAccountDataPanel_basic_admin=Administrator
OsAccountDataPanel_basic_creationDate=Creation Date OsAccountDataPanel_basic_creationDate=Creation Date
@ -5,6 +6,10 @@ OsAccountDataPanel_basic_fullname=Full Name
OsAccountDataPanel_basic_login=Login OsAccountDataPanel_basic_login=Login
OsAccountDataPanel_basic_title=Basic Properties OsAccountDataPanel_basic_title=Basic Properties
OsAccountDataPanel_basic_type=Type OsAccountDataPanel_basic_type=Type
OsAccountDataPanel_data_accessed_title=Last Login
OsAccountDataPanel_host_count_title=Login Count
# {0} - hostName
OsAccountDataPanel_host_section_title={0} Details
OsAccountDataPanel_realm_address=Address OsAccountDataPanel_realm_address=Address
OsAccountDataPanel_realm_confidence=Confidence OsAccountDataPanel_realm_confidence=Confidence
OsAccountDataPanel_realm_name=Name OsAccountDataPanel_realm_name=Name

View File

@ -41,6 +41,7 @@ import javax.swing.SwingWorker;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.contentviewers.osaccount.SectionData.RowData; import org.sleuthkit.autopsy.contentviewers.osaccount.SectionData.RowData;
import org.sleuthkit.datamodel.BlackboardAttribute;
import org.sleuthkit.datamodel.DataSource; import org.sleuthkit.datamodel.DataSource;
import org.sleuthkit.datamodel.Host; import org.sleuthkit.datamodel.Host;
import org.sleuthkit.datamodel.OsAccount; import org.sleuthkit.datamodel.OsAccount;
@ -48,6 +49,7 @@ import org.sleuthkit.datamodel.OsAccountAttribute;
import org.sleuthkit.datamodel.OsAccountInstance; import org.sleuthkit.datamodel.OsAccountInstance;
import org.sleuthkit.datamodel.OsAccountManager; import org.sleuthkit.datamodel.OsAccountManager;
import org.sleuthkit.datamodel.OsAccountRealm; import org.sleuthkit.datamodel.OsAccountRealm;
import org.sleuthkit.datamodel.SleuthkitCase;
/** /**
* Panel for displaying the properties of an OsAccount. * Panel for displaying the properties of an OsAccount.
@ -82,7 +84,6 @@ public class OsAccountDataPanel extends JPanel {
* @param account OsAccount to display, if null is passed the panel will * @param account OsAccount to display, if null is passed the panel will
* appear blank. * appear blank.
*/ */
// void setOsAccount(OsAccount account) {
void setOsAccountId(Long osAccountId) { void setOsAccountId(Long osAccountId) {
removeAll(); removeAll();
revalidate(); revalidate();
@ -225,10 +226,33 @@ public class OsAccountDataPanel extends JPanel {
return data; return data;
} }
@Messages({
"# {0} - hostName",
"OsAccountDataPanel_host_section_title={0} Details",
"OsAccountDataPanel_host_count_title=Login Count",
"OsAccountDataPanel_data_accessed_title=Last Login",
"OsAccountDataPanel_administrator_title=Administrator"
})
private SectionData buildHostData(Host host, List<OsAccountAttribute> attributeList) { private SectionData buildHostData(Host host, List<OsAccountAttribute> attributeList) {
SectionData data = new SectionData(host.getName()); SectionData data = new SectionData(Bundle.OsAccountDataPanel_host_section_title(host.getName()));
for (OsAccountAttribute attribute : attributeList) { for (OsAccountAttribute attribute : attributeList) {
data.addData(attribute.getAttributeType().getDisplayName(), attribute.getDisplayString()); String displayName = attribute.getAttributeType().getDisplayName();
String value = attribute.getDisplayString();
if(attribute.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_COUNT.getTypeID()) {
displayName = Bundle.OsAccountDataPanel_host_count_title();
} else if(attribute.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_IS_ADMIN.getTypeID()) {
displayName = Bundle.OsAccountDataPanel_administrator_title();
if(attribute.getValueInt() == 0) {
value = "False";
} else {
value = "True";
}
} else if(attribute.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_ACCESSED.getTypeID()) {
displayName = Bundle.OsAccountDataPanel_data_accessed_title();
}
data.addData(displayName, value);
} }
return data; return data;
@ -254,7 +278,7 @@ public class OsAccountDataPanel extends JPanel {
* @param row The row in the layout. * @param row The row in the layout.
*/ */
private void addPropertyName(String key, int row) { private void addPropertyName(String key, int row) {
JLabel label = new JLabel(key); JLabel label = new JLabel(key + ":");
add(label, getPropertyNameContraints(row)); add(label, getPropertyNameContraints(row));
} }
@ -359,7 +383,9 @@ public class OsAccountDataPanel extends JPanel {
protected WorkerResults doInBackground() throws Exception { protected WorkerResults doInBackground() throws Exception {
Map<Host, List<OsAccountAttribute>> hostMap = new HashMap<>(); Map<Host, List<OsAccountAttribute>> hostMap = new HashMap<>();
Map<Host, DataSource> instanceMap = new HashMap<>(); Map<Host, DataSource> instanceMap = new HashMap<>();
OsAccountManager osAccountManager = Case.getCurrentCase().getSleuthkitCase().getOsAccountManager(); SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase();
OsAccountManager osAccountManager = skCase.getOsAccountManager();
OsAccountRealm realm = skCase.getOsAccountRealmManager().getRealmById(account.getRealmId());
if(account == null) { if(account == null) {
account = osAccountManager.getOsAccountByObjectId(accountId); account = osAccountManager.getOsAccountByObjectId(accountId);
@ -414,7 +440,7 @@ public class OsAccountDataPanel extends JPanel {
} }
} }
return new WorkerResults(hostMap, instanceMap); return new WorkerResults(hostMap, instanceMap, realm);
} }
@Override @Override
@ -442,20 +468,21 @@ public class OsAccountDataPanel extends JPanel {
hostDataMap.forEach((K, V) -> data.add(buildHostData(K, V))); hostDataMap.forEach((K, V) -> data.add(buildHostData(K, V)));
} }
// TODO - load realm on background thread OsAccountRealm realm = results.getRealm();
//OsAccountRealm realm = account.getRealm(); if (realm != null) {
//if (realm != null) { data.add(buildRealmProperties(realm));
// data.add(buildRealmProperties(realm));
//}
Map<Host, DataSource> instanceMap = results.getDataSourceMap();
if (!instanceMap.isEmpty()) {
SectionData instanceSection = new SectionData("Instances");
instanceMap.forEach((K, V) -> instanceSection.addData(K.getName(), V.getName()));
data.add(instanceSection);
} }
// Removing the instance section for now. Leaving code here for
// future use.
// Map<Host, DataSource> instanceMap = results.getDataSourceMap();
// if (!instanceMap.isEmpty()) {
// SectionData instanceSection = new SectionData("Instances");
// instanceMap.forEach((K, V) -> instanceSection.addData(K.getName(), V.getName()));
//
// data.add(instanceSection);
// }
addDataComponents(data); addDataComponents(data);
revalidate(); revalidate();
@ -472,6 +499,7 @@ public class OsAccountDataPanel extends JPanel {
private final Map<Host, List<OsAccountAttribute>> attributeMap; private final Map<Host, List<OsAccountAttribute>> attributeMap;
private final Map<Host, DataSource> instanceMap; private final Map<Host, DataSource> instanceMap;
private final OsAccountRealm realm;
/** /**
* Construct a new WorkerResult object. * Construct a new WorkerResult object.
@ -481,9 +509,10 @@ public class OsAccountDataPanel extends JPanel {
* @param instanceMap A map of data to display OsAccount instance * @param instanceMap A map of data to display OsAccount instance
* information. * information.
*/ */
WorkerResults(Map<Host, List<OsAccountAttribute>> attributeMap, Map<Host, DataSource> instanceMap) { WorkerResults(Map<Host, List<OsAccountAttribute>> attributeMap, Map<Host, DataSource> instanceMap, OsAccountRealm realm) {
this.attributeMap = attributeMap; this.attributeMap = attributeMap;
this.instanceMap = instanceMap; this.instanceMap = instanceMap;
this.realm = realm;
} }
/** /**
@ -505,5 +534,9 @@ public class OsAccountDataPanel extends JPanel {
Map<Host, DataSource> getDataSourceMap() { Map<Host, DataSource> getDataSourceMap() {
return instanceMap; return instanceMap;
} }
OsAccountRealm getRealm() {
return realm;
}
} }
} }