issue_847: Took another look over the PR for this issue and found nothing alarming. Made some minor tweaks to four files. Should be good to go for PR

This commit is contained in:
TheSilentCoder 2024-10-30 13:36:04 -04:00
parent 18efb25d41
commit 963086fc0e
4 changed files with 33 additions and 65 deletions

View File

@ -147,7 +147,7 @@ public abstract class ReferenceManifestSelector<T extends ReferenceManifest> {
/**
* Construct the criterion that can be used to query for rims matching the
* + * configuration of this {@link ReferenceManifestSelector}.
* configuration of this {@link ReferenceManifestSelector}.
*
* @param criteriaBuilder criteria builder
* @return a Criterion that can be used to query for rims matching the

View File

@ -3,10 +3,10 @@ package hirs.attestationca.portal.datatables;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
@ -18,10 +18,22 @@ import java.util.Map;
/**
* Represents a data table input in a jQuery DataTable.
*/
@NoArgsConstructor(access = AccessLevel.PUBLIC)
@Getter
@NoArgsConstructor
@ToString
public class DataTableInput {
private static final int DEFAULT_LENGTH = 10;
/**
* Order parameter.
*/
@NotEmpty
private final List<Order> order = new ArrayList<>();
/**
* Per-column search parameter.
*/
@NotEmpty
private final List<Column> columns = new ArrayList<>();
/**
* Draw counter. This is used by DataTables to ensure that the Ajax returns from server-side
* processing requests are drawn in sequence by DataTables (Ajax requests are asynchronous and
@ -30,7 +42,6 @@ public class DataTableInput {
*/
@NotNull
@Min(0)
@Getter
@Setter
private int draw = 1;
/**
@ -39,7 +50,6 @@ public class DataTableInput {
*/
@NotNull
@Min(0)
@Getter
@Setter
private int start = 0;
/**
@ -51,28 +61,14 @@ public class DataTableInput {
*/
@NotNull
@Min(-1)
@Getter
@Setter
private int length = DEFAULT_LENGTH;
/**
* Global search parameter.
*/
@Getter
@Setter
@NotNull
private Search search = new Search();
/**
* Order parameter.
*/
@Getter
@NotEmpty
private List<Order> order = new ArrayList<>();
/**
* Per-column search parameter.
*/
@Getter
@NotEmpty
private List<Column> columns = new ArrayList<>();
/**
* Constructor.
@ -200,23 +196,4 @@ public class DataTableInput {
}
return orderColumnName;
}
/**
* Generates a string for this object.
*
* @return the string
*/
@Override
public String toString() {
return "DataTableInput{"
+ "draw=" + draw
+ ", start=" + start
+ ", length=" + length
+ ", search=" + search
+ ", order=" + order
+ ", columns=" + columns
+ '}';
}
}

View File

@ -141,16 +141,14 @@ public class ReferenceManifestDetailsPageController
* @param certificateRepository the certificate manager.
* @param caCertificateRepository the certificate manager.
* @return mapping of the RIM information from the database.
* @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 java.io.IOException error for reading file bytes.
*/
private static HashMap<String, Object> getBaseRimInfo(
final BaseReferenceManifest baseRim,
final ReferenceManifestRepository referenceManifestRepository,
final CertificateRepository certificateRepository,
final CACredentialRepository caCertificateRepository)
throws IOException, CertificateException, NoSuchAlgorithmException {
throws IOException {
HashMap<String, Object> data = new HashMap<>();
// Software Identity
@ -260,8 +258,8 @@ public class ReferenceManifestDetailsPageController
caCertificateRepository));
RIM_VALIDATOR.setTrustStore(truststore);
} catch (IOException e) {
log.error("Error building CA chain for " + caCert.getSubjectKeyIdentifier() + ": "
+ e.getMessage());
log.error("Error building CA chain for {}: {}", caCert.getSubjectKeyIdentifier(),
e.getMessage());
}
if (RIM_VALIDATOR.validateXmlSignature(caCert.getX509Certificate().getPublicKey(),
caCert.getSubjectKeyIdString(), caCert.getEncodedPublicKey())) {
@ -272,7 +270,7 @@ public class ReferenceManifestDetailsPageController
break;
}
} catch (SupplyChainValidatorException scvEx) {
log.error("Error verifying cert chain: " + scvEx.getMessage());
log.error("Error verifying cert chain: {}", scvEx.getMessage());
}
}
}
@ -288,7 +286,7 @@ public class ReferenceManifestDetailsPageController
}
}
} catch (NullPointerException npEx) {
log.warn("Unable to link signing certificate: " + npEx.getMessage());
log.warn("Unable to link signing certificate: {}", npEx.getMessage());
}
return data;
}
@ -610,12 +608,6 @@ public class ReferenceManifestDetailsPageController
String uuidError = "Failed to parse ID from: " + params.getId();
messages.addError(uuidError);
log.error(uuidError, iaEx);
} catch (CertificateException cEx) {
log.error(cEx);
} catch (NoSuchAlgorithmException nsEx) {
log.error(nsEx);
} catch (IOException ioEx) {
log.error(ioEx);
} catch (Exception ex) {
log.error(ex);
}

