mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-02-20 17:52:47 +00:00
Updated the labeling for the Trust chain and platform certificates. The import label is removed and the download icon moved next to the import button. Added the same functionality to the RIMs.
This commit is contained in:
parent
9492c680da
commit
2b7b4bfdd1
@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@ -45,11 +46,15 @@ import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* Controller for the Reference Manifest page.
|
||||
@ -356,6 +361,58 @@ public class ReferenceManifestPageController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles request to download bulk of RIMs by writing it to the response stream
|
||||
* for download in bulk.
|
||||
*
|
||||
* @param response the response object (needed to update the header with the
|
||||
* file name)
|
||||
* @throws java.io.IOException when writing to response output stream
|
||||
*/
|
||||
@RequestMapping(value = "/bulk", method = RequestMethod.GET)
|
||||
public void bulk(final HttpServletResponse response)
|
||||
throws IOException {
|
||||
LOGGER.info("Handling request to download all Reference Integrity Manifests");
|
||||
String fileName = "rims.zip";
|
||||
String zipFileName;
|
||||
|
||||
// Set filename for download.
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
||||
response.setContentType("application/zip");
|
||||
|
||||
List<ReferenceManifest> referenceManifestList = new LinkedList<>();
|
||||
referenceManifestList.addAll(BaseReferenceManifest
|
||||
.select(referenceManifestManager).getRIMs());
|
||||
referenceManifestList.addAll(SupportReferenceManifest
|
||||
.select(referenceManifestManager).getRIMs());
|
||||
|
||||
try (ZipOutputStream zipOut = new ZipOutputStream(response.getOutputStream())) {
|
||||
// get all files
|
||||
for (ReferenceManifest rim : referenceManifestList) {
|
||||
if (rim.getFileName().isEmpty()) {
|
||||
zipFileName = "";
|
||||
} else {
|
||||
// configure the zip entry, the properties of the 'file'
|
||||
zipFileName = rim.getFileName();
|
||||
}
|
||||
ZipEntry zipEntry = new ZipEntry(zipFileName);
|
||||
zipEntry.setSize((long) rim.getRimBytes().length * Byte.SIZE);
|
||||
zipEntry.setTime(System.currentTimeMillis());
|
||||
zipOut.putNextEntry(zipEntry);
|
||||
// the content of the resource
|
||||
StreamUtils.copy(rim.getRimBytes(), zipOut);
|
||||
zipOut.closeEntry();
|
||||
}
|
||||
zipOut.finish();
|
||||
// write cert to output stream
|
||||
} catch (IllegalArgumentException ex) {
|
||||
String uuidError = "Failed to parse ID from: ";
|
||||
LOGGER.error(uuidError, ex);
|
||||
// send a 404 error when invalid certificate
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method takes the parameter and looks for this information in the
|
||||
* Database.
|
||||
|
@ -19,18 +19,15 @@
|
||||
<c:set var="endorsementIcon" value="${icons}/ic_vpn_key_black_24dp.png"/>
|
||||
<div class="aca-input-box-header">
|
||||
<form:form method="POST" action="${portal}/certificate-request/platform-credentials/upload" enctype="multipart/form-data">
|
||||
Import Platform Credentials
|
||||
Platform Credentials
|
||||
<my:file-chooser id="platformCredentialEditor" label="Import Platform Credentials">
|
||||
<input id="importFile" type="file" name="file" multiple="multiple" />
|
||||
</my:file-chooser>
|
||||
<a href="${portal}/certificate-request/platform-credentials/bulk">
|
||||
<img src="${icons}/ic_file_download_black_24dp.png" title="Download Certificates">
|
||||
</a>
|
||||
</form:form>
|
||||
</div>
|
||||
<div class="aca-input-box-header">
|
||||
Bulk Platform Credentials Download
|
||||
<a href="${portal}/certificate-request/platform-credentials/bulk">
|
||||
<img src="${icons}/ic_file_download_black_24dp.png" title="Download Certificates">
|
||||
</a>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="aca-data-table">
|
||||
<table id="platformTable" class="display" width="100%">
|
||||
|
@ -18,10 +18,13 @@
|
||||
<!-- text and icon resource variables -->
|
||||
<div class="aca-input-box-header">
|
||||
<form:form method="POST" action="${portal}/reference-manifests/upload" enctype="multipart/form-data">
|
||||
Import RIMs
|
||||
Reference Integrity Manifests
|
||||
<my:file-chooser id="referenceManifestsEditor" label="Import RIMs">
|
||||
<input id="importFile" type="file" name="file" multiple="multiple" />
|
||||
</my:file-chooser>
|
||||
<a href="${portal}/reference-manifests/bulk">
|
||||
<img src="${icons}/ic_file_download_black_24dp.png" title="Download All RIMs">
|
||||
</a>
|
||||
</form:form>
|
||||
</div>
|
||||
<br/>
|
||||
|
@ -71,20 +71,16 @@
|
||||
</a>
|
||||
<div class="aca-input-box-header">
|
||||
<form:form method="POST" action="${portal}/certificate-request/trust-chain/upload" enctype="multipart/form-data">
|
||||
Import Trust Chain CA Certificates
|
||||
Trust Chain CA Certificates
|
||||
<my:file-chooser id="tc-editor" label="Import Trust Chain Certificates">
|
||||
<input id="importFile" type="file" name="file" multiple="multiple" />
|
||||
</my:file-chooser>
|
||||
<a href="${portal}/certificate-request/trust-chain/bulk">
|
||||
<img src="${icons}/ic_file_download_black_24dp.png" title="Download Certificates">
|
||||
</a>
|
||||
</form:form>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="aca-input-box-header">
|
||||
Bulk Trust Chain CA Credentials Download
|
||||
<a href="${portal}/certificate-request/trust-chain/bulk">
|
||||
<img src="${icons}/ic_file_download_black_24dp.png" title="Download Certificates">
|
||||
</a>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="aca-data-table">
|
||||
<table id="trustChainTable" class="display" width="100%">
|
||||
<thead>
|
||||
|
Loading…
x
Reference in New Issue
Block a user