From c1cea5f389ad290a3525be0824916d4baf1c1f51 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Tue, 28 Sep 2021 15:54:05 -0400 Subject: [PATCH 1/2] shows scope for os account node --- .../datamodel/Bundle.properties-MERGED | 3 ++ .../autopsy/datamodel/OsAccounts.java | 50 +++++++++++++------ 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/datamodel/Bundle.properties-MERGED index f5da7a8696..847e10b58d 100755 --- a/Core/src/org/sleuthkit/autopsy/datamodel/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/datamodel/Bundle.properties-MERGED @@ -356,6 +356,9 @@ OsAccounts_accountNameProperty_name=Name OsAccounts_accountRealmNameProperty_desc=OS Account Realm Name OsAccounts_accountRealmNameProperty_displayName=Realm Name OsAccounts_accountRealmNameProperty_name=RealmName +OsAccounts_accountScopeNameProperty_desc=OS Account Scope Name +OsAccounts_accountScopeNameProperty_displayName=Scope +OsAccounts_accountScopeNameProperty_name=ScopeName OsAccounts_createdTimeProperty_desc=OS Account Creation Time OsAccounts_createdTimeProperty_displayName=Creation Time OsAccounts_createdTimeProperty_name=creationTime diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/OsAccounts.java b/Core/src/org/sleuthkit/autopsy/datamodel/OsAccounts.java index e74275503b..492b952eab 100755 --- a/Core/src/org/sleuthkit/autopsy/datamodel/OsAccounts.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/OsAccounts.java @@ -31,6 +31,7 @@ import java.util.Optional; import java.util.logging.Level; import java.util.stream.Collectors; import javax.swing.Action; +import org.apache.commons.lang3.StringUtils; import org.openide.nodes.ChildFactory; import org.openide.nodes.Children; import org.openide.nodes.Node; @@ -208,6 +209,8 @@ public final class OsAccounts implements AutopsyVisitableItem { && evt.getNewValue() instanceof AsynchOsAcctData && ((AsynchOsAcctData) evt.getNewValue()).getOsAccountId() == account.getId()) { + List> propertiesToUpdate = new ArrayList<>(); + AsynchOsAcctData osAcctData = (AsynchOsAcctData) evt.getNewValue(); List realmNames = osAcctData.getOsAcctRealm().getRealmNames(); @@ -215,31 +218,41 @@ public final class OsAccounts implements AutopsyVisitableItem { String realmNamesStr = realmNames.stream() .map(String::trim) .distinct() - .sorted((a,b) -> a.compareToIgnoreCase(b)) + .sorted((a, b) -> a.compareToIgnoreCase(b)) .collect(Collectors.joining(", ")); - updateSheet(new NodeProperty<>( + propertiesToUpdate.add(new NodeProperty<>( Bundle.OsAccounts_accountRealmNameProperty_name(), Bundle.OsAccounts_accountRealmNameProperty_displayName(), Bundle.OsAccounts_accountRealmNameProperty_desc(), realmNamesStr)); } + String scopeName = osAcctData.getOsAcctRealm().getScope().getName(); + if (StringUtils.isNotBlank(scopeName)) { + propertiesToUpdate.add(new NodeProperty<>( + Bundle.OsAccounts_accountScopeNameProperty_name(), + Bundle.OsAccounts_accountScopeNameProperty_displayName(), + Bundle.OsAccounts_accountScopeNameProperty_desc(), + scopeName)); + } + List hosts = osAcctData.getHosts(); if (!hosts.isEmpty()) { String hostsString = hosts.stream() .map(h -> h.getName().trim()) .distinct() - .sorted((a,b) -> a.compareToIgnoreCase(b)) + .sorted((a, b) -> a.compareToIgnoreCase(b)) .collect(Collectors.joining(", ")); - updateSheet(new NodeProperty<>( + propertiesToUpdate.add(new NodeProperty<>( Bundle.OsAccounts_accountHostNameProperty_name(), Bundle.OsAccounts_accountHostNameProperty_displayName(), Bundle.OsAccounts_accountHostNameProperty_desc(), hostsString)); } + updateSheet(propertiesToUpdate.toArray(new NodeProperty[propertiesToUpdate.size()])); } } }; @@ -296,6 +309,9 @@ public final class OsAccounts implements AutopsyVisitableItem { "OsAccounts_accountHostNameProperty_name=HostName", "OsAccounts_accountHostNameProperty_displayName=Host", "OsAccounts_accountHostNameProperty_desc=OS Account Host Name", + "OsAccounts_accountScopeNameProperty_name=ScopeName", + "OsAccounts_accountScopeNameProperty_displayName=Scope", + "OsAccounts_accountScopeNameProperty_desc=OS Account Scope Name", "OsAccounts_createdTimeProperty_name=creationTime", "OsAccounts_createdTimeProperty_displayName=Creation Time", "OsAccounts_createdTimeProperty_desc=OS Account Creation Time", @@ -332,20 +348,25 @@ public final class OsAccounts implements AutopsyVisitableItem { Bundle.OsAccounts_loginNameProperty_displayName(), Bundle.OsAccounts_loginNameProperty_desc(), optional.isPresent() ? optional.get() : "")); - // Fill with empty string, fetch on background task. - String realmName = ""; - propertiesSet.put(new NodeProperty<>( - Bundle.OsAccounts_accountRealmNameProperty_name(), - Bundle.OsAccounts_accountRealmNameProperty_displayName(), - Bundle.OsAccounts_accountRealmNameProperty_desc(), - realmName)); - String hostName = ""; + // Fill with empty string, fetch on background task. propertiesSet.put(new NodeProperty<>( Bundle.OsAccounts_accountHostNameProperty_name(), Bundle.OsAccounts_accountHostNameProperty_displayName(), Bundle.OsAccounts_accountHostNameProperty_desc(), - hostName)); + "")); + + propertiesSet.put(new NodeProperty<>( + Bundle.OsAccounts_accountScopeNameProperty_name(), + Bundle.OsAccounts_accountScopeNameProperty_displayName(), + Bundle.OsAccounts_accountScopeNameProperty_desc(), + "")); + + propertiesSet.put(new NodeProperty<>( + Bundle.OsAccounts_accountRealmNameProperty_name(), + Bundle.OsAccounts_accountRealmNameProperty_displayName(), + Bundle.OsAccounts_accountRealmNameProperty_desc(), + "")); Optional creationTimeValue = account.getCreationTime(); String timeDisplayStr @@ -442,9 +463,10 @@ public final class OsAccounts implements AutopsyVisitableItem { /** * Main constructor. + * * @param osAccountId The id of the os account. * @param osAcctRealm The realm of the os account. - * @param hosts The hosts that the os account belongs to. + * @param hosts The hosts that the os account belongs to. */ AsynchOsAcctData(long osAccountId, OsAccountRealm osAcctRealm, List hosts) { this.osAccountId = osAccountId; From ae56b0da256b44b01823a9461d4f8271d13d79ae Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Tue, 28 Sep 2021 19:35:47 -0400 Subject: [PATCH 2/2] wrap in invokeLater --- Core/src/org/sleuthkit/autopsy/datamodel/OsAccounts.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/OsAccounts.java b/Core/src/org/sleuthkit/autopsy/datamodel/OsAccounts.java index 492b952eab..060c8f19ba 100755 --- a/Core/src/org/sleuthkit/autopsy/datamodel/OsAccounts.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/OsAccounts.java @@ -31,6 +31,7 @@ import java.util.Optional; import java.util.logging.Level; import java.util.stream.Collectors; import javax.swing.Action; +import javax.swing.SwingUtilities; import org.apache.commons.lang3.StringUtils; import org.openide.nodes.ChildFactory; import org.openide.nodes.Children; @@ -252,7 +253,8 @@ public final class OsAccounts implements AutopsyVisitableItem { hostsString)); } - updateSheet(propertiesToUpdate.toArray(new NodeProperty[propertiesToUpdate.size()])); + SwingUtilities.invokeLater(() -> + updateSheet(propertiesToUpdate.toArray(new NodeProperty[propertiesToUpdate.size()]))); } } };