001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.server.config.beans; 021 022 023import java.util.ArrayList; 024import java.util.List; 025 026import org.apache.directory.api.ldap.model.constants.SchemaConstants; 027import org.apache.directory.server.config.ConfigurationElement; 028 029 030/** 031 * A class used to store the LdapServer configuration. 032 * 033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 034 */ 035public class LdapServerBean extends DSBasedServerBean 036{ 037 /** */ 038 @ConfigurationElement(attributeType = "ads-confidentialityRequired") 039 private boolean confidentialityRequired; 040 041 /** The maximum number of entries returned by the server */ 042 @ConfigurationElement(attributeType = "ads-maxSizeLimit") 043 private int maxSizeLimit; 044 045 /** The maximum time to execute a request on the server */ 046 @ConfigurationElement(attributeType = "ads-maxTimeLimit") 047 private int maxTimeLimit; 048 049 /** The maximum size of an incoming PDU */ 050 @ConfigurationElement(attributeType = "ads-maxPDUSize") 051 private int maxPDUSize = 2048; 052 053 /** The SASL host */ 054 @ConfigurationElement(attributeType = "ads-saslHost") 055 private String saslHost; 056 057 /** The SASL principal */ 058 @ConfigurationElement(attributeType = "ads-saslPrincipal") 059 private String saslPrincipal; 060 061 /** The SASL realms */ 062 @ConfigurationElement(attributeType = "ads-saslRealms") 063 private List<String> saslRealms = new ArrayList<>(); 064 065 /** The keystore file */ 066 @ConfigurationElement(attributeType = "ads-keystoreFile", isOptional = true) 067 private String keystoreFile; 068 069 /** The certificate password */ 070 @ConfigurationElement(attributeType = "ads-certificatePassword", isOptional = true) 071 private String certificatePassword; 072 073 /** A flag telling if the replication is enabled */ 074 @ConfigurationElement(attributeType = SchemaConstants.ADS_REPL_ENABLED) 075 private boolean replEnabled = false; 076 077 /** the replication request handler, server will be in replication provider/master mode if a valid FQCN is given */ 078 @ConfigurationElement(attributeType = "ads-replReqHandler", isOptional = true) 079 private String replReqHandler; 080 081 /** The replication consumer Bean */ 082 @ConfigurationElement(objectClass = "ads-replConsumer", container = "replConsumers", isOptional = true) 083 private List<ReplConsumerBean> replConsumers = new ArrayList<>(); 084 085 /** The list of supported mechanisms */ 086 @ConfigurationElement(objectClass = "ads-saslMechHandler", container = "saslMechHandlers", isOptional = true) 087 private List<SaslMechHandlerBean> saslMechHandlers = new ArrayList<>(); 088 089 /** The list of supported extended operation handlers */ 090 @ConfigurationElement(objectClass = "ads-extendedOpHandler", container = "extendedOpHandlers", isOptional = true) 091 private List<ExtendedOpHandlerBean> extendedOpHandlers = new ArrayList<>(); 092 093 /** the time interval between subsequent pings to each replication provider */ 094 @ConfigurationElement(attributeType = "ads-replPingerSleep") 095 private int replPingerSleep; 096 097 098 /** 099 * Create a new LdapServerBean instance 100 */ 101 public LdapServerBean() 102 { 103 super(); 104 105 // Enabled by default 106 setEnabled( true ); 107 } 108 109 110 /** 111 * @return the ldapServerConfidentialityRequired 112 */ 113 public boolean isLdapServerConfidentialityRequired() 114 { 115 return confidentialityRequired; 116 } 117 118 119 /** 120 * @param ldapServerConfidentialityRequired the ldapServerConfidentialityRequired to set 121 */ 122 public void setLdapServerConfidentialityRequired( boolean ldapServerConfidentialityRequired ) 123 { 124 this.confidentialityRequired = ldapServerConfidentialityRequired; 125 } 126 127 128 /** 129 * @return the ldapServerMaxSizeLimit 130 */ 131 public int getLdapServerMaxSizeLimit() 132 { 133 return maxSizeLimit; 134 } 135 136 137 /** 138 * @param ldapServerMaxSizeLimit the ldapServerMaxSizeLimit to set 139 */ 140 public void setLdapServerMaxSizeLimit( int ldapServerMaxSizeLimit ) 141 { 142 this.maxSizeLimit = ldapServerMaxSizeLimit; 143 } 144 145 146 /** 147 * @return the ldapServerMaxTimeLimit 148 */ 149 public int getLdapServerMaxTimeLimit() 150 { 151 return maxTimeLimit; 152 } 153 154 155 /** 156 * @param ldapServerMaxTimeLimit the ldapServerMaxTimeLimit to set 157 */ 158 public void setLdapServerMaxTimeLimit( int ldapServerMaxTimeLimit ) 159 { 160 this.maxTimeLimit = ldapServerMaxTimeLimit; 161 } 162 163 164 /** 165 * @return the ldapServerSaslHost 166 */ 167 public String getLdapServerSaslHost() 168 { 169 return saslHost; 170 } 171 172 173 /** 174 * @param ldapServerSaslHost the ldapServerSaslHost to set 175 */ 176 public void setLdapServerSaslHost( String ldapServerSaslHost ) 177 { 178 this.saslHost = ldapServerSaslHost; 179 } 180 181 182 /** 183 * @return the ldapServerSaslPrincipal 184 */ 185 public String getLdapServerSaslPrincipal() 186 { 187 return saslPrincipal; 188 } 189 190 191 /** 192 * @param ldapServerSaslPrincipal the ldapServerSaslPrincipal to set 193 */ 194 public void setLdapServerSaslPrincipal( String ldapServerSaslPrincipal ) 195 { 196 this.saslPrincipal = ldapServerSaslPrincipal; 197 } 198 199 200 /** 201 * @return the ldapServerSaslRealms 202 */ 203 public List<String> getLdapServerSaslRealms() 204 { 205 return saslRealms; 206 } 207 208 209 /** 210 * @param ldapServerSaslRealms the ldapServerSaslRealms to set 211 */ 212 public void setLdapServerSaslRealms( List<String> ldapServerSaslRealms ) 213 { 214 this.saslRealms = ldapServerSaslRealms; 215 } 216 217 218 /** 219 * @param ldapServerSaslRealms the ldapServerSaslRealms to add 220 */ 221 public void addSaslRealms( String... ldapServerSaslRealms ) 222 { 223 for ( String saslRealm : ldapServerSaslRealms ) 224 { 225 this.saslRealms.add( saslRealm ); 226 } 227 } 228 229 230 /** 231 * @return the ldapServerKeystoreFile 232 */ 233 public String getLdapServerKeystoreFile() 234 { 235 return keystoreFile; 236 } 237 238 239 /** 240 * @param ldapServerKeystoreFile the ldapServerKeystoreFile to set 241 */ 242 public void setLdapServerKeystoreFile( String ldapServerKeystoreFile ) 243 { 244 this.keystoreFile = ldapServerKeystoreFile; 245 } 246 247 248 /** 249 * @return the ldapServerCertificatePassword 250 */ 251 public String getLdapServerCertificatePassword() 252 { 253 return certificatePassword; 254 } 255 256 257 /** 258 * @param ldapServerCertificatePassword the ldapServerCertificatePassword to set 259 */ 260 public void setLdapServerCertificatePassword( String ldapServerCertificatePassword ) 261 { 262 this.certificatePassword = ldapServerCertificatePassword; 263 } 264 265 266 /** 267 * @return the replReqHandler 268 */ 269 public String getReplReqHandler() 270 { 271 return replReqHandler; 272 } 273 274 275 /** 276 * @param replReqHandler the replReqHandler to set 277 */ 278 public void setReplReqHandler( String replReqHandler ) 279 { 280 this.replReqHandler = replReqHandler; 281 } 282 283 284 /** 285 * @return the saslMechHandlers 286 */ 287 public List<SaslMechHandlerBean> getSaslMechHandlers() 288 { 289 return saslMechHandlers; 290 } 291 292 293 /** 294 * @param saslMechHandlers the saslMechHandlers to set 295 */ 296 public void setSaslMechHandlers( List<SaslMechHandlerBean> saslMechHandlers ) 297 { 298 this.saslMechHandlers = saslMechHandlers; 299 } 300 301 302 /** 303 * @param saslMechHandlers the saslMechHandlers to add 304 */ 305 public void setSaslMechHandlers( SaslMechHandlerBean... saslMechHandlers ) 306 { 307 for ( SaslMechHandlerBean saslMechHandler : saslMechHandlers ) 308 { 309 this.saslMechHandlers.add( saslMechHandler ); 310 } 311 } 312 313 314 /** 315 * @return the extendedOps 316 */ 317 public List<ExtendedOpHandlerBean> getExtendedOps() 318 { 319 return extendedOpHandlers; 320 } 321 322 323 /** 324 * @param extendedOps the extendedOps to set 325 */ 326 public void setExtendedOps( List<ExtendedOpHandlerBean> extendedOps ) 327 { 328 this.extendedOpHandlers = extendedOps; 329 } 330 331 332 /** 333 * @param extendedOps the extendedOps to add 334 */ 335 public void addExtendedOps( ExtendedOpHandlerBean... extendedOps ) 336 { 337 for ( ExtendedOpHandlerBean extendedOp : extendedOps ) 338 { 339 this.extendedOpHandlers.add( extendedOp ); 340 } 341 } 342 343 344 /** 345 * @return the Replication Consumer Bean 346 */ 347 public List<ReplConsumerBean> getReplConsumers() 348 { 349 return replConsumers; 350 } 351 352 353 /** 354 * @param replConsumers the Replication Consumer Bean to set 355 */ 356 public void setReplConsumer( List<ReplConsumerBean> replConsumers ) 357 { 358 this.replConsumers = replConsumers; 359 } 360 361 362 /** 363 * @param replConsumers the Replication Consumer Bean to set 364 */ 365 public void addReplConsumers( ReplConsumerBean... replConsumers ) 366 { 367 for ( ReplConsumerBean bean : replConsumers ) 368 { 369 this.replConsumers.add( bean ); 370 } 371 } 372 373 374 /** 375 * @return the maxPDUSize 376 */ 377 public int getMaxPDUSize() 378 { 379 return maxPDUSize; 380 } 381 382 383 /** 384 * @param maxPDUSize the maxPDUSize to set 385 */ 386 public void setMaxPDUSize( int maxPDUSize ) 387 { 388 this.maxPDUSize = maxPDUSize; 389 } 390 391 392 /** 393 * {@inheritDoc} 394 */ 395 @Override 396 public String toString( String tabs ) 397 { 398 StringBuilder sb = new StringBuilder(); 399 400 sb.append( tabs ).append( "LdapServer :\n" ); 401 sb.append( super.toString( tabs + " " ) ); 402 sb.append( tabs ).append( " max size limit : " ).append( maxSizeLimit ).append( '\n' ); 403 sb.append( tabs ).append( " max time limit : " ).append( maxTimeLimit ).append( '\n' ); 404 sb.append( " max PDU size : " ).append( maxPDUSize ).append( '\n' ); 405 sb.append( toString( tabs, " certificate password", certificatePassword ) ); 406 sb.append( toString( tabs, " keystore file", keystoreFile ) ); 407 sb.append( toString( tabs, " sasl principal", saslPrincipal ) ); 408 sb.append( tabs ).append( " sasl host : " ).append( saslHost ).append( '\n' ); 409 sb.append( toString( tabs, " confidentiality required", confidentialityRequired ) ); 410 sb.append( toString( tabs, " enable replication provider", replReqHandler ) ); 411 sb.append( toString( tabs, " Pinger thread sleep time(in sec.)", replPingerSleep ) ); 412 413 if ( ( extendedOpHandlers != null ) && !extendedOpHandlers.isEmpty() ) 414 { 415 sb.append( tabs ).append( " extended operation handlers :\n" ); 416 417 for ( ExtendedOpHandlerBean extendedOpHandler : extendedOpHandlers ) 418 { 419 sb.append( extendedOpHandler.toString( tabs + " " ) ); 420 } 421 } 422 423 if ( saslMechHandlers != null ) 424 { 425 sb.append( tabs ).append( " SASL mechanism handlers :\n" ); 426 427 for ( SaslMechHandlerBean saslMechHandler : saslMechHandlers ) 428 { 429 sb.append( saslMechHandler.toString( tabs + " " ) ); 430 } 431 } 432 433 if ( ( saslRealms != null ) && !saslRealms.isEmpty() ) 434 { 435 sb.append( tabs ).append( " SASL realms :\n" ); 436 437 for ( String saslRealm : saslRealms ) 438 { 439 sb.append( tabs ).append( " " ).append( saslRealm ).append( "\n" ); 440 } 441 } 442 443 if ( ( replConsumers != null ) && !replConsumers.isEmpty() ) 444 { 445 sb.append( tabs ).append( " replication consumers :\n" ); 446 447 for ( ReplConsumerBean replConsumer : replConsumers ) 448 { 449 sb.append( replConsumer.toString( tabs + " " ) ); 450 } 451 } 452 453 return sb.toString(); 454 } 455 456 457 /** 458 * @return True if the replication service should be enabled 459 */ 460 public boolean isReplEnabled() 461 { 462 return replEnabled; 463 } 464 465 466 /** 467 * Enable or disable the replication 468 * @param replEnabled The new value 469 */ 470 public void setReplEnabled( boolean replEnabled ) 471 { 472 this.replEnabled = replEnabled; 473 } 474 475 476 public int getReplPingerSleep() 477 { 478 return replPingerSleep; 479 } 480 481 482 public void setReplPingerSleep( int replPingerSleep ) 483 { 484 this.replPingerSleep = replPingerSleep; 485 } 486 487 488 /** 489 * {@inheritDoc} 490 */ 491 @Override 492 public String toString() 493 { 494 return toString( "" ); 495 } 496}