diff --git a/bindings/java/src/org/sleuthkit/datamodel/BlackboardAttribute.java b/bindings/java/src/org/sleuthkit/datamodel/BlackboardAttribute.java index 4bf484e02e32125e8a2a44219d315197d0b6c8ac..f23e80aa9cd4e07333e8f255ff7c1be0331d1deb 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/BlackboardAttribute.java +++ b/bindings/java/src/org/sleuthkit/datamodel/BlackboardAttribute.java @@ -18,12 +18,11 @@ */ package org.sleuthkit.datamodel; - /** - * Represents an attribute as stored in the Blackboard. Attributes are a name value - * pair. The name represents the type of data being stored. Attributes are grouped - * together into an Artifact as represented by a BlackboardArtifact object. - * This class is used to create attribute on the blackboard and is used + * Represents an attribute as stored in the Blackboard. Attributes are a name + * value pair. The name represents the type of data being stored. Attributes are + * grouped together into an Artifact as represented by a BlackboardArtifact + * object. This class is used to create attribute on the blackboard and is used * to represent attribute queried from the blackboard. */ public class BlackboardAttribute { @@ -74,6 +73,7 @@ public String getLabel() { /** * Get the enum type for the given type id + * * @param type type id * @return enum type */ @@ -88,9 +88,10 @@ static public TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE fromType(long type) { } /** - * Standard attribute types. Refer to the C++ code for the full - * description of their intended use. See http://wiki.sleuthkit.org/index.php?title=Artifact_Examples - * for more information. + * Standard attribute types. Refer to the C++ code for the full description + * of their intended use. See + * http://wiki.sleuthkit.org/index.php?title=Artifact_Examples for more + * information. */ public enum ATTRIBUTE_TYPE { /* It is very important that this list be kept up to @@ -136,15 +137,15 @@ public enum ATTRIBUTE_TYPE { TSK_ENCRYPTION_DETECTED(38, "TSK_ENCRYPTION_DETECTED", "Encryption Detected"), TSK_MALWARE_DETECTED(39, "TSK_MALWARE_DETECTED", "Malware Detected"), TSK_STEG_DETECTED(40, "TSK_STEG_DETECTED", "Steganography Detected"), - TSK_EMAIL_TO(41,"TSK_EMAIL_TO","E-Mail To"), - TSK_EMAIL_CC(42,"TSK_EMAIL_CC","E-Mail CC"), - TSK_EMAIL_BCC(43,"TSK_EMAIL_BCC","E-Mail BCC"), - TSK_EMAIL_FROM(44,"TSK_EMAIL_FROM","E-Mail From"), + TSK_EMAIL_TO(41, "TSK_EMAIL_TO", "E-Mail To"), + TSK_EMAIL_CC(42, "TSK_EMAIL_CC", "E-Mail CC"), + TSK_EMAIL_BCC(43, "TSK_EMAIL_BCC", "E-Mail BCC"), + TSK_EMAIL_FROM(44, "TSK_EMAIL_FROM", "E-Mail From"), TSK_EMAIL_CONTENT_PLAIN(45, "TSK_EMAIL_CONTENT_PLAIN", "Message (Plaintext)"), TSK_EMAIL_CONTENT_HTML(46, "TSK_EMAIL_CONTENT_HTML", "Message (HTML)"), TSK_EMAIL_CONTENT_RTF(47, "TSK_EMAIL_CONTENT_RTF", "Message (RTF)"), - TSK_MSG_ID(48,"TSK_MSG_ID","Message ID"), - TSK_MSG_REPLY_ID(49,"TSK_MSG_REPLY_ID","Message Reply ID"), + TSK_MSG_ID(48, "TSK_MSG_ID", "Message ID"), + TSK_MSG_REPLY_ID(49, "TSK_MSG_REPLY_ID", "Message Reply ID"), TSK_DATETIME_RCVD(50, "TSK_DATETIME_RCVD", "Date Received"), TSK_DATETIME_SENT(51, "TSK_DATETIME_SENT", "Date Sent"), TSK_SUBJECT(52, "TSK_SUBJECT", "Subject"), @@ -168,10 +169,7 @@ public enum ATTRIBUTE_TYPE { TSK_PROCESSOR_ARCHITECTURE(70, "TSK_PROCESSOR_ARCHITECTURE", "Processor Architecture"), TSK_VERSION(71, "TSK_VERSION", "Version"), ; - - /* SEE ABOVE -- ALSO ADD TO C++ CODE */ - private String label; private int typeID; private String displayName; @@ -184,7 +182,7 @@ private ATTRIBUTE_TYPE(int typeID, String label, String displayName) { /** * Get label string of this attribute - * + * * @return label string */ public String getLabel() { @@ -193,7 +191,7 @@ public String getLabel() { /** * Get type id of this attribute - * + * * @return type id */ public int getTypeID() { @@ -202,7 +200,7 @@ public int getTypeID() { /** * Get the attribute enum for the given label - * + * * @param label label string * @return the enum value */ @@ -214,15 +212,17 @@ static public ATTRIBUTE_TYPE fromLabel(String label) { } throw new IllegalArgumentException("No ATTRIBUTE_TYPE matching type: " + label); } - + public String getDisplayName() { return this.displayName; } } /** - * Constructor for a blackboard attribute. Should only be used by SleuthkitCase + * Constructor for a blackboard attribute. * + * Should only be used by SleuthkitCase + * * @param artifactID artifact id for this attribute * @param attributeTypeID type id * @param moduleName module that created this attribute @@ -233,7 +233,8 @@ public String getDisplayName() { * @param valueDouble value if it is a double * @param valueString value if it is a string * @param valueBytes value if it is a byte array - * @param Case the case that can be used to make calls into the blackboard db + * @param Case the case that can be used to make calls into the blackboard + * db */ protected BlackboardAttribute(long artifactID, int attributeTypeID, String moduleName, String context, TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE valueType, int valueInt, long valueLong, double valueDouble, @@ -247,14 +248,23 @@ protected BlackboardAttribute(long artifactID, int attributeTypeID, String modul this.valueInt = valueInt; this.valueLong = valueLong; this.valueDouble = valueDouble; - this.valueString = valueString; - this.valueBytes = valueBytes; + if (valueString == null) { + this.valueString = ""; + } else { + this.valueString = valueString; + } + if (valueBytes == null) { + this.valueBytes = new byte[0]; + } else { + this.valueBytes = valueBytes; + } this.Case = Case; } - + /** - * Create a blackboard attribute that stores an int (creates an attribute that can be - * added to an artifact) + * Create a blackboard attribute that stores an int (creates an attribute + * that can be added to an artifact) + * * @param attributeTypeID type of the attribute * @param moduleName name of the module that is creating the attribute * @param valueInt the value @@ -273,24 +283,26 @@ public BlackboardAttribute(int attributeTypeID, String moduleName, int valueInt) } /** - * Create a blackboard attribute that stores an int (creates an attribute that can be - * added to an artifact) + * Create a blackboard attribute that stores an int (creates an attribute + * that can be added to an artifact) + * * @param attributeTypeID type of the attribute * @param moduleName name of the module that is creating the attribute * @param context extra information about the attribute * @param valueInt the value - * @Deprecated context parameter will be deprecated - in lieu of specific blackboard attributes - * use the alternative constructor without context + * @Deprecated context parameter will be deprecated - in lieu of specific + * blackboard attributes use the alternative constructor without context */ public BlackboardAttribute(int attributeTypeID, String moduleName, String context, int valueInt) { this(attributeTypeID, moduleName, valueInt); this.context = context; } - + /** - * Create a blackboard attribute that stores a long (creates an attribute that can be - * added to an artifact) + * Create a blackboard attribute that stores a long (creates an attribute + * that can be added to an artifact) + * * @param attributeTypeID type of the attribute * @param moduleName name of the module that is creating the attribute * @param valueLong the value @@ -311,14 +323,15 @@ public BlackboardAttribute(int attributeTypeID, String moduleName, } /** - * Create a blackboard attribute that stores a long (creates an attribute that can be - * added to an artifact) + * Create a blackboard attribute that stores a long (creates an attribute + * that can be added to an artifact) + * * @param attributeTypeID type of the attribute * @param moduleName name of the module that is creating the attribute * @param context extra information about the attribute * @param valueLong the value - * @Deprecated context parameter will be deprecated - in lieu of specific blackboard attributes - * use the alternative constructor without context + * @Deprecated context parameter will be deprecated - in lieu of specific + * blackboard attributes use the alternative constructor without context */ public BlackboardAttribute(int attributeTypeID, String moduleName, String context, long valueLong) { @@ -327,14 +340,15 @@ public BlackboardAttribute(int attributeTypeID, String moduleName, String contex } /** - * Create a blackboard attribute that stores a double (creates an attribute that can be - * added to an artifact) + * Create a blackboard attribute that stores a double (creates an attribute + * that can be added to an artifact) + * * @param attributeTypeID type of the attribute * @param moduleName name of the module that is creating the attribute * @param context extra information about the attribute * @param valueDouble the value */ - public BlackboardAttribute(int attributeTypeID, String moduleName, + public BlackboardAttribute(int attributeTypeID, String moduleName, double valueDouble) { this.artifactID = 0; this.attributeTypeID = attributeTypeID; @@ -347,16 +361,17 @@ public BlackboardAttribute(int attributeTypeID, String moduleName, this.valueBytes = new byte[0]; this.context = ""; } - + /** - * Create a blackboard attribute that stores a double (creates an attribute that can be - * added to an artifact) + * Create a blackboard attribute that stores a double (creates an attribute + * that can be added to an artifact) + * * @param attributeTypeID type of the attribute * @param moduleName name of the module that is creating the attribute * @param context extra information about the attribute * @param valueDouble the value - * @Deprecated context parameter will be deprecated - in lieu of specific blackboard attributes - * use the alternative constructor without context + * @Deprecated context parameter will be deprecated - in lieu of specific + * blackboard attributes use the alternative constructor without context */ public BlackboardAttribute(int attributeTypeID, String moduleName, String context, double valueDouble) { @@ -365,8 +380,9 @@ public BlackboardAttribute(int attributeTypeID, String moduleName, String contex } /** - * Create a blackboard attribute that stores a string (creates an attribute that can be - * added to an artifact) + * Create a blackboard attribute that stores a string (creates an attribute + * that can be added to an artifact) + * * @param attributeTypeID type of the attribute * @param moduleName name of the module that is creating the attribute * @param valueString the value @@ -379,20 +395,25 @@ public BlackboardAttribute(int attributeTypeID, String moduleName, String valueS this.valueInt = 0; this.valueLong = 0; this.valueDouble = 0; - this.valueString = valueString; + if (valueString == null) { + this.valueString = ""; + } else { + this.valueString = valueString; + } this.valueBytes = new byte[0]; this.context = ""; } - + /** - * Create a blackboard attribute that stores a string (creates an attribute that can be - * added to an artifact) + * Create a blackboard attribute that stores a string (creates an attribute + * that can be added to an artifact) + * * @param attributeTypeID type of the attribute * @param moduleName name of the module that is creating the attribute * @param context extra information about the attribute * @param valueString the value - * @Deprecated context parameter will be deprecated - in lieu of specific blackboard attributes - * use the alternative constructor without context + * @Deprecated context parameter will be deprecated - in lieu of specific + * blackboard attributes use the alternative constructor without context */ public BlackboardAttribute(int attributeTypeID, String moduleName, String context, String valueString) { @@ -400,6 +421,34 @@ public BlackboardAttribute(int attributeTypeID, String moduleName, String contex this.context = context; } + /** + * Create a blackboard attribute that stores a byte array (creates an + * attribute that can be added to an artifact) + * + * @param attributeTypeID type of the attribute + * @param moduleName name of the module that is creating the attribute + * @param context extra information about the attribute + * @param valueBytes the value + */ + public BlackboardAttribute(int attributeTypeID, String moduleName, String context, + byte[] valueBytes) { + this.artifactID = 0; + this.attributeTypeID = attributeTypeID; + this.moduleName = moduleName; + this.context = context; + this.valueType = TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.BYTE; + this.valueInt = 0; + this.valueLong = 0; + this.valueDouble = 0; + this.valueString = ""; + if (valueBytes == null) { + this.valueBytes = new byte[0]; + } else { + this.valueBytes = valueBytes; + } + + } + @Override public int hashCode() { int hash = 5; @@ -426,34 +475,10 @@ public boolean equals(Object obj) { public String toString() { return "BlackboardAttribute{" + "artifactID=" + artifactID + ", attributeTypeID=" + attributeTypeID + ", moduleName=" + moduleName + ", context=" + context + ", valueType=" + valueType + ", valueInt=" + valueInt + ", valueLong=" + valueLong + ", valueDouble=" + valueDouble + ", valueString=" + valueString + ", valueBytes=" + valueBytes + ", Case=" + Case + '}'; } - - /** - * Create a blackboard attribute that stores a byte array (creates an attribute that can be - * added to an artifact) - * @param attributeTypeID type of the attribute - * @param moduleName name of the module that is creating the attribute - * @param context extra information about the attribute - * @param valueBytes the value - */ - public BlackboardAttribute(int attributeTypeID, String moduleName, String context, - byte[] valueBytes) { - this.artifactID = 0; - this.attributeTypeID = attributeTypeID; - this.moduleName = moduleName; - this.context = context; - this.valueType = TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.BYTE; - this.valueInt = 0; - this.valueLong = 0; - this.valueDouble = 0; - this.valueString = ""; - this.valueBytes = valueBytes; - - } - - /** - * Get the artifact id + * Get the artifact id + * * @return artifact id */ public long getArtifactID() { @@ -462,6 +487,7 @@ public long getArtifactID() { /** * Get the attribute type id + * * @return type id */ public int getAttributeTypeID() { @@ -470,6 +496,7 @@ public int getAttributeTypeID() { /** * Get the attribute type name string + * * @return type name string */ public String getAttributeTypeName() throws TskCoreException { @@ -478,6 +505,7 @@ public String getAttributeTypeName() throws TskCoreException { /** * Get the attribute type display name + * * @return type display name */ public String getAttributeTypeDisplayName() throws TskCoreException { @@ -485,10 +513,11 @@ public String getAttributeTypeDisplayName() throws TskCoreException { } /** - * Get the value type - * This should be used to identify the type of value and call - * the right value get method. + * Get the value type. * + * This should be used to identify the type of value and + * call the right value get method. + * * @return value type */ public TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE getValueType() { @@ -497,7 +526,7 @@ public TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE getValueType() { /** * Get the value if it is an int - * + * * @return value */ public int getValueInt() { @@ -506,7 +535,7 @@ public int getValueInt() { /** * Get value if it is a long - * + * * @return value */ public long getValueLong() { @@ -515,7 +544,7 @@ public long getValueLong() { /** * Get value if it is a double - * + * * @return value */ public double getValueDouble() { @@ -524,7 +553,7 @@ public double getValueDouble() { /** * Get value if it is a string - * + * * @return value */ public String getValueString() { @@ -533,7 +562,7 @@ public String getValueString() { /** * Get value if it is a byte array - * + * * @return value */ public byte[] getValueBytes() { @@ -542,7 +571,7 @@ public byte[] getValueBytes() { /** * Get module name of the module that created the attribute - * + * * @return name */ public String getModuleName() { @@ -551,7 +580,7 @@ public String getModuleName() { /** * Get context of the data stored in the attribute, if set - * + * * @return context */ public String getContext() { @@ -559,12 +588,15 @@ public String getContext() { } /** - * Get the artifact that this attribute is associated with - * The artifact can be used to find the associated file and other attributes - * associated with this artifact. + * Get the artifact that this attribute is associated with. * + * The artifact can + * be used to find the associated file and other attributes associated with + * this artifact. + * * @return artifact - * @throws TskException exception thrown when critical error occurred within tsk core + * @throws TskException exception thrown when critical error occurred within + * tsk core */ public BlackboardArtifact getParentArtifact() throws TskCoreException { return Case.getBlackboardArtifact(artifactID); @@ -572,7 +604,7 @@ public BlackboardArtifact getParentArtifact() throws TskCoreException { /** * Set the artifactID, this should only be used by sleuthkitCase - * + * * @param artifactID artifactID to set on a newly created attribute */ protected void setArtifactID(long artifactID) { @@ -582,6 +614,7 @@ protected void setArtifactID(long artifactID) { /** * Set the SleuthkitCase handle, this should only be used by SleuthkitCase * on a newly created attribute + * * @param Case case handle to associated with this attribute */ protected void setCase(SleuthkitCase Case) {