mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 00:16:16 +00:00
Added event firing for OsAccount objects
This commit is contained in:
parent
19601d57e5
commit
94435b03ba
@ -81,6 +81,8 @@ import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.DataSourceAddedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.DataSourceDeletedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.DataSourceNameChangedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.OsAccountAddedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.OsAccountChangedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.ReportAddedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.multiusercases.CaseNodeData.CaseNodeDataException;
|
||||
import org.sleuthkit.autopsy.casemodule.multiusercases.CoordinationServiceUtils;
|
||||
@ -128,6 +130,10 @@ import org.sleuthkit.datamodel.ContentTag;
|
||||
import org.sleuthkit.datamodel.DataSource;
|
||||
import org.sleuthkit.datamodel.FileSystem;
|
||||
import org.sleuthkit.datamodel.Image;
|
||||
import org.sleuthkit.datamodel.OsAccount;
|
||||
import org.sleuthkit.datamodel.OsAccountManager;
|
||||
import org.sleuthkit.datamodel.OsAccountManager.OsAccountsAddedEvent;
|
||||
import org.sleuthkit.datamodel.OsAccountManager.OsAccountsChangedEvent;
|
||||
import org.sleuthkit.datamodel.Report;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
import org.sleuthkit.datamodel.TimelineManager;
|
||||
@ -409,7 +415,17 @@ public class Case {
|
||||
* An item in the central repository has had its comment modified. The
|
||||
* old value is null, the new value is string for current comment.
|
||||
*/
|
||||
CR_COMMENT_CHANGED;
|
||||
CR_COMMENT_CHANGED,
|
||||
/**
|
||||
* OSAccount associated with the current case added. Call getOsAccount
|
||||
* to get the added account;
|
||||
*/
|
||||
OS_ACCOUNT_ADDED,
|
||||
/**
|
||||
* OSAccount associated with the current case has changed.
|
||||
* Call getOsAccount to get the changed account;
|
||||
*/
|
||||
OS_ACCOUNT_CHANGED;
|
||||
|
||||
};
|
||||
|
||||
@ -443,6 +459,20 @@ public class Case {
|
||||
event.getArtifacts(artifactType)));
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void publishOsAccountAddedEvent(OsAccountManager.OsAccountsAddedEvent event) {
|
||||
for(OsAccount account: event.getOsAcounts()) {
|
||||
eventPublisher.publish(new OsAccountAddedEvent(account));
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void publishOsAccountAddedEvent(OsAccountManager.OsAccountsChangedEvent event) {
|
||||
for(OsAccount account: event.getOsAcounts()) {
|
||||
eventPublisher.publish(new OsAccountChangedEvent(account));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1639,7 +1669,15 @@ public class Case {
|
||||
public void notifyBlackBoardArtifactTagDeleted(BlackboardArtifactTag deletedTag) {
|
||||
eventPublisher.publish(new BlackBoardArtifactTagDeletedEvent(deletedTag));
|
||||
}
|
||||
|
||||
public void notifyOsAccountAdded(OsAccount account) {
|
||||
eventPublisher.publish(new OsAccountAddedEvent(account));
|
||||
}
|
||||
|
||||
public void notifyOsAccountChanged(OsAccount account) {
|
||||
eventPublisher.publish(new OsAccountChangedEvent(account));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a report to the case.
|
||||
*
|
||||
|
35
Core/src/org/sleuthkit/autopsy/casemodule/events/OsAccountAddedEvent.java
Executable file
35
Core/src/org/sleuthkit/autopsy/casemodule/events/OsAccountAddedEvent.java
Executable file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 added to a case.
|
||||
*/
|
||||
public final class OsAccountAddedEvent extends OsAccountEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public OsAccountAddedEvent(OsAccount account) {
|
||||
super(Case.Events.OS_ACCOUNT_ADDED.toString(), account);
|
||||
}
|
||||
|
||||
}
|
34
Core/src/org/sleuthkit/autopsy/casemodule/events/OsAccountChangedEvent.java
Executable file
34
Core/src/org/sleuthkit/autopsy/casemodule/events/OsAccountChangedEvent.java
Executable 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 updated.
|
||||
*/
|
||||
public final class OsAccountChangedEvent extends OsAccountEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public OsAccountChangedEvent(OsAccount account) {
|
||||
super(Case.Events.OS_ACCOUNT_CHANGED.toString(), account);
|
||||
}
|
||||
}
|
64
Core/src/org/sleuthkit/autopsy/casemodule/events/OsAccountEvent.java
Executable file
64
Core/src/org/sleuthkit/autopsy/casemodule/events/OsAccountEvent.java
Executable file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import org.sleuthkit.datamodel.OsAccount;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
* Parent class for specific OsAccount event classes.
|
||||
*/
|
||||
class OsAccountEvent extends TskDataModelChangeEvent<OsAccount> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Construct a new OsAccountEvent.
|
||||
*
|
||||
* @param eventName The name of the event.
|
||||
* @param account The OsAccount the event applies to.
|
||||
*/
|
||||
OsAccountEvent(String eventName, OsAccount account) {
|
||||
super(eventName, Stream.of(account.getId()).collect(Collectors.toList()), Stream.of(account).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the OsAccount that changed.
|
||||
*
|
||||
* @return The OsAccount that was changed.
|
||||
*/
|
||||
public OsAccount getOsAccount() {
|
||||
List<OsAccount> accounts = getNewValue();
|
||||
return accounts.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<OsAccount> getDataModelObjects(SleuthkitCase caseDb, List<Long> ids) throws TskCoreException {
|
||||
Long id = ids.get(0);
|
||||
OsAccount account = caseDb.getOsAccountManager().getOsAccount(id);
|
||||
List<OsAccount> accounts = new ArrayList<>();
|
||||
accounts.add(account);
|
||||
return accounts;
|
||||
}
|
||||
}
|
@ -75,8 +75,8 @@ public abstract class TskDataModelChangeEvent<T> extends AutopsyEvent {
|
||||
*
|
||||
* @return The unique IDs.
|
||||
*/
|
||||
public final List<T> getDataModelObjectIds() {
|
||||
return Collections.unmodifiableList(dataModelObjects);
|
||||
public final List<Long> getDataModelObjectIds() {
|
||||
return Collections.unmodifiableList(dataModelObjectIds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user