[#24] Implementation of Component Class field (#114)

* This is new code that parses a new field in the upcoming TCG spec for the platform components fields. The new field indicates the type of hardware (ex Memory - DDR3). This information wasn't provided before so it wasn't always clear what the component was. The new information is provided in a json file. A unit test was created to test the different variations. This commit does not include hooks in the base code to use this class yet. This commit is mainly to include the added library and correct bug and checkstyle issues associated with the new code.

Closes #24

* Removed duplicate CONSTANT variable.

* Added newline

* Added Newline

* Updated variable names for json object.

* Fixed line length style error.
This commit is contained in:
Cyrus 2019-03-25 11:14:19 -04:00 committed by GitHub
parent 3ae32b6777
commit 35c63efe19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 1164 additions and 7 deletions

View File

@ -605,10 +605,23 @@
<div class="component col col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<span data-toggle="tooltip" data-placement="top" title="Manufacturer">${component.getComponentManufacturer()}</span>&nbsp;-&nbsp;
<span data-toggle="tooltip" data-placement="top" title="Model">${component.getComponentModel()}</span>
<c:choose>
<c:when test="${not empty fn:trim(component.getComponentClass())}">
<span data-toggle="tooltip" data-placement="top" title="Component Class">${component.getComponentClass()}</span>
</c:when>
<c:otherwise>
<span data-toggle="tooltip" data-placement="top" title="Manufacturer">${component.getComponentManufacturer()}</span>&nbsp;-&nbsp;
<span data-toggle="tooltip" data-placement="top" title="Model">${component.getComponentModel()}</span>
</c:otherwise>
</c:choose>
</div>
<div class="panel-body">
<c:if test="${not empty fn:trim(component.getComponentClass())}">
<span class="fieldHeader">Manufacturer:</span>
<span class="fieldValue">${component.getComponentManufacturer()}</span><br/>
<span class="fieldHeader">Model</span>
<span class="fieldValue">${component.getComponentModel()}</span><br/>
</c:if>
<c:if test="${not empty fn:trim(component.getComponentSerial())}">
<span class="fieldHeader">Serial Number:</span>
<span class="fieldValue">${component.getComponentSerial()}</span><br/>

View File

@ -43,6 +43,7 @@ dependencies {
compile libs.guava
compile libs.spring_core
compile libs.spring_retry
compile libs.minimal_json
compile (libs.xml_rpc_client) {
exclude group: 'junit'
}

View File

@ -9,8 +9,7 @@ import org.bouncycastle.asn1.DERUTF8String;
* <pre>
* componentAddress ::= SEQUENCE {
* addressType AddressType,
* addressValue
* UTF8String (SIZE (1..STRMAX)) }
* addressValue UTF8String (SIZE (1..STRMAX)) }
* where STRMAX is 256
* </pre>
*/
@ -25,7 +24,6 @@ public class ComponentAddress {
private static final String WLAN_MAC = "2.23.133.17.2";
private static final String BLUETOOTH_MAC = "2.23.133.17.3";
private ASN1ObjectIdentifier addressType;
private DERUTF8String addressValue;

View File

@ -0,0 +1,263 @@
package hirs.data.persist.certificate.attributes;
import com.eclipsesource.json.Json;
import com.eclipsesource.json.JsonObject;
import com.eclipsesource.json.JsonObject.Member;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
/**
* <p>
* This class parses the associated component identifier located in Platform
* Certificates and maps them to the corresponding string representation found
* in the associated JSON file. If the value can not be found, either because
* the provided value is malformed or doesn't exist in the mapping, then values
* returned will not match what is expected. This class will return Unknown as a
* category and None as the component which is not a valid mapping. This is
* because None is a category and Unknown is a component identifier.
* </p>
* <pre>
* componentClass ::= SEQUENCE {
* componentClassRegistry ComponentClassRegistry,
* componentClassValue OCTET STRING SIZE(4) ) }
* </pre>
*/
public class ComponentClass {
private static final Logger LOGGER = LoggerFactory.getLogger(ComponentClass.class);
private static final Path JSON_PATH = FileSystems.getDefault()
.getPath("/opt", "hirs", "default-properties", "component-class.json");
private static final String OTHER_STRING = "Other";
private static final String UNKNOWN_STRING = "Unknown";
private static final String NONE_STRING = "None";
// Used to test bytes associated with just the component
private static final int COMPONENT_MASK = 0x0000FFFF;
// Used to test bytes associated with just the category
private static final int CATEGORY_MASK = 0xFFFF0000;
// Used to indicate that the component string value provided is erroneous
private static final int ERROR = -1;
/**
* All categories have Other and Unknown as the first 2 values.
*/
private static final int OTHER = 0;
private static final int UNKNOWN = 1;
private String category;
private String component;
private int componentIdentifier;
/**
* Class Constructor that takes a int representation of the component value.
*
* @param componentIdentifier component value
*/
public ComponentClass(final int componentIdentifier) {
this(JSON_PATH, componentIdentifier);
}
/**
* Class Constructor that takes a String representation of the component
* value.
*
* @param componentIdentifier component value
*/
public ComponentClass(final String componentIdentifier) {
this(JSON_PATH, componentIdentifier);
}
/**
* Class Constructor that takes a String representation of the component
* value.
*
* @param componentClassPath file path for the json
* @param componentIdentifier component value
*/
public ComponentClass(final Path componentClassPath, final String componentIdentifier) {
this(componentClassPath, getComponentIntValue(componentIdentifier));
}
/**
* Main Class Constructor that takes in an integer representation of the
* component value. Sets main class variables to default values and then
* matches the value against defined values in the associated JSON file.
*
* @param componentClassPath file path for the json
* @param componentIdentifier component value
*/
public ComponentClass(final Path componentClassPath, final int componentIdentifier) {
this.category = UNKNOWN_STRING;
this.component = NONE_STRING;
this.componentIdentifier = componentIdentifier;
switch (componentIdentifier) {
case OTHER:
this.category = NONE_STRING;
this.component = OTHER_STRING;
break;
case UNKNOWN:
this.category = NONE_STRING;
this.component = UNKNOWN_STRING;
break;
case ERROR:
// Number Format Exception
break;
default:
getCategory(getJsonObject(componentClassPath));
break;
}
}
/**
* Getter for the Category type.
*
* @return string value of the category
*/
public final String getCategory() {
return category;
}
/**
* Getter for the Component type.
*
* @return string value of the component
*/
public final String getComponent() {
return component;
}
/**
* This is the main way this class will be referenced and how it
* will be displayed on the portal.
* @return String combination of category and component.
*/
@Override
public String toString() {
return String.format("%s - %s", category, component);
}
/**
* Getter for the JSON Object that is associated with the component value
* mapped in the associated JSON file.
*
* @return a JSON Object
*/
private JsonObject getJsonObject(final Path componentClassPath) {
// find the file and load it
JsonObject components = null;
if (Files.notExists(componentClassPath)) {
LOGGER.info(String.format("No file found at %s.", componentClassPath.toString()));
} else {
try {
InputStream inputStream = new FileInputStream(componentClassPath.toString());
JsonObject componentFile = Json.parse(new InputStreamReader(inputStream,
StandardCharsets.UTF_8)).asObject();
components = componentFile.get("Components").asObject();
} catch (IOException ex) {
// add log file thing here indication issue with JSON File
components = null;
}
}
return components;
}
/**
* Getter for the Category mapped to the associated value in.
*
* @param categories a JSON object associated with mapped categories in file
* @componentIndentifier.
*/
private void getCategory(final JsonObject categories) {
int componentID;
if (categories != null) {
for (String name : categories.names()) {
componentID = Integer.decode(categories.get(name).asObject().get("ID").asString());
// check for the correct flag
if ((componentIdentifier & CATEGORY_MASK) == componentID) {
JsonObject componentTypes = categories.get(name)
.asObject().get("Types").asObject();
category = name;
switch (componentIdentifier & COMPONENT_MASK) {
case OTHER:
component = OTHER_STRING;
break;
case UNKNOWN:
component = UNKNOWN_STRING;
break;
default:
getComponent(componentID, componentTypes);
}
}
}
}
}
/**
* Getter for the component associated with the component JSON Object mapped
* in the JSON file.
*
* @param componentID the ID associated with the category
* @param components JSON Object for the categories components
*/
private void getComponent(final int componentID, final JsonObject components) {
int typeID, testID;
if (components != null) {
for (Member member : components) {
typeID = Integer.decode(member.getName());
testID = componentID + typeID;
if (componentIdentifier == testID) {
component = member.getValue().asString();
}
}
}
}
/**
* This method converts the string representation of the component ID into
* an integer. Or throws and error if the format is in error.
*
* @param component string representation of the component ID
* @return the int representation of the component
*/
private static int getComponentIntValue(final String component) {
int componetValue = ERROR;
if (component != null) {
try {
if (component.contains("x")) {
componetValue = Integer.decode(component);
} else {
if (component.contains("#")) {
componetValue = Integer.valueOf(
component.replace("#", ""),
Short.SIZE);
} else {
componetValue = Integer.valueOf(
component, Short.SIZE);
}
}
} catch (NumberFormatException nfEx) {
//invalid entry
}
}
return componetValue;
}
}

View File

@ -17,6 +17,8 @@ import org.bouncycastle.asn1.DERUTF8String;
* Attribute.
* <pre>
* ComponentIdentifier ::= SEQUENCE {
* componentClass
* SEQUENCE(SIZE(1..CONFIGMAX)),
* componentManufacturer UTF8String (SIZE (1..STRMAX)),
* componentModel UTF8String (SIZE (1..STRMAX)),
* componentSerial[0] IMPLICIT UTF8String (SIZE (1..STRMAX)) OPTIONAL,
@ -35,9 +37,10 @@ public class ComponentIdentifier {
*/
public static final int CONFIGMAX = 32;
private static final int COMPONENT_IDENTIFIER = 1;
// optional sequence objects
private static final int COMPONENT_SERIAL = 0;
private static final int COMPONENT_REVISION = 1;
private static final int COMPONENT_IDENTIFIER = 1;
private static final int COMPONENT_MANUFACTURER_ID = 2;
private static final int FIELD_REPLACEABLE = 3;
private static final int COMPONENT_ADDRESS = 4;
@ -295,6 +298,9 @@ public class ComponentIdentifier {
StringBuilder sb = new StringBuilder();
sb.append("ComponentIdentifier{");
sb.append("componentManufacturer=").append(componentManufacturer.getString());
sb.append("componentClass=").append(componentClass);
sb.append(", componentManufacturer=")
.append(componentManufacturer.getString());
sb.append(", componentModel=").append(componentModel.getString());
//Optional not null values
sb.append(", componentSerial=");

View File

@ -0,0 +1,291 @@
{
"Components": {
"Processors": {
"ID": "0x00010000",
"Types": {
"0x00000002": "CPU",
"0x00000003": "Math Processor",
"0x00000004": "DSP Processor",
"0x00000005": "Video Processor",
"0x00000006": "GPU"
}
},
"Containers": {
"ID": "0x00020000",
"Types": {
"0x00000002": "Chassis",
"0x00000003": "Backplane",
"0x00000004": "Server Blade",
"0x00000005": "Stack (Rack)",
"0x00000006": "Stack (Rack)",
"0x00000007": "Stack (Rack)",
"0x00000008": "Stack (Rack)",
"0x00000009": "Stack (Rack)",
"0x0000000A": "Stack (Rack)",
"0x0000000B": "Stack (Rack)",
"0x0000000C": "Stack (Rack)",
"0x0000000D": "Stack (Rack)"
}
},
"IC Boards": {
"ID": "0x00030000",
"Types": {
"0x00000002": "Daughter Board",
"0x00000003": "Motherboard",
"0x00000004": "Riser Card"
}
},
"Modules": {
"ID": "0x00040000",
"Types": {
"0x00000002": "SAS Bridgeboard",
"0x00000003": "Processor Module",
"0x00000004": "I/O Module",
"0x00000005": "Memory Module",
"0x00000006": "Power Module",
"0x00000007": "Processor/Memory Module",
"0x00000008": "Processor/IO Module"
}
},
"Controllers": {
"ID": "0x00050000",
"Types": {
"0x00000002": "Video Controller",
"0x00000003": "SCSI Controller",
"0x00000004": "Ethernet Controller",
"0x00000005": "Token Ring Controller",
"0x00000006": "Audio/Sound Controller",
"0x00000007": "PATA Controller",
"0x00000008": "SATA Controller",
"0x00000009": "SAS Controller",
"0x0000000A": "LED Display Controller",
"0x0000000B": "RAID Controller",
"0x0000000C": "Remote Access Controller",
"0x0000000D": "USB Controller"
}
},
"Memory": {
"ID": "0x00060000",
"Types": {
"0x0000000": "",
"0x00000001": "DRAM Memory",
"0x00000002": "EDRAM Memory",
"0x00000003": "VRAM Memory",
"0x00000004": "SRAM Memory",
"0x00000005": "RAM Memory",
"0x00000006": "ROM Memory",
"0x00000007": "FLASH Memory",
"0x00000008": "EEPROM Memory",
"0x00000009": "FEPROM Memory",
"0x0000000A": "EPROM Memory",
"0x0000000B": "CDRAM Memory",
"0x0000000C": "3DRAM Memory",
"0x0000000D": "SDRAM Memory",
"0x0000000E": "SGRAM Memory",
"0x0000000F": "RDRAM Memory",
"0x00000010": "DDR Memory",
"0x00000011": "DDR2 Memory",
"0x00000012": "DDR3 Memory",
"0x00000013": "DDR4 Memory",
"0x00000014": "LPDDR Memory",
"0x00000015": "LPDDR2 Memory",
"0x00000016": "LPDDR3 Memory",
"0x00000017": "LPDDR4 Memory",
"0x00000018": "NVRAM Memory"
}
},
"Storage": {
"ID": "0x00070000",
"Types": {
"0x00000002": "Storage Drive",
"0x00000003": "SSD Drive",
"0x00000004": "M.2 Drive",
"0x00000005": "HDD Drive"
}
},
"Media Drives": {
"ID": "0x00080000",
"Types": {
"0x00000002": "Floppy Drive",
"0x00000003": "Tape Drive",
"0x00000004": "PCIe Drive",
"0x00000005": "CD Drive",
"0x00000006": "DVD Drive",
"0x00000007": "Blu-Ray Drive"
}
},
"Network Adapters": {
"ID": "0x00090000",
"Types": {
"0x00000002": "Ethernet Adapter",
"0x00000003": "WiFi Adapter",
"0x00000004": "Bluetooh Adapter",
"0x00000005": "Cellular Adapter",
"0x00000006": "Zigbee Adapter",
"0x00000007": "3G Cellular Adapter",
"0x00000008": "4G Cellular Adapter",
"0x00000009": "5G Cellular Adapter",
"0x0000000A": "Network Switch",
"0x0000000B": "Network Router"
}
},
"Energy Object": {
"ID": "0x000A0000",
"Types": {
"0x00000002": "Power Supply",
"0x00000003": "Battery",
"0x00000004": "Coin Battery",
"0x00000005": "Capacitor Battery"
}
},
"Sensors": {
"ID": "0x000B0000",
"Types": {
"0x00000002": "Optical Sensor",
"0x00000003": "Temperature Sensor",
"0x00000004": "Proximity Sensor",
"0x00000005": "IR Sensor",
"0x00000006": "Chemical Sensor",
"0x00000007": "Motion Detection Sensor",
"0x00000008": "Level Sensor",
"0x00000009": "Gyroscopic Sensor",
"0x0000000A": "Humidity Sensor",
"0x0000000B": "Accelerometer Sensor"
}
},
"Display Devices": {
"ID": "0x000C0000",
"Types": {
"0x00000001": "LCD Display Panel",
"0x00000002": "LED Display Panel",
"0x00000003": "OLED Display Panel",
"0x00000004": "CRT Display Panel"
}
},
"Cooling": {
"ID": "0x000D0000",
"Types": {
"0x00000002": "Thermal Assembly",
"0x00000003": "Fan",
"0x00000004": "Chassis Fan",
"0x00000005": "Socket Fan",
"0x00000006": "Heatsink",
"0x00000007": "Liquid Cooling"
}
},
"Input Devices": {
"ID": "0x000E0000",
"Types": {
"0x00000002": "Mouse",
"0x00000003": "Track Ball",
"0x00000004": "Track Point",
"0x00000005": "Glide Point",
"0x00000006": "Touch Pad",
"0x00000007": "Touch Screen",
"0x00000008": "Camera",
"0x00000009": "Fingerpoint Reader",
"0x0000000A": "Keyboard",
"0x0000000B": "Smartcard Reader",
"0x0000000C": "Biometric Reader",
"0x0000000D": "Joystick",
"0x0000000E": "Gaming Controller",
"0x0000000F": "IR Camera",
"0x00000010": "Facial Recognition Camera",
"0x00000011": "Scanner"
}
},
"Slots": {
"ID": "0x000F0000",
"Types": {
"0x00000002": "Socket",
"0x00000003": "ISA Slot",
"0x00000004": "PCI Slot",
"0x00000005": "AGP Slot",
"0x00000006": "PCI-X Slot",
"0x00000007": "M.2 Slot",
"0x00000008": "MXM Slot",
"0x00000009": "PCI Express Slot",
"0x0000000A": "PCI Express Mini",
"0x0000000B": "PC-98 Slot",
"0x0000000C": "Memory Slot"
}
},
"Ports": {
"ID": "0x00100000",
"Types": {
"0x00000002": "Parallel Port",
"0x00000003": "Serial Port",
"0x00000004": "SCSI Port",
"0x00000005": "MIDI Port",
"0x00000006": "USB Port",
"0x00000007": "Firewire Port",
"0x00000008": "PCMCIA Port",
"0x00000009": "ATA Port",
"0x0000000A": "SATA Port",
"0x0000000B": "SAS Port",
"0x0000000C": "Optical Port",
"0x0000000D": "DisplayPort",
"0x0000000E": "Mini DisplayPort",
"0x0000000F": "HDMI Port",
"0x00000010": "Mini HDMI Port",
"0x00000011": "Micro HDMI Port",
"0x00000012": "Thunderbolt Port",
"0x00000013": "VGA Port",
"0x00000014": "Mini VGA Port",
"0x00000015": "DVI Port",
"0x00000016": "DVI-I Port",
"0x00000017": "DVI-D Port",
"0x00000018": "DVI-A Port",
"0x00000019": "Mini DVI Port",
"0x0000001A": "Micro DVI Port",
"0x0000001B": "Ethernet Port",
"0x0000001C": "ADB Port",
"0x0000001D": "Mac Serial Port",
"0x0000001E": "PS/2 Port",
"0x0000001F": "Surround Sound Port",
"0x00000020": "Stereo Port",
"0x00000021": "Dolby 5.1 Port",
"0x00000022": "Dolby 7.1 Port",
"0x00000023": "Dolby 7.2 Port",
"0x00000024": "Line In Port",
"0x00000025": "Microphone Port",
"0x00000026": "Speaker Port",
"0x00000027": "Digital Audio Port",
"0x00000028": "TOSLINK Port"
}
},
"Discrete Component": {
"ID": "0x00110000",
"Types": {
"0x00000002": "Capacitor",
"0x00000003": "Resistor",
"0x00000004": "Inductor",
"0x00000005": "Diode",
"0x00000006": "Crystal Oscilator",
"0x00000007": "Logic Gate",
"0x00000008": "Ferrite Beads",
"0x00000009": "Transistor",
"0x0000000A": "Fuse",
"0x0000000B": "Voltage Regulator",
"0x0000000C": "DC/DC Converter",
"0x0000000D": "Switching Regulator",
"0x0000000E": "Power Switch"
}
},
"Cabling": {
"ID": "0x00120000",
"Types": {
"0x00000002": "AC Adapter",
"0x00000003": "Power Cord",
"0x00000004": "Serial ATA Cable",
"0x00000005": "Serial ATA Power Cable",
"0x00000006": "Drive Cable",
"0x00000007": "Power Supply Cable",
"0x00000008": "IDE Cable",
"0x00000009": "Molex Cable",
"0x0000000A": "Ribbon Cable",
"0x0000000B": "PCI Express"
}
}
}
}

View File

@ -0,0 +1,269 @@
package hirs.data.persist.certificate.attributes;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.net.URISyntaxException;
import java.nio.file.Paths;
/**
* Tests for the ComponentClassTest class.
*/
public class ComponentClassTest {
private static final String JSON_FILE = "/config/component-class.json";
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentNoneUNK() throws URISyntaxException {
int componentIdentifier = 1;
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("Unknown", resultComponent);
Assert.assertEquals("None", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentNoneOther() throws URISyntaxException {
int componentIdentifier = 0;
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("Other", resultComponent);
Assert.assertEquals("None", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentBlank() throws URISyntaxException {
String componentIdentifier = "";
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("None", resultComponent);
Assert.assertEquals("Unknown", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentNFEx() throws URISyntaxException {
String componentIdentifier = "HIRS";
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("None", resultComponent);
Assert.assertEquals("Unknown", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentNull() throws URISyntaxException {
String componentIdentifier = null;
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("None", resultComponent);
Assert.assertEquals("Unknown", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentStandardQuery() throws URISyntaxException {
String componentIdentifier = "0x00040002";
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("SAS Bridgeboard", resultComponent);
Assert.assertEquals("Modules", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentStandardQueryInt() throws URISyntaxException {
int componentIdentifier = 0x00040002;
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("SAS Bridgeboard", resultComponent);
Assert.assertEquals("Modules", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentStandardQueryIntOther() throws URISyntaxException {
int componentIdentifier = 0x00040000;
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("Other", resultComponent);
Assert.assertEquals("Modules", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentStandardQueryIntUnk() throws URISyntaxException {
int componentIdentifier = 0x00040001;
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("Unknown", resultComponent);
Assert.assertEquals("Modules", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentStandardQuery2() throws URISyntaxException {
String componentIdentifier = "0x00060012";
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("DDR3 Memory", resultComponent);
Assert.assertEquals("Memory", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentStandardQueryOther() throws URISyntaxException {
String componentIdentifier = "0x00060000";
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("Other", resultComponent);
Assert.assertEquals("Memory", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentStandardQueryUNK() throws URISyntaxException {
String componentIdentifier = "0x00060001";
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("Unknown", resultComponent);
Assert.assertEquals("Memory", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentNonStandardQuery() throws URISyntaxException {
String componentIdentifier = "00040002";
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("SAS Bridgeboard", resultComponent);
Assert.assertEquals("Modules", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentNonStandardQuery2() throws URISyntaxException {
String componentIdentifier = "#00040002";
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("SAS Bridgeboard", resultComponent);
Assert.assertEquals("Modules", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentNonExistentValue() throws URISyntaxException {
String componentIdentifier = "0x00040014";
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("None", resultComponent);
Assert.assertEquals("Modules", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentNonExistentValue2() throws URISyntaxException {
String componentIdentifier = "0x0004FF14";
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("None", resultComponent);
Assert.assertEquals("Modules", resultCategory);
}
/**
* Test of getComponent method, of class ComponentClass.
* @throws URISyntaxException if there is a problem constructing the URI
*/
@Test
public void testGetComponentNonExistentCategory() throws URISyntaxException {
String componentIdentifier = "0x0015FF14";
ComponentClass instance = new ComponentClass(Paths.get(this.getClass()
.getResource(JSON_FILE).toURI()), componentIdentifier);
String resultCategory = instance.getCategory();
String resultComponent = instance.getComponent();
Assert.assertEquals("None", resultComponent);
Assert.assertEquals("Unknown", resultCategory);
}
}

View File

@ -0,0 +1,291 @@
{
"Components": {
"Processors": {
"ID": "0x00010000",
"Types": {
"0x00000002": "CPU",
"0x00000003": "Math Processor",
"0x00000004": "DSP Processor",
"0x00000005": "Video Processor",
"0x00000006": "GPU"
}
},
"Containers": {
"ID": "0x00020000",
"Types": {
"0x00000002": "Chassis",
"0x00000003": "Backplane",
"0x00000004": "Server Blade",
"0x00000005": "Stack (Rack)",
"0x00000006": "Stack (Rack)",
"0x00000007": "Stack (Rack)",
"0x00000008": "Stack (Rack)",
"0x00000009": "Stack (Rack)",
"0x0000000A": "Stack (Rack)",
"0x0000000B": "Stack (Rack)",
"0x0000000C": "Stack (Rack)",
"0x0000000D": "Stack (Rack)"
}
},
"IC Boards": {
"ID": "0x00030000",
"Types": {
"0x00000002": "Daughter Board",
"0x00000003": "Motherboard",
"0x00000004": "Riser Card"
}
},
"Modules": {
"ID": "0x00040000",
"Types": {
"0x00000002": "SAS Bridgeboard",
"0x00000003": "Processor Module",
"0x00000004": "I/O Module",
"0x00000005": "Memory Module",
"0x00000006": "Power Module",
"0x00000007": "Processor/Memory Module",
"0x00000008": "Processor/IO Module"
}
},
"Controllers": {
"ID": "0x00050000",
"Types": {
"0x00000002": "Video Controller",
"0x00000003": "SCSI Controller",
"0x00000004": "Ethernet Controller",
"0x00000005": "Token Ring Controller",
"0x00000006": "Audio/Sound Controller",
"0x00000007": "PATA Controller",
"0x00000008": "SATA Controller",
"0x00000009": "SAS Controller",
"0x0000000A": "LED Display Controller",
"0x0000000B": "RAID Controller",
"0x0000000C": "Remote Access Controller",
"0x0000000D": "USB Controller"
}
},
"Memory": {
"ID": "0x00060000",
"Types": {
"0x0000000": "",
"0x00000001": "DRAM Memory",
"0x00000002": "EDRAM Memory",
"0x00000003": "VRAM Memory",
"0x00000004": "SRAM Memory",
"0x00000005": "RAM Memory",
"0x00000006": "ROM Memory",
"0x00000007": "FLASH Memory",
"0x00000008": "EEPROM Memory",
"0x00000009": "FEPROM Memory",
"0x0000000A": "EPROM Memory",
"0x0000000B": "CDRAM Memory",
"0x0000000C": "3DRAM Memory",
"0x0000000D": "SDRAM Memory",
"0x0000000E": "SGRAM Memory",
"0x0000000F": "RDRAM Memory",
"0x00000010": "DDR Memory",
"0x00000011": "DDR2 Memory",
"0x00000012": "DDR3 Memory",
"0x00000013": "DDR4 Memory",
"0x00000014": "LPDDR Memory",
"0x00000015": "LPDDR2 Memory",
"0x00000016": "LPDDR3 Memory",
"0x00000017": "LPDDR4 Memory",
"0x00000018": "NVRAM Memory"
}
},
"Storage": {
"ID": "0x00070000",
"Types": {
"0x00000002": "Storage Drive",
"0x00000003": "SSD Drive",
"0x00000004": "M.2 Drive",
"0x00000005": "HDD Drive"
}
},
"Media Drives": {
"ID": "0x00080000",
"Types": {
"0x00000002": "Floppy Drive",
"0x00000003": "Tape Drive",
"0x00000004": "PCIe Drive",
"0x00000005": "CD Drive",
"0x00000006": "DVD Drive",
"0x00000007": "Blu-Ray Drive"
}
},
"Network Adapters": {
"ID": "0x00090000",
"Types": {
"0x00000002": "Ethernet Adapter",
"0x00000003": "WiFi Adapter",
"0x00000004": "Bluetooh Adapter",
"0x00000005": "Cellular Adapter",
"0x00000006": "Zigbee Adapter",
"0x00000007": "3G Cellular Adapter",
"0x00000008": "4G Cellular Adapter",
"0x00000009": "5G Cellular Adapter",
"0x0000000A": "Network Switch",
"0x0000000B": "Network Router"
}
},
"Energy Object": {
"ID": "0x000A0000",
"Types": {
"0x00000002": "Power Supply",
"0x00000003": "Battery",
"0x00000004": "Coin Battery",
"0x00000005": "Capacitor Battery"
}
},
"Sensors": {
"ID": "0x000B0000",
"Types": {
"0x00000002": "Optical Sensor",
"0x00000003": "Temperature Sensor",
"0x00000004": "Proximity Sensor",
"0x00000005": "IR Sensor",
"0x00000006": "Chemical Sensor",
"0x00000007": "Motion Detection Sensor",
"0x00000008": "Level Sensor",
"0x00000009": "Gyroscopic Sensor",
"0x0000000A": "Humidity Sensor",
"0x0000000B": "Accelerometer Sensor"
}
},
"Display Devices": {
"ID": "0x000C0000",
"Types": {
"0x00000001": "LCD Display Panel",
"0x00000002": "LED Display Panel",
"0x00000003": "OLED Display Panel",
"0x00000004": "CRT Display Panel"
}
},
"Cooling": {
"ID": "0x000D0000",
"Types": {
"0x00000002": "Thermal Assembly",
"0x00000003": "Fan",
"0x00000004": "Chassis Fan",
"0x00000005": "Socket Fan",
"0x00000006": "Heatsink",
"0x00000007": "Liquid Cooling"
}
},
"Input Devices": {
"ID": "0x000E0000",
"Types": {
"0x00000002": "Mouse",
"0x00000003": "Track Ball",
"0x00000004": "Track Point",
"0x00000005": "Glide Point",
"0x00000006": "Touch Pad",
"0x00000007": "Touch Screen",
"0x00000008": "Camera",
"0x00000009": "Fingerpoint Reader",
"0x0000000A": "Keyboard",
"0x0000000B": "Smartcard Reader",
"0x0000000C": "Biometric Reader",
"0x0000000D": "Joystick",
"0x0000000E": "Gaming Controller",
"0x0000000F": "IR Camera",
"0x00000010": "Facial Recognition Camera",
"0x00000011": "Scanner"
}
},
"Slots": {
"ID": "0x000F0000",
"Types": {
"0x00000002": "Socket",
"0x00000003": "ISA Slot",
"0x00000004": "PCI Slot",
"0x00000005": "AGP Slot",
"0x00000006": "PCI-X Slot",
"0x00000007": "M.2 Slot",
"0x00000008": "MXM Slot",
"0x00000009": "PCI Express Slot",
"0x0000000A": "PCI Express Mini",
"0x0000000B": "PC-98 Slot",
"0x0000000C": "Memory Slot"
}
},
"Ports": {
"ID": "0x00100000",
"Types": {
"0x00000002": "Parallel Port",
"0x00000003": "Serial Port",
"0x00000004": "SCSI Port",
"0x00000005": "MIDI Port",
"0x00000006": "USB Port",
"0x00000007": "Firewire Port",
"0x00000008": "PCMCIA Port",
"0x00000009": "ATA Port",
"0x0000000A": "SATA Port",
"0x0000000B": "SAS Port",
"0x0000000C": "Optical Port",
"0x0000000D": "DisplayPort",
"0x0000000E": "Mini DisplayPort",
"0x0000000F": "HDMI Port",
"0x00000010": "Mini HDMI Port",
"0x00000011": "Micro HDMI Port",
"0x00000012": "Thunderbolt Port",
"0x00000013": "VGA Port",
"0x00000014": "Mini VGA Port",
"0x00000015": "DVI Port",
"0x00000016": "DVI-I Port",
"0x00000017": "DVI-D Port",
"0x00000018": "DVI-A Port",
"0x00000019": "Mini DVI Port",
"0x0000001A": "Micro DVI Port",
"0x0000001B": "Ethernet Port",
"0x0000001C": "ADB Port",
"0x0000001D": "Mac Serial Port",
"0x0000001E": "PS/2 Port",
"0x0000001F": "Surround Sound Port",
"0x00000020": "Stereo Port",
"0x00000021": "Dolby 5.1 Port",
"0x00000022": "Dolby 7.1 Port",
"0x00000023": "Dolby 7.2 Port",
"0x00000024": "Line In Port",
"0x00000025": "Microphone Port",
"0x00000026": "Speaker Port",
"0x00000027": "Digital Audio Port",
"0x00000028": "TOSLINK Port"
}
},
"Discrete Component": {
"ID": "0x00110000",
"Types": {
"0x00000002": "Capacitor",
"0x00000003": "Resistor",
"0x00000004": "Inductor",
"0x00000005": "Diode",
"0x00000006": "Crystal Oscilator",
"0x00000007": "Logic Gate",
"0x00000008": "Ferrite Beads",
"0x00000009": "Transistor",
"0x0000000A": "Fuse",
"0x0000000B": "Voltage Regulator",
"0x0000000C": "DC/DC Converter",
"0x0000000D": "Switching Regulator",
"0x0000000E": "Power Switch"
}
},
"Cabling": {
"ID": "0x00120000",
"Types": {
"0x00000002": "AC Adapter",
"0x00000003": "Power Cord",
"0x00000004": "Serial ATA Cable",
"0x00000005": "Serial ATA Power Cable",
"0x00000006": "Drive Cable",
"0x00000007": "Power Supply Cable",
"0x00000008": "IDE Cable",
"0x00000009": "Molex Cable",
"0x0000000A": "Ribbon Cable",
"0x0000000B": "PCI Express"
}
}
}
}

24
NOTICE
View File

@ -2244,4 +2244,26 @@ re2 is under the re2 license.
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
EclipseSource minimal-json is copyrighted under MIT License
Copyright (c) 2013, 2014 EclipseSource
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -130,6 +130,7 @@ subprojects {
log_bridge: 'org.apache.logging.log4j:log4j-jcl:2.8.1',
mockito: 'org.mockito:mockito-all:1.10.19',
mariadb: 'org.mariadb.jdbc:mariadb-java-client:2.2.1',
minimal_json: 'com.eclipsesource.minimal-json:minimal-json:0.9.5',
pmd: 'net.sourceforge.pmd:pmd:5.1.1',
powermock: [ 'org.powermock:powermock-core:1.6.3',
'org.powermock:powermock-api-mockito:1.6.3',

View File

@ -226,6 +226,7 @@ fi
%attr(664, root, tomcat) /opt/hirs/default-properties/attestationca/logging.properties
%attr(664, root, tomcat) /opt/hirs/default-properties/attestationca/banner.properties
%attr(664, root, tomcat) /opt/hirs/default-properties/attestationca/persistence.properties
%attr(664, root, tomcat) /opt/hirs/default-properties/component-class.json
%attr(774, root, tomcat) /opt/hirs/scripts/common/aca
%attr(774, root, tomcat) /opt/hirs/scripts/aca
%attr(774, root, tomcat) /opt/hirs/extras/aca/tomcat-mysql-hirs.pp
@ -294,6 +295,7 @@ mkdir -p %{buildroot}/opt/hirs/default-properties/attestationca
cp HIRS_Utils/src/main/resources/persistence.properties %{buildroot}/opt/hirs/default-properties/attestationca/
cp HIRS_Utils/src/main/resources/logging.properties %{buildroot}/opt/hirs/default-properties/attestationca/
cp HIRS_Utils/src/main/resources/banner.properties %{buildroot}/opt/hirs/default-properties/attestationca/
cp HIRS_Utils/src/main/resources/component-class.json %{buildroot}/opt/hirs/default-properties/
# install extras
mkdir -p %{buildroot}/opt/hirs/extras