19 package org.sleuthkit.autopsy.datasourceprocessors.xry;
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.List;
25 import java.util.Optional;
26 import java.util.logging.Level;
36 final class XRYContactsFileParser
extends AbstractSingleEntityParser {
38 private static final Logger logger = Logger.getLogger(XRYContactsFileParser.class.getName());
41 private static final Map<String, BlackboardAttribute.ATTRIBUTE_TYPE> XRY_KEYS =
42 new HashMap<String, BlackboardAttribute.ATTRIBUTE_TYPE>() {{
43 put(
"name", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME);
44 put(
"tel", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER);
45 put(
"mobile", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_MOBILE);
46 put(
"home", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_HOME);
47 put(
"related application", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME);
48 put(
"address home", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_LOCATION);
49 put(
"email home", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_HOME);
50 put(
"deleted", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ISDELETED);
57 put(
"account name", null);
62 boolean canProcess(XRYKeyValuePair pair) {
63 String normalizedKey = pair.getKey().toLowerCase();
64 return XRY_KEYS.containsKey(normalizedKey);
68 boolean isNamespace(String nameSpace) {
77 private Optional<BlackboardAttribute> getBlackboardAttribute(XRYKeyValuePair pair) {
78 String normalizedKey = pair.getKey().toLowerCase();
79 BlackboardAttribute.ATTRIBUTE_TYPE attrType = XRY_KEYS.get(normalizedKey);
80 if(attrType != null) {
81 return Optional.of(
new BlackboardAttribute(attrType, PARSER_NAME, pair.getValue()));
84 logger.log(Level.INFO, String.format(
"[XRY DSP] Key value pair "
85 +
"(in brackets) [ %s ] was recognized but we need "
86 +
"more data or time to finish implementation. Discarding... ",
88 return Optional.empty();
92 void makeArtifact(List<XRYKeyValuePair> keyValuePairs, Content parent)
throws TskCoreException {
93 List<BlackboardAttribute> attributes =
new ArrayList<>();
94 for(XRYKeyValuePair pair : keyValuePairs) {
95 Optional<BlackboardAttribute> attribute = getBlackboardAttribute(pair);
96 if(attribute.isPresent()) {
97 attributes.add(attribute.get());
100 if(!attributes.isEmpty()) {
101 BlackboardArtifact artifact = parent.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT);
102 artifact.addAttributes(attributes);