Skip to content

Commit

Permalink
issue_847: Took another look over the PR for this issue and found not…
Browse files Browse the repository at this point in the history
…hing alarming. Made some minor tweaks to four files. Should be good to go for PR
  • Loading branch information
ThatSilentCoder committed Oct 30, 2024
1 parent 18efb25 commit 963086f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected void setFieldValue(final String name, final Object value) {

/**
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
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;

Expand All @@ -18,10 +18,22 @@
/**
* 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
Expand All @@ -30,7 +42,6 @@ public class DataTableInput {
*/
@NotNull
@Min(0)
@Getter
@Setter
private int draw = 1;
/**
Expand All @@ -39,7 +50,6 @@ public class DataTableInput {
*/
@NotNull
@Min(0)
@Getter
@Setter
private int start = 0;
/**
Expand All @@ -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.
Expand Down Expand Up @@ -200,23 +196,4 @@ public String getOrderColumnName() {
}
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
+ '}';
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,14 @@ public static HashMap<String, Object> getRimDetailInfo(final UUID uuid,
* @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
Expand Down Expand Up @@ -260,8 +258,8 @@ private static HashMap<String, Object> getBaseRimInfo(
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())) {
Expand All @@ -272,7 +270,7 @@ private static HashMap<String, Object> getBaseRimInfo(
break;
}
} catch (SupplyChainValidatorException scvEx) {
log.error("Error verifying cert chain: " + scvEx.getMessage());
log.error("Error verifying cert chain: {}", scvEx.getMessage());
}
}
}
Expand All @@ -288,7 +286,7 @@ private static HashMap<String, Object> getBaseRimInfo(
}
}
} catch (NullPointerException npEx) {
log.warn("Unable to link signing certificate: " + npEx.getMessage());
log.warn("Unable to link signing certificate: {}", npEx.getMessage());
}
return data;
}
Expand Down Expand Up @@ -610,12 +608,6 @@ public ModelAndView initPage(final ReferenceManifestDetailsPageParams params,
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
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;
Expand Down Expand Up @@ -115,10 +116,10 @@ public ModelAndView initPage(final NoPageParams params, final Model model) {
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();
Expand All @@ -145,8 +146,7 @@ public DataTableResponse<SupplyChainValidationSummary> getTableData(
* @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 {

Expand All @@ -158,7 +158,7 @@ public void download(final HttpServletRequest request,
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;
Expand All @@ -171,7 +171,7 @@ public void download(final HttpServletRequest request,
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);
Expand Down Expand Up @@ -335,7 +335,6 @@ public void download(final HttpServletRequest request,
* @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,
Expand Down Expand Up @@ -384,19 +383,19 @@ private JsonObject assembleJsonContent(final PlatformCredential pc,
* @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);
Expand All @@ -406,16 +405,16 @@ private ArrayList<ArrayList<String>> parseComponents(final PlatformCredential pc
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);
Expand Down

0 comments on commit 963086f

Please sign in to comment.