本文整理汇总了Java中eu.europa.esig.dss.utils.Utils.copy方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.copy方法的具体用法?Java Utils.copy怎么用?Java Utils.copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eu.europa.esig.dss.utils.Utils
的用法示例。
在下文中一共展示了Utils.copy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: downloadSignedFile
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@RequestMapping(value = "/download", method = RequestMethod.GET)
public String downloadSignedFile(@ModelAttribute("signedDocument") InMemoryDocument signedDocument, HttpServletResponse response) {
try {
MimeType mimeType = signedDocument.getMimeType();
if (mimeType != null) {
response.setContentType(mimeType.getMimeTypeString());
}
response.setHeader("Content-Transfer-Encoding", "binary");
response.setHeader("Content-Disposition", "attachment; filename=\"" + signedDocument.getName() + "\"");
Utils.copy(new ByteArrayInputStream(signedDocument.getBytes()), response.getOutputStream());
} catch (Exception e) {
logger.error("An error occured while pushing file in response : " + e.getMessage(), e);
}
return null;
}
示例2: main
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
preparePKCS12TokenAndKey();
DSSDocument toBeSigned = new FileDocument("src/main/resources/xml_example.xml");
XAdESSignatureParameters params = new XAdESSignatureParameters();
params.setSignatureLevel(SignatureLevel.XAdES_BASELINE_B);
params.setSignaturePackaging(SignaturePackaging.ENVELOPED);
params.setSigningCertificate(privateKey.getCertificate());
params.setCertificateChain(privateKey.getCertificateChain());
params.bLevel().setSigningDate(new Date());
CommonCertificateVerifier commonCertificateVerifier = new CommonCertificateVerifier();
XAdESService service = new XAdESService(commonCertificateVerifier);
ToBeSigned dataToSign = service.getDataToSign(toBeSigned, params);
SignatureValue signatureValue = signingToken.sign(dataToSign, params.getDigestAlgorithm(), privateKey);
DSSDocument signedDocument = service.signDocument(toBeSigned, params, signatureValue);
Utils.copy(signedDocument.openStream(), System.out);
}
示例3: extend
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@RequestMapping(method = RequestMethod.POST)
public String extend(HttpServletRequest request, HttpServletResponse response, @ModelAttribute("extensionForm") @Valid ExtensionForm extensionForm,
BindingResult result) {
if (result.hasErrors()) {
return EXTENSION_TILE;
}
DSSDocument extendedDocument = signingService.extend(extensionForm);
response.setContentType(extendedDocument.getMimeType().getMimeTypeString());
response.setHeader("Content-Disposition", "attachment; filename=\"" + extendedDocument.getName() + "\"");
try {
Utils.copy(extendedDocument.openStream(), response.getOutputStream());
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return null;
}
示例4: save
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private void save(DSSDocument signedDocument) {
FileChooser fileChooser = new FileChooser();
fileChooser.setInitialFileName(signedDocument.getName());
MimeType mimeType = signedDocument.getMimeType();
ExtensionFilter extFilter = new ExtensionFilter(mimeType.getMimeTypeString(), "*." + MimeType.getExtension(mimeType));
fileChooser.getExtensionFilters().add(extFilter);
File fileToSave = fileChooser.showSaveDialog(stage);
if (fileToSave != null) {
try {
FileOutputStream fos = new FileOutputStream(fileToSave);
Utils.copy(signedDocument.openStream(), fos);
Utils.closeQuietly(fos);
} catch (Exception e) {
Alert alert = new Alert(AlertType.ERROR, "Unable to save file : " + e.getMessage(), ButtonType.CLOSE);
alert.showAndWait();
return;
}
}
}
示例5: copyArchiveContentWithoutSignatures
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private void copyArchiveContentWithoutSignatures(DSSDocument archiveDocument, ZipOutputStream zos) throws IOException {
try (InputStream is = archiveDocument.openStream(); ZipInputStream zis = new ZipInputStream(is)) {
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
final String name = entry.getName();
final ZipEntry newEntry = new ZipEntry(name);
if (!isSignatureFilename(name)) {
zos.putNextEntry(newEntry);
Utils.copy(zis, zos);
}
}
}
}
示例6: storeSignedFiles
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private void storeSignedFiles(final List<DSSDocument> detachedDocuments, final ZipOutputStream zos) throws IOException {
for (DSSDocument detachedDocument : detachedDocuments) {
try (InputStream is = detachedDocument.openStream()) {
final String detachedDocumentName = detachedDocument.getName();
final String name = detachedDocumentName != null ? detachedDocumentName : ZIP_ENTRY_DETACHED_FILE;
final ZipEntry entryDocument = new ZipEntry(name);
zos.setLevel(ZipEntry.DEFLATED);
zos.putNextEntry(entryDocument);
Utils.copy(is, zos);
}
}
}
示例7: getCurrentDocument
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private DSSDocument getCurrentDocument(String filepath, ZipInputStream zis) throws IOException {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
Utils.copy(zis, baos);
baos.flush();
return new InMemoryDocument(baos.toByteArray(), filepath);
}
}
示例8: saveToFile
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* This method saves the given array of {@code byte} to the provided {@code File}.
*
* @param bytes
* to save
* @param file
* @throws DSSException
*/
public static void saveToFile(final byte[] bytes, final File file) throws DSSException {
file.getParentFile().mkdirs();
try (InputStream is = new ByteArrayInputStream(bytes); OutputStream os = new FileOutputStream(file)) {
Utils.copy(is, os);
} catch (IOException e) {
throw new DSSException(e);
}
}