mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Defined a new class, CentralRepoExaminer, to disambiguate from the Examiner class in case database.
This commit is contained in:
parent
2b75a00256
commit
204d2e17d8
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Central Repository
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.centralrepository.datamodel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encapsulates the concept of an examiner associated with a case.
|
||||||
|
*/
|
||||||
|
final public class CentralRepoExaminer {
|
||||||
|
|
||||||
|
private final long id; // Row id in the examiners table in central repo database.
|
||||||
|
private final String loginName;
|
||||||
|
private final String displayName;
|
||||||
|
|
||||||
|
public CentralRepoExaminer(long id, String loginName, String displayName) {
|
||||||
|
this.id = id;
|
||||||
|
this.loginName = loginName;
|
||||||
|
this.displayName = displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the id
|
||||||
|
*
|
||||||
|
* @return id
|
||||||
|
*/
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the login name of examiner
|
||||||
|
*
|
||||||
|
* @return login name
|
||||||
|
*/
|
||||||
|
public String getLoginName() {
|
||||||
|
return this.loginName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the display name of examiner
|
||||||
|
*
|
||||||
|
* @return display name, may be a blank string
|
||||||
|
*/
|
||||||
|
public String getDisplayName() {
|
||||||
|
if (displayName == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -177,7 +177,7 @@ public interface CentralRepository {
|
|||||||
* @return Examiner Current examiner.
|
* @return Examiner Current examiner.
|
||||||
* @throws CentralRepoException
|
* @throws CentralRepoException
|
||||||
*/
|
*/
|
||||||
Examiner getCurrentCentralRepoExaminer() throws CentralRepoException;
|
CentralRepoExaminer getCurrentCentralRepoExaminer() throws CentralRepoException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves Central Repo case based on an Autopsy Case
|
* Retrieves Central Repo case based on an Autopsy Case
|
||||||
|
@ -27,7 +27,6 @@ import java.util.Collections;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.sleuthkit.datamodel.Examiner;
|
|
||||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,7 +125,7 @@ public class Persona {
|
|||||||
private final long createdDate;
|
private final long createdDate;
|
||||||
private final long modifiedDate;
|
private final long modifiedDate;
|
||||||
private final PersonaStatus status;
|
private final PersonaStatus status;
|
||||||
private final Examiner examiner;
|
private final CentralRepoExaminer examiner;
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
@ -156,11 +155,11 @@ public class Persona {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Examiner getExaminer() {
|
public CentralRepoExaminer getExaminer() {
|
||||||
return examiner;
|
return examiner;
|
||||||
}
|
}
|
||||||
|
|
||||||
Persona(long id, String uuidStr, String name, String comment, long created_date, long modified_date, PersonaStatus status, Examiner examiner) {
|
Persona(long id, String uuidStr, String name, String comment, long created_date, long modified_date, PersonaStatus status, CentralRepoExaminer examiner) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.uuidStr = uuidStr;
|
this.uuidStr = uuidStr;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -207,7 +206,7 @@ public class Persona {
|
|||||||
private static Persona createPersona(String name, String comment, PersonaStatus status) throws CentralRepoException {
|
private static Persona createPersona(String name, String comment, PersonaStatus status) throws CentralRepoException {
|
||||||
// generate a UUID for the persona
|
// generate a UUID for the persona
|
||||||
String uuidStr = UUID.randomUUID().toString();
|
String uuidStr = UUID.randomUUID().toString();
|
||||||
Examiner examiner = CentralRepository.getInstance().getCurrentCentralRepoExaminer();
|
CentralRepoExaminer examiner = CentralRepository.getInstance().getCurrentCentralRepoExaminer();
|
||||||
|
|
||||||
Instant instant = Instant.now();
|
Instant instant = Instant.now();
|
||||||
Long timeStampMillis = instant.toEpochMilli();
|
Long timeStampMillis = instant.toEpochMilli();
|
||||||
@ -240,7 +239,7 @@ public class Persona {
|
|||||||
*/
|
*/
|
||||||
public PersonaAccount addAccountToPersona(CentralRepoAccount account, String justification, Persona.Confidence confidence) throws CentralRepoException {
|
public PersonaAccount addAccountToPersona(CentralRepoAccount account, String justification, Persona.Confidence confidence) throws CentralRepoException {
|
||||||
|
|
||||||
Examiner currentExaminer = CentralRepository.getInstance().getCurrentCentralRepoExaminer();
|
CentralRepoExaminer currentExaminer = CentralRepository.getInstance().getCurrentCentralRepoExaminer();
|
||||||
|
|
||||||
Instant instant = Instant.now();
|
Instant instant = Instant.now();
|
||||||
Long timeStampMillis = instant.toEpochMilli();
|
Long timeStampMillis = instant.toEpochMilli();
|
||||||
@ -269,7 +268,7 @@ public class Persona {
|
|||||||
public void process(ResultSet rs) throws SQLException {
|
public void process(ResultSet rs) throws SQLException {
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
Examiner examiner = new Examiner(
|
CentralRepoExaminer examiner = new CentralRepoExaminer(
|
||||||
rs.getInt("examiner_id"),
|
rs.getInt("examiner_id"),
|
||||||
rs.getString("login_name"),
|
rs.getString("login_name"),
|
||||||
rs.getString("display_name"));
|
rs.getString("display_name"));
|
||||||
@ -612,7 +611,7 @@ public class Persona {
|
|||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
|
|
||||||
// examiner that created the persona
|
// examiner that created the persona
|
||||||
Examiner personaExaminer = new Examiner(
|
CentralRepoExaminer personaExaminer = new CentralRepoExaminer(
|
||||||
resultSet.getInt("persona_examiner_id"),
|
resultSet.getInt("persona_examiner_id"),
|
||||||
resultSet.getString("persona_examiner_login_name"),
|
resultSet.getString("persona_examiner_login_name"),
|
||||||
resultSet.getString("persona_examiner_display_name"));
|
resultSet.getString("persona_examiner_display_name"));
|
||||||
|
@ -23,7 +23,6 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import org.sleuthkit.datamodel.Examiner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents an association between a Persona and an Account.
|
* This class represents an association between a Persona and an Account.
|
||||||
@ -39,9 +38,9 @@ public class PersonaAccount {
|
|||||||
private final String justification;
|
private final String justification;
|
||||||
private final Persona.Confidence confidence;
|
private final Persona.Confidence confidence;
|
||||||
private final long dateAdded;
|
private final long dateAdded;
|
||||||
private final Examiner examiner;
|
private final CentralRepoExaminer examiner;
|
||||||
|
|
||||||
public PersonaAccount(Persona persona, CentralRepoAccount account, String justification, Persona.Confidence confidence, long dateAdded, Examiner examiner) {
|
public PersonaAccount(Persona persona, CentralRepoAccount account, String justification, Persona.Confidence confidence, long dateAdded, CentralRepoExaminer examiner) {
|
||||||
this.persona = persona;
|
this.persona = persona;
|
||||||
this.account = account;
|
this.account = account;
|
||||||
this.justification = justification;
|
this.justification = justification;
|
||||||
@ -70,7 +69,7 @@ public class PersonaAccount {
|
|||||||
return dateAdded;
|
return dateAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Examiner getExaminer() {
|
public CentralRepoExaminer getExaminer() {
|
||||||
return examiner;
|
return examiner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,13 +85,13 @@ public class PersonaAccount {
|
|||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
// examiner that created the persona/account association
|
// examiner that created the persona/account association
|
||||||
Examiner paExaminer = new Examiner(
|
CentralRepoExaminer paExaminer = new CentralRepoExaminer(
|
||||||
rs.getInt("pa_examiner_id"),
|
rs.getInt("pa_examiner_id"),
|
||||||
rs.getString("pa_examiner_login_name"),
|
rs.getString("pa_examiner_login_name"),
|
||||||
rs.getString("pa_examiner_display_name"));
|
rs.getString("pa_examiner_display_name"));
|
||||||
|
|
||||||
// examiner that created the persona
|
// examiner that created the persona
|
||||||
Examiner personaExaminer = new Examiner(
|
CentralRepoExaminer personaExaminer = new CentralRepoExaminer(
|
||||||
rs.getInt("persona_examiner_id"),
|
rs.getInt("persona_examiner_id"),
|
||||||
rs.getString("persona_examiner_login_name"),
|
rs.getString("persona_examiner_login_name"),
|
||||||
rs.getString("persona_examiner_display_name"));
|
rs.getString("persona_examiner_display_name"));
|
||||||
|
@ -25,7 +25,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.sleuthkit.datamodel.Examiner;
|
|
||||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,7 +39,7 @@ public class PersonaAlias {
|
|||||||
private final String justification;
|
private final String justification;
|
||||||
private final Persona.Confidence confidence;
|
private final Persona.Confidence confidence;
|
||||||
private final long dateAdded;
|
private final long dateAdded;
|
||||||
private final Examiner examiner;
|
private final CentralRepoExaminer examiner;
|
||||||
|
|
||||||
public long getPersonaId() {
|
public long getPersonaId() {
|
||||||
return personaId;
|
return personaId;
|
||||||
@ -62,11 +61,11 @@ public class PersonaAlias {
|
|||||||
return dateAdded;
|
return dateAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Examiner getExaminer() {
|
public CentralRepoExaminer getExaminer() {
|
||||||
return examiner;
|
return examiner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PersonaAlias(long personaId, String alias, String justification, Persona.Confidence confidence, long dateAdded, Examiner examiner) {
|
public PersonaAlias(long personaId, String alias, String justification, Persona.Confidence confidence, long dateAdded, CentralRepoExaminer examiner) {
|
||||||
this.personaId = personaId;
|
this.personaId = personaId;
|
||||||
this.alias = alias;
|
this.alias = alias;
|
||||||
this.justification = justification;
|
this.justification = justification;
|
||||||
@ -88,7 +87,7 @@ public class PersonaAlias {
|
|||||||
*/
|
*/
|
||||||
static PersonaAlias addPersonaAlias(Persona persona, String alias, String justification, Persona.Confidence confidence) throws CentralRepoException {
|
static PersonaAlias addPersonaAlias(Persona persona, String alias, String justification, Persona.Confidence confidence) throws CentralRepoException {
|
||||||
|
|
||||||
Examiner examiner = CentralRepository.getInstance().getCurrentCentralRepoExaminer();
|
CentralRepoExaminer examiner = CentralRepository.getInstance().getCurrentCentralRepoExaminer();
|
||||||
|
|
||||||
Instant instant = Instant.now();
|
Instant instant = Instant.now();
|
||||||
Long timeStampMillis = instant.toEpochMilli();
|
Long timeStampMillis = instant.toEpochMilli();
|
||||||
@ -118,7 +117,7 @@ public class PersonaAlias {
|
|||||||
public void process(ResultSet rs) throws SQLException {
|
public void process(ResultSet rs) throws SQLException {
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
Examiner examiner = new Examiner(
|
CentralRepoExaminer examiner = new CentralRepoExaminer(
|
||||||
rs.getInt("examiner_id"),
|
rs.getInt("examiner_id"),
|
||||||
rs.getString("login_name"),
|
rs.getString("login_name"),
|
||||||
rs.getString("display_name"));
|
rs.getString("display_name"));
|
||||||
|
@ -43,7 +43,7 @@ public class PersonaMetadata {
|
|||||||
private final String justification;
|
private final String justification;
|
||||||
private final Persona.Confidence confidence;
|
private final Persona.Confidence confidence;
|
||||||
private final long dateAdded;
|
private final long dateAdded;
|
||||||
private final Examiner examiner;
|
private final CentralRepoExaminer examiner;
|
||||||
|
|
||||||
public long getPersonaId() {
|
public long getPersonaId() {
|
||||||
return personaId;
|
return personaId;
|
||||||
@ -69,11 +69,11 @@ public class PersonaMetadata {
|
|||||||
return dateAdded;
|
return dateAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Examiner getExaminer() {
|
public CentralRepoExaminer getExaminer() {
|
||||||
return examiner;
|
return examiner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PersonaMetadata(long personaId, String name, String value, String justification, Persona.Confidence confidence, long dateAdded, Examiner examiner) {
|
public PersonaMetadata(long personaId, String name, String value, String justification, Persona.Confidence confidence, long dateAdded, CentralRepoExaminer examiner) {
|
||||||
this.personaId = personaId;
|
this.personaId = personaId;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
@ -97,7 +97,7 @@ public class PersonaMetadata {
|
|||||||
*/
|
*/
|
||||||
static PersonaMetadata addPersonaMetadata(long personaId, String name, String value, String justification, Persona.Confidence confidence) throws CentralRepoException {
|
static PersonaMetadata addPersonaMetadata(long personaId, String name, String value, String justification, Persona.Confidence confidence) throws CentralRepoException {
|
||||||
|
|
||||||
Examiner examiner = CentralRepository.getInstance().getCurrentCentralRepoExaminer();
|
CentralRepoExaminer examiner = CentralRepository.getInstance().getCurrentCentralRepoExaminer();
|
||||||
|
|
||||||
Instant instant = Instant.now();
|
Instant instant = Instant.now();
|
||||||
Long timeStampMillis = instant.toEpochMilli();
|
Long timeStampMillis = instant.toEpochMilli();
|
||||||
@ -128,7 +128,7 @@ public class PersonaMetadata {
|
|||||||
public void process(ResultSet rs) throws SQLException {
|
public void process(ResultSet rs) throws SQLException {
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
Examiner examiner = new Examiner(
|
CentralRepoExaminer examiner = new CentralRepoExaminer(
|
||||||
rs.getInt("examiner_id"),
|
rs.getInt("examiner_id"),
|
||||||
rs.getString("login_name"),
|
rs.getString("login_name"),
|
||||||
rs.getString("display_name"));
|
rs.getString("display_name"));
|
||||||
|
@ -102,7 +102,7 @@ abstract class RdbmsCentralRepo implements CentralRepository {
|
|||||||
// Update Test code if this changes. It's hard coded there.
|
// Update Test code if this changes. It's hard coded there.
|
||||||
static final int DEFAULT_BULK_THRESHHOLD = 1000;
|
static final int DEFAULT_BULK_THRESHHOLD = 1000;
|
||||||
|
|
||||||
private Examiner cachedCurrentExaminer = null;
|
private CentralRepoExaminer cachedCurrentExaminer = null;
|
||||||
|
|
||||||
private static final int QUERY_STR_MAX_LEN = 1000;
|
private static final int QUERY_STR_MAX_LEN = 1000;
|
||||||
|
|
||||||
@ -2557,7 +2557,7 @@ abstract class RdbmsCentralRepo implements CentralRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Examiner getCurrentCentralRepoExaminer() throws CentralRepoException {
|
public CentralRepoExaminer getCurrentCentralRepoExaminer() throws CentralRepoException {
|
||||||
|
|
||||||
// return cached value if there's one
|
// return cached value if there's one
|
||||||
if (cachedCurrentExaminer != null) {
|
if (cachedCurrentExaminer != null) {
|
||||||
@ -2575,7 +2575,7 @@ abstract class RdbmsCentralRepo implements CentralRepository {
|
|||||||
ResultSet resultSet = statement.executeQuery(querySQL);) {
|
ResultSet resultSet = statement.executeQuery(querySQL);) {
|
||||||
|
|
||||||
if (resultSet.next()) {
|
if (resultSet.next()) {
|
||||||
cachedCurrentExaminer = new Examiner(resultSet.getLong("id"), resultSet.getString("login_name"), resultSet.getString("display_name"));
|
cachedCurrentExaminer = new CentralRepoExaminer(resultSet.getLong("id"), resultSet.getString("login_name"), resultSet.getString("display_name"));
|
||||||
return cachedCurrentExaminer;
|
return cachedCurrentExaminer;
|
||||||
} else {
|
} else {
|
||||||
throw new CentralRepoException("Error getting examiner for name = " + loginName);
|
throw new CentralRepoException("Error getting examiner for name = " + loginName);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user