1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.config.beans;
21
22
23 import java.util.ArrayList;
24 import java.util.List;
25
26 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
27 import org.apache.directory.server.config.ConfigurationElement;
28
29
30
31
32
33
34
35 public class DirectoryServiceBean extends AdsBaseBean
36 {
37
38 @ConfigurationElement(attributeType = SchemaConstants.ADS_DIRECTORY_SERVICE_ID, isRdn = true)
39 private String directoryServiceId;
40
41
42 @ConfigurationElement(attributeType = SchemaConstants.ADS_DS_REPLICA_ID)
43 private int dsReplicaId;
44
45
46 @ConfigurationElement(attributeType = "ads-dsAccessControlEnabled")
47 private boolean dsAccessControlEnabled = true;
48
49
50 @ConfigurationElement(attributeType = "ads-dsAllowAnonymousAccess")
51 private boolean dsAllowAnonymousAccess = false;
52
53
54 @ConfigurationElement(attributeType = "ads-dsDenormalizeOpAttrsEnabled")
55 private boolean dsDenormalizeOpAttrsEnabled = true;
56
57
58 @ConfigurationElement(attributeType = "ads-dsPasswordHidden")
59 private boolean dsPasswordHidden = false;
60
61
62 @ConfigurationElement(attributeType = "ads-dsSyncPeriodMillis")
63 private long dsSyncPeriodMillis = 15000L;
64
65
66 @ConfigurationElement(attributeType = "ads-dsTestEntries", isOptional = true)
67 private String dsTestEntries;
68
69
70 @ConfigurationElement(objectClass = "ads-changelog")
71 private ChangeLogBean changeLog;
72
73
74 @ConfigurationElement(objectClass = "ads-journal")
75 private JournalBean journal;
76
77
78 @ConfigurationElement(objectClass = "ads-server", container = "servers")
79 private List<ServerBean> servers = new ArrayList<>();
80
81
82 @ConfigurationElement(objectClass = "ads-interceptor", container = "interceptors")
83 private List<InterceptorBean> interceptors = new ArrayList<>();
84
85
86 @ConfigurationElement(objectClass = "ads-partition", container = "partitions")
87 private List<PartitionBean> partitions = new ArrayList<>();
88
89
90
91
92
93 public DirectoryServiceBean()
94 {
95 }
96
97
98
99
100
101
102 public void setDirectoryServiceId( String directoryServiceId )
103 {
104 this.directoryServiceId = directoryServiceId;
105 }
106
107
108
109
110
111 public String getDirectoryServiceId()
112 {
113 return directoryServiceId;
114 }
115
116
117
118
119
120 public int getDsReplicaId()
121 {
122 return dsReplicaId;
123 }
124
125
126
127
128
129 public void setDsReplicaId( int dsReplicaId )
130 {
131 if ( ( dsReplicaId < 0 ) || ( dsReplicaId > 999 ) )
132 {
133 this.dsReplicaId = 0;
134 }
135 else
136 {
137 this.dsReplicaId = dsReplicaId;
138 }
139 }
140
141
142
143
144
145
146
147 public List<InterceptorBean> getInterceptors()
148 {
149 return interceptors;
150 }
151
152
153
154
155
156
157
158 public void setInterceptors( List<InterceptorBean> interceptors )
159 {
160 this.interceptors = interceptors;
161 }
162
163
164
165
166
167
168
169 public void addInterceptors( InterceptorBean... interceptors )
170 {
171 for ( InterceptorBean interceptor : interceptors )
172 {
173 this.interceptors.add( interceptor );
174 }
175 }
176
177
178
179
180
181 public boolean isDsAccessControlEnabled()
182 {
183 return dsAccessControlEnabled;
184 }
185
186
187
188
189
190 public void setDsAccessControlEnabled( boolean dsAccessControlEnabled )
191 {
192 this.dsAccessControlEnabled = dsAccessControlEnabled;
193 }
194
195
196
197
198
199 public boolean isDsAllowAnonymousAccess()
200 {
201 return dsAllowAnonymousAccess;
202 }
203
204
205
206
207
208 public void setDsAllowAnonymousAccess( boolean dsAllowAnonymousAccess )
209 {
210 this.dsAllowAnonymousAccess = dsAllowAnonymousAccess;
211 }
212
213
214
215
216
217 public boolean isDsDenormalizeOpAttrsEnabled()
218 {
219 return dsDenormalizeOpAttrsEnabled;
220 }
221
222
223
224
225
226 public void setDsDenormalizeOpAttrsEnabled( boolean dsDenormalizeOpAttrsEnabled )
227 {
228 this.dsDenormalizeOpAttrsEnabled = dsDenormalizeOpAttrsEnabled;
229 }
230
231
232
233
234
235 public boolean isDsPasswordHidden()
236 {
237 return dsPasswordHidden;
238 }
239
240
241
242
243
244 public void setDsPasswordHidden( boolean dsPasswordHidden )
245 {
246 this.dsPasswordHidden = dsPasswordHidden;
247 }
248
249
250
251
252
253 public long getDsSyncPeriodMillis()
254 {
255 return dsSyncPeriodMillis;
256 }
257
258
259
260
261
262 public void setDsSyncPeriodMillis( long dsSyncPeriodMillis )
263 {
264 this.dsSyncPeriodMillis = dsSyncPeriodMillis;
265 }
266
267
268
269
270
271 public String getDsTestEntries()
272 {
273 return dsTestEntries;
274 }
275
276
277
278
279
280 public void setDsTestEntries( String dsTestEntries )
281 {
282 this.dsTestEntries = dsTestEntries;
283 }
284
285
286
287
288
289 public ChangeLogBean getChangeLog()
290 {
291 return changeLog;
292 }
293
294
295
296
297
298 public void setChangeLog( ChangeLogBean changeLog )
299 {
300 this.changeLog = changeLog;
301 }
302
303
304
305
306
307 public JournalBean getJournal()
308 {
309 return journal;
310 }
311
312
313
314
315
316 public void setJournal( JournalBean journal )
317 {
318 this.journal = journal;
319 }
320
321
322
323
324
325 public void clearPartitions()
326 {
327 partitions.clear();
328 }
329
330
331
332
333
334 public List<PartitionBean> getPartitions()
335 {
336 return partitions;
337 }
338
339
340
341
342
343 public void setPartitions( List<PartitionBean> partitions )
344 {
345 this.partitions = partitions;
346 }
347
348
349
350
351
352 public void addPartitions( PartitionBean... partitions )
353 {
354 for ( PartitionBean partition : partitions )
355 {
356 this.partitions.add( partition );
357 }
358 }
359
360
361
362
363
364 public List<ServerBean> getServers()
365 {
366 return servers;
367 }
368
369
370
371
372
373 public LdapServerBean getLdapServerBean()
374 {
375 for ( ServerBean server : servers )
376 {
377 if ( server instanceof LdapServerBean )
378 {
379 return ( LdapServerBean ) server;
380 }
381 }
382
383 return null;
384 }
385
386
387
388
389
390 public NtpServerBean getNtpServerBean()
391 {
392 for ( ServerBean server : servers )
393 {
394 if ( server instanceof NtpServerBean )
395 {
396 return ( NtpServerBean ) server;
397 }
398 }
399
400 return null;
401 }
402
403
404
405
406
407 public DnsServerBean getDnsServerBean()
408 {
409 for ( ServerBean server : servers )
410 {
411 if ( server instanceof DnsServerBean )
412 {
413 return ( DnsServerBean ) server;
414 }
415 }
416
417 return null;
418 }
419
420
421
422
423
424 public DhcpServerBean getDhcpServerBean()
425 {
426 for ( ServerBean server : servers )
427 {
428 if ( server instanceof DhcpServerBean )
429 {
430 return ( DhcpServerBean ) server;
431 }
432 }
433
434 return null;
435 }
436
437
438
439
440
441 public HttpServerBean getHttpServerBean()
442 {
443 for ( ServerBean server : servers )
444 {
445 if ( server instanceof HttpServerBean )
446 {
447 return ( HttpServerBean ) server;
448 }
449 }
450
451 return null;
452 }
453
454
455
456
457
458 public KdcServerBean getKdcServerBean()
459 {
460 for ( ServerBean server : servers )
461 {
462 if ( server instanceof KdcServerBean )
463 {
464 return ( KdcServerBean ) server;
465 }
466 }
467
468 return null;
469 }
470
471
472
473
474
475 public ChangePasswordServerBean getChangePasswordServerBean()
476 {
477 for ( ServerBean server : servers )
478 {
479 if ( server instanceof ChangePasswordServerBean )
480 {
481 return ( ChangePasswordServerBean ) server;
482 }
483 }
484
485 return null;
486 }
487
488
489
490
491
492 public void setServers( List<ServerBean> servers )
493 {
494 this.servers = servers;
495 }
496
497
498
499
500
501 public void addServers( ServerBean... servers )
502 {
503 for ( ServerBean server : servers )
504 {
505 this.servers.add( server );
506 }
507 }
508
509
510
511
512
513 @Override
514 public String toString()
515 {
516 StringBuilder sb = new StringBuilder();
517
518 sb.append( "DirectoryServiceBean : \n" );
519 sb.append( super.toString( " " ) );
520
521
522 sb.append( " directoryService ID : " ).append( directoryServiceId ).append( '\n' );
523 sb.append( " replica ID : " ).append( dsReplicaId ).append( '\n' );
524 sb.append( toString( " ", "accessControl enabled", dsAccessControlEnabled ) );
525 sb.append( toString( " ", "allow anonymous access", dsAllowAnonymousAccess ) );
526 sb.append( toString( " ", "denormalized attributes enabled", dsDenormalizeOpAttrsEnabled ) );
527 sb.append( toString( " ", "password hidden", dsPasswordHidden ) );
528 sb.append( " sync period millisecond : " ).append( dsSyncPeriodMillis ).append( '\n' );
529 sb.append( toString( " ", "test entries", dsTestEntries ) );
530
531 sb.append( " interceptors : \n" );
532
533 if ( ( interceptors != null ) && !interceptors.isEmpty() )
534 {
535 for ( InterceptorBean interceptor : interceptors )
536 {
537 sb.append( interceptor.toString( " " ) );
538 }
539 }
540
541 sb.append( " partitions : \n" );
542
543 if ( ( partitions != null ) && !partitions.isEmpty() )
544 {
545 for ( PartitionBean partition : partitions )
546 {
547 sb.append( partition.toString( " " ) );
548 }
549 }
550
551 if ( journal != null )
552 {
553 sb.append( journal.toString( " " ) );
554 }
555
556 if ( changeLog != null )
557 {
558 sb.append( changeLog.toString( " " ) );
559 }
560
561 sb.append( " servers : \n" );
562
563 if ( ( servers != null ) && !servers.isEmpty() )
564 {
565 for ( ServerBean server : servers )
566 {
567 sb.append( server.toString( " " ) );
568 }
569 }
570
571 sb.append( '\n' );
572
573 return sb.toString();
574 }
575 }