View File

@ -28,6 +28,7 @@ import org.springframework.data.domain.Sort;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@ -115,10 +116,10 @@ public class ValidationReportsPageController extends PageController<NoPageParams
public DataTableResponse<SupplyChainValidationSummary> getTableData(
final DataTableInput input) {
log.debug("Handling request for summary list: " + input);
log.debug("Handling request for summary list: {}", input);
// attempt to get the column property based on the order index.
String orderColumnName = input.getOrderColumnName();
log.debug("Ordering on column: " + orderColumnName);
log.debug("Ordering on column: {}", orderColumnName);
FilteredRecordsList<SupplyChainValidationSummary> records = new FilteredRecordsList<>();
int currentPage = input.getStart() / input.getLength();
@ -145,8 +146,7 @@ public class ValidationReportsPageController extends PageController<NoPageParams
* @param response object
* @throws IOException thrown by BufferedWriter object
*/
@SuppressWarnings({"checkstyle:magicnumber", "checkstyle:methodlength"})
@RequestMapping(value = "download", method = RequestMethod.POST)
@PostMapping(value = "download")
public void download(final HttpServletRequest request,
final HttpServletResponse response) throws IOException {
@ -158,7 +158,7 @@ public class ValidationReportsPageController extends PageController<NoPageParams
DateTimeFormatter dateTimeFormat = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss");
LocalDate startDate = null;
LocalDate endDate = null;
ArrayList<LocalDate> createTimes = new ArrayList<LocalDate>();
ArrayList<LocalDate> createTimes = new ArrayList<>();
String[] deviceNames = new String[] {};
String columnHeaders = "";
boolean systemOnly = false;
@ -171,7 +171,7 @@ public class ValidationReportsPageController extends PageController<NoPageParams
while (parameters.hasMoreElements()) {
String parameter = (String) parameters.nextElement();
String parameterValue = request.getParameter(parameter);
log.info(parameter + ": " + parameterValue);
log.info("{}: {}", parameter, parameterValue);
switch (parameter) {
case "company":
Matcher companyMatcher = pattern.matcher(parameterValue);
@ -335,7 +335,6 @@ public class ValidationReportsPageController extends PageController<NoPageParams
* @param contractNumber contract number.
* @return the JSON object in String format.
*/
@SuppressWarnings({"checkstyle:magicnumber"})
private JsonObject assembleJsonContent(final PlatformCredential pc,
final ArrayList<ArrayList<String>> parsedComponents,
final String company,
@ -384,19 +383,19 @@ public class ValidationReportsPageController extends PageController<NoPageParams
* @return the ArrayList of ArrayLists containing the parsed component data.
*/
private ArrayList<ArrayList<String>> parseComponents(final PlatformCredential pc) {
ArrayList<ArrayList<String>> parsedComponents = new ArrayList<ArrayList<String>>();
ArrayList<ArrayList<String>> parsedComponents = new ArrayList<>();
ArrayList<ArrayList<Object>> chainComponents = new ArrayList<>();
StringBuilder componentFailureString = new StringBuilder();
if (pc.getComponentIdentifiers() != null
&& pc.getComponentIdentifiers().size() > 0) {
&& !pc.getComponentIdentifiers().isEmpty()) {
componentFailureString.append(pc.getComponentFailures());
// get all the certificates associated with the platform serial
List<PlatformCredential> chainCertificates =
certificateRepository.byBoardSerialNumber(pc.getPlatformSerial());
// combine all components in each certificate
for (ComponentIdentifier ci : pc.getComponentIdentifiers()) {
ArrayList<Object> issuerAndComponent = new ArrayList<Object>();
ArrayList<Object> issuerAndComponent = new ArrayList<>();
issuerAndComponent.add(pc.getHolderIssuer());
issuerAndComponent.add(ci);
chainComponents.add(issuerAndComponent);
@ -406,16 +405,16 @@ public class ValidationReportsPageController extends PageController<NoPageParams
componentFailureString.append(cert.getComponentFailures());
if (!cert.isPlatformBase()) {
for (ComponentIdentifier ci : cert.getComponentIdentifiers()) {
ArrayList<Object> issuerAndComponent = new ArrayList<Object>();
ArrayList<Object> issuerAndComponent = new ArrayList<>();
issuerAndComponent.add(cert.getHolderIssuer());
issuerAndComponent.add(ci);
chainComponents.add(issuerAndComponent);
}
}
}
log.info("Component failures: " + componentFailureString);
log.info("Component failures: {}", componentFailureString);
for (ArrayList<Object> issuerAndComponent : chainComponents) {
ArrayList<String> componentData = new ArrayList<String>();
ArrayList<String> componentData = new ArrayList<>();
String issuer = (String) issuerAndComponent.get(0);
issuer = issuer.replaceAll(",", " ");
ComponentIdentifier ci = (ComponentIdentifier) issuerAndComponent.get(1);