11package redis .clients .jedis ;
22
3+ import javax .net .ssl .HostnameVerifier ;
4+ import javax .net .ssl .SSLParameters ;
5+ import javax .net .ssl .SSLSocketFactory ;
6+
37public class DefaultJedisClientConfig implements JedisClientConfig {
48
9+ private final int connectionTimeout ;
10+ private final int soTimeout ;
511 private final int infiniteSoTimeout ;
12+
613 private final String user ;
714 private final String password ;
815 private final int database ;
916 private final String clientName ;
1017
11- private DefaultJedisClientConfig (int infiniteSoTimeout ,
12- String user , String password , int database , String clientName ) {
18+ private final boolean ssl ;
19+ private final SSLSocketFactory sslSocketFactory ;
20+ private final SSLParameters sslParameters ;
21+ private final HostnameVerifier hostnameVerifier ;
22+
23+ private final HostAndPortMapper hostAndPortMapper ;
24+
25+ private DefaultJedisClientConfig (int connectionTimeout , int soTimeout , int infiniteSoTimeout ,
26+ String user , String password , int database , String clientName ,
27+ boolean ssl , SSLSocketFactory sslSocketFactory , SSLParameters sslParameters ,
28+ HostnameVerifier hostnameVerifier , HostAndPortMapper hostAndPortMapper ) {
29+ this .connectionTimeout = connectionTimeout ;
30+ this .soTimeout = soTimeout ;
1331 this .infiniteSoTimeout = infiniteSoTimeout ;
1432 this .user = user ;
1533 this .password = password ;
1634 this .database = database ;
1735 this .clientName = clientName ;
36+ this .ssl = ssl ;
37+ this .sslSocketFactory = sslSocketFactory ;
38+ this .sslParameters = sslParameters ;
39+ this .hostnameVerifier = hostnameVerifier ;
40+ this .hostAndPortMapper = hostAndPortMapper ;
1841 }
1942
2043 public static Builder builder () {
2144 return new Builder ();
2245 }
2346
47+ @ Override
48+ public int getConnectionTimeout () {
49+ return connectionTimeout ;
50+ }
51+
52+ @ Override
53+ public int getSoTimeout () {
54+ return soTimeout ;
55+ }
56+
2457 @ Override
2558 public int getInfiniteSoTimeout () {
2659 return infiniteSoTimeout ;
@@ -46,20 +79,66 @@ public String getClientName() {
4679 return clientName ;
4780 }
4881
82+ @ Override
83+ public boolean isSSL () {
84+ return ssl ;
85+ }
86+
87+ @ Override
88+ public SSLSocketFactory getSSLSocketFactory () {
89+ return sslSocketFactory ;
90+ }
91+
92+ @ Override
93+ public SSLParameters getSSLParameters () {
94+ return sslParameters ;
95+ }
96+
97+ @ Override
98+ public HostnameVerifier getHostnameVerifier () {
99+ return hostnameVerifier ;
100+ }
101+
102+ @ Override
103+ public HostAndPortMapper getHostAndPortMapper () {
104+ return hostAndPortMapper ;
105+ }
106+
49107 public static class Builder {
50108
109+ private int connectionTimeout = Protocol .DEFAULT_TIMEOUT ;
110+ private int soTimeout = Protocol .DEFAULT_TIMEOUT ;
51111 private int infiniteSoTimeout = 0 ;
52112
53113 private String user = null ;
54114 private String password = null ;
55115 private int databse = Protocol .DEFAULT_DATABASE ;
56116 private String clinetName = null ;
57117
118+ private boolean ssl = false ;
119+ private SSLSocketFactory sslSocketFactory = null ;
120+ private SSLParameters sslParameters = null ;
121+ private HostnameVerifier hostnameVerifier = null ;
122+
123+ private HostAndPortMapper hostAndPortMapper = null ;
124+
58125 private Builder () {
59126 }
60127
61128 public DefaultJedisClientConfig build () {
62- return new DefaultJedisClientConfig (infiniteSoTimeout , user , password , databse , clinetName );
129+ return new DefaultJedisClientConfig (connectionTimeout , soTimeout , infiniteSoTimeout ,
130+ user , password , databse , clinetName ,
131+ ssl , sslSocketFactory , sslParameters , hostnameVerifier , hostAndPortMapper );
132+ }
133+
134+ public Builder withConnectionTimeout (int connectionTimeout ) {
135+ this .connectionTimeout = connectionTimeout ;
136+ return this ;
137+ }
138+
139+ public Builder withSoTimeout (int soTimeout ) {
140+ this .soTimeout = soTimeout ;
141+ return this ;
63142 }
64143
65144 public Builder withInfiniteSoTimeout (int infiniteSoTimeout ) {
@@ -87,6 +166,39 @@ public Builder withClinetName(String clinetName) {
87166 return this ;
88167 }
89168
169+ public Builder withSsl (boolean ssl ) {
170+ this .ssl = ssl ;
171+ return this ;
172+ }
173+
174+ public Builder withSslSocketFactory (SSLSocketFactory sslSocketFactory ) {
175+ this .sslSocketFactory = sslSocketFactory ;
176+ return this ;
177+ }
178+
179+ public Builder withSslParameters (SSLParameters sslParameters ) {
180+ this .sslParameters = sslParameters ;
181+ return this ;
182+ }
183+
184+ public Builder withHostnameVerifier (HostnameVerifier hostnameVerifier ) {
185+ this .hostnameVerifier = hostnameVerifier ;
186+ return this ;
187+ }
188+
189+ public Builder withHostAndPortMapper (HostAndPortMapper hostAndPortMapper ) {
190+ this .hostAndPortMapper = hostAndPortMapper ;
191+ return this ;
192+ }
193+
194+ public int getConnectionTimeout () {
195+ return connectionTimeout ;
196+ }
197+
198+ public int getSoTimeout () {
199+ return soTimeout ;
200+ }
201+
90202 public int getInfiniteSoTimeout () {
91203 return infiniteSoTimeout ;
92204 }
@@ -107,5 +219,24 @@ public String getClinetName() {
107219 return clinetName ;
108220 }
109221
222+ public boolean isSsl () {
223+ return ssl ;
224+ }
225+
226+ public SSLSocketFactory getSslSocketFactory () {
227+ return sslSocketFactory ;
228+ }
229+
230+ public SSLParameters getSslParameters () {
231+ return sslParameters ;
232+ }
233+
234+ public HostnameVerifier getHostnameVerifier () {
235+ return hostnameVerifier ;
236+ }
237+
238+ public HostAndPortMapper getHostAndPortMapper () {
239+ return hostAndPortMapper ;
240+ }
110241 }
111242}
0 commit comments