Skip to content

Commit adc3dbe

Browse files
committed
Removed duplicate code
1 parent 5ddff00 commit adc3dbe

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

ayza/src/main/java/nl/altindag/ssl/util/CertificateUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public static <T extends Certificate> void write(Path destination, T certificate
136136
public static List<Certificate> loadCertificate(String... certificatePaths) {
137137
return loadCertificate(certificatePath ->
138138
requireNotNull(
139-
CertificateUtils.class.getClassLoader().getResourceAsStream(certificatePath),
139+
IOUtils.getResourceAsStream(certificatePath),
140140
CERTIFICATE_NOT_FOUND_EXCEPTION_MESSAGE.apply(certificatePath)),
141141
certificatePaths
142142
);

ayza/src/main/java/nl/altindag/ssl/util/KeyStoreUtils.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.nio.file.Files;
2929
import java.nio.file.Path;
3030
import java.nio.file.Paths;
31-
import java.nio.file.StandardOpenOption;
3231
import java.security.Key;
3332
import java.security.KeyStore;
3433
import java.security.KeyStoreException;
@@ -84,7 +83,7 @@ public static KeyStore loadKeyStore(String keystorePath, char[] keystorePassword
8483
}
8584

8685
private static KeyStore loadKeyStore(String keystorePath, KeyStoreFunction<InputStream, KeyStore> keyStoreKeyStoreFunction) {
87-
try (InputStream keystoreInputStream = KeyStoreUtils.class.getClassLoader().getResourceAsStream(keystorePath)) {
86+
try (InputStream keystoreInputStream = IOUtils.getResourceAsStream(keystorePath)) {
8887
requireNotNull(keystoreInputStream, KEYSTORE_NOT_FOUND_EXCEPTION_MESSAGE.apply(keystorePath));
8988
return keyStoreKeyStoreFunction.apply(keystoreInputStream);
9089
} catch (Exception e) {
@@ -109,7 +108,7 @@ public static KeyStore loadKeyStore(Path keystorePath, char[] keystorePassword,
109108
}
110109

111110
private static KeyStore loadKeyStore(Path keystorePath, KeyStoreFunction<InputStream, KeyStore> mapper) {
112-
try (InputStream keystoreInputStream = Files.newInputStream(keystorePath, StandardOpenOption.READ)) {
111+
try (InputStream keystoreInputStream = IOUtils.getFileAsStream(keystorePath)) {
113112
return mapper.apply(keystoreInputStream);
114113
} catch (Exception e) {
115114
throw new GenericKeyStoreException(e);

0 commit comments

Comments
 (0)