mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-03-21 11:35:52 +00:00
[#905] 404 Error Code While Uploading Platform Certificates (#907)
Some checks failed
Dotnet Provisioner Unit Tests / Restore and Run Unit Tests (ubuntu-20.04) (push) Has been cancelled
Dotnet Provisioner Unit Tests / Restore and Run Unit Tests (windows-2022) (push) Has been cancelled
HIRS Build and Unit Test / ACA_Provisioner_Unit_Tests (push) Has been cancelled
HIRS System Tests / DockerTests (push) Has been cancelled
Dotnet Provisioner Unit Tests / Evaluate Tests (push) Has been cancelled
Some checks failed
Dotnet Provisioner Unit Tests / Restore and Run Unit Tests (ubuntu-20.04) (push) Has been cancelled
Dotnet Provisioner Unit Tests / Restore and Run Unit Tests (windows-2022) (push) Has been cancelled
HIRS Build and Unit Test / ACA_Provisioner_Unit_Tests (push) Has been cancelled
HIRS System Tests / DockerTests (push) Has been cancelled
Dotnet Provisioner Unit Tests / Evaluate Tests (push) Has been cancelled
* v3_issue_905: Finally figured out why we were getting a null pointer exception. Fixed the issue and can now upload plat form certs with unusual components without any hiccups. * v3_issue_905: CI/CD pipeline should be happy now.
This commit is contained in:
parent
60cc011197
commit
2d89f7b20e
@ -155,7 +155,7 @@ ComponentClass {
|
|||||||
* @param component string representation of the component ID
|
* @param component string representation of the component ID
|
||||||
* @return the int representation of the component
|
* @return the int representation of the component
|
||||||
*/
|
*/
|
||||||
private static String verifyComponentValue(final String component) {
|
private String verifyComponentValue(final String component) {
|
||||||
String componentValue = ERROR;
|
String componentValue = ERROR;
|
||||||
|
|
||||||
if (component != null) {
|
if (component != null) {
|
||||||
@ -223,7 +223,7 @@ ComponentClass {
|
|||||||
} else if (componentMask.equals(UNKNOWN)) {
|
} else if (componentMask.equals(UNKNOWN)) {
|
||||||
this.componentStr = UNKNOWN_STRING;
|
this.componentStr = UNKNOWN_STRING;
|
||||||
} else {
|
} else {
|
||||||
getComponent(componentTypes);
|
setComponentString(componentTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -247,12 +247,11 @@ ComponentClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for the component associated with the component JSON Object mapped
|
* Sets the component string value based on the provided JSON object's components.
|
||||||
* in the JSON file.
|
|
||||||
*
|
*
|
||||||
* @param components JSON Object for the categories components
|
* @param components JSON Object components
|
||||||
*/
|
*/
|
||||||
private void getComponent(final JsonObject components) {
|
private void setComponentString(final JsonObject components) {
|
||||||
String typeID;
|
String typeID;
|
||||||
|
|
||||||
if (components != null) {
|
if (components != null) {
|
||||||
@ -264,5 +263,10 @@ ComponentClass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the component string is still null after doing a lookup
|
||||||
|
if (componentStr == null) {
|
||||||
|
componentStr = UNKNOWN_STRING;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import java.net.URISyntaxException;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the ComponentClassTest class.
|
* Tests for the ComponentClassTest class.
|
||||||
@ -28,8 +28,8 @@ public class ComponentClassTest {
|
|||||||
componentIdentifier);
|
componentIdentifier);
|
||||||
String resultCategory = instance.getCategoryStr();
|
String resultCategory = instance.getCategoryStr();
|
||||||
String resultComponent = instance.getComponentStr();
|
String resultComponent = instance.getComponentStr();
|
||||||
assertEquals(resultComponent, "Unknown");
|
assertEquals("Unknown", resultComponent);
|
||||||
assertEquals(resultCategory, "None");
|
assertEquals("None", resultCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,8 +44,8 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategoryStr();
|
String resultCategory = instance.getCategoryStr();
|
||||||
String resultComponent = instance.getComponentStr();
|
String resultComponent = instance.getComponentStr();
|
||||||
assertEquals(resultComponent, "Unknown");
|
assertEquals("Unknown", resultComponent);
|
||||||
assertEquals(resultCategory, "None");
|
assertEquals("None", resultCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,8 +60,8 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategoryStr();
|
String resultCategory = instance.getCategoryStr();
|
||||||
String resultComponent = instance.getComponentStr();
|
String resultComponent = instance.getComponentStr();
|
||||||
assertEquals(resultComponent, "Unknown");
|
assertEquals("Unknown", resultComponent);
|
||||||
assertEquals(resultCategory, "None");
|
assertEquals("None", resultCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,8 +76,8 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategoryStr();
|
String resultCategory = instance.getCategoryStr();
|
||||||
String resultComponent = instance.getComponentStr();
|
String resultComponent = instance.getComponentStr();
|
||||||
assertEquals(resultComponent, "Unknown");
|
assertEquals("Unknown", resultComponent);
|
||||||
assertEquals(resultCategory, "None");
|
assertEquals("None", resultCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,8 +92,8 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategoryStr();
|
String resultCategory = instance.getCategoryStr();
|
||||||
String resultComponent = instance.getComponentStr();
|
String resultComponent = instance.getComponentStr();
|
||||||
assertEquals(resultComponent, "Unknown");
|
assertEquals("Unknown", resultComponent);
|
||||||
assertEquals(resultCategory, "None");
|
assertEquals("None", resultCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,8 +108,8 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategoryStr();
|
String resultCategory = instance.getCategoryStr();
|
||||||
String resultComponent = instance.getComponentStr();
|
String resultComponent = instance.getComponentStr();
|
||||||
assertEquals(resultComponent, "SAS Bridgeboard");
|
assertEquals("SAS Bridgeboard", resultComponent);
|
||||||
assertEquals(resultCategory, "Modules");
|
assertEquals("Modules", resultCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,8 +140,8 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategoryStr();
|
String resultCategory = instance.getCategoryStr();
|
||||||
String resultComponent = instance.getComponentStr();
|
String resultComponent = instance.getComponentStr();
|
||||||
assertEquals(resultComponent, "SAS Bridgeboard");
|
assertEquals("SAS Bridgeboard", resultComponent);
|
||||||
assertEquals(resultCategory, "Modules");
|
assertEquals("Modules", resultCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -236,8 +236,8 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategoryStr();
|
String resultCategory = instance.getCategoryStr();
|
||||||
String resultComponent = instance.getComponentStr();
|
String resultComponent = instance.getComponentStr();
|
||||||
assertEquals(resultComponent, "SAS Bridgeboard");
|
assertEquals("SAS Bridgeboard", resultComponent);
|
||||||
assertEquals(resultCategory, "Modules");
|
assertEquals("Modules", resultCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -252,8 +252,8 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategoryStr();
|
String resultCategory = instance.getCategoryStr();
|
||||||
String resultComponent = instance.getComponentStr();
|
String resultComponent = instance.getComponentStr();
|
||||||
assertEquals(resultComponent, "SAS Bridgeboard");
|
assertEquals("SAS Bridgeboard", resultComponent);
|
||||||
assertEquals(resultCategory, "Modules");
|
assertEquals("Modules", resultCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -268,8 +268,9 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategoryStr();
|
String resultCategory = instance.getCategoryStr();
|
||||||
String resultComponent = instance.getComponentStr();
|
String resultComponent = instance.getComponentStr();
|
||||||
assertNull(resultComponent);
|
assertNotNull(resultComponent);
|
||||||
assertEquals(resultCategory, "Modules");
|
assertEquals("Unknown", resultComponent);
|
||||||
|
assertEquals("Modules", resultCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -284,8 +285,9 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategoryStr();
|
String resultCategory = instance.getCategoryStr();
|
||||||
String resultComponent = instance.getComponentStr();
|
String resultComponent = instance.getComponentStr();
|
||||||
assertNull(resultComponent);
|
assertNotNull(resultComponent);
|
||||||
assertEquals(resultCategory, "Modules");
|
assertEquals("Unknown", resultComponent);
|
||||||
|
assertEquals("Modules", resultCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -300,7 +302,7 @@ public class ComponentClassTest {
|
|||||||
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
.getResource(JSON_FILE).toURI()), componentIdentifier);
|
||||||
String resultCategory = instance.getCategoryStr();
|
String resultCategory = instance.getCategoryStr();
|
||||||
String resultComponent = instance.getComponentStr();
|
String resultComponent = instance.getComponentStr();
|
||||||
assertEquals(resultComponent, "Unknown");
|
assertEquals("Unknown", resultComponent);
|
||||||
assertEquals(resultCategory, "None");
|
assertEquals("None", resultCategory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package hirs.attestationca.portal.page;
|
package hirs.attestationca.portal.page;
|
||||||
|
|
||||||
import hirs.utils.VersionHelper;
|
import hirs.utils.VersionHelper;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains attributes required to display a portal page and its menu link.
|
* Contains attributes required to display a portal page and its menu link.
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
public enum Page {
|
public enum Page {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,14 +75,25 @@ public enum Page {
|
|||||||
HELP("Help", "ic_live_help");
|
HELP("Help", "ic_live_help");
|
||||||
|
|
||||||
private final String title;
|
private final String title;
|
||||||
|
|
||||||
private final String subtitle;
|
private final String subtitle;
|
||||||
|
|
||||||
private final String icon;
|
private final String icon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boolean representation of whether the page should display the navigation menu.
|
||||||
|
*/
|
||||||
private final boolean hasMenu;
|
private final boolean hasMenu;
|
||||||
|
|
||||||
private final String menuLinkClass;
|
private final String menuLinkClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boolean representation of whether the page should be displayed in the navigation menu.
|
||||||
|
*/
|
||||||
private final boolean inMenu;
|
private final boolean inMenu;
|
||||||
|
|
||||||
private final String prefixPath;
|
private final String prefixPath;
|
||||||
|
|
||||||
private final String viewName;
|
private final String viewName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,80 +163,4 @@ public enum Page {
|
|||||||
final String icon) {
|
final String icon) {
|
||||||
this(title, null, icon, true, true, null, null);
|
this(title, null, icon, true, true, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the title of the page.
|
|
||||||
*
|
|
||||||
* @return the title of the page.
|
|
||||||
*/
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the subtitle of the page.
|
|
||||||
*
|
|
||||||
* @return the subtitle of the page.
|
|
||||||
*/
|
|
||||||
public String getSubtitle() {
|
|
||||||
return subtitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the base filename of the icon for page. E.g. "ic_my_icon", which will be appended
|
|
||||||
* with appropriate size string (_24dp/_48dp) and file extension (.png) when used.
|
|
||||||
*
|
|
||||||
* @return the base filename of the icon for page.
|
|
||||||
*/
|
|
||||||
public String getIcon() {
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the page should be displayed in the navigation menu.
|
|
||||||
*
|
|
||||||
* @return true if the page should be displayed in the navigation menu.
|
|
||||||
*/
|
|
||||||
public boolean getInMenu() {
|
|
||||||
return inMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the css class to add to the menu link to display it appropriately. E.g. "first" if
|
|
||||||
* the link is the first in a group to separate it visually from the previous group.
|
|
||||||
*
|
|
||||||
* @return he class to add to the menu link to display it appropriately.
|
|
||||||
*/
|
|
||||||
public String getMenuLinkClass() {
|
|
||||||
return menuLinkClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the page should display the navigation menu.
|
|
||||||
*
|
|
||||||
* @return true if the page should display the navigation menu.
|
|
||||||
*/
|
|
||||||
public boolean getHasMenu() {
|
|
||||||
return hasMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the page's view name.
|
|
||||||
*
|
|
||||||
* @return the page's view name
|
|
||||||
*/
|
|
||||||
public String getViewName() {
|
|
||||||
return viewName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the page's view name.
|
|
||||||
*
|
|
||||||
* @return the page's view name
|
|
||||||
*/
|
|
||||||
public String getPrefixPath() {
|
|
||||||
return prefixPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,21 +165,15 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
* @return the certificate class type
|
* @return the certificate class type
|
||||||
*/
|
*/
|
||||||
private static Class<? extends Certificate> getCertificateClass(final String certificateType) {
|
private static Class<? extends Certificate> getCertificateClass(final String certificateType) {
|
||||||
switch (certificateType) {
|
return switch (certificateType) {
|
||||||
case PLATFORMCREDENTIAL:
|
case PLATFORMCREDENTIAL -> PlatformCredential.class;
|
||||||
return PlatformCredential.class;
|
case ENDORSEMENTCREDENTIAL -> EndorsementCredential.class;
|
||||||
case ENDORSEMENTCREDENTIAL:
|
case ISSUEDCERTIFICATES -> IssuedAttestationCertificate.class;
|
||||||
return EndorsementCredential.class;
|
case IDEVIDCERTIFICATE -> IDevIDCertificate.class;
|
||||||
case ISSUEDCERTIFICATES:
|
case TRUSTCHAIN -> CertificateAuthorityCredential.class;
|
||||||
return IssuedAttestationCertificate.class;
|
default -> throw new IllegalArgumentException(
|
||||||
case IDEVIDCERTIFICATE:
|
String.format("Unknown certificate type: %s", certificateType));
|
||||||
return IDevIDCertificate.class;
|
};
|
||||||
case TRUSTCHAIN:
|
|
||||||
return CertificateAuthorityCredential.class;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
String.format("Unknown certificate type: %s", certificateType));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -288,107 +282,115 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
// special parsing for platform credential
|
// special parsing for platform credential
|
||||||
// Add the EndorsementCredential for each PlatformCredential based on the
|
// Add the EndorsementCredential for each PlatformCredential based on the
|
||||||
// serial number. (pc.HolderSerialNumber = ec.SerialNumber)
|
// serial number. (pc.HolderSerialNumber = ec.SerialNumber)
|
||||||
if (certificateType.equals(PLATFORMCREDENTIAL)) {
|
switch (certificateType) {
|
||||||
FilteredRecordsList<PlatformCredential> records = new FilteredRecordsList<>();
|
case PLATFORMCREDENTIAL -> {
|
||||||
org.springframework.data.domain.Page<PlatformCredential> pagedResult =
|
FilteredRecordsList<PlatformCredential> records = new FilteredRecordsList<>();
|
||||||
this.platformCertificateRepository.findByArchiveFlag(false, paging);
|
org.springframework.data.domain.Page<PlatformCredential> pagedResult =
|
||||||
|
this.platformCertificateRepository.findByArchiveFlag(false, paging);
|
||||||
|
|
||||||
if (pagedResult.hasContent()) {
|
if (pagedResult.hasContent()) {
|
||||||
records.addAll(pagedResult.getContent());
|
records.addAll(pagedResult.getContent());
|
||||||
records.setRecordsTotal(pagedResult.getContent().size());
|
records.setRecordsTotal(pagedResult.getContent().size());
|
||||||
} else {
|
} else {
|
||||||
records.setRecordsTotal(input.getLength());
|
records.setRecordsTotal(input.getLength());
|
||||||
}
|
|
||||||
|
|
||||||
records.setRecordsFiltered(platformCertificateRepository.findByArchiveFlag(false).size());
|
|
||||||
EndorsementCredential associatedEC;
|
|
||||||
|
|
||||||
if (!records.isEmpty()) {
|
|
||||||
// loop all the platform certificates
|
|
||||||
for (int i = 0; i < records.size(); i++) {
|
|
||||||
PlatformCredential pc = records.get(i);
|
|
||||||
// find the EC using the PC's "holder serial number"
|
|
||||||
associatedEC = this.endorsementCredentialRepository
|
|
||||||
.findBySerialNumber(pc.getHolderSerialNumber());
|
|
||||||
|
|
||||||
if (associatedEC != null) {
|
|
||||||
log.debug("EC ID for holder s/n " + pc
|
|
||||||
.getHolderSerialNumber() + " = " + associatedEC.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
pc.setEndorsementCredential(associatedEC);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
records.setRecordsFiltered(platformCertificateRepository.findByArchiveFlag(false).size());
|
||||||
|
EndorsementCredential associatedEC;
|
||||||
|
|
||||||
|
if (!records.isEmpty()) {
|
||||||
|
// loop all the platform certificates
|
||||||
|
for (PlatformCredential pc : records) {
|
||||||
|
// find the EC using the PC's "holder serial number"
|
||||||
|
associatedEC = this.endorsementCredentialRepository
|
||||||
|
.findBySerialNumber(pc.getHolderSerialNumber());
|
||||||
|
|
||||||
|
if (associatedEC != null) {
|
||||||
|
log.debug("EC ID for holder s/n {} = {}", pc
|
||||||
|
.getHolderSerialNumber(), associatedEC.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
pc.setEndorsementCredential(associatedEC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.debug("Returning the size of the list of platform credentials: {}", records.size());
|
||||||
|
return new DataTableResponse<>(records, input);
|
||||||
}
|
}
|
||||||
|
case ENDORSEMENTCREDENTIAL -> {
|
||||||
|
FilteredRecordsList<EndorsementCredential> records = new FilteredRecordsList<>();
|
||||||
|
org.springframework.data.domain.Page<EndorsementCredential> pagedResult =
|
||||||
|
this.endorsementCredentialRepository.findByArchiveFlag(false, paging);
|
||||||
|
|
||||||
log.debug("Returning list of size: " + records.size());
|
if (pagedResult.hasContent()) {
|
||||||
return new DataTableResponse<>(records, input);
|
records.addAll(pagedResult.getContent());
|
||||||
} else if (certificateType.equals(ENDORSEMENTCREDENTIAL)) {
|
records.setRecordsTotal(pagedResult.getContent().size());
|
||||||
FilteredRecordsList<EndorsementCredential> records = new FilteredRecordsList<>();
|
} else {
|
||||||
org.springframework.data.domain.Page<EndorsementCredential> pagedResult =
|
records.setRecordsTotal(input.getLength());
|
||||||
this.endorsementCredentialRepository.findByArchiveFlag(false, paging);
|
}
|
||||||
|
|
||||||
if (pagedResult.hasContent()) {
|
records.setRecordsFiltered(endorsementCredentialRepository.findByArchiveFlag(false).size());
|
||||||
records.addAll(pagedResult.getContent());
|
|
||||||
records.setRecordsTotal(pagedResult.getContent().size());
|
log.debug("Returning the size of the list of endorsement credentials: {}", records.size());
|
||||||
} else {
|
return new DataTableResponse<>(records, input);
|
||||||
records.setRecordsTotal(input.getLength());
|
|
||||||
}
|
}
|
||||||
|
case TRUSTCHAIN -> {
|
||||||
|
FilteredRecordsList<CertificateAuthorityCredential> records = new FilteredRecordsList<>();
|
||||||
|
org.springframework.data.domain.Page<CertificateAuthorityCredential> pagedResult =
|
||||||
|
this.caCredentialRepository.findByArchiveFlag(false, paging);
|
||||||
|
|
||||||
records.setRecordsFiltered(endorsementCredentialRepository.findByArchiveFlag(false).size());
|
if (pagedResult.hasContent()) {
|
||||||
|
records.addAll(pagedResult.getContent());
|
||||||
|
records.setRecordsTotal(pagedResult.getContent().size());
|
||||||
|
} else {
|
||||||
|
records.setRecordsTotal(input.getLength());
|
||||||
|
}
|
||||||
|
|
||||||
log.debug("Returning list of size: " + records.size());
|
records.setRecordsFiltered(caCredentialRepository.findByArchiveFlag(false).size());
|
||||||
return new DataTableResponse<>(records, input);
|
|
||||||
} else if (certificateType.equals(TRUSTCHAIN)) {
|
|
||||||
FilteredRecordsList<CertificateAuthorityCredential> records = new FilteredRecordsList<>();
|
|
||||||
org.springframework.data.domain.Page<CertificateAuthorityCredential> pagedResult =
|
|
||||||
this.caCredentialRepository.findByArchiveFlag(false, paging);
|
|
||||||
|
|
||||||
if (pagedResult.hasContent()) {
|
log.debug("Returning the size of the list of certificate trust chains: {}", records.size());
|
||||||
records.addAll(pagedResult.getContent());
|
return new DataTableResponse<>(records, input);
|
||||||
records.setRecordsTotal(pagedResult.getContent().size());
|
|
||||||
} else {
|
|
||||||
records.setRecordsTotal(input.getLength());
|
|
||||||
}
|
}
|
||||||
|
case ISSUEDCERTIFICATES -> {
|
||||||
|
FilteredRecordsList<IssuedAttestationCertificate> records = new FilteredRecordsList<>();
|
||||||
|
org.springframework.data.domain.Page<IssuedAttestationCertificate> pagedResult =
|
||||||
|
this.issuedCertificateRepository.findByArchiveFlag(false, paging);
|
||||||
|
|
||||||
records.setRecordsFiltered(caCredentialRepository.findByArchiveFlag(false).size());
|
if (pagedResult.hasContent()) {
|
||||||
|
records.addAll(pagedResult.getContent());
|
||||||
|
records.setRecordsTotal(pagedResult.getContent().size());
|
||||||
|
} else {
|
||||||
|
records.setRecordsTotal(input.getLength());
|
||||||
|
}
|
||||||
|
|
||||||
log.debug("Returning list of size: " + records.size());
|
records.setRecordsFiltered(issuedCertificateRepository.findByArchiveFlag(false).size());
|
||||||
return new DataTableResponse<>(records, input);
|
|
||||||
} else if (certificateType.equals(ISSUEDCERTIFICATES)) {
|
|
||||||
FilteredRecordsList<IssuedAttestationCertificate> records = new FilteredRecordsList<>();
|
|
||||||
org.springframework.data.domain.Page<IssuedAttestationCertificate> pagedResult =
|
|
||||||
this.issuedCertificateRepository.findByArchiveFlag(false, paging);
|
|
||||||
|
|
||||||
if (pagedResult.hasContent()) {
|
log.debug("Returning the size of the list of issued certificates: {}", records.size());
|
||||||
records.addAll(pagedResult.getContent());
|
return new DataTableResponse<>(records, input);
|
||||||
records.setRecordsTotal(pagedResult.getContent().size());
|
|
||||||
} else {
|
|
||||||
records.setRecordsTotal(input.getLength());
|
|
||||||
}
|
}
|
||||||
|
case IDEVIDCERTIFICATE -> {
|
||||||
|
FilteredRecordsList<IDevIDCertificate> records = new FilteredRecordsList<IDevIDCertificate>();
|
||||||
|
org.springframework.data.domain.Page<IDevIDCertificate> pagedResult =
|
||||||
|
this.iDevIDCertificateRepository.findByArchiveFlag(false, paging);
|
||||||
|
|
||||||
records.setRecordsFiltered(issuedCertificateRepository.findByArchiveFlag(false).size());
|
if (pagedResult.hasContent()) {
|
||||||
|
records.addAll(pagedResult.getContent());
|
||||||
|
records.setRecordsTotal(pagedResult.getContent().size());
|
||||||
|
} else {
|
||||||
|
records.setRecordsTotal(input.getLength());
|
||||||
|
}
|
||||||
|
|
||||||
log.debug("Returning list of size: " + records.size());
|
records.setRecordsFiltered(iDevIDCertificateRepository.findByArchiveFlag(false).size());
|
||||||
return new DataTableResponse<>(records, input);
|
|
||||||
} else if (certificateType.equals(IDEVIDCERTIFICATE)) {
|
|
||||||
FilteredRecordsList<IDevIDCertificate> records = new FilteredRecordsList<IDevIDCertificate>();
|
|
||||||
org.springframework.data.domain.Page<IDevIDCertificate> pagedResult =
|
|
||||||
this.iDevIDCertificateRepository.findByArchiveFlag(false, paging);
|
|
||||||
|
|
||||||
if (pagedResult.hasContent()) {
|
log.debug("Returning the size of the list of IDEVID certificates: {}", records.size());
|
||||||
records.addAll(pagedResult.getContent());
|
return new DataTableResponse<>(records, input);
|
||||||
records.setRecordsTotal(pagedResult.getContent().size());
|
}
|
||||||
} else {
|
default -> {
|
||||||
records.setRecordsTotal(input.getLength());
|
log.error("Cannot provide the size of the records because the"
|
||||||
|
+ "provided certificate type does not exist.");
|
||||||
|
return new DataTableResponse<>(new FilteredRecordsList<>(), input);
|
||||||
}
|
}
|
||||||
|
|
||||||
records.setRecordsFiltered(iDevIDCertificateRepository.findByArchiveFlag(false).size());
|
|
||||||
|
|
||||||
log.debug("Returning list of size: " + records.size());
|
|
||||||
return new DataTableResponse<>(records, input);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DataTableResponse<>(new FilteredRecordsList<>(), input);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -443,7 +445,7 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
@PathVariable("certificateType") final String certificateType,
|
@PathVariable("certificateType") final String certificateType,
|
||||||
@RequestParam final String id,
|
@RequestParam final String id,
|
||||||
final RedirectAttributes attr) throws URISyntaxException {
|
final RedirectAttributes attr) throws URISyntaxException {
|
||||||
log.info("Handling request to delete " + id);
|
log.info("Handling request to delete {}", id);
|
||||||
|
|
||||||
Map<String, Object> model = new HashMap<>();
|
Map<String, Object> model = new HashMap<>();
|
||||||
PageMessages messages = new PageMessages();
|
PageMessages messages = new PageMessages();
|
||||||
@ -506,7 +508,7 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
* @param id the UUID of the cert to download
|
* @param id the UUID of the cert to download
|
||||||
* @param response the response object (needed to update the header with the
|
* @param response the response object (needed to update the header with the
|
||||||
* file name)
|
* file name)
|
||||||
* @throws java.io.IOException when writing to response output stream
|
* @throws IOException when writing to response output stream
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/{certificateType}/download", method = RequestMethod.GET)
|
@RequestMapping(value = "/{certificateType}/download", method = RequestMethod.GET)
|
||||||
public void download(
|
public void download(
|
||||||
@ -514,7 +516,7 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
@RequestParam final String id,
|
@RequestParam final String id,
|
||||||
final HttpServletResponse response)
|
final HttpServletResponse response)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
log.info("Handling request to download " + id);
|
log.info("Handling request to download {}", id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
UUID uuid = UUID.fromString(id);
|
UUID uuid = UUID.fromString(id);
|
||||||
@ -552,7 +554,7 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
*
|
*
|
||||||
* @param response the response object (needed to update the header with the
|
* @param response the response object (needed to update the header with the
|
||||||
* file name)
|
* file name)
|
||||||
* @throws java.io.IOException when writing to response output stream
|
* @throws IOException when writing to response output stream
|
||||||
*/
|
*/
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping(value = "/trust-chain/download-aca-cert", method = RequestMethod.GET)
|
@RequestMapping(value = "/trust-chain/download-aca-cert", method = RequestMethod.GET)
|
||||||
@ -573,7 +575,7 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
*
|
*
|
||||||
* @param response the response object (needed to update the header with the
|
* @param response the response object (needed to update the header with the
|
||||||
* file name)
|
* file name)
|
||||||
* @throws java.io.IOException when writing to response output stream
|
* @throws IOException when writing to response output stream
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/trust-chain/bulk", method = RequestMethod.GET)
|
@RequestMapping(value = "/trust-chain/bulk", method = RequestMethod.GET)
|
||||||
public void caBulkDownload(final HttpServletResponse response)
|
public void caBulkDownload(final HttpServletResponse response)
|
||||||
@ -605,7 +607,7 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
*
|
*
|
||||||
* @param response the response object (needed to update the header with the
|
* @param response the response object (needed to update the header with the
|
||||||
* file name)
|
* file name)
|
||||||
* @throws java.io.IOException when writing to response output stream
|
* @throws IOException when writing to response output stream
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/platform-credentials/bulk", method = RequestMethod.GET)
|
@RequestMapping(value = "/platform-credentials/bulk", method = RequestMethod.GET)
|
||||||
public void pcBulkDownload(final HttpServletResponse response)
|
public void pcBulkDownload(final HttpServletResponse response)
|
||||||
@ -637,7 +639,7 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
*
|
*
|
||||||
* @param response the response object (needed to update the header with the
|
* @param response the response object (needed to update the header with the
|
||||||
* file name)
|
* file name)
|
||||||
* @throws java.io.IOException when writing to response output stream
|
* @throws IOException when writing to response output stream
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/issued-certificates/bulk", method = RequestMethod.GET)
|
@RequestMapping(value = "/issued-certificates/bulk", method = RequestMethod.GET)
|
||||||
public void icBulkDownload(final HttpServletResponse response)
|
public void icBulkDownload(final HttpServletResponse response)
|
||||||
@ -670,7 +672,7 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
*
|
*
|
||||||
* @param response the response object (needed to update the header with the
|
* @param response the response object (needed to update the header with the
|
||||||
* file name)
|
* file name)
|
||||||
* @throws java.io.IOException when writing to response output stream
|
* @throws IOException when writing to response output stream
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/endorsement-key-credentials/bulk", method = RequestMethod.GET)
|
@RequestMapping(value = "/endorsement-key-credentials/bulk", method = RequestMethod.GET)
|
||||||
public void ekBulkDownload(final HttpServletResponse response)
|
public void ekBulkDownload(final HttpServletResponse response)
|
||||||
@ -696,6 +698,15 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method that packages a collection of certificates into a zip file.
|
||||||
|
*
|
||||||
|
* @param zipOut zip outputs stream
|
||||||
|
* @param certificates collection of certificates
|
||||||
|
* @param singleFileName zip file name
|
||||||
|
* @return zip outputs stream
|
||||||
|
* @throws IOException if there are any issues packaging or downloading the zip file
|
||||||
|
*/
|
||||||
private ZipOutputStream bulkDownload(final ZipOutputStream zipOut,
|
private ZipOutputStream bulkDownload(final ZipOutputStream zipOut,
|
||||||
final List<Certificate> certificates,
|
final List<Certificate> certificates,
|
||||||
final String singleFileName) throws IOException {
|
final String singleFileName) throws IOException {
|
||||||
@ -727,9 +738,8 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
* table, false otherwise.
|
* table, false otherwise.
|
||||||
*/
|
*/
|
||||||
private boolean hasDeviceTableToJoin(final String certificateType) {
|
private boolean hasDeviceTableToJoin(final String certificateType) {
|
||||||
boolean hasDevice = !certificateType.equals(TRUSTCHAIN);
|
|
||||||
// Trust_Chain Credential do not contain the device table to join.
|
// Trust_Chain Credential do not contain the device table to join.
|
||||||
return hasDevice;
|
return !certificateType.equals(TRUSTCHAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -744,26 +754,21 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
final String certificateType,
|
final String certificateType,
|
||||||
final int certificateHash) {
|
final int certificateHash) {
|
||||||
|
|
||||||
switch (certificateType) {
|
return switch (certificateType) {
|
||||||
case PLATFORMCREDENTIAL:
|
case PLATFORMCREDENTIAL -> this.certificateRepository
|
||||||
return this.certificateRepository
|
.findByCertificateHash(certificateHash,
|
||||||
.findByCertificateHash(certificateHash,
|
"PlatformCredential");
|
||||||
"PlatformCredential");
|
case ENDORSEMENTCREDENTIAL -> this.certificateRepository
|
||||||
case ENDORSEMENTCREDENTIAL:
|
.findByCertificateHash(certificateHash,
|
||||||
return this.certificateRepository
|
"EndorsementCredential");
|
||||||
.findByCertificateHash(certificateHash,
|
case TRUSTCHAIN -> this.certificateRepository
|
||||||
"EndorsementCredential");
|
.findByCertificateHash(certificateHash,
|
||||||
case TRUSTCHAIN:
|
"CertificateAuthorityCredential");
|
||||||
return this.certificateRepository
|
case IDEVIDCERTIFICATE -> this.certificateRepository
|
||||||
.findByCertificateHash(certificateHash,
|
.findByCertificateHash(certificateHash,
|
||||||
"CertificateAuthorityCredential");
|
"IDevIDCertificate");
|
||||||
case IDEVIDCERTIFICATE:
|
default -> null;
|
||||||
return this.certificateRepository
|
};
|
||||||
.findByCertificateHash(certificateHash,
|
|
||||||
"IDevIDCertificate");
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -779,11 +784,9 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
List<PlatformCredential> associatedCertificates = new LinkedList<>();
|
List<PlatformCredential> associatedCertificates = new LinkedList<>();
|
||||||
|
|
||||||
if (serialNumber != null) {
|
if (serialNumber != null) {
|
||||||
switch (certificateType) {
|
if (certificateType.equals(PLATFORMCREDENTIAL)) {
|
||||||
case PLATFORMCREDENTIAL:
|
associatedCertificates.addAll(this.certificateRepository
|
||||||
associatedCertificates.addAll(this.certificateRepository
|
.byBoardSerialNumber(serialNumber));
|
||||||
.byBoardSerialNumber(serialNumber));
|
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1010,6 +1013,12 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
log.error(failMessage);
|
log.error(failMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method that utilizes the components of the provided platform certificate to generate
|
||||||
|
* a collection of component results and subsequently stores these results in the database.
|
||||||
|
*
|
||||||
|
* @param certificate certificate
|
||||||
|
*/
|
||||||
private void handlePlatformComponents(final Certificate certificate) {
|
private void handlePlatformComponents(final Certificate certificate) {
|
||||||
PlatformCredential platformCredential;
|
PlatformCredential platformCredential;
|
||||||
|
|
||||||
@ -1021,8 +1030,10 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
platformCredential.getPlatformSerial());
|
platformCredential.getPlatformSerial());
|
||||||
if (componentResults.isEmpty()) {
|
if (componentResults.isEmpty()) {
|
||||||
ComponentResult componentResult;
|
ComponentResult componentResult;
|
||||||
for (ComponentIdentifier componentIdentifier : platformCredential
|
|
||||||
.getComponentIdentifiers()) {
|
List<ComponentIdentifier> componentIdentifiers = platformCredential.getComponentIdentifiers();
|
||||||
|
|
||||||
|
for (ComponentIdentifier componentIdentifier : componentIdentifiers) {
|
||||||
componentResult = new ComponentResult(platformCredential.getPlatformSerial(),
|
componentResult = new ComponentResult(platformCredential.getPlatformSerial(),
|
||||||
platformCredential.getSerialNumber().toString(),
|
platformCredential.getSerialNumber().toString(),
|
||||||
platformCredential.getPlatformChainType(),
|
platformCredential.getPlatformChainType(),
|
||||||
@ -1041,6 +1052,11 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method that deletes component results based on the provided platform serial number.
|
||||||
|
*
|
||||||
|
* @param platformSerial platform serial number
|
||||||
|
*/
|
||||||
private void deleteComponentResults(final String platformSerial) {
|
private void deleteComponentResults(final String platformSerial) {
|
||||||
List<ComponentResult> componentResults = componentResultRepository
|
List<ComponentResult> componentResults = componentResultRepository
|
||||||
.findByBoardSerialNumber(platformSerial);
|
.findByBoardSerialNumber(platformSerial);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user