|
12 | 12 | */ |
13 | 13 | package tech.pegasys.ethsigner; |
14 | 14 |
|
15 | | -import tech.pegasys.ethsigner.core.config.ClientAuthConstraints; |
| 15 | +import tech.pegasys.ethsigner.config.PicoCliDownstreamTrustStore; |
| 16 | +import tech.pegasys.ethsigner.config.PicoCliTlsClientCertificateOptions; |
| 17 | +import tech.pegasys.ethsigner.config.PicoCliTlsServerOptions; |
16 | 18 | import tech.pegasys.ethsigner.core.config.Config; |
17 | 19 | import tech.pegasys.ethsigner.core.config.PkcsStoreConfig; |
18 | 20 | import tech.pegasys.ethsigner.core.config.TlsOptions; |
19 | 21 | import tech.pegasys.ethsigner.core.signing.ChainIdProvider; |
20 | 22 | import tech.pegasys.ethsigner.core.signing.ConfigurationChainId; |
21 | 23 |
|
22 | | -import java.io.File; |
23 | 24 | import java.net.InetAddress; |
24 | 25 | import java.nio.file.Path; |
25 | 26 | import java.time.Duration; |
|
50 | 51 | footer = "EthSigner is licensed under the Apache License 2.0") |
51 | 52 | public class EthSignerBaseCommand implements Config { |
52 | 53 |
|
53 | | - static class TlsClientCertificateOptions implements PkcsStoreConfig { |
54 | | - |
55 | | - @Option( |
56 | | - names = "--downstream-http-tls-keystore-file", |
57 | | - description = |
58 | | - "Path to a PKCS#12 formatted keystore, contains TLS certificate to present to " |
59 | | - + "a TLS-enabled web3 provider", |
60 | | - arity = "1", |
61 | | - required = true) |
62 | | - private File clientCertificateFile; |
63 | | - |
64 | | - @Option( |
65 | | - names = "--downstream-http-tls-keystore-password-file", |
66 | | - description = "Path to a file containing the password used to decrypt the client cert.", |
67 | | - arity = "1", |
68 | | - required = true) |
69 | | - private File clientCertificatePasswordFile; |
70 | | - |
71 | | - @Override |
72 | | - public File getStoreFile() { |
73 | | - return clientCertificateFile; |
74 | | - } |
75 | | - |
76 | | - @Override |
77 | | - public File getStorePasswordFile() { |
78 | | - return clientCertificatePasswordFile; |
79 | | - } |
80 | | - } |
81 | | - |
82 | | - static class Web3ProviderTrustStore implements PkcsStoreConfig { |
83 | | - |
84 | | - @Option( |
85 | | - names = "--downstream-http-tls-truststore-file", |
86 | | - description = |
87 | | - "Path to a PKCS#12 formatted truststore, containing all trusted root " |
88 | | - + "certificates.", |
89 | | - arity = "1", |
90 | | - required = true) |
91 | | - private File trustStoreFile; |
92 | | - |
93 | | - @Option( |
94 | | - names = "--downstream-http-tls-truststore-password-file", |
95 | | - description = "Path to a file containing the password used to decrypt the truststore.", |
96 | | - arity = "1", |
97 | | - required = true) |
98 | | - private File trustStorePasswordFile; |
99 | | - |
100 | | - @Override |
101 | | - public File getStoreFile() { |
102 | | - return trustStoreFile; |
103 | | - } |
104 | | - |
105 | | - @Override |
106 | | - public File getStorePasswordFile() { |
107 | | - return trustStorePasswordFile; |
108 | | - } |
109 | | - } |
110 | | - |
111 | | - static class TlsClientAuthorizationMechanisms implements ClientAuthConstraints { |
112 | | - |
113 | | - @Option( |
114 | | - names = "--tls-known-clients-file", |
115 | | - description = "Path to a file containing the fingerprints of authorized clients.", |
116 | | - arity = "1") |
117 | | - private File tlsKnownClientsFile = null; |
118 | | - |
119 | | - @Option( |
120 | | - names = "--tls-allow-ca-clients", |
121 | | - description = "If defined, allows clients authorized by the CA to connect to Ethsigner.", |
122 | | - arity = "0") |
123 | | - private Boolean tlsAllowCaClients = false; |
124 | | - |
125 | | - @Override |
126 | | - public Optional<File> getKnownClientsFile() { |
127 | | - return Optional.ofNullable(tlsKnownClientsFile); |
128 | | - } |
129 | | - |
130 | | - @Override |
131 | | - public boolean isCaAuthorizedClientAllowed() { |
132 | | - return tlsAllowCaClients; |
133 | | - } |
134 | | - } |
135 | | - |
136 | | - static class TlsClientAuthentication { |
137 | | - |
138 | | - @SuppressWarnings("UnusedVariable") |
139 | | - @ArgGroup(exclusive = false) |
140 | | - private TlsClientAuthorizationMechanisms authMechanisms; |
141 | | - |
142 | | - @Option( |
143 | | - names = "--tls-allow-any-client", |
144 | | - description = |
145 | | - "If defined, will allow any client to connect. Is mutually exclusive with other " |
146 | | - + "client authentication settings", |
147 | | - arity = "0") |
148 | | - private Boolean tlsAllowAnyClient = false; |
149 | | - } |
150 | | - |
151 | | - static class TlsServerOptions implements TlsOptions { |
152 | | - |
153 | | - @Option( |
154 | | - names = "--tls-keystore-file", |
155 | | - description = |
156 | | - "Path to a PKCS#12 formatted keystore; used to enable TLS on inbound connections.", |
157 | | - arity = "1", |
158 | | - required = true) |
159 | | - private File keyStoreFile; |
160 | | - |
161 | | - @Option( |
162 | | - names = "--tls-keystore-password-file", |
163 | | - description = "Path to a file containing the password used to decrypt the keystore.", |
164 | | - arity = "1", |
165 | | - required = true) |
166 | | - private File keyStorePasswordFile; |
167 | | - |
168 | | - @ArgGroup(multiplicity = "1", exclusive = true) |
169 | | - private TlsClientAuthentication tlsClientAuthentication; |
170 | | - |
171 | | - @Override |
172 | | - public File getKeyStoreFile() { |
173 | | - return keyStoreFile; |
174 | | - } |
175 | | - |
176 | | - @Override |
177 | | - public File getKeyStorePasswordFile() { |
178 | | - return keyStorePasswordFile; |
179 | | - } |
180 | | - |
181 | | - @Override |
182 | | - public Optional<ClientAuthConstraints> getClientAuthConstraints() { |
183 | | - return tlsClientAuthentication.tlsAllowAnyClient |
184 | | - ? Optional.empty() |
185 | | - : Optional.of(tlsClientAuthentication.authMechanisms); |
186 | | - } |
187 | | - } |
188 | | - |
189 | 54 | @Option( |
190 | 55 | names = {"--logging", "-l"}, |
191 | 56 | paramLabel = "<LOG VERBOSITY LEVEL>", |
@@ -245,13 +110,13 @@ public Optional<ClientAuthConstraints> getClientAuthConstraints() { |
245 | 110 | private Path dataPath; |
246 | 111 |
|
247 | 112 | @ArgGroup(exclusive = false) |
248 | | - private TlsServerOptions tlsServerOptions; |
| 113 | + private PicoCliTlsServerOptions picoCliTlsServerOptions; |
249 | 114 |
|
250 | 115 | @ArgGroup(exclusive = false) |
251 | | - private TlsClientCertificateOptions clientTlsCertificateOptions; |
| 116 | + private PicoCliTlsClientCertificateOptions clientTlsCertificateOptions; |
252 | 117 |
|
253 | 118 | @ArgGroup(exclusive = false) |
254 | | - private Web3ProviderTrustStore web3ProviderTrustStore; |
| 119 | + private PicoCliDownstreamTrustStore picoCliDownstreamTrustStore; |
255 | 120 |
|
256 | 121 | @Override |
257 | 122 | public Level getLogLevel() { |
@@ -295,12 +160,12 @@ public Duration getDownstreamHttpRequestTimeout() { |
295 | 160 |
|
296 | 161 | @Override |
297 | 162 | public Optional<TlsOptions> getTlsOptions() { |
298 | | - return Optional.ofNullable(tlsServerOptions); |
| 163 | + return Optional.ofNullable(picoCliTlsServerOptions); |
299 | 164 | } |
300 | 165 |
|
301 | 166 | @Override |
302 | 167 | public Optional<PkcsStoreConfig> getWeb3TrustStoreOptions() { |
303 | | - return Optional.ofNullable(web3ProviderTrustStore); |
| 168 | + return Optional.ofNullable(picoCliDownstreamTrustStore); |
304 | 169 | } |
305 | 170 |
|
306 | 171 | @Override |
|
0 commit comments