diff --git a/bindings/java/src/org/sleuthkit/datamodel/AbstractContent.java b/bindings/java/src/org/sleuthkit/datamodel/AbstractContent.java index 2a95b7b39fef08d32336fcaaa8b2d4f159055809..c37a5463a5e17605367f89457dc3b661d714a4e4 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/AbstractContent.java +++ b/bindings/java/src/org/sleuthkit/datamodel/AbstractContent.java @@ -348,7 +348,7 @@ public DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, Collec DataArtifact artifact = db.getBlackboard().newDataArtifact(artifactType, objId, this.getDataSource().getId(), attributesList, osAccount); if(osAccount != null) { - db.getOsAccountManager().createOsAccountInstance(osAccount, (DataSource)getDataSource(), OsAccountInstance.OsAccountInstanceType.LAUNCHED); + db.getOsAccountManager().newOsAccountInstance(osAccount, (DataSource)getDataSource(), OsAccountInstance.OsAccountInstanceType.LAUNCHED); } return artifact; } diff --git a/bindings/java/src/org/sleuthkit/datamodel/HostAddressManager.java b/bindings/java/src/org/sleuthkit/datamodel/HostAddressManager.java index c0554672401b2df0fd6c24b1dd0f3b67273e5209..307fafa0977210a1d354c3ecaf0fb979c18ef61e 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/HostAddressManager.java +++ b/bindings/java/src/org/sleuthkit/datamodel/HostAddressManager.java @@ -141,10 +141,10 @@ private Optional<HostAddress> getHostAddress(HostAddress.HostAddressType type, S * * @throws TskCoreException */ - public HostAddress createHostAddress(HostAddress.HostAddressType type, String address) throws TskCoreException { + public HostAddress newHostAddress(HostAddress.HostAddressType type, String address) throws TskCoreException { CaseDbConnection connection = this.db.getConnection(); try { - return HostAddressManager.this.createHostAddress(type, address, connection); + return HostAddressManager.this.newHostAddress(type, address, connection); } catch (TskCoreException ex) { // The insert may have failed because the HostAddress already exists, so // try loading it from the database. @@ -169,7 +169,7 @@ public HostAddress createHostAddress(HostAddress.HostAddressType type, String ad * * @throws TskCoreException */ - private HostAddress createHostAddress(HostAddress.HostAddressType type, String address, CaseDbConnection connection) throws TskCoreException { + private HostAddress newHostAddress(HostAddress.HostAddressType type, String address, CaseDbConnection connection) throws TskCoreException { HostAddress.HostAddressType addressType = type; if (type.equals(HostAddress.HostAddressType.DNS_AUTO)) { addressType = getDNSType(address); diff --git a/bindings/java/src/org/sleuthkit/datamodel/HostManager.java b/bindings/java/src/org/sleuthkit/datamodel/HostManager.java index 6ac0fbe2bae9f331e3529a1dadb2cdb6d082dc5e..40ad7529bc9269dfdc917e8ab1cf7f7c2650e023 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/HostManager.java +++ b/bindings/java/src/org/sleuthkit/datamodel/HostManager.java @@ -51,21 +51,6 @@ public final class HostManager { this.db = skCase; } - /** - * Get or create host with specified name. - * - * TODO: This should be deleted before release - * - * @param name Host name. - * - * @return Host with the specified name. - * - * @throws TskCoreException - */ - public Host getOrCreateHost(String name) throws TskCoreException { - return createHost(name); - } - /** * Create a host with specified name. If a host already exists with the * given name, it returns the existing host. @@ -76,10 +61,10 @@ public Host getOrCreateHost(String name) throws TskCoreException { * * @throws TskCoreException */ - public Host createHost(String name) throws TskCoreException { + public Host newHost(String name) throws TskCoreException { CaseDbTransaction transaction = db.beginTransaction(); try { - Host host = createHost(name, transaction); + Host host = newHost(name, transaction); transaction.commit(); transaction = null; return host; @@ -114,7 +99,7 @@ public Host createHost(String name) throws TskCoreException { * * @throws TskCoreException */ - Host createHost(String name, CaseDbTransaction trans) throws TskCoreException { + Host newHost(String name, CaseDbTransaction trans) throws TskCoreException { // must have a name if (Strings.isNullOrEmpty(name)) { throw new TskCoreException("Illegal argument passed to createHost: Host name is required."); @@ -157,7 +142,7 @@ Host createHost(String name, CaseDbTransaction trans) throws TskCoreException { } // It may be the case that the host already exists, so try to get it. - Optional<Host> optHost = getHost(name, connection); + Optional<Host> optHost = getHostByName(name, connection); if (optHost.isPresent()) { return optHost.get(); } @@ -200,7 +185,7 @@ public Host updateHostName(Host host, String newName) throws TskCoreException { connection.executeUpdate(preparedStatement); - updatedHost = getHost(hostId, connection).orElseThrow(() + updatedHost = getHostById(hostId, connection).orElseThrow(() -> new TskCoreException((String.format("Error while fetching newly updated host with id: %d, ")))); } catch (SQLException ex) { @@ -324,9 +309,9 @@ public List<DataSource> getDataSourcesForHost(Host host) throws TskCoreException * * @throws TskCoreException */ - public Optional<Host> getHost(String name) throws TskCoreException { + public Optional<Host> getHostByName(String name) throws TskCoreException { try (CaseDbConnection connection = db.getConnection()) { - return getHost(name, connection); + return getHostByName(name, connection); } } @@ -340,7 +325,7 @@ public Optional<Host> getHost(String name) throws TskCoreException { * * @throws TskCoreException */ - private Optional<Host> getHost(String name, CaseDbConnection connection) throws TskCoreException { + private Optional<Host> getHostByName(String name, CaseDbConnection connection) throws TskCoreException { String queryString = "SELECT * FROM tsk_hosts" + " WHERE LOWER(name) = LOWER(?)" @@ -375,9 +360,9 @@ private Optional<Host> getHost(String name, CaseDbConnection connection) throws * * @throws TskCoreException */ - public Optional<Host> getHost(long id) throws TskCoreException { + public Optional<Host> getHostById(long id) throws TskCoreException { try (CaseDbConnection connection = db.getConnection()) { - return getHost(id, connection); + return getHostById(id, connection); } } @@ -391,7 +376,7 @@ public Optional<Host> getHost(long id) throws TskCoreException { * * @throws TskCoreException */ - private Optional<Host> getHost(long id, CaseDbConnection connection) throws TskCoreException { + private Optional<Host> getHostById(long id, CaseDbConnection connection) throws TskCoreException { String queryString = "SELECT * FROM tsk_hosts WHERE id = " + id; @@ -418,7 +403,7 @@ private Optional<Host> getHost(long id, CaseDbConnection connection) throws TskC * * @throws TskCoreException */ - public List<Host> getHosts() throws TskCoreException { + public List<Host> getAllHosts() throws TskCoreException { String queryString = "SELECT * FROM tsk_hosts WHERE db_status = " + HostDbStatus.ACTIVE.getId(); List<Host> hosts = new ArrayList<>(); @@ -448,7 +433,7 @@ public List<Host> getHosts() throws TskCoreException { * * @throws TskCoreException if no host is found or an error occurs. */ - public Host getHost(DataSource dataSource) throws TskCoreException { + public Host getHostByDataSource(DataSource dataSource) throws TskCoreException { String queryString = "SELECT tsk_hosts.id AS hostId, tsk_hosts.name AS name, tsk_hosts.db_status AS db_status FROM \n" + "tsk_hosts INNER JOIN data_source_info \n" diff --git a/bindings/java/src/org/sleuthkit/datamodel/Image.java b/bindings/java/src/org/sleuthkit/datamodel/Image.java index 57284faf6fa85312c4d4f9d829f44186ae2acdf8..7e2d793a29e1749b0d4b4aa192334d73fa4def6b 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/Image.java +++ b/bindings/java/src/org/sleuthkit/datamodel/Image.java @@ -611,7 +611,7 @@ public Host getHost() throws TskCoreException { // This is a check-then-act race condition that may occasionally result // in additional processing but is safer than using locks. if (host == null) { - host = getSleuthkitCase().getHostManager().getHost(this); + host = getSleuthkitCase().getHostManager().getHostByDataSource(this); } return host; } diff --git a/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java b/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java index f85c55c4d5a62c75ca7c4b23e83df24bd2bac376..fbf5449a8c61b52be375fffc28166219b9c02136 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java +++ b/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java @@ -268,7 +268,7 @@ public Host getHost() throws TskCoreException { // This is a check-then-act race condition that may occasionally result // in additional processing but is safer than using locks. if (host == null) { - host = getSleuthkitCase().getHostManager().getHost(this); + host = getSleuthkitCase().getHostManager().getHostByDataSource(this); } return host; } diff --git a/bindings/java/src/org/sleuthkit/datamodel/OsAccount.java b/bindings/java/src/org/sleuthkit/datamodel/OsAccount.java index 5d7887daca119ec830dbeaa108dfaaa19aea7a45..02a5809a4d7eb82e3d657dc6bd7680a3d1c742f5 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/OsAccount.java +++ b/bindings/java/src/org/sleuthkit/datamodel/OsAccount.java @@ -316,7 +316,7 @@ public Optional<String> getAddr() { /** * Get the ID for the account realm. Get the Realm via - * OsAccountRealmManager.getRealmById() NOTE: The realm may get updated as + * OsAccountRealmManager.getRealmByRealmId() NOTE: The realm may get updated as * more data is parsed, so listen for events to update as needed. * * @return diff --git a/bindings/java/src/org/sleuthkit/datamodel/OsAccountManager.java b/bindings/java/src/org/sleuthkit/datamodel/OsAccountManager.java index 874797fd1e70756f1c27268e6c81ef581ffff96b..d3336ddcc4c1423e173adcb73f9c75e82b8cfccd 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/OsAccountManager.java +++ b/bindings/java/src/org/sleuthkit/datamodel/OsAccountManager.java @@ -75,7 +75,7 @@ public final class OsAccountManager { * @throws TskCoreException If there is an error in creating the OSAccount. * */ - OsAccount createOsAccount(String uniqueAccountId, OsAccountRealm realm) throws TskCoreException { + OsAccount newOsAccount(String uniqueAccountId, OsAccountRealm realm) throws TskCoreException { // ensure unique id is provided if (Strings.isNullOrEmpty(uniqueAccountId)) { @@ -91,7 +91,7 @@ OsAccount createOsAccount(String uniqueAccountId, OsAccountRealm realm) throws T // try to create account try { - OsAccount account = createOsAccount(uniqueAccountId, null, realm, OsAccount.OsAccountStatus.UNKNOWN, trans); + OsAccount account = newOsAccount(uniqueAccountId, null, realm, OsAccount.OsAccountStatus.UNKNOWN, trans); trans.commit(); trans = null; return account; @@ -140,7 +140,7 @@ OsAccount createOsAccount(String uniqueAccountId, OsAccountRealm realm) throws T * user SID. * */ - public OsAccount createWindowsOsAccount(String sid, String loginName, String realmName, Host referringHost, OsAccountRealm.RealmScope realmScope) throws TskCoreException, NotUserSIDException { + public OsAccount newWindowsOsAccount(String sid, String loginName, String realmName, Host referringHost, OsAccountRealm.RealmScope realmScope) throws TskCoreException, NotUserSIDException { if (realmScope == null) { throw new TskCoreException("RealmScope cannot be null. Use UNKNOWN if scope is not known."); @@ -172,14 +172,14 @@ public OsAccount createWindowsOsAccount(String sid, String loginName, String rea realm = realmOptional.get(); } else { // realm was not found, create it. - realm = db.getOsAccountRealmManager().createWindowsRealm(sid, realmName, referringHost, realmScope); + realm = db.getOsAccountRealmManager().newWindowsRealm(sid, realmName, referringHost, realmScope); } CaseDbTransaction trans = db.beginTransaction(); try { // try to create account try { - OsAccount account = createOsAccount(sid, loginName, realm, OsAccount.OsAccountStatus.UNKNOWN, trans); + OsAccount account = newOsAccount(sid, loginName, realm, OsAccount.OsAccountStatus.UNKNOWN, trans); trans.commit(); trans = null; return account; @@ -233,7 +233,7 @@ public OsAccount createWindowsOsAccount(String sid, String loginName, String rea * * @throws TskCoreException If there is an error creating the account. */ - private OsAccount createOsAccount(String uniqueId, String loginName, OsAccountRealm realm, OsAccount.OsAccountStatus accountStatus, CaseDbTransaction trans) throws TskCoreException, SQLException { + private OsAccount newOsAccount(String uniqueId, String loginName, OsAccountRealm realm, OsAccount.OsAccountStatus accountStatus, CaseDbTransaction trans) throws TskCoreException, SQLException { if (Objects.isNull(realm)) { throw new TskCoreException("Cannot create an OS Account, realm is NULL."); @@ -513,7 +513,7 @@ private Optional<Long> getOsAccountInstanceId(OsAccount osAccount, DataSource da * @throws TskCoreException If there is an error creating the account * instance. */ - public void createOsAccountInstance(OsAccount osAccount, DataSource dataSource, OsAccountInstance.OsAccountInstanceType instanceType) throws TskCoreException { + public void newOsAccountInstance(OsAccount osAccount, DataSource dataSource, OsAccountInstance.OsAccountInstanceType instanceType) throws TskCoreException { if (osAccount == null) { throw new TskCoreException("Cannot create account instance with null account."); } @@ -528,7 +528,7 @@ public void createOsAccountInstance(OsAccount osAccount, DataSource dataSource, } try (CaseDbConnection connection = this.db.getConnection()) { - createOsAccountInstance(osAccount, dataSource, instanceType, connection); + newOsAccountInstance(osAccount, dataSource, instanceType, connection); } } @@ -544,7 +544,7 @@ public void createOsAccountInstance(OsAccount osAccount, DataSource dataSource, * @throws TskCoreException If there is an error creating the account * instance. */ - void createOsAccountInstance(OsAccount osAccount, DataSource dataSource, OsAccountInstance.OsAccountInstanceType instanceType, CaseDbConnection connection) throws TskCoreException { + void newOsAccountInstance(OsAccount osAccount, DataSource dataSource, OsAccountInstance.OsAccountInstanceType instanceType, CaseDbConnection connection) throws TskCoreException { if (osAccount == null) { throw new TskCoreException("Cannot create account instance with null account."); @@ -553,7 +553,7 @@ void createOsAccountInstance(OsAccount osAccount, DataSource dataSource, OsAccou throw new TskCoreException("Cannot create account instance with null data source."); } - createOsAccountInstance(osAccount, dataSource.getId(), instanceType, connection); + newOsAccountInstance(osAccount, dataSource.getId(), instanceType, connection); } /** @@ -568,7 +568,7 @@ void createOsAccountInstance(OsAccount osAccount, DataSource dataSource, OsAccou * @throws TskCoreException If there is an error creating the account * instance. */ - void createOsAccountInstance(OsAccount osAccount, long dataSourceObjId, OsAccountInstance.OsAccountInstanceType instanceType, CaseDbConnection connection) throws TskCoreException { + void newOsAccountInstance(OsAccount osAccount, long dataSourceObjId, OsAccountInstance.OsAccountInstanceType instanceType, CaseDbConnection connection) throws TskCoreException { if (osAccount == null) { throw new TskCoreException("Cannot create account instance with null account."); diff --git a/bindings/java/src/org/sleuthkit/datamodel/OsAccountRealmManager.java b/bindings/java/src/org/sleuthkit/datamodel/OsAccountRealmManager.java index 43ccfa3f0e8045c8ef6798f690c3c5497136f4e0..c9ebe104eb3b02a50ea099822e1a590233a0bea0 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/OsAccountRealmManager.java +++ b/bindings/java/src/org/sleuthkit/datamodel/OsAccountRealmManager.java @@ -72,7 +72,7 @@ public final class OsAccountRealmManager { * @throws OsAccountManager.NotUserSIDException If the SID is not a user * SID. */ - public OsAccountRealm createWindowsRealm(String accountSid, String realmName, Host referringHost, OsAccountRealm.RealmScope realmScope) throws TskCoreException, OsAccountManager.NotUserSIDException { + public OsAccountRealm newWindowsRealm(String accountSid, String realmName, Host referringHost, OsAccountRealm.RealmScope realmScope) throws TskCoreException, OsAccountManager.NotUserSIDException { if (realmScope == null) { throw new TskCoreException("RealmScope cannot be null. Use UNKNOWN if scope is not known."); @@ -132,7 +132,7 @@ public OsAccountRealm createWindowsRealm(String accountSid, String realmName, Ho String signature = makeRealmSignature(realmAddr, realmName, scopeHost); // create a realm - return createRealm(realmName, realmAddr, signature, scopeHost, scopeConfidence); + return newRealm(realmName, realmAddr, signature, scopeHost, scopeConfidence); } /** @@ -362,7 +362,7 @@ private OsRealmUpdateResult updateRealm(OsAccountRealm realm, String realmAddr, connection.executeUpdate(preparedStatement); // read the updated realm - updatedRealm = this.getRealmById(realm.getRealmId(), connection); + updatedRealm = this.getRealmByRealmId(realm.getRealmId(), connection); return new OsRealmUpdateResult(updateStatusCode, updatedRealm); } catch (SQLException ex) { @@ -389,9 +389,9 @@ private OsRealmUpdateResult updateRealm(OsAccountRealm realm, String realmAddr, * @throws TskCoreException on error */ - public OsAccountRealm getRealmById(long id) throws TskCoreException { + public OsAccountRealm getRealmByRealmId(long id) throws TskCoreException { try (CaseDbConnection connection = this.db.getConnection()) { - return getRealmById(id, connection); + return getRealmByRealmId(id, connection); } } @@ -404,7 +404,7 @@ public OsAccountRealm getRealmById(long id) throws TskCoreException { * @return Realm. * @throws TskCoreException */ - OsAccountRealm getRealmById(long id, CaseDbConnection connection) throws TskCoreException { + OsAccountRealm getRealmByRealmId(long id, CaseDbConnection connection) throws TskCoreException { String queryString = REALM_QUERY_STRING + " WHERE realms.id = " + id; @@ -648,7 +648,7 @@ private OsAccountRealm resultSetToAccountRealm(ResultSet rs) throws SQLException * * @throws TskCoreException If there is an internal error. */ - private OsAccountRealm createRealm(String realmName, String realmAddr, String signature, Host host, OsAccountRealm.ScopeConfidence scopeConfidence) throws TskCoreException { + private OsAccountRealm newRealm(String realmName, String realmAddr, String signature, Host host, OsAccountRealm.ScopeConfidence scopeConfidence) throws TskCoreException { db.acquireSingleUserCaseWriteLock(); try (CaseDbConnection connection = this.db.getConnection()) { @@ -785,7 +785,7 @@ void moveOrMergeRealm(OsAccountRealm sourceRealm, Host destHost, CaseDbTransacti // Merge the realm with the matching name into the realm with the matching address. // Reload from database afterward to make sure everything is up-to-date. mergeRealms(optDestRealmName.get(), optDestRealmAddr.get(), trans); - destRealm = getRealmById(optDestRealmAddr.get().getRealmId(), trans.getConnection()); + destRealm = getRealmByRealmId(optDestRealmAddr.get().getRealmId(), trans.getConnection()); } } } else if (optDestRealmAddr.isPresent()) { diff --git a/bindings/java/src/org/sleuthkit/datamodel/PersonManager.java b/bindings/java/src/org/sleuthkit/datamodel/PersonManager.java index 1956b4fdf2cf6e377b149151108ee08fb1fd48c3..2f60210216f5f22c468beccfc7c59314c29b27f6 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/PersonManager.java +++ b/bindings/java/src/org/sleuthkit/datamodel/PersonManager.java @@ -205,7 +205,7 @@ public Optional<Person> getPerson(long id) throws TskCoreException { * * @throws TskCoreException */ - public Person createPerson(String name) throws TskCoreException { + public Person newPerson(String name) throws TskCoreException { // Must have a name if (Strings.isNullOrEmpty(name)) { diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java index ad2d2de91d1e6c25b6a47b61ffd99dd6b6044f3a..ddc96594ca05efdccc7c23ef8da740f780d31d88 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java @@ -6499,7 +6499,7 @@ public LocalFilesDataSource addLocalFilesDataSource(String deviceId, String root // If no host was supplied, make one if (host == null) { - host = getHostManager().createHost("LogicalFileSet_" + newObjId + " Host", transaction); + host = getHostManager().newHost("LogicalFileSet_" + newObjId + " Host", transaction); } // Insert a row for the virtual directory of the data source into @@ -6656,9 +6656,9 @@ public Image addImage(TskData.TSK_IMG_TYPE_ENUM type, long sectorSize, long size // Create a host if needed if (host == null) { if (name.isEmpty()) { - host = getHostManager().createHost("Image_" + newObjId + " Host", transaction); + host = getHostManager().newHost("Image_" + newObjId + " Host", transaction); } else { - host = getHostManager().createHost(name + "_" + newObjId + " Host", transaction); + host = getHostManager().newHost(name + "_" + newObjId + " Host", transaction); } } @@ -7052,7 +7052,7 @@ public FsContent addFileSystemFile(long dataSourceObjId, long fsObjId, } if(osAccount != null) { - osAccountManager.createOsAccountInstance(osAccount, dataSourceObjId, OsAccountInstance.OsAccountInstanceType.LAUNCHED, connection); + osAccountManager.newOsAccountInstance(osAccount, dataSourceObjId, OsAccountInstance.OsAccountInstanceType.LAUNCHED, connection); } return new org.sleuthkit.datamodel.File(this, objectId, dataSourceObjId, fsObjId, diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java index 41ba5f41174603c729d98e141f43d2ba3cb9af1b..1e847df0c96e8c957c11b758b5907c211476ceed 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java @@ -449,7 +449,7 @@ long addImageInfo(long deviceObjId, List<String> imageFilePaths, String timeZone } else { hostName = "Image_" + deviceObjId + " Host"; } - host = skCase.getHostManager().createHost(hostName); + host = skCase.getHostManager().newHost(hostName); } TskCaseDbBridge dbHelper = new TskCaseDbBridge(skCase, new DefaultAddDataSourceCallbacks(), host); long tskAutoDbPointer = initializeAddImgNat(dbHelper, timezoneLongToShort(timeZone), false, false, false); diff --git a/bindings/java/src/org/sleuthkit/datamodel/TskCaseDbBridge.java b/bindings/java/src/org/sleuthkit/datamodel/TskCaseDbBridge.java index 3c02bc59a24e9e093faec2ddaf75242aca960122..ab761bf00ecff600be3e6a5d05d40a367ff927eb 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/TskCaseDbBridge.java +++ b/bindings/java/src/org/sleuthkit/datamodel/TskCaseDbBridge.java @@ -384,7 +384,7 @@ private long addBatchedFilesToDb() { } else { // account not found in the database, create the account and add to map // Currently we expect only NTFS systems to provide a windows style SID as owner id. - OsAccount newAccount = caseDb.getOsAccountManager().createWindowsOsAccount(ownerUid, null, null, imageHost, OsAccountRealm.RealmScope.UNKNOWN); + OsAccount newAccount = caseDb.getOsAccountManager().newWindowsOsAccount(ownerUid, null, null, imageHost, OsAccountRealm.RealmScope.UNKNOWN); ownerIdToAccountMap.put(ownerUid, newAccount); } } catch (NotUserSIDException ex) { diff --git a/bindings/java/test/org/sleuthkit/datamodel/ArtifactTest.java b/bindings/java/test/org/sleuthkit/datamodel/ArtifactTest.java index 06da37bb59a6f235eff96c907c4bf17e7b5e2a09..26c3fa00380b3f255f474781ad11a56c6d04e2cd 100644 --- a/bindings/java/test/org/sleuthkit/datamodel/ArtifactTest.java +++ b/bindings/java/test/org/sleuthkit/datamodel/ArtifactTest.java @@ -165,13 +165,13 @@ public void artifactTests() throws TskCoreException, Blackboard.BlackboardExcept String realmName1 = "realm1"; String ownerUid1 = "S-1-5-21-111111111-222222222-3333333333-0001"; - Host host1 = caseDB.getHostManager().createHost(hostname1); - OsAccountRealm localRealm1 = caseDB.getOsAccountRealmManager().createWindowsRealm(ownerUid1, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); - OsAccount osAccount1 = caseDB.getOsAccountManager().createWindowsOsAccount(ownerUid1, null, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); + Host host1 = caseDB.getHostManager().newHost(hostname1); + OsAccountRealm localRealm1 = caseDB.getOsAccountRealmManager().newWindowsRealm(ownerUid1, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); + OsAccount osAccount1 = caseDB.getOsAccountManager().newWindowsOsAccount(ownerUid1, null, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); // create a 2nd account on the same host String ownerUid2 = "S-1-5-21-111111111-222222222-3333333333-0009"; - OsAccount osAccount2 = caseDB.getOsAccountManager().createWindowsOsAccount(ownerUid2, null, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); + OsAccount osAccount2 = caseDB.getOsAccountManager().newWindowsOsAccount(ownerUid2, null, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); // now find the file abc.text diff --git a/bindings/java/test/org/sleuthkit/datamodel/OsAccountTest.java b/bindings/java/test/org/sleuthkit/datamodel/OsAccountTest.java index 1281e9da15517e2f969c056b5ed5fd43047763b7..eeb5d566e5c381dc38112b6787574e8f8c1ad34c 100644 --- a/bindings/java/test/org/sleuthkit/datamodel/OsAccountTest.java +++ b/bindings/java/test/org/sleuthkit/datamodel/OsAccountTest.java @@ -114,33 +114,33 @@ public void hostTests() throws TskCoreException { String HOSTNAME1 = "host11"; // Test: create a host - Host host1 = caseDB.getHostManager().createHost(HOSTNAME1); + Host host1 = caseDB.getHostManager().newHost(HOSTNAME1); assertEquals(host1.getName().equalsIgnoreCase(HOSTNAME1), true ); // Test: get a host we just created. - Optional<Host> optionalhost1 = caseDB.getHostManager().getHost(HOSTNAME1); + Optional<Host> optionalhost1 = caseDB.getHostManager().getHostByName(HOSTNAME1); assertEquals(optionalhost1.isPresent(), true ); String HOSTNAME2 = "host22"; // Get a host not yet created - Optional<Host> optionalhost2 = caseDB.getHostManager().getHost(HOSTNAME2); + Optional<Host> optionalhost2 = caseDB.getHostManager().getHostByName(HOSTNAME2); assertEquals(optionalhost2.isPresent(), false ); // now create the second host - Host host2 = caseDB.getHostManager().createHost(HOSTNAME2); + Host host2 = caseDB.getHostManager().newHost(HOSTNAME2); assertEquals(host2.getName().equalsIgnoreCase(HOSTNAME2), true ); // now get it again, should be found this time - optionalhost2 = caseDB.getHostManager().getHost(HOSTNAME2); + optionalhost2 = caseDB.getHostManager().getHostByName(HOSTNAME2); assertEquals(optionalhost2.isPresent(), true); // create a host that already exists - should transperently return the existting host. - Host host2_2 = caseDB.getHostManager().createHost(HOSTNAME2); + Host host2_2 = caseDB.getHostManager().newHost(HOSTNAME2); assertEquals(host2_2.getName().equalsIgnoreCase(HOSTNAME2), true ); } @@ -157,7 +157,7 @@ public void personTests() throws TskCoreException { org.sleuthkit.datamodel.PersonManager pm = caseDB.getPersonManager(); - Person p1 = pm.createPerson(personName1); + Person p1 = pm.newPerson(personName1); assertEquals(personName1.equals(p1.getName()), true); Optional<Person> p1opt = pm.getPerson(personName1.toLowerCase()); @@ -181,8 +181,8 @@ public void mergeHostTests() throws TskCoreException, OsAccountManager.NotUserSI // Host 1 will be merged into Host 2 String host1Name = "host1forHostMergeTest"; String host2Name = "host2forHostMergeTest"; - Host host1 = caseDB.getHostManager().createHost(host1Name); - Host host2 = caseDB.getHostManager().createHost(host2Name); + Host host1 = caseDB.getHostManager().newHost(host1Name); + Host host2 = caseDB.getHostManager().newHost(host2Name); // Data source is originally associated with host1 org.sleuthkit.datamodel.SleuthkitCase.CaseDbTransaction trans = caseDB.beginTransaction(); @@ -211,40 +211,40 @@ public void mergeHostTests() throws TskCoreException, OsAccountManager.NotUserSI OsAccountRealmManager realmManager = caseDB.getOsAccountRealmManager(); // 1 - Should get moved - OsAccountRealm realm1 = realmManager.createWindowsRealm(null, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm realm1 = realmManager.newWindowsRealm(null, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); // 2 - Should be merged into 5 - OsAccountRealm realm2 = realmManager.createWindowsRealm(null, realmName2, host1, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm realm2 = realmManager.newWindowsRealm(null, realmName2, host1, OsAccountRealm.RealmScope.LOCAL); // 3 - Should be merged into 5 - OsAccountRealm realm3 = realmManager.createWindowsRealm(sid3, null, host1, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm realm3 = realmManager.newWindowsRealm(sid3, null, host1, OsAccountRealm.RealmScope.LOCAL); // 4 - Should get moved - not merged into 6 since addrs are different - OsAccountRealm realm4 = realmManager.createWindowsRealm(sid4, realmName4, host1, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm realm4 = realmManager.newWindowsRealm(sid4, realmName4, host1, OsAccountRealm.RealmScope.LOCAL); // 5 - 2 and 3 should get merged in - OsAccountRealm realm5 = realmManager.createWindowsRealm(sid3, realmName2, host2, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm realm5 = realmManager.newWindowsRealm(sid3, realmName2, host2, OsAccountRealm.RealmScope.LOCAL); // 6 - Should not get merged with 4 - OsAccountRealm realm6 = realmManager.createWindowsRealm(sid5, realmName4, host2, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm realm6 = realmManager.newWindowsRealm(sid5, realmName4, host2, OsAccountRealm.RealmScope.LOCAL); // 7 - Should be unchanged - OsAccountRealm realm7 = realmManager.createWindowsRealm(null, realmName5, host2, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm realm7 = realmManager.newWindowsRealm(null, realmName5, host2, OsAccountRealm.RealmScope.LOCAL); // 8, 9, 10 - 8 should be merged into 9 and then 10 should be merged into 9 - OsAccountRealm realm8 = realmManager.createWindowsRealm(null, realmName6, host2, OsAccountRealm.RealmScope.LOCAL); - OsAccount realm8acct = caseDB.getOsAccountManager().createWindowsOsAccount(null, realm8AcctName, realmName6, host2, OsAccountRealm.RealmScope.LOCAL); - OsAccountRealm realm9 = realmManager.createWindowsRealm(sid6, null, host2, OsAccountRealm.RealmScope.LOCAL); - OsAccountRealm realm10 = realmManager.createWindowsRealm(sid6, realmName6, host1, OsAccountRealm.RealmScope.LOCAL); - OsAccount realm10acct = caseDB.getOsAccountManager().createWindowsOsAccount(null, realm10AcctName, realmName6, host1, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm realm8 = realmManager.newWindowsRealm(null, realmName6, host2, OsAccountRealm.RealmScope.LOCAL); + OsAccount realm8acct = caseDB.getOsAccountManager().newWindowsOsAccount(null, realm8AcctName, realmName6, host2, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm realm9 = realmManager.newWindowsRealm(sid6, null, host2, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm realm10 = realmManager.newWindowsRealm(sid6, realmName6, host1, OsAccountRealm.RealmScope.LOCAL); + OsAccount realm10acct = caseDB.getOsAccountManager().newWindowsOsAccount(null, realm10AcctName, realmName6, host1, OsAccountRealm.RealmScope.LOCAL); // 11, 12 - 11 should get merged into 12, adding the addr "sid8" to 12 - OsAccountRealm realm11 = realmManager.createWindowsRealm(sid8, realmName7, host1, OsAccountRealm.RealmScope.LOCAL); - OsAccountRealm realm12 = realmManager.createWindowsRealm(null, realmName7, host2, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm realm11 = realmManager.newWindowsRealm(sid8, realmName7, host1, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm realm12 = realmManager.newWindowsRealm(null, realmName7, host2, OsAccountRealm.RealmScope.LOCAL); // 13,14 - 13 should get merged into 14, name for 14 should not change - OsAccountRealm realm13 = realmManager.createWindowsRealm(sid7, "notRealm8", host1, OsAccountRealm.RealmScope.LOCAL); - OsAccountRealm realm14 = realmManager.createWindowsRealm(sid7, realmName8, host2, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm realm13 = realmManager.newWindowsRealm(sid7, "notRealm8", host1, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm realm14 = realmManager.newWindowsRealm(sid7, realmName8, host2, OsAccountRealm.RealmScope.LOCAL); // Do the merge caseDB.getHostManager().mergeHosts(host1, host2); @@ -289,15 +289,15 @@ public void mergeHostTests() throws TskCoreException, OsAccountManager.NotUserSI } // The data source should now reference host2 - Host host = caseDB.getHostManager().getHost(ds); + Host host = caseDB.getHostManager().getHostByDataSource(ds); assertEquals(host.getHostId() == host2.getHostId(), true); // We should get no results on a search for host1 - Optional<Host> optHost = caseDB.getHostManager().getHost(host1Name); + Optional<Host> optHost = caseDB.getHostManager().getHostByName(host1Name); assertEquals(optHost.isPresent(), false); // If we attempt to make a new host with the same name host1 had, we should get a new object Id - host = caseDB.getHostManager().createHost(host1Name); + host = caseDB.getHostManager().newHost(host1Name); assertEquals(host.getHostId() != host1.getHostId(), true); } @@ -308,7 +308,7 @@ public void mergeHostTests() throws TskCoreException, OsAccountManager.NotUserSI private void testUpdatedRealm(OsAccountRealm origRealm, OsAccountRealm.RealmDbStatus expectedStatus, Optional<String> expectedAddr, List<String> expectedNames, Optional<Host> expectedHost, org.sleuthkit.datamodel.SleuthkitCase.CaseDbConnection connection) throws TskCoreException { - OsAccountRealm realm = caseDB.getOsAccountRealmManager().getRealmById(origRealm.getRealmId(), connection); + OsAccountRealm realm = caseDB.getOsAccountRealmManager().getRealmByRealmId(origRealm.getRealmId(), connection); assertEquals(realm.getDbStatus().equals(expectedStatus), true); if (expectedAddr != null) { assertEquals(realm.getRealmAddr().equals(expectedAddr), true); @@ -324,7 +324,7 @@ private void testUpdatedRealm(OsAccountRealm origRealm, OsAccountRealm.RealmDbSt @Test public void mergeRealmsTests() throws TskCoreException, OsAccountManager.NotUserSIDException { - Host host = caseDB.getHostManager().createHost("mergeTestHost"); + Host host = caseDB.getHostManager().newHost("mergeTestHost"); String destRealmName = "mergeTestDestRealm"; String srcRealmName = "mergeTestSourceRealm"; @@ -337,13 +337,13 @@ public void mergeRealmsTests() throws TskCoreException, OsAccountManager.NotUser String fullName1 = "FullName1"; long creationTime1 = 555; - OsAccountRealm srcRealm = caseDB.getOsAccountRealmManager().createWindowsRealm(null, srcRealmName, host, OsAccountRealm.RealmScope.LOCAL); - OsAccountRealm destRealm = caseDB.getOsAccountRealmManager().createWindowsRealm(null, destRealmName, host, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm srcRealm = caseDB.getOsAccountRealmManager().newWindowsRealm(null, srcRealmName, host, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm destRealm = caseDB.getOsAccountRealmManager().newWindowsRealm(null, destRealmName, host, OsAccountRealm.RealmScope.LOCAL); - OsAccount account1 = caseDB.getOsAccountManager().createWindowsOsAccount(null, "uniqueRealm1Account", destRealmName, host, OsAccountRealm.RealmScope.LOCAL); - OsAccount account2 = caseDB.getOsAccountManager().createWindowsOsAccount(null, matchingName, destRealmName, host, OsAccountRealm.RealmScope.LOCAL); - OsAccount account3 = caseDB.getOsAccountManager().createWindowsOsAccount(null, uniqueRealm2Name, srcRealmName, host, OsAccountRealm.RealmScope.LOCAL); - OsAccount account4 = caseDB.getOsAccountManager().createWindowsOsAccount(null, matchingName, srcRealmName, host, OsAccountRealm.RealmScope.LOCAL); + OsAccount account1 = caseDB.getOsAccountManager().newWindowsOsAccount(null, "uniqueRealm1Account", destRealmName, host, OsAccountRealm.RealmScope.LOCAL); + OsAccount account2 = caseDB.getOsAccountManager().newWindowsOsAccount(null, matchingName, destRealmName, host, OsAccountRealm.RealmScope.LOCAL); + OsAccount account3 = caseDB.getOsAccountManager().newWindowsOsAccount(null, uniqueRealm2Name, srcRealmName, host, OsAccountRealm.RealmScope.LOCAL); + OsAccount account4 = caseDB.getOsAccountManager().newWindowsOsAccount(null, matchingName, srcRealmName, host, OsAccountRealm.RealmScope.LOCAL); OsAccountUpdateResult updateResult = caseDB.getOsAccountManager().updateStandardOsAccountAttributes(account4, fullName1, null, null, creationTime1); @@ -352,11 +352,11 @@ public void mergeRealmsTests() throws TskCoreException, OsAccountManager.NotUser account4 = updateResult.getUpdatedAccount().orElseThrow(() -> new TskCoreException("Updated account not found.")); - OsAccount account5 = caseDB.getOsAccountManager().createWindowsOsAccount(sid1, null, destRealmName, host, OsAccountRealm.RealmScope.LOCAL); - OsAccount account6 = caseDB.getOsAccountManager().createWindowsOsAccount(sid1, null, srcRealmName, host, OsAccountRealm.RealmScope.LOCAL); - OsAccount account7 = caseDB.getOsAccountManager().createWindowsOsAccount(sid2, null, destRealmName, host, OsAccountRealm.RealmScope.LOCAL); - OsAccount account8 = caseDB.getOsAccountManager().createWindowsOsAccount(null, "nameForCombining", destRealmName, host, OsAccountRealm.RealmScope.LOCAL); - OsAccount account9 = caseDB.getOsAccountManager().createWindowsOsAccount(sid2, "nameForCombining", srcRealmName, host, OsAccountRealm.RealmScope.LOCAL); + OsAccount account5 = caseDB.getOsAccountManager().newWindowsOsAccount(sid1, null, destRealmName, host, OsAccountRealm.RealmScope.LOCAL); + OsAccount account6 = caseDB.getOsAccountManager().newWindowsOsAccount(sid1, null, srcRealmName, host, OsAccountRealm.RealmScope.LOCAL); + OsAccount account7 = caseDB.getOsAccountManager().newWindowsOsAccount(sid2, null, destRealmName, host, OsAccountRealm.RealmScope.LOCAL); + OsAccount account8 = caseDB.getOsAccountManager().newWindowsOsAccount(null, "nameForCombining", destRealmName, host, OsAccountRealm.RealmScope.LOCAL); + OsAccount account9 = caseDB.getOsAccountManager().newWindowsOsAccount(sid2, "nameForCombining", srcRealmName, host, OsAccountRealm.RealmScope.LOCAL); // Test that we can currently get the source realm by name Optional<OsAccountRealm> optRealm = caseDB.getOsAccountRealmManager().getWindowsRealm(null, srcRealmName, host); @@ -429,14 +429,14 @@ public void hostAddressTests() throws TskCoreException { String hostnameStr = "basis.com"; // Test creation - HostAddress ipv4addr = caseDB.getHostAddressManager().createHostAddress(HostAddress.HostAddressType.IPV4, ipv4Str); + HostAddress ipv4addr = caseDB.getHostAddressManager().newHostAddress(HostAddress.HostAddressType.IPV4, ipv4Str); assertEquals(ipv4addr.getAddress().equalsIgnoreCase(ipv4Str), true); - HostAddress addr2 = caseDB.getHostAddressManager().createHostAddress(HostAddress.HostAddressType.DNS_AUTO, ipv6Str); + HostAddress addr2 = caseDB.getHostAddressManager().newHostAddress(HostAddress.HostAddressType.DNS_AUTO, ipv6Str); assertEquals(addr2.getAddress().equalsIgnoreCase(ipv6Str), true); assertEquals(HostAddress.HostAddressType.IPV6.equals(addr2.getAddressType()), true); - HostAddress hostAddr = caseDB.getHostAddressManager().createHostAddress(HostAddress.HostAddressType.DNS_AUTO, hostnameStr); + HostAddress hostAddr = caseDB.getHostAddressManager().newHostAddress(HostAddress.HostAddressType.DNS_AUTO, hostnameStr); assertEquals(hostAddr.getAddress().equalsIgnoreCase(hostnameStr), true); assertEquals(HostAddress.HostAddressType.HOSTNAME.equals(hostAddr.getAddressType()), true); @@ -445,7 +445,7 @@ public void hostAddressTests() throws TskCoreException { assertEquals(addr4opt.isPresent(), true); // Test host map - Host host = caseDB.getHostManager().createHost("TestHostAddress"); + Host host = caseDB.getHostManager().newHost("TestHostAddress"); trans = caseDB.beginTransaction(); DataSource ds = caseDB.addLocalFilesDataSource("devId", "pathToFiles", "EST", null, trans); @@ -487,13 +487,13 @@ public void osAccountRealmTests() throws TskCoreException, OsAccountManager.NotU // TEST: create a DOMAIN realm String HOSTNAME1 = "host1"; - Host host1 = caseDB.getHostManager().createHost(HOSTNAME1); + Host host1 = caseDB.getHostManager().newHost(HOSTNAME1); String realmName1 = "basis"; String realmSID1 = "S-1-5-21-1111111111-2222222222-3333333333"; String realmAddr1 = "S-1-5-21-1111111111-2222222222"; - OsAccountRealm domainRealm1 = caseDB.getOsAccountRealmManager().createWindowsRealm(realmSID1, realmName1, host1, OsAccountRealm.RealmScope.DOMAIN); + OsAccountRealm domainRealm1 = caseDB.getOsAccountRealmManager().newWindowsRealm(realmSID1, realmName1, host1, OsAccountRealm.RealmScope.DOMAIN); assertEquals(domainRealm1.getRealmNames().get(0).equalsIgnoreCase(realmName1), true ); assertEquals(domainRealm1.getScopeConfidence(), OsAccountRealm.ScopeConfidence.KNOWN); @@ -506,8 +506,8 @@ public void osAccountRealmTests() throws TskCoreException, OsAccountManager.NotU String realmName2 = "win-raman-abcd"; String hostName2 = "host2"; - Host host2 = caseDB.getHostManager().createHost(hostName2); - OsAccountRealm localRealm2 = caseDB.getOsAccountRealmManager().createWindowsRealm(realmSID2, null, host2, OsAccountRealm.RealmScope.LOCAL); + Host host2 = caseDB.getHostManager().newHost(hostName2); + OsAccountRealm localRealm2 = caseDB.getOsAccountRealmManager().newWindowsRealm(realmSID2, null, host2, OsAccountRealm.RealmScope.LOCAL); assertEquals(localRealm2.getRealmAddr().orElse("").equalsIgnoreCase(realmAddr2), true ); assertEquals(localRealm2.getScopeHost().orElse(null).getName().equalsIgnoreCase(hostName2), true); @@ -526,7 +526,7 @@ public void osAccountRealmTests() throws TskCoreException, OsAccountManager.NotU String realmSID3 = realmAddr1 + "-88888888"; String hostName3 = "host3"; - Host host3 = caseDB.getHostManager().createHost(hostName3); + Host host3 = caseDB.getHostManager().newHost(hostName3); // expect this to return realm1 Optional<OsAccountRealm> existingRealm3 = caseDB.getOsAccountRealmManager().getWindowsRealm(realmSID3, null, host3); @@ -537,7 +537,7 @@ public void osAccountRealmTests() throws TskCoreException, OsAccountManager.NotU // TEST get a existing LOCAL realm by addr, BUT on a new referring host. String hostName4 = "host4"; - Host host4 = caseDB.getHostManager().createHost(hostName4); + Host host4 = caseDB.getHostManager().newHost(hostName4); // Although the realm exists with this addr, it should NOT match since the host is different from what the realm was created with Optional<OsAccountRealm> realm4 = caseDB.getOsAccountRealmManager().getWindowsRealm(realmSID2, null, host4); @@ -565,22 +565,22 @@ public void basicOsAccountTests() throws TskCoreException, OsAccountManager.NotU String realmName1 = "local"; String hostname1 = "host1"; - Host host1 = caseDB.getHostManager().createHost(hostname1); + Host host1 = caseDB.getHostManager().newHost(hostname1); - //OsAccountRealm localRealm1 = caseDB.getOsAccountRealmManager().createWindowsRealm(ownerUid1, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); - OsAccount osAccount1 = caseDB.getOsAccountManager().createWindowsOsAccount(ownerUid1, loginName1, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); + //OsAccountRealm localRealm1 = caseDB.getOsAccountRealmManager().newWindowsRealm(ownerUid1, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); + OsAccount osAccount1 = caseDB.getOsAccountManager().newWindowsOsAccount(ownerUid1, loginName1, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); assertEquals(osAccount1.getAddr().orElse("").equalsIgnoreCase(ownerUid1), true); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(osAccount1.getRealmId()).getRealmNames().get(0).equalsIgnoreCase(realmName1), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(osAccount1.getRealmId()).getRealmNames().get(0).equalsIgnoreCase(realmName1), true); // Create another account - with same SID on the same host - should return the existing account String loginName11 = "BlueJay"; String realmName11 = "DESKTOP-9TO5"; - OsAccount osAccount11 = caseDB.getOsAccountManager().createWindowsOsAccount(ownerUid1, loginName11, realmName11, host1, OsAccountRealm.RealmScope.DOMAIN); + OsAccount osAccount11 = caseDB.getOsAccountManager().newWindowsOsAccount(ownerUid1, loginName11, realmName11, host1, OsAccountRealm.RealmScope.DOMAIN); // account should be the same as osAccount1 assertEquals(osAccount11.getAddr().orElse("").equalsIgnoreCase(ownerUid1), true); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(osAccount11.getRealmId()).getRealmNames().get(0).equalsIgnoreCase(realmName1), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(osAccount11.getRealmId()).getRealmNames().get(0).equalsIgnoreCase(realmName1), true); assertEquals(osAccount11.getLoginName().orElse("").equalsIgnoreCase(loginName1), true); @@ -599,11 +599,11 @@ public void basicOsAccountTests() throws TskCoreException, OsAccountManager.NotU // now try and create osAccount1 again - it should return the existing account - OsAccount osAccount1_copy1 = caseDB.getOsAccountManager().createWindowsOsAccount(ownerUid1, null, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); + OsAccount osAccount1_copy1 = caseDB.getOsAccountManager().newWindowsOsAccount(ownerUid1, null, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); assertEquals(osAccount1_copy1.getAddr().orElse("").equalsIgnoreCase(ownerUid1), true); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(osAccount1_copy1.getRealmId()).getRealmNames().get(0).equalsIgnoreCase(realmName1), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(osAccount1_copy1.getRealmId()).getRealmNames().get(0).equalsIgnoreCase(realmName1), true); assertEquals(osAccount1_copy1.getFullName().orElse("").equalsIgnoreCase(fullName1), true); @@ -627,21 +627,21 @@ public void basicOsAccountTests() throws TskCoreException, OsAccountManager.NotU String hostname2 = "host2"; String hostname3 = "host3"; - Host host2 = caseDB.getHostManager().createHost(hostname2); - Host host3 = caseDB.getHostManager().createHost(hostname3); + Host host2 = caseDB.getHostManager().newHost(hostname2); + Host host3 = caseDB.getHostManager().newHost(hostname3); - OsAccountRealm domainRealm1 = caseDB.getOsAccountRealmManager().createWindowsRealm(ownerUid2, realmName2, host2, OsAccountRealm.RealmScope.DOMAIN); + OsAccountRealm domainRealm1 = caseDB.getOsAccountRealmManager().newWindowsRealm(ownerUid2, realmName2, host2, OsAccountRealm.RealmScope.DOMAIN); // create accounts in this domain scoped realm - OsAccount osAccount2 = caseDB.getOsAccountManager().createWindowsOsAccount(ownerUid2, null, realmName2, host2, OsAccountRealm.RealmScope.DOMAIN); - OsAccount osAccount3 = caseDB.getOsAccountManager().createWindowsOsAccount(ownerUid3, null, realmName2, host3, OsAccountRealm.RealmScope.DOMAIN); + OsAccount osAccount2 = caseDB.getOsAccountManager().newWindowsOsAccount(ownerUid2, null, realmName2, host2, OsAccountRealm.RealmScope.DOMAIN); + OsAccount osAccount3 = caseDB.getOsAccountManager().newWindowsOsAccount(ownerUid3, null, realmName2, host3, OsAccountRealm.RealmScope.DOMAIN); assertEquals(osAccount2.getAddr().orElse("").equalsIgnoreCase(ownerUid2), true); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(osAccount2.getRealmId()).getRealmNames().get(0).equalsIgnoreCase(realmName2), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(osAccount2.getRealmId()).getRealmNames().get(0).equalsIgnoreCase(realmName2), true); assertEquals(osAccount3.getAddr().orElse("").equalsIgnoreCase(ownerUid3), true); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(osAccount3.getRealmId()).getRealmNames().get(0).equalsIgnoreCase(realmName2), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(osAccount3.getRealmId()).getRealmNames().get(0).equalsIgnoreCase(realmName2), true); } @@ -663,50 +663,50 @@ public void windowsSpecialAccountTests() throws TskCoreException, OsAccountManag // TEST create accounts with special SIDs on host2 { String hostname2 = "host222"; - Host host2 = caseDB.getHostManager().createHost(hostname2); + Host host2 = caseDB.getHostManager().newHost(hostname2); String specialSid1 = "S-1-5-18"; String specialSid2 = "S-1-5-19"; String specialSid3 = "S-1-5-20"; - OsAccount specialAccount1 = caseDB.getOsAccountManager().createWindowsOsAccount(specialSid1, null, null, host2, OsAccountRealm.RealmScope.UNKNOWN); - OsAccount specialAccount2 = caseDB.getOsAccountManager().createWindowsOsAccount(specialSid2, null, null, host2, OsAccountRealm.RealmScope.UNKNOWN); - OsAccount specialAccount3 = caseDB.getOsAccountManager().createWindowsOsAccount(specialSid3, null, null, host2, OsAccountRealm.RealmScope.UNKNOWN); + OsAccount specialAccount1 = caseDB.getOsAccountManager().newWindowsOsAccount(specialSid1, null, null, host2, OsAccountRealm.RealmScope.UNKNOWN); + OsAccount specialAccount2 = caseDB.getOsAccountManager().newWindowsOsAccount(specialSid2, null, null, host2, OsAccountRealm.RealmScope.UNKNOWN); + OsAccount specialAccount3 = caseDB.getOsAccountManager().newWindowsOsAccount(specialSid3, null, null, host2, OsAccountRealm.RealmScope.UNKNOWN); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(specialAccount1.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(specialAccount2.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(specialAccount3.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(specialAccount1.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(specialAccount2.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(specialAccount3.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); } // TEST create accounts with special SIDs on host3 - should create their own realm { String hostname3 = "host333"; - Host host3 = caseDB.getHostManager().createHost(hostname3); + Host host3 = caseDB.getHostManager().newHost(hostname3); String specialSid1 = "S-1-5-18"; String specialSid2 = "S-1-5-19"; String specialSid3 = "S-1-5-20"; - OsAccount specialAccount1 = caseDB.getOsAccountManager().createWindowsOsAccount(specialSid1, null, null, host3, OsAccountRealm.RealmScope.UNKNOWN); - OsAccount specialAccount2 = caseDB.getOsAccountManager().createWindowsOsAccount(specialSid2, null, null, host3, OsAccountRealm.RealmScope.UNKNOWN); - OsAccount specialAccount3 = caseDB.getOsAccountManager().createWindowsOsAccount(specialSid3, null, null, host3, OsAccountRealm.RealmScope.UNKNOWN); + OsAccount specialAccount1 = caseDB.getOsAccountManager().newWindowsOsAccount(specialSid1, null, null, host3, OsAccountRealm.RealmScope.UNKNOWN); + OsAccount specialAccount2 = caseDB.getOsAccountManager().newWindowsOsAccount(specialSid2, null, null, host3, OsAccountRealm.RealmScope.UNKNOWN); + OsAccount specialAccount3 = caseDB.getOsAccountManager().newWindowsOsAccount(specialSid3, null, null, host3, OsAccountRealm.RealmScope.UNKNOWN); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(specialAccount1.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(specialAccount2.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(specialAccount3.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(specialAccount1.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(specialAccount2.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(specialAccount3.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); // verify a new local realm with host3 was created for these account even they've been seen previously on another host - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(specialAccount1.getRealmId()).getScopeHost().orElse(null).getName().equalsIgnoreCase(hostname3), true); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(specialAccount1.getRealmId()).getScopeHost().orElse(null).getName().equalsIgnoreCase(hostname3), true); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(specialAccount1.getRealmId()).getScopeHost().orElse(null).getName().equalsIgnoreCase(hostname3), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(specialAccount1.getRealmId()).getScopeHost().orElse(null).getName().equalsIgnoreCase(hostname3), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(specialAccount1.getRealmId()).getScopeHost().orElse(null).getName().equalsIgnoreCase(hostname3), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(specialAccount1.getRealmId()).getScopeHost().orElse(null).getName().equalsIgnoreCase(hostname3), true); } // Test some other special account. { String hostname4 = "host444"; - Host host4 = caseDB.getHostManager().createHost(hostname4); + Host host4 = caseDB.getHostManager().newHost(hostname4); String specialSid1 = "S-1-5-80-3696737894-3623014651-202832235-645492566-13622391"; String specialSid2 = "S-1-5-82-4003674586-223046494-4022293810-2417516693-151509167"; @@ -714,16 +714,16 @@ public void windowsSpecialAccountTests() throws TskCoreException, OsAccountManag String specialSid4 = "S-1-5-96-0-3"; - OsAccount specialAccount1 = caseDB.getOsAccountManager().createWindowsOsAccount(specialSid1, null, null, host4, OsAccountRealm.RealmScope.UNKNOWN); - OsAccount specialAccount2 = caseDB.getOsAccountManager().createWindowsOsAccount(specialSid2, null, null, host4, OsAccountRealm.RealmScope.UNKNOWN); - OsAccount specialAccount3 = caseDB.getOsAccountManager().createWindowsOsAccount(specialSid3, null, null, host4, OsAccountRealm.RealmScope.UNKNOWN); - OsAccount specialAccount4 = caseDB.getOsAccountManager().createWindowsOsAccount(specialSid4, null, null, host4, OsAccountRealm.RealmScope.UNKNOWN); + OsAccount specialAccount1 = caseDB.getOsAccountManager().newWindowsOsAccount(specialSid1, null, null, host4, OsAccountRealm.RealmScope.UNKNOWN); + OsAccount specialAccount2 = caseDB.getOsAccountManager().newWindowsOsAccount(specialSid2, null, null, host4, OsAccountRealm.RealmScope.UNKNOWN); + OsAccount specialAccount3 = caseDB.getOsAccountManager().newWindowsOsAccount(specialSid3, null, null, host4, OsAccountRealm.RealmScope.UNKNOWN); + OsAccount specialAccount4 = caseDB.getOsAccountManager().newWindowsOsAccount(specialSid4, null, null, host4, OsAccountRealm.RealmScope.UNKNOWN); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(specialAccount1.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(specialAccount2.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(specialAccount3.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); - assertEquals(caseDB.getOsAccountRealmManager().getRealmById(specialAccount4.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(specialAccount1.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(specialAccount2.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(specialAccount3.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); + assertEquals(caseDB.getOsAccountRealmManager().getRealmByRealmId(specialAccount4.getRealmId()).getRealmAddr().orElse("").equalsIgnoreCase(SPECIAL_WINDOWS_REALM_ADDR), true); } @@ -732,11 +732,11 @@ public void windowsSpecialAccountTests() throws TskCoreException, OsAccountManag { String hostname5 = "host555"; String realmName5 = "realmName555"; - Host host5 = caseDB.getHostManager().createHost(hostname5); + Host host5 = caseDB.getHostManager().newHost(hostname5); try { String sid1 = "S-1-5-32-544"; // builtin Administrators - OsAccount osAccount1 = caseDB.getOsAccountManager().createWindowsOsAccount(sid1, null, realmName5, host5, OsAccountRealm.RealmScope.UNKNOWN); + OsAccount osAccount1 = caseDB.getOsAccountManager().newWindowsOsAccount(sid1, null, realmName5, host5, OsAccountRealm.RealmScope.UNKNOWN); // above should raise an exception assertEquals(true, false); @@ -747,7 +747,7 @@ public void windowsSpecialAccountTests() throws TskCoreException, OsAccountManag try { String sid2 = "S-1-5-21-725345543-854245398-1060284298-512"; // domain admins group - OsAccount osAccount2 = caseDB.getOsAccountManager().createWindowsOsAccount(sid2, null, realmName5, host5, OsAccountRealm.RealmScope.UNKNOWN); + OsAccount osAccount2 = caseDB.getOsAccountManager().newWindowsOsAccount(sid2, null, realmName5, host5, OsAccountRealm.RealmScope.UNKNOWN); // above should raise an exception assertEquals(true, false); @@ -758,7 +758,7 @@ public void windowsSpecialAccountTests() throws TskCoreException, OsAccountManag try { String sid3 = "S-1-1-0"; // Everyone - OsAccount osAccount3 = caseDB.getOsAccountManager().createWindowsOsAccount(sid3, null, realmName5, host5, OsAccountRealm.RealmScope.UNKNOWN); + OsAccount osAccount3 = caseDB.getOsAccountManager().newWindowsOsAccount(sid3, null, realmName5, host5, OsAccountRealm.RealmScope.UNKNOWN); // above should raise an exception assertEquals(true, false); @@ -784,21 +784,21 @@ public void osAccountInstanceTests() throws TskCoreException, OsAccountManager.N String realmName1 = "realm1111"; String hostname1 = "host1111"; - Host host1 = caseDB.getHostManager().createHost(hostname1); + Host host1 = caseDB.getHostManager().newHost(hostname1); - OsAccountRealm localRealm1 = caseDB.getOsAccountRealmManager().createWindowsRealm(ownerUid1, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); - OsAccount osAccount1 = caseDB.getOsAccountManager().createWindowsOsAccount(ownerUid1, null, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); + OsAccountRealm localRealm1 = caseDB.getOsAccountRealmManager().newWindowsRealm(ownerUid1, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); + OsAccount osAccount1 = caseDB.getOsAccountManager().newWindowsOsAccount(ownerUid1, null, realmName1, host1, OsAccountRealm.RealmScope.LOCAL); // Test: add an instance - caseDB.getOsAccountManager().createOsAccountInstance(osAccount1, image, OsAccountInstance.OsAccountInstanceType.LAUNCHED); + caseDB.getOsAccountManager().newOsAccountInstance(osAccount1, image, OsAccountInstance.OsAccountInstanceType.LAUNCHED); // Test: add an existing instance - should be a no-op. - caseDB.getOsAccountManager().createOsAccountInstance(osAccount1, image, OsAccountInstance.OsAccountInstanceType.LAUNCHED); + caseDB.getOsAccountManager().newOsAccountInstance(osAccount1, image, OsAccountInstance.OsAccountInstanceType.LAUNCHED); // Test: create account instance on a new host String hostname2 = "host2222"; - Host host2 = caseDB.getHostManager().createHost(hostname2); - caseDB.getOsAccountManager().createOsAccountInstance(osAccount1, image, OsAccountInstance.OsAccountInstanceType.LAUNCHED); + Host host2 = caseDB.getHostManager().newHost(hostname2); + caseDB.getOsAccountManager().newOsAccountInstance(osAccount1, image, OsAccountInstance.OsAccountInstanceType.LAUNCHED); List<OsAccountAttribute> accountAttributes = new ArrayList<>(); @@ -817,7 +817,7 @@ public void osAccountInstanceTests() throws TskCoreException, OsAccountManager.N caseDB.getOsAccountManager().addExtendedOsAccountAttributes(osAccount1, accountAttributes); // now get the account with same sid, and get its attribuites and verify. - Optional<OsAccount> existingAccount1 = caseDB.getOsAccountManager().getOsAccountByAddr(osAccount1.getAddr().get(), caseDB.getOsAccountRealmManager().getRealmById(osAccount1.getRealmId())); + Optional<OsAccount> existingAccount1 = caseDB.getOsAccountManager().getOsAccountByAddr(osAccount1.getAddr().get(), caseDB.getOsAccountRealmManager().getRealmByRealmId(osAccount1.getRealmId())); List<OsAccountAttribute> existingAccountAttribs = existingAccount1.get().getExtendedOsAccountAttributes(); @@ -843,15 +843,15 @@ public void windowsAccountRealmUpdateTests() throws TskCoreException, OsAccountM //String realmName1 = "realm4444"; String hostname1 = "host4444"; - Host host1 = caseDB.getHostManager().createHost(hostname1); + Host host1 = caseDB.getHostManager().newHost(hostname1); // create an account, a realm should be created implicitly with just the SID, and no name - OsAccount osAccount1 = caseDB.getOsAccountManager().createWindowsOsAccount(ownerUid1, null, null, host1, OsAccountRealm.RealmScope.LOCAL); + OsAccount osAccount1 = caseDB.getOsAccountManager().newWindowsOsAccount(ownerUid1, null, null, host1, OsAccountRealm.RealmScope.LOCAL); String realmAddr1 = "S-1-5-21-111111111-222222222-4444444444"; - OsAccountRealm realm1 = caseDB.getOsAccountRealmManager().getRealmById(osAccount1.getRealmId()); + OsAccountRealm realm1 = caseDB.getOsAccountRealmManager().getRealmByRealmId(osAccount1.getRealmId()); assertEquals(realm1.getRealmAddr().orElse("").equalsIgnoreCase(realmAddr1), true ); assertEquals(realm1.getRealmNames().isEmpty(), true); // @@ -861,10 +861,10 @@ public void windowsAccountRealmUpdateTests() throws TskCoreException, OsAccountM String ownerUid2 = "S-1-5-21-111111111-222222222-4444444444-0002"; String realmName2 = "realm4444"; - OsAccount osAccount2 = caseDB.getOsAccountManager().createWindowsOsAccount(ownerUid2, null, realmName2, host1, OsAccountRealm.RealmScope.LOCAL); + OsAccount osAccount2 = caseDB.getOsAccountManager().newWindowsOsAccount(ownerUid2, null, realmName2, host1, OsAccountRealm.RealmScope.LOCAL); // Account 2 should have the same realm by addr, but it's realm name should now get updated. - OsAccountRealm realm2 = caseDB.getOsAccountRealmManager().getRealmById(osAccount2.getRealmId()); + OsAccountRealm realm2 = caseDB.getOsAccountRealmManager().getRealmByRealmId(osAccount2.getRealmId()); assertEquals(osAccount1.getRealmId(), osAccount2.getRealmId() ); assertEquals(realm2.getRealmAddr().orElse("").equalsIgnoreCase(realmAddr1), true ); @@ -874,13 +874,13 @@ public void windowsAccountRealmUpdateTests() throws TskCoreException, OsAccountM // Create an account with known realm name but no known addr String hostname3 = "host4444_3"; - Host host3 = caseDB.getHostManager().createHost(hostname3); + Host host3 = caseDB.getHostManager().newHost(hostname3); String realmName3 = "realm4444_3"; String loginName3 = "User4444_3"; - OsAccount osAccount3 = caseDB.getOsAccountManager().createWindowsOsAccount(null, loginName3, realmName3, host3, OsAccountRealm.RealmScope.DOMAIN); + OsAccount osAccount3 = caseDB.getOsAccountManager().newWindowsOsAccount(null, loginName3, realmName3, host3, OsAccountRealm.RealmScope.DOMAIN); - OsAccountRealm realm3 = caseDB.getOsAccountRealmManager().getRealmById(osAccount3.getRealmId()); + OsAccountRealm realm3 = caseDB.getOsAccountRealmManager().getRealmByRealmId(osAccount3.getRealmId()); assertEquals(realm3.getRealmAddr().orElse("").equalsIgnoreCase(""), true ); assertEquals(realm3.getRealmNames().size(), 1 ); // should have 1 name assertEquals(realm3.getRealmNames().get(0).equalsIgnoreCase(realmName3), true ); @@ -892,12 +892,12 @@ public void windowsAccountRealmUpdateTests() throws TskCoreException, OsAccountM String realm4Addr = "S-1-5-21-111111111-444444444-4444444444"; String hostname4 = "host4444_4"; - Host host4 = caseDB.getHostManager().createHost(hostname4); + Host host4 = caseDB.getHostManager().newHost(hostname4); - OsAccount osAccount4 = caseDB.getOsAccountManager().createWindowsOsAccount(ownerSid4, loginName4, realmName3, host4, OsAccountRealm.RealmScope.DOMAIN); + OsAccount osAccount4 = caseDB.getOsAccountManager().newWindowsOsAccount(ownerSid4, loginName4, realmName3, host4, OsAccountRealm.RealmScope.DOMAIN); // realm4 should be the same as realm3 but the addr should be updaed now - OsAccountRealm realm4 = caseDB.getOsAccountRealmManager().getRealmById(osAccount4.getRealmId()); + OsAccountRealm realm4 = caseDB.getOsAccountRealmManager().getRealmByRealmId(osAccount4.getRealmId()); assertEquals(osAccount3.getRealmId(), osAccount4.getRealmId() ); assertEquals(realm4.getRealmAddr().orElse("").equalsIgnoreCase(realm4Addr), true ); assertEquals(realm4.getRealmNames().size(), 1 ); // should have 1 name