当前位置: 首页>>代码示例>>Java>>正文


Java Utils.copy方法代码示例

本文整理汇总了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;
}
 
开发者ID:esig,项目名称:dss-demonstrations,代码行数:17,代码来源:SignatureController.java

示例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);
	}
 
开发者ID:esig,项目名称:dss,代码行数:22,代码来源:SigningApplication.java

示例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;
}
 
开发者ID:esig,项目名称:dss-demonstrations,代码行数:20,代码来源:ExtensionController.java

示例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;
		}
	}
}
 
开发者ID:esig,项目名称:dss-demonstrations,代码行数:21,代码来源:SignatureController.java

示例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);
			}
		}
	}
}
 
开发者ID:esig,项目名称:dss,代码行数:14,代码来源:AbstractASiCSignatureService.java

示例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);
		}
	}
}
 
开发者ID:esig,项目名称:dss,代码行数:14,代码来源:AbstractASiCSignatureService.java

示例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);
	}
}
 
开发者ID:esig,项目名称:dss,代码行数:8,代码来源:AbstractASiCContainerExtractor.java

示例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);
	}
}
 
开发者ID:esig,项目名称:dss,代码行数:17,代码来源:DSSUtils.java


注:本文中的eu.europa.esig.dss.utils.Utils.copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。