View Javadoc
1   /*
2    *   Licensed to the Apache Software Foundation (ASF) under one
3    *   or more contributor license agreements.  See the NOTICE file
4    *   distributed with this work for additional information
5    *   regarding copyright ownership.  The ASF licenses this file
6    *   to you under the Apache License, Version 2.0 (the
7    *   "License"); you may not use this file except in compliance
8    *   with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing,
13   *   software distributed under the License is distributed on an
14   *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *   KIND, either express or implied.  See the License for the
16   *   specific language governing permissions and limitations
17   *   under the License.
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   * A class used to store the Replication Consumer configuration.
32   *
33   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
34   */
35  public class ReplConsumerBean extends AdsBaseBean
36  {
37      /** The consumer id */
38      @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_CONSUMER_ID, isRdn = true)
39      private String replConsumerId;
40  
41      /** The Search Base Dn */
42      @ConfigurationElement(attributeType = SchemaConstants.ADS_SEARCH_BASE_DN)
43      private String searchBaseDn;
44  
45      /** The replication provider host name */
46      @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_PROV_HOST_NAME)
47      private String replProvHostName;
48  
49      /** The replication provider port */
50      @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_PROV_PORT)
51      private int replProvPort;
52  
53      /** The Alias Dereferencing mode */
54      @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_ALIAS_DEREF_MODE)
55      private String replAliasDerefMode;
56  
57      /** The replication provider attribute */
58      @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_ATTRIBUTES)
59      private List<String> replAttributes = new ArrayList<>();
60  
61      /** The refresh interval */
62      @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_REFRESH_INTERVAL)
63      private long replRefreshInterval;
64  
65      /** Tells if we should persist */
66      @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_REFRESH_N_PERSIST)
67      private boolean replRefreshNPersist;
68  
69      /** The search scope */
70      @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_SEARCH_SCOPE)
71      private String replSearchScope;
72  
73      /** The replication search filter */
74      @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_SEARCH_FILTER)
75      private String replSearchFilter;
76  
77      /** The search size limit */
78      @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_SEARCH_SIZE_LIMIT)
79      private int replSearchSizeLimit;
80  
81      /** The search time limit */
82      @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_SEARCH_TIMEOUT)
83      private int replSearchTimeout;
84  
85      /** The replication user Dn */
86      @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_USER_DN)
87      private String replUserDn;
88  
89      /** The replication user password */
90      @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_USER_PASSWORD)
91      private byte[] replUserPassword;
92  
93      /** The replication cookie */
94      @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_COOKIE, isOptional = true)
95      private String replCookie;
96  
97      /** Tells if TLS should be used during replication */
98      @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_USE_TLS, isOptional = true)
99      private boolean replUseTls;
100 
101     /** Tells if the certificate validation should be strict or not */
102     @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_STRICT_CERT_VALIDATION, isOptional = true)
103     private boolean replStrictCertValidation;
104 
105     /** The FQCN of replication client implementation */
106     @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_CONSUMER_IMPL, isOptional = true)
107     private String replConsumerImpl;
108 
109 
110     /**
111      * Create a new Replication Consumer instance
112      */
113     public ReplConsumerBean()
114     {
115         super();
116 
117         // Enabled by default
118         setEnabled( true );
119     }
120 
121 
122     /**
123      * @return the replConsumerId
124      */
125     public String getReplConsumerId()
126     {
127         return replConsumerId;
128     }
129 
130 
131     /**
132      * @param replConsumerId the replication consumer id to set
133      */
134     public void setReplConsumerId( String replConsumerId )
135     {
136         this.replConsumerId = replConsumerId;
137     }
138 
139 
140     /**
141      * @return the searchBaseDn
142      */
143     public String getSearchBaseDn()
144     {
145         return searchBaseDn;
146     }
147 
148 
149     /**
150      * @param searchBaseDn the searchBaseDn to set
151      */
152     public void setSearchBaseDn( String searchBaseDn )
153     {
154         this.searchBaseDn = searchBaseDn;
155     }
156 
157 
158     /**
159      * @return the replProvHostName
160      */
161     public String getReplProvHostName()
162     {
163         return replProvHostName;
164     }
165 
166 
167     /**
168      * @param replProvHostName the replProvHostName to set
169      */
170     public void setReplProvHostName( String replProvHostName )
171     {
172         this.replProvHostName = replProvHostName;
173     }
174 
175 
176     /**
177      * @return the replProvPort
178      */
179     public int getReplProvPort()
180     {
181         return replProvPort;
182     }
183 
184 
185     /**
186      * @param replProvPort the replProvPort to set
187      */
188     public void setReplProvPort( int replProvPort )
189     {
190         this.replProvPort = replProvPort;
191     }
192 
193 
194     /**
195      * @return the replAliasDerefMode
196      */
197     public String getReplAliasDerefMode()
198     {
199         return replAliasDerefMode;
200     }
201 
202 
203     /**
204      * @param replAliasDerefMode the replAliasDerefMode to set
205      */
206     public void setReplAliasDerefMode( String replAliasDerefMode )
207     {
208         this.replAliasDerefMode = replAliasDerefMode;
209     }
210 
211 
212     /**
213      * @return the replAttributes
214      */
215     public List<String> getReplAttributes()
216     {
217         return replAttributes;
218     }
219 
220 
221     /**
222      * @param replAttributes the replAttribute to set
223      */
224     public void setReplAttributes( List<String> replAttributes )
225     {
226         this.replAttributes = replAttributes;
227     }
228 
229 
230     /**
231      * @param replAttributes the replAttribute to add
232      */
233     public void addReplAttributes( String... replAttributes )
234     {
235         for ( String at : replAttributes )
236         {
237             this.replAttributes.add( at );
238         }
239     }
240 
241 
242     /**
243      * @return the replRefreshInterval
244      */
245     public long getReplRefreshInterval()
246     {
247         return replRefreshInterval;
248     }
249 
250 
251     /**
252      * @param replRefreshInterval the replRefreshInterval to set
253      */
254     public void setReplRefreshInterval( long replRefreshInterval )
255     {
256         this.replRefreshInterval = replRefreshInterval;
257     }
258 
259 
260     /**
261      * @return the replRefreshNPersist
262      */
263     public boolean isReplRefreshNPersist()
264     {
265         return replRefreshNPersist;
266     }
267 
268 
269     /**
270      * @param replRefreshNPersist the replRefreshNPersist to set
271      */
272     public void setReplRefreshNPersist( boolean replRefreshNPersist )
273     {
274         this.replRefreshNPersist = replRefreshNPersist;
275     }
276 
277 
278     /**
279      * @return the replSearchScope
280      */
281     public String getReplSearchScope()
282     {
283         return replSearchScope;
284     }
285 
286 
287     /**
288      * @param replSearchScope the replSearchScope to set
289      */
290     public void setReplSearchScope( String replSearchScope )
291     {
292         this.replSearchScope = replSearchScope;
293     }
294 
295 
296     /**
297      * @return the replSearchFilter
298      */
299     public String getReplSearchFilter()
300     {
301         return replSearchFilter;
302     }
303 
304 
305     /**
306      * @param replSearchFilter the replSearchFilter to set
307      */
308     public void setReplSearchFilter( String replSearchFilter )
309     {
310         this.replSearchFilter = replSearchFilter;
311     }
312 
313 
314     /**
315      * @return the replSearchSizeLimit
316      */
317     public int getReplSearchSizeLimit()
318     {
319         return replSearchSizeLimit;
320     }
321 
322 
323     /**
324      * @param replSearchSizeLimit the replSearchSizeLimit to set
325      */
326     public void setReplSearchSizeLimit( int replSearchSizeLimit )
327     {
328         this.replSearchSizeLimit = replSearchSizeLimit;
329     }
330 
331 
332     /**
333      * @return the replSearchTimeOut
334      */
335     public int getReplSearchTimeout()
336     {
337         return replSearchTimeout;
338     }
339 
340 
341     /**
342      * @param replSearchTimeout the replSearchTimeout to set
343      */
344     public void setReplSearchTimeout( int replSearchTimeout )
345     {
346         this.replSearchTimeout = replSearchTimeout;
347     }
348 
349 
350     /**
351      * @return the replUserDn
352      */
353     public String getReplUserDn()
354     {
355         return replUserDn;
356     }
357 
358 
359     /**
360      * @param replUserDn the replUserDn to set
361      */
362     public void setReplUserDn( String replUserDn )
363     {
364         this.replUserDn = replUserDn;
365     }
366 
367 
368     /**
369      * @return the replUserPassword
370      */
371     public byte[] getReplUserPassword()
372     {
373         return replUserPassword;
374     }
375 
376 
377     /**
378      * @param replUserPassword the replUserPassword to set
379      */
380     public void setReplUserPassword( byte[] replUserPassword )
381     {
382         this.replUserPassword = replUserPassword;
383     }
384 
385 
386     /**
387      * @return the replCookie
388      */
389     public String getReplCookie()
390     {
391         return replCookie;
392     }
393 
394 
395     /**
396      * @param replCookie the replCookie to set
397      */
398     public void setReplCookie( String replCookie )
399     {
400         this.replCookie = replCookie;
401     }
402 
403 
404     /**
405      * @return the replUseTls
406      */
407     public boolean isReplUseTls()
408     {
409         return replUseTls;
410     }
411 
412 
413     /**
414      * @param replUseTls the replUseTls to set
415      */
416     public void setReplUseTls( boolean replUseTls )
417     {
418         this.replUseTls = replUseTls;
419     }
420 
421 
422     /**
423      * @return the replStrictCertValidation
424      */
425     public boolean isReplStrictCertValidation()
426     {
427         return replStrictCertValidation;
428     }
429 
430 
431     /**
432      * @param replStrictCertValidation the replStrictCertValidation to set
433      */
434     public void setReplStrictCertValidation( boolean replStrictCertValidation )
435     {
436         this.replStrictCertValidation = replStrictCertValidation;
437     }
438 
439 
440     /**
441      * @return the replConsumerImpl
442      */
443     public String getReplConsumerImpl()
444     {
445         return replConsumerImpl;
446     }
447 
448 
449     /**
450      * @param replConsumerImpl the replConsumerImpl to set
451      */
452     public void setReplConsumerImpl( String replConsumerImpl )
453     {
454         this.replConsumerImpl = replConsumerImpl;
455     }
456 
457 
458     /**
459      * {@inheritDoc}
460      */
461     @Override
462     public String toString( String tabs )
463     {
464         StringBuilder sb = new StringBuilder();
465 
466         sb.append( tabs ).append( "Replication provider :\n" );
467         sb.append( super.toString( tabs + "  " ) );
468 
469         sb.append( tabs ).append( "  provider ID : " ).append( replConsumerId ).append( '\n' );
470         sb.append( tabs ).append( "  search base Dn : " ).append( searchBaseDn ).append( '\n' );
471         sb.append( tabs ).append( "  provider host name : " ).append( replProvHostName ).append( '\n' );
472         sb.append( tabs ).append( "  provider port : " ).append( replProvPort ).append( '\n' );
473         sb.append( toString( tabs, "  alias dereferencing mode", replAliasDerefMode ) );
474         sb.append( toString( tabs, "  attributes", String.valueOf( replAttributes ) ) );
475         sb.append( tabs ).append( "  refresh interval : " ).append( replRefreshInterval ).append( '\n' );
476         sb.append( toString( tabs, "  refresh and persist mode", replRefreshNPersist ) );
477         sb.append( toString( tabs, "  search scope", replSearchScope ) );
478         sb.append( toString( tabs, "  search filter", replSearchFilter ) );
479         sb.append( tabs ).append( "  search size limit : " ).append( replSearchSizeLimit ).append( '\n' );
480         sb.append( tabs ).append( "  search time limit : " ).append( replSearchTimeout ).append( '\n' );
481         sb.append( toString( tabs, "  user Dn", replUserDn ) );
482         sb.append( toString( tabs, "  user password", String.valueOf( replUserPassword ) ) ); // do not reveal the password, just null or not
483         sb.append( toString( tabs, "  cookie", replCookie ) );
484         sb.append( tabs ).append( "  consumer implementation's FQCN : " ).append( replConsumerImpl ).append( '\n' );
485 
486         sb.append( toString( tabs, "  struct certivicate validation", replStrictCertValidation ) );
487         sb.append( toString( tabs, "  use TLS", replUseTls ) );
488 
489         return sb.toString();
490     }
491 
492 
493     /**
494      * {@inheritDoc}
495      */
496     @Override
497     public String toString()
498     {
499         return toString( "" );
500     }
501 }