Handle OS account removed event

This commit is contained in:
apriestman 2021-03-18 15:06:54 -04:00
parent 60a7e47153
commit ee85de968f
3 changed files with 54 additions and 3 deletions

View File

@ -87,6 +87,7 @@ import org.sleuthkit.autopsy.casemodule.events.HostsChangedEvent;
import org.sleuthkit.autopsy.casemodule.events.HostsRemovedEvent;
import org.sleuthkit.autopsy.casemodule.events.OsAccountAddedEvent;
import org.sleuthkit.autopsy.casemodule.events.OsAccountChangedEvent;
import org.sleuthkit.autopsy.casemodule.events.OsAccountRemovedEvent;
import org.sleuthkit.autopsy.casemodule.events.PersonsAddedEvent;
import org.sleuthkit.autopsy.casemodule.events.PersonsChangedEvent;
import org.sleuthkit.autopsy.casemodule.events.PersonsRemovedEvent;
@ -143,8 +144,8 @@ import org.sleuthkit.datamodel.HostManager.HostsUpdateEvent;
import org.sleuthkit.datamodel.HostManager.HostsDeletionEvent;
import org.sleuthkit.datamodel.Image;
import org.sleuthkit.datamodel.OsAccount;
import org.sleuthkit.datamodel.OsAccountManager;
import org.sleuthkit.datamodel.OsAccountManager.OsAccountsCreationEvent;
import org.sleuthkit.datamodel.OsAccountManager.OsAccountsDeleteEvent;
import org.sleuthkit.datamodel.OsAccountManager.OsAccountsUpdateEvent;
import org.sleuthkit.datamodel.Person;
import org.sleuthkit.datamodel.PersonManager.PersonsCreationEvent;
@ -442,6 +443,10 @@ public class Case {
* Call getOsAccount to get the changed account;
*/
OS_ACCOUNT_CHANGED,
/**
* OSAccount associated with the current case has been deleted.
*/
OS_ACCOUNT_REMOVED,
/**
* Hosts associated with the current case added.
@ -520,6 +525,13 @@ public class Case {
}
}
@Subscribe
public void publishOsAccountDeletedEvent(OsAccountsDeleteEvent event) {
for(OsAccount account: event.getOsAcounts()) {
eventPublisher.publish(new OsAccountRemovedEvent(account));
}
}
/**
* Publishes an autopsy event from the sleuthkit HostCreationEvent
* indicating that hosts have been created.
@ -1798,6 +1810,10 @@ public class Case {
eventPublisher.publish(new OsAccountChangedEvent(account));
}
public void notifyOsAccountRemoved(OsAccount account) {
eventPublisher.publish(new OsAccountRemovedEvent(account));
}
/**
* Notify via an autopsy event that a host has been added.
* @param host The host that has been added.

View File

@ -0,0 +1,34 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.casemodule.events;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.datamodel.OsAccount;
/**
* Event published when an OsAccount is deleted.
*/
public final class OsAccountRemovedEvent extends OsAccountEvent {
private static final long serialVersionUID = 1L;
public OsAccountRemovedEvent(OsAccount account) {
super(Case.Events.OS_ACCOUNT_REMOVED.toString(), account);
}
}

View File

@ -114,7 +114,8 @@ public final class OsAccounts implements AutopsyVisitableItem {
@Override
public void propertyChange(PropertyChangeEvent evt) {
String eventType = evt.getPropertyName();
if(eventType.equals(Case.Events.OS_ACCOUNT_ADDED.toString())) {
if(eventType.equals(Case.Events.OS_ACCOUNT_ADDED.toString())
|| eventType.equals(Case.Events.OS_ACCOUNT_REMOVED.toString())) {
refresh(true);
} else if (eventType.equals(Case.Events.CURRENT_CASE.toString())) {
// case was closed. Remove listeners so that we don't get called with a stale case handle
@ -128,7 +129,7 @@ public final class OsAccounts implements AutopsyVisitableItem {
@Override
protected void addNotify() {
Case.addEventTypeSubscriber(Collections.singleton(Case.Events.OS_ACCOUNT_ADDED), listener);
Case.addEventTypeSubscriber(EnumSet.of(Case.Events.OS_ACCOUNT_ADDED, Case.Events.OS_ACCOUNT_REMOVED), listener);
Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), listener);
}