mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
Merge pull request #5948 from kellykelly3/1478-CVT-query-for-specific-account-type
1478 cvt query for specific account type
This commit is contained in:
commit
7aa735c91b
@ -27,6 +27,7 @@ import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
import org.sleuthkit.datamodel.Account;
|
||||
|
||||
/**
|
||||
* This class represents an association between a Persona and an Account.
|
||||
@ -130,7 +131,13 @@ public class PersonaAccount {
|
||||
* account.
|
||||
*/
|
||||
static PersonaAccount addPersonaAccount(Persona persona, CentralRepoAccount account, String justification, Persona.Confidence confidence) throws CentralRepoException {
|
||||
CentralRepoExaminer currentExaminer = CentralRepository.getInstance().getOrInsertExaminer(System.getProperty("user.name"));
|
||||
CentralRepository cr = CentralRepository.getInstance();
|
||||
|
||||
if(cr == null) {
|
||||
throw new CentralRepoException("Failed to add Persona, Central Repository is not enable");
|
||||
}
|
||||
|
||||
CentralRepoExaminer currentExaminer = cr.getOrInsertExaminer(System.getProperty("user.name"));
|
||||
|
||||
Instant instant = Instant.now();
|
||||
Long timeStampMillis = instant.toEpochMilli();
|
||||
@ -235,38 +242,53 @@ public class PersonaAccount {
|
||||
* Gets all the Accounts for the specified Persona.
|
||||
*
|
||||
* @param personaId Id of persona for which to get the accounts for.
|
||||
*
|
||||
* @return Collection of PersonaAccounts, may be empty.
|
||||
*
|
||||
* @throws CentralRepoException If there is an error in getting the
|
||||
* persona_account.
|
||||
* persona_account.
|
||||
*/
|
||||
static Collection<PersonaAccount> getPersonaAccountsForPersona(long personaId) throws CentralRepoException {
|
||||
String queryClause = PERSONA_ACCOUNTS_QUERY_CALUSE
|
||||
+ " WHERE persona_accounts.persona_id = " + personaId;
|
||||
CentralRepository cr = CentralRepository.getInstance();
|
||||
|
||||
PersonaAccountsQueryCallback queryCallback = new PersonaAccountsQueryCallback();
|
||||
CentralRepository.getInstance().executeSelectSQL(queryClause, queryCallback);
|
||||
if (cr != null) {
|
||||
String queryClause = PERSONA_ACCOUNTS_QUERY_CALUSE
|
||||
+ " WHERE persona_accounts.persona_id = " + personaId;
|
||||
|
||||
return queryCallback.getPersonaAccountsList();
|
||||
PersonaAccountsQueryCallback queryCallback = new PersonaAccountsQueryCallback();
|
||||
cr.executeSelectSQL(queryClause, queryCallback);
|
||||
|
||||
return queryCallback.getPersonaAccountsList();
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the Persona for the specified Account.
|
||||
*
|
||||
* @param accountId Id of account for which to get the Personas for.
|
||||
*
|
||||
* @return Collection of PersonaAccounts. may be empty.
|
||||
*
|
||||
* @throws CentralRepoException If there is an error in getting the
|
||||
* persona_account.
|
||||
* persona_account.
|
||||
*/
|
||||
public static Collection<PersonaAccount> getPersonaAccountsForAccount(long accountId) throws CentralRepoException {
|
||||
String queryClause = PERSONA_ACCOUNTS_QUERY_CALUSE
|
||||
+ " WHERE persona_accounts.account_id = " + accountId;
|
||||
|
||||
PersonaAccountsQueryCallback queryCallback = new PersonaAccountsQueryCallback();
|
||||
CentralRepository.getInstance().executeSelectSQL(queryClause, queryCallback);
|
||||
CentralRepository cr = CentralRepository.getInstance();
|
||||
|
||||
return queryCallback.getPersonaAccountsList();
|
||||
if (cr != null) {
|
||||
String queryClause = PERSONA_ACCOUNTS_QUERY_CALUSE
|
||||
+ " WHERE persona_accounts.account_id = " + accountId;
|
||||
|
||||
PersonaAccountsQueryCallback queryCallback = new PersonaAccountsQueryCallback();
|
||||
cr.executeSelectSQL(queryClause, queryCallback);
|
||||
|
||||
return queryCallback.getPersonaAccountsList();
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -274,20 +296,50 @@ public class PersonaAccount {
|
||||
* account identifier substring.
|
||||
*
|
||||
* @param accountIdentifierSubstring Account identifier substring to search
|
||||
* for.
|
||||
* for.
|
||||
*
|
||||
* @return Collection of PersonaAccounts. may be empty.
|
||||
*
|
||||
* @throws CentralRepoException If there is an error in getting the
|
||||
* persona_account.
|
||||
* persona_account.
|
||||
*/
|
||||
public static Collection<PersonaAccount> getPersonaAccountsForIdentifierLike(String accountIdentifierSubstring) throws CentralRepoException {
|
||||
String queryClause = PERSONA_ACCOUNTS_QUERY_CALUSE
|
||||
+ " WHERE LOWER(accounts.account_unique_identifier) LIKE LOWER('%" + accountIdentifierSubstring + "%')";
|
||||
|
||||
PersonaAccountsQueryCallback queryCallback = new PersonaAccountsQueryCallback();
|
||||
CentralRepository.getInstance().executeSelectSQL(queryClause, queryCallback);
|
||||
CentralRepository cr = CentralRepository.getInstance();
|
||||
if (cr != null) {
|
||||
PersonaAccountsQueryCallback queryCallback = new PersonaAccountsQueryCallback();
|
||||
cr.executeSelectSQL(queryClause, queryCallback);
|
||||
|
||||
return queryCallback.getPersonaAccountsList();
|
||||
return queryCallback.getPersonaAccountsList();
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the Persona associated with the given account.
|
||||
*
|
||||
* @param account Account to search for.
|
||||
*
|
||||
* @return Collection of PersonaAccounts, maybe empty if none were found or
|
||||
* CR is not enabled.
|
||||
*
|
||||
* @throws CentralRepoException
|
||||
*/
|
||||
public static Collection<PersonaAccount> getPersonaAccountsForAccount(Account account) throws CentralRepoException {
|
||||
String queryClause = PERSONA_ACCOUNTS_QUERY_CALUSE
|
||||
+ " WHERE LOWER(accounts.account_unique_identifier) LIKE LOWER('%" + account.getTypeSpecificID() + "%') AND type_name = '" + account.getAccountType().getTypeName() + "' ";
|
||||
|
||||
CentralRepository cr = CentralRepository.getInstance();
|
||||
if (cr != null) {
|
||||
PersonaAccountsQueryCallback queryCallback = new PersonaAccountsQueryCallback();
|
||||
cr.executeSelectSQL(queryClause, queryCallback);
|
||||
return queryCallback.getPersonaAccountsList();
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -299,8 +351,14 @@ public class PersonaAccount {
|
||||
* account.
|
||||
*/
|
||||
static void removePersonaAccount(long id) throws CentralRepoException {
|
||||
CentralRepository cr = CentralRepository.getInstance();
|
||||
|
||||
if(cr == null) {
|
||||
throw new CentralRepoException("Failed to remove persona account, Central Repo is not enabled");
|
||||
}
|
||||
|
||||
String deleteClause = " DELETE FROM persona_accounts WHERE id = " + id;
|
||||
CentralRepository.getInstance().executeDeleteSQL(deleteClause);
|
||||
cr.executeDeleteSQL(deleteClause);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -343,17 +401,23 @@ public class PersonaAccount {
|
||||
* accounts.
|
||||
*/
|
||||
static Collection<CentralRepoAccount> getAccountsForPersona(long personaId) throws CentralRepoException {
|
||||
String queryClause = "SELECT account_id, "
|
||||
+ " accounts.account_type_id as account_type_id, accounts.account_unique_identifier as account_unique_identifier,"
|
||||
+ " account_types.type_name as type_name "
|
||||
+ " FROM persona_accounts "
|
||||
+ " JOIN accounts as accounts on persona_accounts.account_id = accounts.id "
|
||||
+ " JOIN account_types as account_types on accounts.account_type_id = account_types.id "
|
||||
+ " WHERE persona_accounts.persona_id = " + personaId;
|
||||
CentralRepository cr = CentralRepository.getInstance();
|
||||
|
||||
AccountsForPersonaQueryCallback queryCallback = new AccountsForPersonaQueryCallback();
|
||||
CentralRepository.getInstance().executeSelectSQL(queryClause, queryCallback);
|
||||
if (cr != null) {
|
||||
String queryClause = "SELECT account_id, "
|
||||
+ " accounts.account_type_id as account_type_id, accounts.account_unique_identifier as account_unique_identifier,"
|
||||
+ " account_types.type_name as type_name "
|
||||
+ " FROM persona_accounts "
|
||||
+ " JOIN accounts as accounts on persona_accounts.account_id = accounts.id "
|
||||
+ " JOIN account_types as account_types on accounts.account_type_id = account_types.id "
|
||||
+ " WHERE persona_accounts.persona_id = " + personaId;
|
||||
|
||||
return queryCallback.getAccountsList();
|
||||
AccountsForPersonaQueryCallback queryCallback = new AccountsForPersonaQueryCallback();
|
||||
cr.executeSelectSQL(queryClause, queryCallback);
|
||||
|
||||
return queryCallback.getAccountsList();
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,38 @@
|
||||
AddAccountDialog.title.text=Add Account
|
||||
AddAccountDialog_dup_msg=This account is already added to the persona
|
||||
AddAccountDialog_dup_Title=Account add failure
|
||||
AddAccountDialog_empty_msg=The identifier field cannot be empty
|
||||
AddAccountDialog_empty_Title=Empty identifier
|
||||
AddAccountDialog_get_types_exception_msg=Failed to access central repository
|
||||
AddAccountDialog_get_types_exception_Title=Central Repository failure
|
||||
AddAccountDialog_validate_id_failure=Account ID must not be empty
|
||||
AddAccountDialog_validate_id_failure_title=Account ID issue
|
||||
AddAccountDialog_search_empty_msg=Account not found for given identifier and type
|
||||
AddAccountDialog_search_empty_Title=Account not found
|
||||
AddAccountDialog_search_failure_msg=Central Repository account search failed
|
||||
AddAccountDialog_search_failure_Title=Account add failure
|
||||
AddAliasDialog.title.text=Add Alias
|
||||
AddAliasDialog_dup_msg=This alias has already been added to this persona
|
||||
AddAliasDialog_dup_Title=Alias add failure
|
||||
AddMetadataDialog.title.text=Add Metadata
|
||||
AddMetadataDialog_dup_msg=A metadata entry with this name has already been added to this persona
|
||||
AddMetadataDialog_dup_Title=Metadata add failure
|
||||
CTL_OpenPersonaManager=Persona Manager
|
||||
CTL_PersonaManagerTopComponentAction=Persona Manager
|
||||
CTL_PersonaDetailsTopComponent=Persona Details
|
||||
OpenPersonasAction.displayName=Persona Manager
|
||||
PersonaDetailsDialogCreateTitle=Create Persona
|
||||
PersonaDetailsDialogEditTitle=Edit Persona
|
||||
PersonaDetailsPanel_CentralRepoErr_msg=Failure to write to Central Repository
|
||||
PersonaDetailsPanel_CentralRepoErr_Title=Central Repository failure
|
||||
PersonaDetailsPanel_EmptyName_msg=Persona name cannot be empty
|
||||
PersonaDetailsPanel_EmptyName_Title=Empty persona name
|
||||
PersonaDetailsPanel_load_exception_msg=Failed to load persona
|
||||
PersonaDetailsPanel_load_exception_Title=Initialization failure
|
||||
PersonaDetailsPanel_NameCreate=Create Persona
|
||||
PersonaDetailsPanel_NameEdit=Edit Persona
|
||||
PersonaDetailsPanel_NameView=View Persona
|
||||
PersonaManagerTopComponent.createBtn.text=Create New
|
||||
PersonaDetailsPanel_NotEnoughAccounts_msg=Two or more accounts are necessary to create a persona
|
||||
PersonaDetailsPanel_NotEnoughAccounts_Title=Not enough accounts
|
||||
PersonaManagerTopComponent.createBtn.text=New Persona
|
||||
PersonaManagerTopComponent.searchBtn.text=Search
|
||||
PersonaManagerTopComponent.resultsTable.columnModel.title1=Name
|
||||
PersonaManagerTopComponent.resultsTable.columnModel.title0=ID
|
||||
@ -20,6 +40,17 @@ PersonaManagerTopComponent.resultsTable.toolTipText=
|
||||
PersonaManagerTopComponent.searchAccountRadio.text=Account
|
||||
PersonaManagerTopComponent.searchNameRadio.text=Name
|
||||
PersonaManagerTopComponent.searchField.text=
|
||||
AddAccountDialog.cancelBtn.text=Cancel
|
||||
AddAccountDialog.okBtn.text=OK
|
||||
PersonaManagerTopComponent.editBtn.text=Edit Persona
|
||||
PersonaDetailsDialog.cancelBtn.text=Cancel
|
||||
PersonaDetailsDialog.okBtn.text=OK
|
||||
PersonaDetailsPanel.deleteCaseBtn.text=Delete
|
||||
PersonaDetailsPanel.addCaseBtn.text=Add
|
||||
PersonaDetailsPanel.casesLbl.text=Cases found in:
|
||||
PersonaDetailsPanel.deleteAliasBtn.text=Delete
|
||||
PersonaDetailsPanel.addAliasBtn.text=Add
|
||||
PersonaDetailsPanel.aliasesLabel.text=Aliases:
|
||||
PersonaDetailsPanel.deleteMetadataBtn.text=Delete
|
||||
PersonaDetailsPanel.addMetadataBtn.text=Add
|
||||
PersonaDetailsPanel.metadataLabel.text=Metadata:
|
||||
@ -27,18 +58,32 @@ PersonaDetailsPanel.deleteAccountBtn.text=Delete
|
||||
PersonaDetailsPanel.addAccountBtn.text=Add
|
||||
PersonaDetailsPanel.accountsLbl.text=Accounts:
|
||||
PersonaDetailsPanel.nameField.text=
|
||||
PersonaDetailsPanel.saveBtn.toolTipText=
|
||||
PersonaDetailsPanel.saveBtn.text=Save Changes
|
||||
PersonaDetailsPanel.nameLbl.text=Name:
|
||||
PersonaDetailsPanel.deleteCaseBtn.text=Delete
|
||||
PersonaDetailsPanel.addCaseBtn.text=Add
|
||||
PersonaDetailsPanel.casesLbl.text=Cases found in:
|
||||
PersonaDetailsPanel.deleteAliasBtn.text=Delete
|
||||
PersonaDetailsPanel.addAliasBtn.text=Add
|
||||
PersonaDetailsPanel.aliasesLabel.text=Aliases:
|
||||
AddAccountDialog.cancelBtn.text=Cancel
|
||||
AddAccountDialog.okBtn.text=OK
|
||||
PersonaManagerTopComponent.editBtn.text=Edit
|
||||
AddAliasDialog.accountsLbl.text=Account:
|
||||
AddAliasDialog.okBtn.text=OK
|
||||
AddAliasDialog.cancelBtn.text=Cancel
|
||||
AddMetadataDialog.cancelBtn.text=Cancel
|
||||
AddMetadataDialog.okBtn.text=OK
|
||||
AddMetadataDialog.nameLbl.text=Name:
|
||||
AddMetadataDialog.nameTextField.text=
|
||||
AddMetadataDialog.valueLbl.text=Value:
|
||||
AddMetadataDialog.valueTextField.text=
|
||||
AddMetadataDialog.justificationLbl.text=Justification:
|
||||
AddMetadataDialog.justificationTextField.text=
|
||||
AddMetadataDialog.confidenceLbl.text=Confidence:
|
||||
AddAliasDialog.justificationLbl.text=Justification:
|
||||
AddAliasDialog.okBtn.text_1=OK
|
||||
AddAliasDialog.cancelBtn.text_1=Cancel
|
||||
AddAliasDialog.confidenceLbl.text=Confidence:
|
||||
AddAliasDialog.justificationTextField.text=
|
||||
AddAliasDialog.aliasLbl.text=Alias:
|
||||
AddAliasDialog.aliasTextField.text=
|
||||
AddAccountDialog.justificationTextField.text=
|
||||
AddAccountDialog.justificationLbl.text=Justification:
|
||||
AddAccountDialog.confidenceLbl.text=Confidence:
|
||||
AddAccountDialog.typeLbl.text=Type:
|
||||
AddAccountDialog.identiferLbl.text=Identifier:
|
||||
AddAccountDialog.identifierTextField.text=
|
||||
PMTopComponent_Name=Persona Manager
|
||||
PMTopComponent_search_exception_msg=Failed to search personas
|
||||
PMTopComponent_search_exception_Title=Search failure
|
||||
|
@ -123,7 +123,7 @@ final class AccountDeviceInstanceNode extends AbstractNode {
|
||||
public String getShortDescription() {
|
||||
List<PersonaAccount> personaList;
|
||||
try {
|
||||
personaList = CVTPersonaCache.getPersonaAccounts(getName());
|
||||
personaList = CVTPersonaCache.getPersonaAccounts(account);
|
||||
} catch (ExecutionException ex) {
|
||||
logger.log(Level.WARNING, "Failed to retrieve Persona details for node.", ex);
|
||||
return getDisplayName();
|
||||
|
@ -31,6 +31,7 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.PersonaAccount;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.datamodel.Account;
|
||||
|
||||
/**
|
||||
* A singleton cache of the PersonaAccount information. The list of
|
||||
@ -40,7 +41,7 @@ import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
final class CVTPersonaCache {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CVTPersonaCache.class.getName());
|
||||
private final LoadingCache<String, List<PersonaAccount>> accountMap;
|
||||
private final LoadingCache<Account, List<PersonaAccount>> accountMap;
|
||||
|
||||
private static CVTPersonaCache instance;
|
||||
|
||||
@ -49,13 +50,13 @@ final class CVTPersonaCache {
|
||||
*/
|
||||
private CVTPersonaCache() {
|
||||
accountMap = CacheBuilder.newBuilder().expireAfterAccess(5, TimeUnit.MINUTES).build(
|
||||
new CacheLoader<String, List<PersonaAccount>>() {
|
||||
new CacheLoader<Account, List<PersonaAccount>>() {
|
||||
@Override
|
||||
public List<PersonaAccount> load(String key) {
|
||||
public List<PersonaAccount> load(Account key) {
|
||||
List<PersonaAccount> accountList = new ArrayList<>();
|
||||
try {
|
||||
if (CentralRepository.isEnabled()) {
|
||||
Collection<PersonaAccount> accounts = PersonaAccount.getPersonaAccountsForIdentifierLike(key);
|
||||
Collection<PersonaAccount> accounts = PersonaAccount.getPersonaAccountsForAccount(key);
|
||||
accountList.addAll(accounts);
|
||||
}
|
||||
} catch (CentralRepoException ex) {
|
||||
@ -89,7 +90,7 @@ final class CVTPersonaCache {
|
||||
*
|
||||
* @throws ExecutionException
|
||||
*/
|
||||
static synchronized List<PersonaAccount> getPersonaAccounts(String typeSpecificID) throws ExecutionException {
|
||||
return getInstance().accountMap.get(typeSpecificID);
|
||||
static synchronized List<PersonaAccount> getPersonaAccounts(Account account) throws ExecutionException {
|
||||
return getInstance().accountMap.get(account);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user