Skip to content

Commit 0089190

Browse files
committed
cleanup exceptions
1 parent 05e3fd1 commit 0089190

File tree

6 files changed

+7
-30
lines changed

6 files changed

+7
-30
lines changed

libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/PemKeyConfig.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
package org.elasticsearch.common.ssl;
1111

1212
import org.elasticsearch.core.Tuple;
13-
import org.elasticsearch.entitlement.runtime.api.NotEntitledException;
1413

1514
import java.io.IOException;
1615
import java.nio.file.Path;
17-
import java.security.AccessControlException;
1816
import java.security.GeneralSecurityException;
1917
import java.security.KeyStore;
2018
import java.security.PrivateKey;
@@ -126,10 +124,8 @@ private PrivateKey getPrivateKey(Path path) {
126124
throw new SslConfigException("could not load ssl private key file [" + path + "]");
127125
}
128126
return privateKey;
129-
} catch (AccessControlException e) {
127+
} catch (SecurityException e) {
130128
throw SslFileUtil.accessControlFailure(KEY_FILE_TYPE, List.of(path), e, configBasePath);
131-
} catch (NotEntitledException e) {
132-
throw SslFileUtil.notEntitledFailure(KEY_FILE_TYPE, List.of(path), e, configBasePath);
133129
} catch (IOException e) {
134130
throw SslFileUtil.ioException(KEY_FILE_TYPE, List.of(path), e);
135131
} catch (GeneralSecurityException e) {
@@ -140,7 +136,7 @@ private PrivateKey getPrivateKey(Path path) {
140136
private List<Certificate> getCertificates(Path path) {
141137
try {
142138
return PemUtils.readCertificates(Collections.singleton(path));
143-
} catch (AccessControlException e) {
139+
} catch (SecurityException e) {
144140
throw SslFileUtil.accessControlFailure(CERT_FILE_TYPE, List.of(path), e, configBasePath);
145141
} catch (IOException e) {
146142
throw SslFileUtil.ioException(CERT_FILE_TYPE, List.of(path), e);

libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/PemTrustConfig.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99

1010
package org.elasticsearch.common.ssl;
1111

12-
import org.elasticsearch.entitlement.runtime.api.NotEntitledException;
13-
1412
import java.io.IOException;
1513
import java.io.InputStream;
1614
import java.nio.file.Path;
17-
import java.security.AccessControlException;
1815
import java.security.GeneralSecurityException;
1916
import java.security.KeyStore;
2017
import java.security.cert.Certificate;
@@ -99,10 +96,8 @@ private Path resolveFile(String other) {
9996
private List<Certificate> readCertificates(List<Path> paths) {
10097
try {
10198
return PemUtils.readCertificates(paths);
102-
} catch (AccessControlException e) {
99+
} catch (SecurityException e) {
103100
throw SslFileUtil.accessControlFailure(CA_FILE_TYPE, paths, e, basePath);
104-
} catch (NotEntitledException e) {
105-
throw SslFileUtil.notEntitledFailure(CA_FILE_TYPE, paths, e, basePath);
106101
} catch (IOException e) {
107102
throw SslFileUtil.ioException(CA_FILE_TYPE, paths, e);
108103
} catch (GeneralSecurityException e) {

libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/PemUtils.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
package org.elasticsearch.common.ssl;
1111

1212
import org.elasticsearch.core.CharArrays;
13-
import org.elasticsearch.entitlement.runtime.api.NotEntitledException;
1413

1514
import java.io.BufferedReader;
1615
import java.io.IOException;
@@ -19,7 +18,6 @@
1918
import java.nio.charset.StandardCharsets;
2019
import java.nio.file.Files;
2120
import java.nio.file.Path;
22-
import java.security.AccessControlException;
2321
import java.security.AlgorithmParameters;
2422
import java.security.GeneralSecurityException;
2523
import java.security.KeyFactory;
@@ -111,10 +109,8 @@ public static PrivateKey readPrivateKey(Path path, Supplier<char[]> passwordSupp
111109
throw new SslConfigException("could not load ssl private key file [" + path + "]");
112110
}
113111
return privateKey;
114-
} catch (AccessControlException e) {
112+
} catch (SecurityException e) {
115113
throw SslFileUtil.accessControlFailure("PEM private key", List.of(path), e, null);
116-
} catch (NotEntitledException e) {
117-
throw SslFileUtil.notEntitledFailure("PEM private key", List.of(path), e, null);
118114
} catch (IOException e) {
119115
throw SslFileUtil.ioException("PEM private key", List.of(path), e);
120116
} catch (GeneralSecurityException e) {

libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/SslFileUtil.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import java.nio.file.AccessDeniedException;
1717
import java.nio.file.NoSuchFileException;
1818
import java.nio.file.Path;
19-
import java.security.AccessControlException;
2019
import java.security.GeneralSecurityException;
2120
import java.security.UnrecoverableKeyException;
2221
import java.util.List;
@@ -84,7 +83,7 @@ static SslConfigException notEntitledFailure(String fileType, List<Path> paths,
8483
return innerAccessControlFailure(fileType, paths, cause, basePath);
8584
}
8685

87-
static SslConfigException accessControlFailure(String fileType, List<Path> paths, AccessControlException cause, Path basePath) {
86+
static SslConfigException accessControlFailure(String fileType, List<Path> paths, SecurityException cause, Path basePath) {
8887
return innerAccessControlFailure(fileType, paths, cause, basePath);
8988
}
9089

libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/StoreKeyConfig.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111

1212
import org.elasticsearch.core.Nullable;
1313
import org.elasticsearch.core.Tuple;
14-
import org.elasticsearch.entitlement.runtime.api.NotEntitledException;
1514

1615
import java.io.IOException;
1716
import java.nio.file.Path;
18-
import java.security.AccessControlException;
1917
import java.security.GeneralSecurityException;
2018
import java.security.KeyStore;
2119
import java.security.KeyStoreException;
@@ -167,10 +165,8 @@ private KeyStore processKeyStore(KeyStore keyStore) {
167165
private KeyStore readKeyStore(Path path) {
168166
try {
169167
return KeyStoreUtil.readKeyStore(path, type, storePassword);
170-
} catch (AccessControlException e) {
168+
} catch (SecurityException e) {
171169
throw SslFileUtil.accessControlFailure("[" + type + "] keystore", List.of(path), e, configBasePath);
172-
} catch (NotEntitledException e) {
173-
throw SslFileUtil.notEntitledFailure("[" + type + "] keystore", List.of(path), e, configBasePath);
174170
} catch (IOException e) {
175171
throw SslFileUtil.ioException("[" + type + "] keystore", List.of(path), e);
176172
} catch (GeneralSecurityException e) {

libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/StoreTrustConfig.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99

1010
package org.elasticsearch.common.ssl;
1111

12-
import org.elasticsearch.entitlement.runtime.api.NotEntitledException;
13-
1412
import java.io.IOException;
1513
import java.nio.file.Path;
16-
import java.security.AccessControlException;
1714
import java.security.GeneralSecurityException;
1815
import java.security.KeyStore;
1916
import java.security.cert.X509Certificate;
@@ -95,10 +92,8 @@ public X509ExtendedTrustManager createTrustManager() {
9592
private KeyStore readKeyStore(Path path) {
9693
try {
9794
return KeyStoreUtil.readKeyStore(path, type, password);
98-
} catch (AccessControlException e) {
95+
} catch (SecurityException e) {
9996
throw SslFileUtil.accessControlFailure(fileTypeForException(), List.of(path), e, configBasePath);
100-
} catch (NotEntitledException e) {
101-
throw SslFileUtil.notEntitledFailure(fileTypeForException(), List.of(path), e, configBasePath);
10297
} catch (IOException e) {
10398
throw SslFileUtil.ioException(fileTypeForException(), List.of(path), e, getAdditionalErrorDetails());
10499
} catch (GeneralSecurityException e) {

0 commit comments

Comments
 (0)