本文整理了Java中eu.europa.esig.dss.utils.Utils.closeQuietly()
方法的一些代码示例,展示了Utils.closeQuietly()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.closeQuietly()
方法的具体详情如下:
包路径:eu.europa.esig.dss.utils.Utils
类名称:Utils
方法名:closeQuietly
暂无
代码示例来源:origin: esig/dss
private void initKeystore(final InputStream ksStream, final String ksType, final String ksPassword) {
try {
keyStore = KeyStore.getInstance(ksType);
final char[] password = (ksPassword == null) ? null : ksPassword.toCharArray();
keyStore.load(ksStream, password);
passwordProtection = new PasswordProtection(password);
} catch (GeneralSecurityException | IOException e) {
throw new DSSException("Unable to initialize the keystore", e);
} finally {
Utils.closeQuietly(ksStream);
}
}
代码示例来源:origin: esig/dss
@Test
public void closeQuietly() throws IOException {
Utils.closeQuietly(null);
String newFileName = "target/sample2.txt";
String newFileContent = "Hello world!";
FileOutputStream fos = new FileOutputStream(newFileName);
fos.write(newFileContent.getBytes("UTF-8"));
fos.close();
Utils.closeQuietly(new FileInputStream(newFileName));
Utils.closeQuietly(new FileOutputStream("target/sample3.txt"));
}
代码示例来源:origin: esig/dss
public byte[] call() {
OutputStream out = null;
InputStream inputStream = null;
byte[] result = null;
try {
URLConnection connection = createConnection();
connection.setUseCaches(useCaches);
connection.setDoInput(true);
if (content != null) {
connection.setDoOutput(true);
out = connection.getOutputStream();
Utils.write(content, out);
}
inputStream = connection.getInputStream();
result = Utils.toByteArray(maxInputSize > 0? new MaxSizeInputStream(inputStream, maxInputSize, url): inputStream);
} catch (IOException e) {
throw new DSSException(String.format(ERROR_MESSAGE, url, e.getMessage()), e);
} finally {
Utils.closeQuietly(out);
Utils.closeQuietly(inputStream);
}
return result;
}
代码示例来源:origin: esig/dss
Utils.closeQuietly(httpResponse);
Utils.closeQuietly(client);
代码示例来源:origin: esig/dss
Utils.closeQuietly(httpResponse);
Utils.closeQuietly(client);
代码示例来源:origin: esig/dss
@Test
public void getDigestSignaturePolicy() throws Exception {
FileInputStream fis = new FileInputStream("src/test/resources/signature-policy-example.der");
byte[] policyBytes = Utils.toByteArray(fis);
Utils.closeQuietly(fis);
byte[] signaturePolicyDigest = DSSASN1Utils.getAsn1SignaturePolicyDigest(DigestAlgorithm.SHA256, policyBytes);
String hexSignaturePolicyDigest = Utils.toHex(signaturePolicyDigest);
assertEquals("fe71e01aedd99f444238602d4e98f47bbab405c58c0e3811b9511dcd58c3c983", hexSignaturePolicyDigest);
}
代码示例来源:origin: esig/dss
@Test
public void loadCertificate() throws Exception {
CertificateToken certificate = DSSUtils.loadCertificate(new FileInputStream("src/test/resources/belgiumrs2.crt"));
assertNotNull(certificate);
FileInputStream fis = new FileInputStream("src/test/resources/belgiumrs2.crt");
byte[] byteArray = Utils.toByteArray(fis);
logger.info(Utils.toBase64(byteArray));
Utils.closeQuietly(fis);
CertificateToken certificate2 = DSSUtils.loadCertificate(byteArray);
assertNotNull(certificate2);
CertificateToken certificateNew = DSSUtils.loadCertificate(new FileInputStream("src/test/resources/belgiumrs2-new.crt"));
assertNotNull(certificateNew);
FileInputStream fisNew = new FileInputStream("src/test/resources/belgiumrs2-new.crt");
byte[] byteArrayNew = Utils.toByteArray(fisNew);
logger.info(Utils.toBase64(byteArrayNew));
Utils.closeQuietly(fisNew);
CertificateToken certificate2New = DSSUtils.loadCertificate(byteArrayNew);
assertNotNull(certificate2New);
// String cert =
// "PGh0bWw+PGhlYWQ+PHRpdGxlPlJlcXVlc3QgUmVqZWN0ZWQ8L3RpdGxlPjwvaGVhZD48Ym9keT5UaGUgcmVxdWVzdGVkIFVSTCB3YXMgcmVqZWN0ZWQuIFBsZWFzZSBjb25zdWx0IHdpdGggeW91ciBhZG1pbmlzdHJhdG9yLjxicj48YnI+WW91ciBzdXBwb3J0IElEIGlzOiAxMTY1Njg3NjQzMzgzMDI3NjMxNjwvYm9keT48L2h0bWw+";
// byte[] decodeBase64 = Base64.decodeBase64(cert);
// byte[] decodeBase642 = Base64.decodeBase64(decodeBase64);
// CertificateToken certificate3 =
// DSSUtils.loadCertificate(base64StringToBase64Binary);
// assertNotNull(certificate3);
}
内容来源于网络,如有侵权,请联系作者删除!