19 package org.sleuthkit.datamodel;
21 import com.google.common.collect.ImmutableSet;
28 final class WindowsAccountUtils {
31 final static String SPECIAL_WINDOWS_REALM_ADDR =
"SPECIAL_WINDOWS_ACCOUNTS";
37 private static final Set<String> GROUP_SIDS = ImmutableSet.of(
68 private static final Set<String> GROUP_SID_PREFIX = ImmutableSet.of(
74 private static final String DOMAIN_SID_PREFIX =
"S-1-5";
75 private static final Set<String> DOMAIN_GROUP_SID_SUFFIX = ImmutableSet.of(
107 private static final Set<String> SPECIAL_SIDS = ImmutableSet.of(
112 private static final Set<String> SPECIAL_SID_PREFIXES = ImmutableSet.of(
128 static boolean isWindowsSpecialSid(String sid) {
129 if (SPECIAL_SIDS.contains(sid)) {
132 for (String specialPrefix: SPECIAL_SID_PREFIXES) {
133 if (sid.startsWith(specialPrefix)) {
150 static boolean isWindowsUserSid(String sid) {
152 if (GROUP_SIDS.contains(sid)) {
156 for (String prefix: GROUP_SID_PREFIX) {
157 if (sid.startsWith(prefix)) {
163 if (sid.startsWith(DOMAIN_SID_PREFIX)) {
164 for (String suffix : DOMAIN_GROUP_SID_SUFFIX) {
165 if (sid.endsWith(suffix)) {
188 public static String getWindowsRealmAddress(String sid)
throws TskCoreException {
193 if (isWindowsSpecialSid(sid) || sid.equals(SPECIAL_WINDOWS_REALM_ADDR)) {
194 realmAddr = SPECIAL_WINDOWS_REALM_ADDR;
197 if (
org.apache.commons.lang3.StringUtils.countMatches(sid,
"-") < 4) {
198 throw new TskCoreException(String.format(
"Invalid SID %s for a host/domain", sid));
201 realmAddr = sid.substring(0, sid.lastIndexOf(
'-'));