diff --git a/Core/src/org/sleuthkit/autopsy/datasourceprocessors/xry/XRYCallsFileParser.java b/Core/src/org/sleuthkit/autopsy/datasourceprocessors/xry/XRYCallsFileParser.java index 87d9fee141..58a418e66d 100755 --- a/Core/src/org/sleuthkit/autopsy/datasourceprocessors/xry/XRYCallsFileParser.java +++ b/Core/src/org/sleuthkit/autopsy/datasourceprocessors/xry/XRYCallsFileParser.java @@ -188,10 +188,10 @@ final class XRYCallsFileParser extends AbstractSingleEntityParser { switch (xryKey) { case TEL: case NUMBER: - if(!XRYUtils.isPhoneValid(pair.getValue())) { + if (!XRYUtils.isPhoneValid(pair.getValue())) { continue; } - + // Apply namespace or direction if (xryNamespace == XryNamespace.FROM || direction == CommunicationDirection.INCOMING) { callerId = pair.getValue(); @@ -206,30 +206,30 @@ final class XRYCallsFileParser extends AbstractSingleEntityParser { // Although confusing, as these are also 'name spaces', it appears // later versions of XRY just made these standardized lines. case TO: - if(!XRYUtils.isPhoneValid(pair.getValue())) { + if (!XRYUtils.isPhoneValid(pair.getValue())) { continue; } - + calleeList.add(pair.getValue()); break; case FROM: - if(!XRYUtils.isPhoneValid(pair.getValue())) { + if (!XRYUtils.isPhoneValid(pair.getValue())) { continue; } - + callerId = pair.getValue(); break; case TIME: try { - //Tranform value to seconds since epoch - long dateTimeSinceEpoch = XRYUtils.calculateSecondsSinceEpoch(pair.getValue()); - startTime = dateTimeSinceEpoch; - } catch (DateTimeParseException ex) { - logger.log(Level.WARNING, String.format("[XRY DSP] Assumption" - + " about the date time formatting of call logs is " - + "not right. Here is the value [ %s ]", pair.getValue()), ex); - } - break; + //Tranform value to seconds since epoch + long dateTimeSinceEpoch = XRYUtils.calculateSecondsSinceEpoch(pair.getValue()); + startTime = dateTimeSinceEpoch; + } catch (DateTimeParseException ex) { + logger.log(Level.WARNING, String.format("[XRY DSP] Assumption" + + " about the date time formatting of call logs is " + + "not right. Here is the value [ %s ]", pair.getValue()), ex); + } + break; case DIRECTION: String directionString = pair.getValue().toLowerCase(); if (directionString.equals("incoming")) { @@ -263,7 +263,6 @@ final class XRYCallsFileParser extends AbstractSingleEntityParser { // Make sure we have the required fields, otherwise the CommHelper will // complain about illegal arguments. - // These are all the invalid combinations. if (callerId == null && calleeList.isEmpty() || direction == CommunicationDirection.INCOMING && callerId == null @@ -288,10 +287,10 @@ final class XRYCallsFileParser extends AbstractSingleEntityParser { // it would have been a valid combination. if (callerId != null) { try { - currentCase.getCommunicationsManager().createAccountFileInstance( - Account.Type.PHONE, callerId, PARSER_NAME, parent); + currentCase.getCommunicationsManager().createAccountFileInstance( + Account.Type.PHONE, callerId, PARSER_NAME, parent); } catch (InvalidAccountIDException ex) { - logger.log(Level.WARNING, String.format("Invalid account identifier %s", callerId), ex); + logger.log(Level.WARNING, String.format("Invalid account identifier %s", callerId), ex); } otherAttributes.add(new BlackboardAttribute( @@ -301,12 +300,11 @@ final class XRYCallsFileParser extends AbstractSingleEntityParser { for (String phone : calleeList) { try { - currentCase.getCommunicationsManager().createAccountFileInstance( - Account.Type.PHONE, phone, PARSER_NAME, parent); + currentCase.getCommunicationsManager().createAccountFileInstance( + Account.Type.PHONE, phone, PARSER_NAME, parent); } catch (InvalidAccountIDException ex) { logger.log(Level.WARNING, String.format("Invalid account identifier %s", phone), ex); } - otherAttributes.add(new BlackboardAttribute( BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER, @@ -315,7 +313,7 @@ final class XRYCallsFileParser extends AbstractSingleEntityParser { if (!otherAttributes.isEmpty()) { BlackboardArtifact artifact = parent.newDataArtifact(new BlackboardArtifact.Type(BlackboardArtifact.ARTIFACT_TYPE.TSK_CALLLOG), otherAttributes); - + currentCase.getBlackboard().postArtifact(artifact, PARSER_NAME); } } else { @@ -328,4 +326,4 @@ final class XRYCallsFileParser extends AbstractSingleEntityParser { endTime, callType, otherAttributes); } } -} \ No newline at end of file +} diff --git a/Core/src/org/sleuthkit/autopsy/datasourceprocessors/xry/XRYContactsFileParser.java b/Core/src/org/sleuthkit/autopsy/datasourceprocessors/xry/XRYContactsFileParser.java index 585de02389..f721479d07 100755 --- a/Core/src/org/sleuthkit/autopsy/datasourceprocessors/xry/XRYContactsFileParser.java +++ b/Core/src/org/sleuthkit/autopsy/datasourceprocessors/xry/XRYContactsFileParser.java @@ -144,7 +144,7 @@ final class XRYContactsFileParser extends AbstractSingleEntityParser { // Just create an artifact with the attributes that we do have. if (!additionalAttributes.isEmpty()) { BlackboardArtifact artifact = parent.newDataArtifact(new BlackboardArtifact.Type(BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT), additionalAttributes); - + currentCase.getBlackboard().postArtifact(artifact, PARSER_NAME); } } diff --git a/Core/src/org/sleuthkit/autopsy/datasourceprocessors/xry/XRYMessagesFileParser.java b/Core/src/org/sleuthkit/autopsy/datasourceprocessors/xry/XRYMessagesFileParser.java index de56bb2d47..6fb7413c8e 100755 --- a/Core/src/org/sleuthkit/autopsy/datasourceprocessors/xry/XRYMessagesFileParser.java +++ b/Core/src/org/sleuthkit/autopsy/datasourceprocessors/xry/XRYMessagesFileParser.java @@ -95,6 +95,7 @@ final class XRYMessagesFileParser implements XRYFileParser { * Indicates if the display name of the XRY key is a recognized type. * * @param name + * * @return */ public static boolean contains(String name) { @@ -114,6 +115,7 @@ final class XRYMessagesFileParser implements XRYFileParser { * contains() before hand. * * @param name + * * @return */ public static XryKey fromDisplayName(String name) { @@ -149,6 +151,7 @@ final class XRYMessagesFileParser implements XRYFileParser { * type. * * @param xryNamespace + * * @return */ public static boolean contains(String xryNamespace) { @@ -169,6 +172,7 @@ final class XRYMessagesFileParser implements XRYFileParser { * contains() before hand. * * @param xryNamespace + * * @return */ public static XryNamespace fromDisplayName(String xryNamespace) { @@ -206,6 +210,7 @@ final class XRYMessagesFileParser implements XRYFileParser { * Indicates if the display name of the XRY key is a recognized type. * * @param name + * * @return */ public static boolean contains(String name) { @@ -225,6 +230,7 @@ final class XRYMessagesFileParser implements XRYFileParser { * contains() before hand. * * @param name + * * @return */ public static XryMetaKey fromDisplayName(String name) { @@ -253,11 +259,13 @@ final class XRYMessagesFileParser implements XRYFileParser { * assumption is correct, otherwise an error will appear in the logs. * * @param reader The XRYFileReader that reads XRY entities from the - * Message-SMS report. + * Message-SMS report. * @param parent The parent Content to create artifacts from. - * @throws IOException If an I/O error is encountered during report reading + * + * @throws IOException If an I/O error is encountered during report + * reading * @throws TskCoreException If an error during artifact creation is - * encountered. + * encountered. */ @Override public void parse(XRYFileReader reader, Content parent, SleuthkitCase currentCase) throws IOException, TskCoreException, BlackboardException { @@ -270,10 +278,10 @@ final class XRYMessagesFileParser implements XRYFileParser { while (reader.hasNextEntity()) { String xryEntity = reader.nextEntity(); - + // This call will combine all segmented text into a single key value pair List pairs = getXRYKeyValuePairs(xryEntity, reader, referenceNumbersSeen); - + // Transform all the data from XRY land into the appropriate CommHelper // data types. final String messageType = PARSER_NAME; @@ -286,8 +294,8 @@ final class XRYMessagesFileParser implements XRYFileParser { String text = null; final String threadId = null; final Collection otherAttributes = new ArrayList<>(); - - for(XRYKeyValuePair pair : pairs) { + + for (XRYKeyValuePair pair : pairs) { XryNamespace namespace = XryNamespace.NONE; if (XryNamespace.contains(pair.getNamespace())) { namespace = XryNamespace.fromDisplayName(pair.getNamespace()); @@ -298,14 +306,14 @@ final class XRYMessagesFileParser implements XRYFileParser { switch (key) { case TEL: case NUMBER: - if(!XRYUtils.isPhoneValid(pair.getValue())) { + if (!XRYUtils.isPhoneValid(pair.getValue())) { continue; } - + // Apply namespace or direction - if(namespace == XryNamespace.FROM || direction == CommunicationDirection.INCOMING) { + if (namespace == XryNamespace.FROM || direction == CommunicationDirection.INCOMING) { senderId = pair.getValue(); - } else if(namespace == XryNamespace.TO || direction == CommunicationDirection.OUTGOING) { + } else if (namespace == XryNamespace.TO || direction == CommunicationDirection.OUTGOING) { recipientIdsList.add(pair.getValue()); } else { try { @@ -316,37 +324,37 @@ final class XRYMessagesFileParser implements XRYFileParser { } otherAttributes.add(new BlackboardAttribute( - BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER, - PARSER_NAME, pair.getValue())); + BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER, + PARSER_NAME, pair.getValue())); } break; // Although confusing, as these are also 'name spaces', it appears // later versions of XRY just made these standardized lines. case FROM: - if(!XRYUtils.isPhoneValid(pair.getValue())) { + if (!XRYUtils.isPhoneValid(pair.getValue())) { continue; } - + senderId = pair.getValue(); break; case TO: - if(!XRYUtils.isPhoneValid(pair.getValue())) { + if (!XRYUtils.isPhoneValid(pair.getValue())) { continue; } - + recipientIdsList.add(pair.getValue()); break; case TIME: try { - //Tranform value to seconds since epoch - long dateTimeSinceInEpoch = XRYUtils.calculateSecondsSinceEpoch(pair.getValue()); - dateTime = dateTimeSinceInEpoch; - } catch (DateTimeParseException ex) { - logger.log(Level.WARNING, String.format("[%s] Assumption" - + " about the date time formatting of messages is " - + "not right. Here is the pair [ %s ]", PARSER_NAME, pair), ex); - } - break; + //Tranform value to seconds since epoch + long dateTimeSinceInEpoch = XRYUtils.calculateSecondsSinceEpoch(pair.getValue()); + dateTime = dateTimeSinceInEpoch; + } catch (DateTimeParseException ex) { + logger.log(Level.WARNING, String.format("[%s] Assumption" + + " about the date time formatting of messages is " + + "not right. Here is the pair [ %s ]", PARSER_NAME, pair), ex); + } + break; case TYPE: switch (normalizedValue) { case "incoming": @@ -406,11 +414,11 @@ final class XRYMessagesFileParser implements XRYFileParser { } break; case SERVICE_CENTER: - if(!XRYUtils.isPhoneValid(pair.getValue())) { + if (!XRYUtils.isPhoneValid(pair.getValue())) { continue; } - - otherAttributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER, + + otherAttributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER, PARSER_NAME, pair.getValue())); break; default: @@ -427,18 +435,18 @@ final class XRYMessagesFileParser implements XRYFileParser { } } } - - CommunicationArtifactsHelper helper = new CommunicationArtifactsHelper( - currentCase, PARSER_NAME, parent, Account.Type.PHONE); - helper.addMessage(messageType, direction, senderId, recipientIdsList, - dateTime, readStatus, subject, text, threadId, otherAttributes); + CommunicationArtifactsHelper helper = new CommunicationArtifactsHelper( + currentCase, PARSER_NAME, parent, Account.Type.PHONE); + + helper.addMessage(messageType, direction, senderId, recipientIdsList, + dateTime, readStatus, subject, text, threadId, otherAttributes); } } /** - * Extracts all pairs from the XRY Entity. This function - * will unify any segmented text, if need be. + * Extracts all pairs from the XRY Entity. This function will unify any + * segmented text, if need be. */ private List getXRYKeyValuePairs(String xryEntity, XRYFileReader reader, Set referenceValues) throws IOException { @@ -508,10 +516,13 @@ final class XRYMessagesFileParser implements XRYFileParser { * Builds up segmented message entities so that the text is unified for a * single artifact. * - * @param reader File reader that is producing XRY entities. - * @param referenceNumbersSeen All known references numbers up until this point. - * @param xryEntity The source XRY entity. + * @param reader File reader that is producing XRY entities. + * @param referenceNumbersSeen All known references numbers up until this + * point. + * @param xryEntity The source XRY entity. + * * @return + * * @throws IOException */ private String getSegmentedText(String[] xryEntity, XRYFileReader reader, @@ -604,7 +615,8 @@ final class XRYMessagesFileParser implements XRYFileParser { * Extracts the value of the XRY meta key, if any. * * @param xryLines XRY entity to extract from. - * @param metaKey The key type to extract. + * @param metaKey The key type to extract. + * * @return */ private Optional getMetaKeyValue(String[] xryLines, XryMetaKey metaKey) { @@ -629,10 +641,12 @@ final class XRYMessagesFileParser implements XRYFileParser { /** * Extracts the ith XRY Key Value pair in the XRY Entity. * - * The total number of pairs can be determined via getCountOfKeyValuePairs(). + * The total number of pairs can be determined via + * getCountOfKeyValuePairs(). * * @param xryLines XRY entity. - * @param index The requested Key Value pair. + * @param index The requested Key Value pair. + * * @return */ private Optional getKeyValuePairByIndex(String[] xryLines, int index) { @@ -672,4 +686,4 @@ final class XRYMessagesFileParser implements XRYFileParser { return Optional.empty(); } -} \ No newline at end of file +}