diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java index 9a7da962..64cd88cc 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java @@ -4,21 +4,21 @@ import hirs.data.persist.BaseReferenceManifest; import hirs.data.persist.ReferenceManifest; import hirs.data.persist.SupportReferenceManifest; import hirs.data.persist.SwidResource; -import hirs.persist.DBManagerException; import hirs.persist.ReferenceManifestManager; import hirs.tpm.eventlog.TCGEventLog; import hirs.attestationca.portal.page.Page; import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageMessages; import hirs.attestationca.portal.page.params.ReferenceManifestDetailsPageParams; + import java.io.IOException; -import java.nio.file.NoSuchFileException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.ArrayList; +import java.util.Set; import java.util.UUID; import org.apache.logging.log4j.LogManager; @@ -57,13 +57,13 @@ public class ReferenceManifestDetailsPageController * Returns the filePath for the view and the data model for the page. * * @param params The object to map url parameters into. - * @param model The data model for the request. Can contain data from - * redirect. + * @param model The data model for the request. Can contain data from + * redirect. * @return the path for the view and data model for the page. */ @Override public ModelAndView initPage(final ReferenceManifestDetailsPageParams params, - final Model model) { + final Model model) { // get the basic information to render the page ModelAndView mav = getBaseModelAndView(); PageMessages messages = new PageMessages(); @@ -106,16 +106,16 @@ public class ReferenceManifestDetailsPageController * This method takes the place of an entire class for a string builder. * Gathers all information and returns it for displays. * - * @param uuid database reference for the requested RIM. + * @param uuid database reference for the requested RIM. * @param referenceManifestManager the reference manifest manager. * @return mapping of the RIM information from the database. - * @throws java.io.IOException error for reading file bytes. + * @throws java.io.IOException error for reading file bytes. * @throws NoSuchAlgorithmException If an unknown Algorithm is encountered. - * @throws CertificateException if a certificate doesn't parse. + * @throws CertificateException if a certificate doesn't parse. */ public static HashMap getRimDetailInfo(final UUID uuid, - final ReferenceManifestManager referenceManifestManager) throws IOException, - CertificateException, NoSuchAlgorithmException { + final ReferenceManifestManager referenceManifestManager) throws IOException, + CertificateException, NoSuchAlgorithmException { HashMap data = new HashMap<>(); ReferenceManifest rim = ReferenceManifest @@ -169,7 +169,6 @@ public class ReferenceManifestDetailsPageController data.put("pcUriLocal", bRim.getPcURILocal()); data.put("rimLinkHash", bRim.getRimLinkHash()); data.put("rimType", bRim.getRimType()); - data.put("associatedRim", bRim.getAssociatedRim()); List resources = bRim.parseResource(); String resourceFilename = null; @@ -177,45 +176,49 @@ public class ReferenceManifestDetailsPageController // going to have to pull the filename and grab that from the DB // to get the id to make the link - try { - for (SwidResource swidRes : resources) { - resourceFilename = swidRes.getName(); - ReferenceManifest dbRim = ReferenceManifest.select( - referenceManifestManager).byFileName(resourceFilename).getRIM(); + for (SwidResource swidRes : resources) { + resourceFilename = swidRes.getName(); + ReferenceManifest dbRim = ReferenceManifest.select( + referenceManifestManager).byFileName(resourceFilename).getRIM(); - if (dbRim != null) { - logProcessor = new TCGEventLog(dbRim.getRimBytes()); - swidRes.setPcrValues(Arrays.asList( - logProcessor.getExpectedPCRValues())); + if (dbRim != null) { + logProcessor = new TCGEventLog(dbRim.getRimBytes()); + swidRes.setPcrValues(Arrays.asList( + logProcessor.getExpectedPCRValues())); - if (bRim.getAssociatedRim() == null) { - bRim.setAssociatedRim(dbRim.getId()); - } - } else { - swidRes.setPcrValues(new ArrayList<>()); + if (bRim.getAssociatedRim() == null) { + bRim.setAssociatedRim(dbRim.getId()); } + } else { + swidRes.setPcrValues(new ArrayList<>()); } - } catch (NoSuchFileException nsfEx) { - LOGGER.error(String.format("File Not found!: %s", - resourceFilename)); - LOGGER.error(nsfEx); - } catch (DBManagerException dbmEx) { - LOGGER.error(dbmEx); } data.put("associatedRim", bRim.getAssociatedRim()); data.put("swidFiles", resources); } else if (rim instanceof SupportReferenceManifest) { SupportReferenceManifest sRim = (SupportReferenceManifest) rim; - data.put("baseRim", sRim.getFileName()); + + if (sRim.getAssociatedRim() == null) { + Set rims = ReferenceManifest + .select(referenceManifestManager).getRIMs(); + for (ReferenceManifest dbRim : rims) { + if (dbRim instanceof BaseReferenceManifest + && dbRim.getTagId().equals(sRim.getTagId())) { + sRim.setAssociatedRim(dbRim.getId()); + break; + } + } + } + data.put("baseRim", sRim.getTagId()); data.put("associatedRim", sRim.getAssociatedRim()); data.put("rimType", sRim.getRimType()); TCGEventLog logProcessor = new TCGEventLog(sRim.getRimBytes()); data.put("events", logProcessor.getEventList()); } else { - LOGGER.error(String.format("Unable to find Reference Integrity " - + "Manifest with ID: %s", uuid)); + LOGGER.error(String.format("Unable to find Reference Integrity " + + "Manifest with ID: %s", uuid)); } return data; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java index f9a08d69..9c8eb677 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java @@ -28,7 +28,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.UUID; -import java.nio.file.Path; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.servlet.http.HttpServletResponse; @@ -189,7 +188,6 @@ public class ReferenceManifestPageController Map model = new HashMap<>(); PageMessages messages = new PageMessages(); String fileName; - Path filePath; Pattern pattern; Matcher matcher; boolean supportRIM = false; @@ -208,26 +206,24 @@ public class ReferenceManifestPageController .select(referenceManifestManager).getRIMs(); // update information for associated support rims - if (supportRIM) { - for (ReferenceManifest element : rims) { + for (ReferenceManifest element : rims) { + if (supportRIM) { if (element instanceof BaseReferenceManifest) { BaseReferenceManifest bRim = (BaseReferenceManifest) element; for (SwidResource swid : bRim.parseResource()) { if (swid.getName().equals(rim.getFileName())) { rim.setFirmwareVersion(swid.getSize()); - rim.setPlatformManufacturer(element.getPlatformManufacturer()); - rim.setPlatformModel(element.getPlatformModel()); - rim.setTagId(element.getTagId()); - rim.setAssociatedRim(element.getId()); + rim.setPlatformManufacturer(bRim.getPlatformManufacturer()); + rim.setPlatformModel(bRim.getPlatformModel()); + rim.setTagId(bRim.getTagId()); + rim.setAssociatedRim(bRim.getId()); break; } } } - } - } else { - BaseReferenceManifest bRim = (BaseReferenceManifest) rim; - for (SwidResource swid : bRim.parseResource()) { - for (ReferenceManifest element : rims) { + } else { + BaseReferenceManifest bRim = (BaseReferenceManifest) rim; + for (SwidResource swid : bRim.parseResource()) { if (element instanceof SupportReferenceManifest) { SupportReferenceManifest sRim = (SupportReferenceManifest) element; if (swid.getName().equals(sRim.getFileName())) { @@ -239,8 +235,8 @@ public class ReferenceManifestPageController try { referenceManifestManager.update(sRim); } catch (DBManagerException dbmEx) { - LOGGER.error(String.format("Couldn't update Base RIM %s with " - + "associated UUID %s", rim.getTagId(), + LOGGER.error(String.format("Couldn't update Support RIM " + + "%s with associated UUID %s", rim.getTagId(), sRim.getId()), dbmEx); } break; diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/rim-details.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/rim-details.jsp index 46629bed..e801ab21 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/rim-details.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/rim-details.jsp @@ -28,7 +28,6 @@ ${initialData.associatedRim} -
Base RIM not uploaded from the ACA RIM Page
@@ -54,18 +53,18 @@ ${count} - ${event.getPcrIndex()} + PCR${event.getPcrIndex()} ${event.getEventTypeStr()} ${event.getEventDigestStr()} ${event.getEventContentStr()} - +
${initialData.events.size()} entries
@@ -279,6 +278,21 @@ } } } + window.onload = function() { + // Constant retrieved from server-side via JSP + var maxRows = 11; + + var table = document.getElementById('eventLog'); + var wrapper = table.parentNode; + var rowsInTable = table.rows.length; + var height = 0; + if (rowsInTable > maxRows) { + for (var i = 0; i < maxRows; i++) { + height += table.rows[i].clientHeight; + } + wrapper.style.height = height + "px"; + } + } diff --git a/HIRS_AttestationCAPortal/src/main/webapp/common/rim_details.css b/HIRS_AttestationCAPortal/src/main/webapp/common/rim_details.css new file mode 100644 index 00000000..36170572 --- /dev/null +++ b/HIRS_AttestationCAPortal/src/main/webapp/common/rim_details.css @@ -0,0 +1,36 @@ +#eventInput { + width: 100%; + font-size: 16px; /* Increase font-size */ + padding: 12px 20px 12px 40px; /* Add some padding */ + border: 1px solid #ddd; /* Add a grey border */ + margin-bottom: 12px; /* Add some space below the input */ +} + +#tableDivTag { + padding-top: 5px; + padding-left: 125px; + padding-right: 150px; + overflow-y: scroll; +} + +#eventLog { + border-collapse: collapse; /* Collapse borders */ + width: 100%; + border: 1px solid #ddd; /* Add a grey border */ + font-size: 14px; /* Increase font-size */ +} + +#eventLog th, #eventLog td { + text-align: left; /* Left-align text */ + padding: 10px; /* Add padding */ +} + +#eventLog tr { + /* Add a bottom border to all table rows */ + border-bottom: 1px solid #ddd; +} + +#eventLog tr.header, #eventLog tr:hover { + /* Add a grey background color to the table header and on hover */ + background-color: #f1f1f1; +}