Sleuth Kit Java Bindings (JNI) 4.14.0
Java bindings for using The Sleuth Kit
Loading...
Searching...
No Matches
OsAccount.java
Go to the documentation of this file.
1/*
2 * Sleuth Kit Data Model
3 *
4 * Copyright 2020-2021 Basis Technology Corp.
5 * Contact: carrier <at> sleuthkit <dot> org
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19package org.sleuthkit.datamodel;
20
21import java.util.Collections;
22import java.util.List;
23import java.util.Optional;
24import java.util.ResourceBundle;
25
35public final class OsAccount extends AbstractContent {
36
37 private static final ResourceBundle bundle = ResourceBundle.getBundle("org.sleuthkit.datamodel.Bundle");
38
39 final static Long NO_ACCOUNT = null;
40 final static String NO_OWNER_ID = null;
41
42 private final SleuthkitCase sleuthkitCase;
43
44 private final long osAccountObjId; // Object ID within the database
45 private final long realmId; // realm where the account exists in (could be local or domain scoped)
46 private final String loginName; // user login name - may be null
47 private final String addr; // a unique user sid/uid, may be null
48
49 private final String signature; // This exists only to prevent duplicates.
50 // Together realm_id & signature must be unique for each account.
51 // It is either addr if addr is defined,
52 // or the login_name if login_name is defined.
53
54 private final String fullName; // full name, may be null
55 private final OsAccountType osAccountType;
56 private final OsAccountStatus osAccountStatus;
57 private final OsAccountDbStatus osAccountDbStatus; // Status of row in the database
58 private final Long creationTime;
59
60 private List<OsAccountAttribute> osAccountAttributes = null;
61
66 public enum OsAccountStatus {
67 UNKNOWN(0, bundle.getString("OsAccountStatus.Unknown.text")),
68 ACTIVE(1, bundle.getString("OsAccountStatus.Active.text")),
69 DISABLED(2, bundle.getString("OsAccountStatus.Disabled.text")),
70 @Deprecated
71 DELETED(3, bundle.getString("OsAccountStatus.Deleted.text")),
72 NON_EXISTENT(4, bundle.getString("OsAccountStatus.NonExistent.text"));
73
74 private final int id;
75 private final String name;
76
77 OsAccountStatus(int id, String name) {
78 this.id = id;
79 this.name = name;
80 }
81
87 public int getId() {
88 return id;
89 }
90
96 public String getName() {
97 return name;
98 }
99
107 public static OsAccountStatus fromID(int statusId) {
108 for (OsAccountStatus statusType : OsAccountStatus.values()) {
109 if (statusType.ordinal() == statusId) {
110 return statusType;
111 }
112 }
113 return null;
114 }
115 }
116
123 ACTIVE(0, "Active"),
124 MERGED(1, "Merged"),
125 DELETED(2, "Deleted");
126
127 private final int id;
128 private final String name;
129
130 OsAccountDbStatus(int id, String name) {
131 this.id = id;
132 this.name = name;
133 }
134
135 int getId() {
136 return id;
137 }
138
139 String getName() {
140 return name;
141 }
142
143 static OsAccountDbStatus fromID(int typeId) {
144 for (OsAccountDbStatus type : OsAccountDbStatus.values()) {
145 if (type.ordinal() == typeId) {
146 return type;
147 }
148 }
149 return null;
150 }
151 }
152
157 public enum OsAccountType {
158 UNKNOWN(0, bundle.getString("OsAccountType.Unknown.text")),
159 SERVICE(1, bundle.getString("OsAccountType.Service.text")),
160 INTERACTIVE(2, bundle.getString("OsAccountType.Interactive.text"));
161
162 private final int id;
163 private final String name;
164
165 OsAccountType(int id, String name) {
166 this.id = id;
167 this.name = name;
168 }
169
175 public int getId() {
176 return id;
177 }
178
184 public String getName() {
185 return name;
186 }
187
195 public static OsAccountType fromID(int typeId) {
196 for (OsAccountType accountType : OsAccountType.values()) {
197 if (accountType.ordinal() == typeId) {
198 return accountType;
199 }
200 }
201 return null;
202 }
203 }
204
224 OsAccount(SleuthkitCase sleuthkitCase, long osAccountobjId, long realmId, String loginName, String uniqueId, String signature,
225 String fullName, Long creationTime, OsAccountType accountType, OsAccountStatus accountStatus, OsAccountDbStatus accountDbStatus) {
226
227 super(sleuthkitCase, osAccountobjId, signature);
228
229 this.sleuthkitCase = sleuthkitCase;
230 this.osAccountObjId = osAccountobjId;
231 this.realmId = realmId;
232 this.loginName = loginName;
233 this.addr = uniqueId;
234 this.signature = signature;
235 this.fullName = fullName;
236 this.creationTime = creationTime;
237 this.osAccountType = accountType;
238 this.osAccountStatus = accountStatus;
239 this.osAccountDbStatus = accountDbStatus;
240 }
241
248 synchronized void setAttributesInternal(List<OsAccountAttribute> osAccountAttributes) {
249 this.osAccountAttributes = osAccountAttributes;
250 }
251
258 @Override
259 public long getId() {
260 return osAccountObjId;
261 }
262
269 public Optional<String> getAddr() {
270 return Optional.ofNullable(addr);
271 }
272
280 public long getRealmId() {
281 return realmId;
282 }
283
289 public Optional<String> getLoginName() {
290 return Optional.ofNullable(loginName);
291 }
292
298 String getSignature() {
299 return signature;
300 }
301
307 public Optional<String> getFullName() {
308 return Optional.ofNullable(fullName);
309 }
310
316 public Optional<Long> getCreationTime() {
317 return Optional.ofNullable(creationTime);
318 }
319
325 public Optional<OsAccountType> getOsAccountType() {
326 return Optional.ofNullable(osAccountType);
327 }
328
334 public Optional<OsAccountStatus> getOsAccountStatus() {
335 return Optional.ofNullable(osAccountStatus);
336 }
337
344 return osAccountDbStatus;
345 }
346
354 public synchronized List<OsAccountAttribute> getExtendedOsAccountAttributes() throws TskCoreException {
355 if (osAccountAttributes == null) {
356 osAccountAttributes = sleuthkitCase.getOsAccountManager().getOsAccountAttributes(this);
357 }
358 return Collections.unmodifiableList(osAccountAttributes);
359 }
360
368 public synchronized List<OsAccountInstance> getOsAccountInstances() throws TskCoreException {
369 return sleuthkitCase.getOsAccountManager().getOsAccountInstances(this);
370 }
371
377 @Override
379 return sleuthkitCase;
380 }
381
382 @Override
383 public int read(byte[] buf, long offset, long len) throws TskCoreException {
384 // No data to read.
385 return 0;
386 }
387
388 @Override
389 public void close() {
390 // nothing to close
391 }
392
393 @Override
394 public long getSize() {
395 // No data.
396 return 0;
397 }
398
399 @Override
400 public <T> T accept(ContentVisitor<T> v) {
401
402 throw new UnsupportedOperationException("Not supported yet.");
403 }
404
405 @Override
406 public <T> T accept(SleuthkitItemVisitor<T> v) {
407 return v.visit(this);
408 }
409
418 public final class OsAccountAttribute extends AbstractAttribute {
419
420 private final long osAccountObjId; // OS account to which this attribute belongs.
421 private final Long hostId; // Host to which this attribute applies, may be null
422 private final Long sourceObjId; // Object id of the source where the attribute was discovered.
423
436 public OsAccountAttribute(BlackboardAttribute.Type attributeType, int valueInt, OsAccount osAccount, Host host, Content sourceObj) {
437 super(attributeType, valueInt);
438
439 this.osAccountObjId = osAccount.getId();
440 this.hostId = (host != null ? host.getHostId() : null);
441 this.sourceObjId = (sourceObj != null ? sourceObj.getId() : null);
442 }
443
454 public OsAccountAttribute(BlackboardAttribute.Type attributeType, long valueLong, OsAccount osAccount, Host host, Content sourceObj) {
455 super(attributeType, valueLong);
456
457 this.osAccountObjId = osAccount.getId();
458 this.hostId = (host != null ? host.getHostId() : null);
459 this.sourceObjId = (sourceObj != null ? sourceObj.getId() : null);
460 }
461
472 public OsAccountAttribute(BlackboardAttribute.Type attributeType, double valueDouble, OsAccount osAccount, Host host, Content sourceObj) {
473 super(attributeType, valueDouble);
474
475 this.osAccountObjId = osAccount.getId();
476 this.hostId = (host != null ? host.getHostId() : null);
477 this.sourceObjId = (sourceObj != null ? sourceObj.getId() : null);
478 }
479
490 public OsAccountAttribute(BlackboardAttribute.Type attributeType, String valueString, OsAccount osAccount, Host host, Content sourceObj) {
491 super(attributeType, valueString);
492
493 this.osAccountObjId = osAccount.getId();
494 this.hostId = (host != null ? host.getHostId() : null);
495 this.sourceObjId = (sourceObj != null ? sourceObj.getId() : null);
496 }
497
508 public OsAccountAttribute(BlackboardAttribute.Type attributeType, byte[] valueBytes, OsAccount osAccount, Host host, Content sourceObj) {
509 super(attributeType, valueBytes);
510
511 this.osAccountObjId = osAccount.getId();
512 this.hostId = (host != null ? host.getHostId() : null);
513 this.sourceObjId = (sourceObj != null ? sourceObj.getId() : null);
514 }
515
532 OsAccountAttribute(BlackboardAttribute.Type attributeType, int valueInt, long valueLong, double valueDouble, String valueString, byte[] valueBytes,
533 SleuthkitCase sleuthkitCase, OsAccount osAccount, Host host, Content sourceObj) {
534
535 super(attributeType,
536 valueInt, valueLong, valueDouble, valueString, valueBytes,
537 sleuthkitCase);
538 this.osAccountObjId = osAccount.getId();
539 this.hostId = (host != null ? host.getHostId() : null);
540 this.sourceObjId = (sourceObj != null ? sourceObj.getId() : null);
541 }
542
548 public Optional<Long> getHostId() {
549 return Optional.ofNullable(hostId);
550 }
551
557 public long getOsAccountObjectId() {
558 return osAccountObjId;
559 }
560
566 public Optional<Long> getSourceObjectId() {
567 return Optional.ofNullable(sourceObjId);
568 }
569 }
570}
AbstractAttribute(BlackboardAttribute.Type attributeType, int valueInt)
AbstractContent(SleuthkitCase db, long obj_id, String name)
OsAccountAttribute(BlackboardAttribute.Type attributeType, int valueInt, OsAccount osAccount, Host host, Content sourceObj)
OsAccountAttribute(BlackboardAttribute.Type attributeType, long valueLong, OsAccount osAccount, Host host, Content sourceObj)
OsAccountAttribute(BlackboardAttribute.Type attributeType, byte[] valueBytes, OsAccount osAccount, Host host, Content sourceObj)
OsAccountAttribute(BlackboardAttribute.Type attributeType, String valueString, OsAccount osAccount, Host host, Content sourceObj)
OsAccountAttribute(BlackboardAttribute.Type attributeType, double valueDouble, OsAccount osAccount, Host host, Content sourceObj)
synchronized List< OsAccountAttribute > getExtendedOsAccountAttributes()
OsAccountDbStatus getOsAccountDbStatus()
Optional< OsAccountStatus > getOsAccountStatus()
Optional< String > getLoginName()
synchronized List< OsAccountInstance > getOsAccountInstances()
int read(byte[] buf, long offset, long len)
Optional< OsAccountType > getOsAccountType()
Optional< String > getFullName()
Optional< Long > getCreationTime()
static OsAccountDbStatus fromID(int typeId)
static OsAccountStatus fromID(int statusId)
static OsAccountType fromID(int typeId)

Copyright © 2011-2024 Brian Carrier. (carrier -at- sleuthkit -dot- org)
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.