diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java index 87632ce1..d1fae962 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java @@ -17,7 +17,6 @@ public interface ReferenceDigestValueRepository extends JpaRepository findByManufacturer(String manufacturer); @Query(value = "SELECT * FROM ReferenceDigestValue WHERE baseRimId = '?1' OR supportRimId = '?1'", nativeQuery = true) List getValuesByRimId(UUID associatedRimId); - @Query(value = "SELECT * FROM ReferenceDigestValue WHERE supportRimId = '?1'", nativeQuery = true) List findBySupportRimId(UUID supportRimId); List findBySupportRimHash(String supportRimHash); } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/DeviceAssociatedCertificate.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/DeviceAssociatedCertificate.java index 924c4abc..e0f54321 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/DeviceAssociatedCertificate.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/DeviceAssociatedCertificate.java @@ -28,6 +28,10 @@ public abstract class DeviceAssociatedCertificate extends Certificate { @JdbcTypeCode(java.sql.Types.VARCHAR) @Column private UUID deviceId; + @Getter + @Setter + @Column + private String deviceName; /** * Holds the name of the entity 'DEVICE_ID' field. diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java index 94a01748..674d6c7f 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java @@ -31,6 +31,9 @@ import lombok.extern.log4j.Log4j2; import org.bouncycastle.util.encoders.DecoderException; import org.hibernate.Session; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -58,9 +61,6 @@ import java.util.UUID; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -//import java.security.cert.CertificateEncodingException; -//import java.security.cert.X509Certificate; - // note uploading base64 certs, old or new having decode issues check ACA channel /** @@ -220,19 +220,24 @@ public class CertificatePageController extends PageController { } }; + int currentPage = input.getStart() / input.getLength(); + Pageable paging = PageRequest.of(currentPage, input.getLength(), Sort.by(orderColumnName)); - /** - * Ok I think what I will do is make repositories for each certificate type to I can - * tell it what the type T is. - */ - FilteredRecordsList records = new FilteredRecordsList<>(); // special parsing for platform credential // Add the EndorsementCredential for each PlatformCredential based on the // serial number. (pc.HolderSerialNumber = ec.SerialNumber) if (certificateType.equals(PLATFORMCREDENTIAL)) { - records = OrderedListQueryDataTableAdapter.getOrderedList( - getCertificateClass(certificateType), platformCertificateRepository, - input, orderColumnName, criteriaModifier); +// records = OrderedListQueryDataTableAdapter.getOrderedList( +// getCertificateClass(certificateType), platformCertificateRepository, +// input, orderColumnName, criteriaModifier); + FilteredRecordsList records = new FilteredRecordsList<>(); + + org.springframework.data.domain.Page pagedResult = this.platformCertificateRepository.findAll(paging); + if (pagedResult.hasContent()) { + records.addAll(pagedResult.getContent()); + } + records.setRecordsTotal(input.getLength()); + records.setRecordsFiltered(platformCertificateRepository.count()); EndorsementCredential associatedEC; if (!records.isEmpty()) { @@ -251,18 +256,53 @@ public class CertificatePageController extends PageController { pc.setEndorsementCredential(associatedEC); } } + + log.debug("Returning list of size: " + records.size()); + return new DataTableResponse<>(records, input); } else if (certificateType.equals(ENDORSEMENTCREDENTIAL)) { - records = OrderedListQueryDataTableAdapter.getOrderedList( - getCertificateClass(certificateType), endorsementCredentialRepository, - input, orderColumnName, criteriaModifier); +// records = OrderedListQueryDataTableAdapter.getOrderedList( +// getCertificateClass(certificateType), endorsementCredentialRepository, +// input, orderColumnName, criteriaModifier); + FilteredRecordsList records = new FilteredRecordsList<>(); + org.springframework.data.domain.Page pagedResult = this.endorsementCredentialRepository.findAll(paging); + if (pagedResult.hasContent()) { + records.addAll(pagedResult.getContent()); + } + + records.setRecordsTotal(input.getLength()); + records.setRecordsFiltered(endorsementCredentialRepository.count()); + + log.debug("Returning list of size: " + records.size()); + return new DataTableResponse<>(records, input); } else if (certificateType.equals(TRUSTCHAIN)) { - records = OrderedListQueryDataTableAdapter.getOrderedList( - getCertificateClass(certificateType), caCredentialRepository, - input, orderColumnName, criteriaModifier); +// records = OrderedListQueryDataTableAdapter.getOrderedList( +// getCertificateClass(certificateType), caCredentialRepository, +// input, orderColumnName, criteriaModifier); + FilteredRecordsList records = new FilteredRecordsList<>(); + org.springframework.data.domain.Page pagedResult = this.caCredentialRepository.findAll(paging); + + if (pagedResult.hasContent()) { + records.addAll(pagedResult.getContent()); + } + records.setRecordsTotal(input.getLength()); + records.setRecordsFiltered(caCredentialRepository.count()); + + log.debug("Returning list of size: " + records.size()); + return new DataTableResponse<>(records, input); + } else if (certificateType.equals(ISSUEDCERTIFICATES)) { + FilteredRecordsList records = new FilteredRecordsList<>(); + org.springframework.data.domain.Page pagedResult = this.issuedCertificateRepository.findAll(paging); + if (pagedResult.hasContent()) { + records.addAll(pagedResult.getContent()); + } + records.setRecordsTotal(input.getLength()); + records.setRecordsFiltered(issuedCertificateRepository.count()); + + log.debug("Returning list of size: " + records.size()); + return new DataTableResponse<>(records, input); } - log.debug("Returning list of size: " + records.size()); - return new DataTableResponse<>(records, input); + return new DataTableResponse(new FilteredRecordsList<>(), input); } /** diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java index 3df1e90b..b596e788 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java @@ -20,6 +20,9 @@ import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.params.NoPageParams; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -80,16 +83,26 @@ public class DevicePageController extends PageController { log.info("Ordering on column: " + orderColumnName); // get all the devices - FilteredRecordsList deviceList = - OrderedListQueryDataTableAdapter.getOrderedList( - Device.class, - deviceRepository, - input, orderColumnName); + FilteredRecordsList deviceList = new FilteredRecordsList<>(); +// OrderedListQueryDataTableAdapter.getOrderedList( +// Device.class, +// deviceRepository, +// input, orderColumnName); - FilteredRecordsList> record + int currentPage = input.getStart() / input.getLength(); + Pageable paging = PageRequest.of(currentPage, input.getLength(), Sort.by(orderColumnName)); + org.springframework.data.domain.Page pagedResult = deviceRepository.findAll(paging); + + if (pagedResult.hasContent()) { + deviceList.addAll(pagedResult.getContent()); + } + deviceList.setRecordsTotal(input.getLength()); + deviceList.setRecordsFiltered(deviceRepository.count()); + + FilteredRecordsList> records = retrieveDevicesAndAssociatedCertificates(deviceList); - return new DataTableResponse<>(record, input); + return new DataTableResponse<>(records, input); } /** 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 37bf6ac3..a2ee5373 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 @@ -312,7 +312,7 @@ public class ReferenceManifestDetailsPageController extends PageController records - = OrderedListQueryDataTableAdapter.getOrderedList( - ReferenceManifest.class, - this.referenceManifestRepository, - input, orderColumnName, criteriaModifier); + + log.info("Querying with the following dataTableInput: " + input.toString()); + + FilteredRecordsList records = new FilteredRecordsList<>(); + int currentPage = input.getStart() / input.getLength(); + Pageable paging = PageRequest.of(currentPage, input.getLength(), Sort.by(orderColumnName)); + org.springframework.data.domain.Page pagedResult = referenceManifestRepository.findAll(paging); + + if (pagedResult.hasContent()) { + records.addAll(pagedResult.getContent()); + } + records.setRecordsTotal(input.getLength()); + records.setRecordsFiltered(referenceManifestRepository.count()); +// FilteredRecordsList records +// = OrderedListQueryDataTableAdapter.getOrderedList( +// ReferenceManifest.class, +// this.referenceManifestRepository, +// input, orderColumnName, criteriaModifier); log.debug("Returning list of size: " + records.size()); return new DataTableResponse<>(records, input); diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java index b27f7b05..b7aef697 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java @@ -106,17 +106,19 @@ public class RimDatabasePageController extends PageController { } }; - log.info("Querying with the following datatableinput: " + input.toString()); - FilteredRecordsList referenceDigestValues = new FilteredRecordsList<>(); - Pageable paging = PageRequest.of(input.getStart(), input.getLength(), Sort.by(orderColumnName)); + log.info("Querying with the following dataTableInput: " + input.toString()); + FilteredRecordsList referenceDigestValues = new FilteredRecordsList<>(); + + int currentPage = input.getStart() / input.getLength(); + Pageable paging = PageRequest.of(currentPage, input.getLength(), Sort.by(orderColumnName)); org.springframework.data.domain.Page pagedResult = referenceDigestValueRepository.findAll(paging); if (pagedResult.hasContent()) { referenceDigestValues.addAll(pagedResult.getContent()); } - referenceDigestValues.setRecordsTotal(referenceDigestValueRepository.count()); - referenceDigestValues.setRecordsFiltered(input.getLength()); + referenceDigestValues.setRecordsTotal(input.getLength()); + referenceDigestValues.setRecordsFiltered(referenceDigestValueRepository.count()); // FilteredRecordsList referenceDigestValues = // OrderedListQueryDataTableAdapter.getOrderedList( @@ -140,6 +142,7 @@ public class RimDatabasePageController extends PageController { } } + log.debug("Returning list of size: " + referenceDigestValues.size()); return new DataTableResponse<>(referenceDigestValues, input); } } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java index 24d4b788..9106180f 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java @@ -29,6 +29,9 @@ import jakarta.servlet.http.HttpServletResponse; import lombok.extern.log4j.Log4j2; import org.hibernate.Session; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -121,23 +124,13 @@ public class ValidationReportsPageController extends PageController records = - OrderedListQueryDataTableAdapter.getOrderedList( - SupplyChainValidationSummary.class, - supplyChainValidatorSummaryRepository, input, orderColumnName, - criteriaModifier); + FilteredRecordsList records = new FilteredRecordsList<>(); + int currentPage = input.getStart() / input.getLength(); + Pageable paging = PageRequest.of(currentPage, input.getLength(), Sort.by(orderColumnName)); + org.springframework.data.domain.Page pagedResult = supplyChainValidatorSummaryRepository.findAll(paging); + + if (pagedResult.hasContent()) { + records.addAll(pagedResult.getContent()); + } + records.setRecordsTotal(input.getLength()); + records.setRecordsFiltered(supplyChainValidatorSummaryRepository.count()); + +// FilteredRecordsList records = +// OrderedListQueryDataTableAdapter.getOrderedList( +// SupplyChainValidationSummary.class, +// supplyChainValidatorSummaryRepository, input, orderColumnName, +// criteriaModifier); return new DataTableResponse<>(records, input); } diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/endorsement-key-credentials.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/endorsement-key-credentials.jsp index 5e40dce6..75706028 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/endorsement-key-credentials.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/endorsement-key-credentials.jsp @@ -49,14 +49,14 @@ var url = pagePath +'/list'; var columns = [ { - data: 'device.name', + data: 'deviceName', render: function (data, type, full, meta) { // if there's a device, display its name, otherwise // display nothing if (full.device) { // TODO render a link to a device details page, // passing the device.id - return full.device.name; + return full.deviceName; } return ''; } diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/issued-certificates.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/issued-certificates.jsp index bd8052e2..0ed637bb 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/issued-certificates.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/issued-certificates.jsp @@ -44,14 +44,14 @@ var url = pagePath + '/list'; var columns = [ { - data: 'device.name', + data: 'deviceName', render: function (data, type, full, meta) { // if there's a device, display its name, otherwise // display nothing if (full.device) { // TODO render a link to a device details page, // passing the device.id - return full.device.name; + return full.deviceName; } return ''; } diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/platform-credentials.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/platform-credentials.jsp index 59e11c61..defb07e1 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/platform-credentials.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/platform-credentials.jsp @@ -54,14 +54,14 @@ var url = pagePath +'/list'; var columns = [ { - data: 'device.name', + data: 'deviceName', render: function (data, type, full, meta) { // if there's a device, display its name, otherwise // display nothing if (full.device) { // TODO render a link to a device details page, // passing the device.id - return full.device.name; + return full.deviceName; } return ''; } diff --git a/HIRS_Utils/src/main/java/hirs/utils/BouncyCastleUtils.java b/HIRS_Utils/src/main/java/hirs/utils/BouncyCastleUtils.java index d04cd993..3c748284 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/BouncyCastleUtils.java +++ b/HIRS_Utils/src/main/java/hirs/utils/BouncyCastleUtils.java @@ -27,7 +27,7 @@ public final class BouncyCastleUtils { */ public static boolean x500NameCompare(final String nameValue1, final String nameValue2) { if (nameValue1 == null || nameValue2 == null) { - log.error("Provided DN string is null."); + log.warn("Provided DN string is null."); return true; }