1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.bremersee.spring.boot.autoconfigure.ldaptive;
18
19 import java.time.Duration;
20 import java.util.ArrayList;
21 import java.util.List;
22 import lombok.Data;
23 import lombok.EqualsAndHashCode;
24 import lombok.Getter;
25 import lombok.Setter;
26 import lombok.ToString;
27 import org.springframework.boot.context.properties.ConfigurationProperties;
28
29
30
31
32
33
34 @ConfigurationProperties(prefix = "bremersee.ldaptive")
35 @Getter
36 @Setter
37 @ToString(exclude = {"bindCredentials"})
38 @EqualsAndHashCode(exclude = {"bindCredentials"})
39 public class LdaptiveConnectionProperties {
40
41
42
43
44 private Class<?> ldaptiveTemplateClass;
45
46
47
48
49 private boolean immutable;
50
51
52
53
54
55 private String ldapUrl;
56
57
58
59
60 private Duration connectTimeout = Duration.ofMinutes(1);
61
62
63
64
65 private Duration startTlsTimeout = Duration.ofMinutes(1);
66
67
68
69
70 private Duration responseTimeout = Duration.ofMinutes(1);
71
72
73
74
75
76 private Duration reconnectTimeout = Duration.ofMinutes(2);
77
78
79
80
81 private boolean autoReconnect = true;
82
83
84
85
86 private ReconnectStrategy reconnectStrategy = ReconnectStrategy.ONE_RECONNECT_ATTEMPT;
87
88
89
90
91 private boolean autoReplay = true;
92
93
94
95
96 private SslProperties sslConfig = new SslProperties();
97
98
99
100
101 private boolean useStartTls;
102
103
104
105
106 private String bindDn;
107
108
109
110
111 private String bindCredentials;
112
113
114
115
116 private boolean fastBind = false;
117
118
119
120
121 private ConnectionStrategy connectionStrategy = ConnectionStrategy.ACTIVE_PASSIVE;
122
123
124
125
126 private ConnectionValidatorProperties connectionValidator = new ConnectionValidatorProperties();
127
128
129
130
131 private boolean pooled = false;
132
133
134
135
136 private ConnectionPoolProperties connectionPool = new ConnectionPoolProperties();
137
138
139
140
141 public LdaptiveConnectionProperties() {
142 super();
143 }
144
145
146
147
148 public enum ReconnectStrategy {
149
150
151
152
153 ONE_RECONNECT_ATTEMPT,
154
155
156
157
158 INFINITE_RECONNECT_ATTEMPTS,
159
160
161
162
163 INFINITE_RECONNECT_ATTEMPTS_WITH_BACKOFF
164
165 }
166
167
168
169
170 @Data
171 public static class SslProperties {
172
173
174
175
176 private String trustCertificates;
177
178
179
180
181 private String authenticationCertificate;
182
183
184
185
186 private String authenticationKey;
187
188
189
190
191 private HostnameVerifier hostnameVerifier = HostnameVerifier.DEFAULT;
192
193
194
195
196 public SslProperties() {
197 super();
198 }
199
200
201
202
203 public enum HostnameVerifier {
204
205
206
207
208 DEFAULT,
209
210
211
212
213 ALLOW_ANY
214
215 }
216 }
217
218
219
220
221 public enum ConnectionStrategy {
222
223
224
225
226
227 ACTIVE_PASSIVE,
228
229
230
231
232 RANDOM,
233
234
235
236
237
238 ROUND_ROBIN,
239
240
241
242
243
244
245 DNS
246
247 }
248
249
250
251
252 @Data
253 public static class ConnectionValidatorProperties {
254
255
256
257
258 private Duration validatePeriod = Duration.ofMinutes(30);
259
260
261
262
263 private Duration validateTimeout = Duration.ofSeconds(5);
264
265
266
267
268 private SearchRequestProperties searchRequest = new SearchRequestProperties();
269
270
271
272
273 public ConnectionValidatorProperties() {
274 super();
275 }
276
277
278
279
280 @Data
281 public static class SearchRequestProperties {
282
283
284
285
286 private String baseDn;
287
288
289
290
291 private SearchFilterProperties searchFilter = new SearchFilterProperties();
292
293
294
295
296 private Integer sizeLimit;
297
298
299
300
301 private SearchScope searchScope;
302
303
304
305
306 private List<String> returnAttributes = new ArrayList<>();
307
308
309
310
311 public SearchRequestProperties() {
312 super();
313 }
314
315
316
317
318 @Data
319 public static class SearchFilterProperties {
320
321
322
323
324 private String filter;
325
326
327
328
329 public SearchFilterProperties() {
330 super();
331 }
332 }
333 }
334 }
335
336
337
338
339 @Data
340 public static class ConnectionPoolProperties {
341
342
343
344
345 private Duration blockWaitTime = Duration.ofMinutes(1);
346
347
348
349
350 private int minPoolSize = 3;
351
352
353
354
355 private int maxPoolSize = 10;
356
357
358
359
360 private boolean connectOnCreate = true;
361
362
363
364
365 private boolean failFastInitialize = true;
366
367
368
369
370 private boolean validateOnCheckIn = false;
371
372
373
374
375 private boolean validateOnCheckOut = false;
376
377
378
379
380 private boolean validatePeriodically = false;
381
382
383
384
385 private ConnectionValidatorProperties validator = new ConnectionValidatorProperties();
386
387
388
389
390 private Duration prunePeriod = Duration.ofMinutes(5);
391
392
393
394
395 private Duration idleTime = Duration.ofMinutes(10);
396
397
398
399
400 public ConnectionPoolProperties() {
401 super();
402 }
403 }
404
405
406
407
408 public enum SearchScope {
409
410
411
412
413 OBJECT,
414
415
416
417
418 ONELEVEL,
419
420
421
422
423 SUBTREE,
424
425
426
427
428 SUBORDINATE
429 }
430 }