1 /** 2 * $RCSfile$ 3 * $Revision: 3306 $ 4 * $Date: 2006-01-16 14:34:56 -0300 (Mon, 16 Jan 2006) $ 5 * 6 * Copyright 2003-2007 Jive Software. 7 * 8 * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 21 package org.jivesoftware.smack; 22 23 import org.jivesoftware.smack.proxy.ProxyInfo; 24 import org.jivesoftware.smack.util.DNSUtil; 25 import org.jivesoftware.smack.util.dns.HostAddress; 26 27 import javax.net.SocketFactory; 28 import javax.net.ssl.SSLContext; 29 import org.apache.harmony.javax.security.auth.callback.CallbackHandler; 30 import java.io.File; 31 import java.util.ArrayList; 32 import java.util.Collections; 33 import java.util.List; 34 35 /** 36 * Configuration to use while establishing the connection to the server. It is possible to 37 * configure the path to the trustore file that keeps the trusted CA root certificates and 38 * enable or disable all or some of the checkings done while verifying server certificates.<p> 39 * 40 * It is also possible to configure if TLS, SASL, and compression are used or not. 41 * 42 * @author Gaston Dombiak 43 */ 44 public class ConnectionConfiguration implements Cloneable { 45 46 /** 47 * Hostname of the XMPP server. Usually servers use the same service name as the name 48 * of the server. However, there are some servers like google where host would be 49 * talk.google.com and the serviceName would be gmail.com. 50 */ 51 private String serviceName; 52 53 private String host; 54 private int port; 55 protected List<HostAddress> hostAddresses; 56 57 private String truststorePath; 58 private String truststoreType; 59 private String truststorePassword; 60 private String keystorePath; 61 private String keystoreType; 62 private String pkcs11Library; 63 private boolean verifyChainEnabled = false; 64 private boolean verifyRootCAEnabled = false; 65 private boolean selfSignedCertificateEnabled = false; 66 private boolean expiredCertificatesCheckEnabled = false; 67 private boolean notMatchingDomainCheckEnabled = false; 68 private boolean isRosterVersioningAvailable = false; 69 private SSLContext customSSLContext; 70 71 private boolean compressionEnabled = false; 72 73 private boolean saslAuthenticationEnabled = true; 74 /** 75 * Used to get information from the user 76 */ 77 private CallbackHandler callbackHandler; 78 79 private boolean debuggerEnabled = Connection.DEBUG_ENABLED; 80 81 // Flag that indicates if a reconnection should be attempted when abruptly disconnected 82 private boolean reconnectionAllowed = true; 83 84 // Holds the socket factory that is used to generate the socket in the connection 85 private SocketFactory socketFactory; 86 87 // Holds the authentication information for future reconnections 88 private String username; 89 private String password; 90 private String resource; 91 private boolean sendPresence = true; 92 private boolean rosterLoadedAtLogin = true; 93 private SecurityMode securityMode = SecurityMode.enabled; 94 95 // Holds the proxy information (such as proxyhost, proxyport, username, password etc) 96 protected ProxyInfo proxy; 97 98 /** 99 * Creates a new ConnectionConfiguration for the specified service name. 100 * A DNS SRV lookup will be performed to find out the actual host address 101 * and port to use for the connection. 102 * 103 * @param serviceName the name of the service provided by an XMPP server. 104 */ 105 public ConnectionConfiguration(String serviceName) { 106 // Perform DNS lookup to get host and port to use 107 hostAddresses = DNSUtil.resolveXMPPDomain(serviceName); 108 init(serviceName, ProxyInfo.forDefaultProxy()); 109 } 110 111 /** 112 * 113 */ 114 protected ConnectionConfiguration() { 115 /* Does nothing */ 116 } 117 118 /** 119 * Creates a new ConnectionConfiguration for the specified service name 120 * with specified proxy. 121 * A DNS SRV lookup will be performed to find out the actual host address 122 * and port to use for the connection. 123 * 124 * @param serviceName the name of the service provided by an XMPP server. 125 * @param proxy the proxy through which XMPP is to be connected 126 */ 127 public ConnectionConfiguration(String serviceName,ProxyInfo proxy) { 128 // Perform DNS lookup to get host and port to use 129 hostAddresses = DNSUtil.resolveXMPPDomain(serviceName); 130 init(serviceName, proxy); 131 } 132 133 /** 134 * Creates a new ConnectionConfiguration using the specified host, port and 135 * service name. This is useful for manually overriding the DNS SRV lookup 136 * process that's used with the {@link #ConnectionConfiguration(String)} 137 * constructor. For example, say that an XMPP server is running at localhost 138 * in an internal network on port 5222 but is configured to think that it's 139 * "example.com" for testing purposes. This constructor is necessary to connect 140 * to the server in that case since a DNS SRV lookup for example.com would not 141 * point to the local testing server. 142 * 143 * @param host the host where the XMPP server is running. 144 * @param port the port where the XMPP is listening. 145 * @param serviceName the name of the service provided by an XMPP server. 146 */ 147 public ConnectionConfiguration(String host, int port, String serviceName) { 148 initHostAddresses(host, port); 149 init(serviceName, ProxyInfo.forDefaultProxy()); 150 } 151 152 /** 153 * Creates a new ConnectionConfiguration using the specified host, port and 154 * service name. This is useful for manually overriding the DNS SRV lookup 155 * process that's used with the {@link #ConnectionConfiguration(String)} 156 * constructor. For example, say that an XMPP server is running at localhost 157 * in an internal network on port 5222 but is configured to think that it's 158 * "example.com" for testing purposes. This constructor is necessary to connect 159 * to the server in that case since a DNS SRV lookup for example.com would not 160 * point to the local testing server. 161 * 162 * @param host the host where the XMPP server is running. 163 * @param port the port where the XMPP is listening. 164 * @param serviceName the name of the service provided by an XMPP server. 165 * @param proxy the proxy through which XMPP is to be connected 166 */ 167 public ConnectionConfiguration(String host, int port, String serviceName, ProxyInfo proxy) { 168 initHostAddresses(host, port); 169 init(serviceName, proxy); 170 } 171 172 /** 173 * Creates a new ConnectionConfiguration for a connection that will connect 174 * to the desired host and port. 175 * 176 * @param host the host where the XMPP server is running. 177 * @param port the port where the XMPP is listening. 178 */ 179 public ConnectionConfiguration(String host, int port) { 180 initHostAddresses(host, port); 181 init(host, ProxyInfo.forDefaultProxy()); 182 } 183 184 /** 185 * Creates a new ConnectionConfiguration for a connection that will connect 186 * to the desired host and port with desired proxy. 187 * 188 * @param host the host where the XMPP server is running. 189 * @param port the port where the XMPP is listening. 190 * @param proxy the proxy through which XMPP is to be connected 191 */ 192 public ConnectionConfiguration(String host, int port, ProxyInfo proxy) { 193 initHostAddresses(host, port); 194 init(host, proxy); 195 } 196 197 protected void init(String serviceName, ProxyInfo proxy) { 198 this.serviceName = serviceName; 199 this.proxy = proxy; 200 201 // Build the default path to the cacert truststore file. By default we are 202 // going to use the file located in $JREHOME/lib/security/cacerts. 203 String javaHome = System.getProperty("java.home"); 204 StringBuilder buffer = new StringBuilder(); 205 buffer.append(javaHome).append(File.separator).append("lib"); 206 buffer.append(File.separator).append("security"); 207 buffer.append(File.separator).append("cacerts"); 208 truststorePath = buffer.toString(); 209 // Set the default store type 210 truststoreType = "jks"; 211 // Set the default password of the cacert file that is "changeit" 212 truststorePassword = "changeit"; 213 keystorePath = System.getProperty("javax.net.ssl.keyStore"); 214 keystoreType = "jks"; 215 pkcs11Library = "pkcs11.config"; 216 217 //Setting the SocketFactory according to proxy supplied 218 socketFactory = proxy.getSocketFactory(); 219 } 220 221 /** 222 * Sets the server name, also known as XMPP domain of the target server. 223 * 224 * @param serviceName the XMPP domain of the target server. 225 */ 226 public void setServiceName(String serviceName) { 227 this.serviceName = serviceName; 228 } 229 230 /** 231 * Returns the server name of the target server. 232 * 233 * @return the server name of the target server. 234 */ 235 public String getServiceName() { 236 return serviceName; 237 } 238 239 /** 240 * Returns the host to use when establishing the connection. The host and port to use 241 * might have been resolved by a DNS lookup as specified by the XMPP spec (and therefore 242 * may not match the {@link #getServiceName service name}. 243 * 244 * @return the host to use when establishing the connection. 245 */ 246 public String getHost() { 247 return host; 248 } 249 250 /** 251 * Returns the port to use when establishing the connection. The host and port to use 252 * might have been resolved by a DNS lookup as specified by the XMPP spec. 253 * 254 * @return the port to use when establishing the connection. 255 */ 256 public int getPort() { 257 return port; 258 } 259 260 public void setUsedHostAddress(HostAddress hostAddress) { 261 this.host = hostAddress.getFQDN(); 262 this.port = hostAddress.getPort(); 263 } 264 265 /** 266 * Returns the TLS security mode used when making the connection. By default, 267 * the mode is {@link SecurityMode#enabled}. 268 * 269 * @return the security mode. 270 */ 271 public SecurityMode getSecurityMode() { 272 return securityMode; 273 } 274 275 /** 276 * Sets the TLS security mode used when making the connection. By default, 277 * the mode is {@link SecurityMode#enabled}. 278 * 279 * @param securityMode the security mode. 280 */ 281 public void setSecurityMode(SecurityMode securityMode) { 282 this.securityMode = securityMode; 283 } 284 285 /** 286 * Retuns the path to the trust store file. The trust store file contains the root 287 * certificates of several well known CAs. By default, will attempt to use the 288 * the file located in $JREHOME/lib/security/cacerts. 289 * 290 * @return the path to the truststore file. 291 */ 292 public String getTruststorePath() { 293 return truststorePath; 294 } 295 296 /** 297 * Sets the path to the trust store file. The truststore file contains the root 298 * certificates of several well?known CAs. By default Smack is going to use 299 * the file located in $JREHOME/lib/security/cacerts. 300 * 301 * @param truststorePath the path to the truststore file. 302 */ 303 public void setTruststorePath(String truststorePath) { 304 this.truststorePath = truststorePath; 305 } 306 307 /** 308 * Returns the trust store type, or <tt>null</tt> if it's not set. 309 * 310 * @return the trust store type. 311 */ 312 public String getTruststoreType() { 313 return truststoreType; 314 } 315 316 /** 317 * Sets the trust store type. 318 * 319 * @param truststoreType the trust store type. 320 */ 321 public void setTruststoreType(String truststoreType) { 322 this.truststoreType = truststoreType; 323 } 324 325 /** 326 * Returns the password to use to access the trust store file. It is assumed that all 327 * certificates share the same password in the trust store. 328 * 329 * @return the password to use to access the truststore file. 330 */ 331 public String getTruststorePassword() { 332 return truststorePassword; 333 } 334 335 /** 336 * Sets the password to use to access the trust store file. It is assumed that all 337 * certificates share the same password in the trust store. 338 * 339 * @param truststorePassword the password to use to access the truststore file. 340 */ 341 public void setTruststorePassword(String truststorePassword) { 342 this.truststorePassword = truststorePassword; 343 } 344 345 /** 346 * Retuns the path to the keystore file. The key store file contains the 347 * certificates that may be used to authenticate the client to the server, 348 * in the event the server requests or requires it. 349 * 350 * @return the path to the keystore file. 351 */ 352 public String getKeystorePath() { 353 return keystorePath; 354 } 355 356 /** 357 * Sets the path to the keystore file. The key store file contains the 358 * certificates that may be used to authenticate the client to the server, 359 * in the event the server requests or requires it. 360 * 361 * @param keystorePath the path to the keystore file. 362 */ 363 public void setKeystorePath(String keystorePath) { 364 this.keystorePath = keystorePath; 365 } 366 367 /** 368 * Returns the keystore type, or <tt>null</tt> if it's not set. 369 * 370 * @return the keystore type. 371 */ 372 public String getKeystoreType() { 373 return keystoreType; 374 } 375 376 /** 377 * Sets the keystore type. 378 * 379 * @param keystoreType the keystore type. 380 */ 381 public void setKeystoreType(String keystoreType) { 382 this.keystoreType = keystoreType; 383 } 384 385 386 /** 387 * Returns the PKCS11 library file location, needed when the 388 * Keystore type is PKCS11. 389 * 390 * @return the path to the PKCS11 library file 391 */ 392 public String getPKCS11Library() { 393 return pkcs11Library; 394 } 395 396 /** 397 * Sets the PKCS11 library file location, needed when the 398 * Keystore type is PKCS11 399 * 400 * @param pkcs11Library the path to the PKCS11 library file 401 */ 402 public void setPKCS11Library(String pkcs11Library) { 403 this.pkcs11Library = pkcs11Library; 404 } 405 406 /** 407 * Returns true if the whole chain of certificates presented by the server are going to 408 * be checked. By default the certificate chain is not verified. 409 * 410 * @return true if the whole chaing of certificates presented by the server are going to 411 * be checked. 412 */ 413 public boolean isVerifyChainEnabled() { 414 return verifyChainEnabled; 415 } 416 417 /** 418 * Sets if the whole chain of certificates presented by the server are going to 419 * be checked. By default the certificate chain is not verified. 420 * 421 * @param verifyChainEnabled if the whole chaing of certificates presented by the server 422 * are going to be checked. 423 */ 424 public void setVerifyChainEnabled(boolean verifyChainEnabled) { 425 this.verifyChainEnabled = verifyChainEnabled; 426 } 427 428 /** 429 * Returns true if root CA checking is going to be done. By default checking is disabled. 430 * 431 * @return true if root CA checking is going to be done. 432 */ 433 public boolean isVerifyRootCAEnabled() { 434 return verifyRootCAEnabled; 435 } 436 437 /** 438 * Sets if root CA checking is going to be done. By default checking is disabled. 439 * 440 * @param verifyRootCAEnabled if root CA checking is going to be done. 441 */ 442 public void setVerifyRootCAEnabled(boolean verifyRootCAEnabled) { 443 this.verifyRootCAEnabled = verifyRootCAEnabled; 444 } 445 446 /** 447 * Returns true if self-signed certificates are going to be accepted. By default 448 * this option is disabled. 449 * 450 * @return true if self-signed certificates are going to be accepted. 451 */ 452 public boolean isSelfSignedCertificateEnabled() { 453 return selfSignedCertificateEnabled; 454 } 455 456 /** 457 * Sets if self-signed certificates are going to be accepted. By default 458 * this option is disabled. 459 * 460 * @param selfSignedCertificateEnabled if self-signed certificates are going to be accepted. 461 */ 462 public void setSelfSignedCertificateEnabled(boolean selfSignedCertificateEnabled) { 463 this.selfSignedCertificateEnabled = selfSignedCertificateEnabled; 464 } 465 466 /** 467 * Returns true if certificates presented by the server are going to be checked for their 468 * validity. By default certificates are not verified. 469 * 470 * @return true if certificates presented by the server are going to be checked for their 471 * validity. 472 */ 473 public boolean isExpiredCertificatesCheckEnabled() { 474 return expiredCertificatesCheckEnabled; 475 } 476 477 /** 478 * Sets if certificates presented by the server are going to be checked for their 479 * validity. By default certificates are not verified. 480 * 481 * @param expiredCertificatesCheckEnabled if certificates presented by the server are going 482 * to be checked for their validity. 483 */ 484 public void setExpiredCertificatesCheckEnabled(boolean expiredCertificatesCheckEnabled) { 485 this.expiredCertificatesCheckEnabled = expiredCertificatesCheckEnabled; 486 } 487 488 /** 489 * Returns true if certificates presented by the server are going to be checked for their 490 * domain. By default certificates are not verified. 491 * 492 * @return true if certificates presented by the server are going to be checked for their 493 * domain. 494 */ 495 public boolean isNotMatchingDomainCheckEnabled() { 496 return notMatchingDomainCheckEnabled; 497 } 498 499 /** 500 * Sets if certificates presented by the server are going to be checked for their 501 * domain. By default certificates are not verified. 502 * 503 * @param notMatchingDomainCheckEnabled if certificates presented by the server are going 504 * to be checked for their domain. 505 */ 506 public void setNotMatchingDomainCheckEnabled(boolean notMatchingDomainCheckEnabled) { 507 this.notMatchingDomainCheckEnabled = notMatchingDomainCheckEnabled; 508 } 509 510 /** 511 * Gets the custom SSLContext for SSL sockets. This is null by default. 512 * 513 * @return the SSLContext previously set with setCustomSSLContext() or null. 514 */ 515 public SSLContext getCustomSSLContext() { 516 return this.customSSLContext; 517 } 518 519 /** 520 * Sets a custom SSLContext for creating SSL sockets. A custom Context causes all other 521 * SSL/TLS realted settings to be ignored. 522 * 523 * @param context the custom SSLContext for new sockets; null to reset default behavior. 524 */ 525 public void setCustomSSLContext(SSLContext context) { 526 this.customSSLContext = context; 527 } 528 529 /** 530 * Returns true if the connection is going to use stream compression. Stream compression 531 * will be requested after TLS was established (if TLS was enabled) and only if the server 532 * offered stream compression. With stream compression network traffic can be reduced 533 * up to 90%. By default compression is disabled. 534 * 535 * @return true if the connection is going to use stream compression. 536 */ 537 public boolean isCompressionEnabled() { 538 return compressionEnabled; 539 } 540 541 /** 542 * Sets if the connection is going to use stream compression. Stream compression 543 * will be requested after TLS was established (if TLS was enabled) and only if the server 544 * offered stream compression. With stream compression network traffic can be reduced 545 * up to 90%. By default compression is disabled. 546 * 547 * @param compressionEnabled if the connection is going to use stream compression. 548 */ 549 public void setCompressionEnabled(boolean compressionEnabled) { 550 this.compressionEnabled = compressionEnabled; 551 } 552 553 /** 554 * Returns true if the client is going to use SASL authentication when logging into the 555 * server. If SASL authenticatin fails then the client will try to use non-sasl authentication. 556 * By default SASL is enabled. 557 * 558 * @return true if the client is going to use SASL authentication when logging into the 559 * server. 560 */ 561 public boolean isSASLAuthenticationEnabled() { 562 return saslAuthenticationEnabled; 563 } 564 565 /** 566 * Sets whether the client will use SASL authentication when logging into the 567 * server. If SASL authenticatin fails then the client will try to use non-sasl authentication. 568 * By default, SASL is enabled. 569 * 570 * @param saslAuthenticationEnabled if the client is going to use SASL authentication when 571 * logging into the server. 572 */ 573 public void setSASLAuthenticationEnabled(boolean saslAuthenticationEnabled) { 574 this.saslAuthenticationEnabled = saslAuthenticationEnabled; 575 } 576 577 /** 578 * Returns true if the new connection about to be establish is going to be debugged. By 579 * default the value of {@link Connection#DEBUG_ENABLED} is used. 580 * 581 * @return true if the new connection about to be establish is going to be debugged. 582 */ 583 public boolean isDebuggerEnabled() { 584 return debuggerEnabled; 585 } 586 587 /** 588 * Sets if the new connection about to be establish is going to be debugged. By 589 * default the value of {@link Connection#DEBUG_ENABLED} is used. 590 * 591 * @param debuggerEnabled if the new connection about to be establish is going to be debugged. 592 */ 593 public void setDebuggerEnabled(boolean debuggerEnabled) { 594 this.debuggerEnabled = debuggerEnabled; 595 } 596 597 /** 598 * Sets if the reconnection mechanism is allowed to be used. By default 599 * reconnection is allowed. 600 * 601 * @param isAllowed if the reconnection mechanism is allowed to use. 602 */ 603 public void setReconnectionAllowed(boolean isAllowed) { 604 this.reconnectionAllowed = isAllowed; 605 } 606 /** 607 * Returns if the reconnection mechanism is allowed to be used. By default 608 * reconnection is allowed. 609 * 610 * @return if the reconnection mechanism is allowed to be used. 611 */ 612 public boolean isReconnectionAllowed() { 613 return this.reconnectionAllowed; 614 } 615 616 /** 617 * Sets the socket factory used to create new xmppConnection sockets. 618 * This is useful when connecting through SOCKS5 proxies. 619 * 620 * @param socketFactory used to create new sockets. 621 */ 622 public void setSocketFactory(SocketFactory socketFactory) { 623 this.socketFactory = socketFactory; 624 } 625 626 /** 627 * Sets if an initial available presence will be sent to the server. By default 628 * an available presence will be sent to the server indicating that this presence 629 * is not online and available to receive messages. If you want to log in without 630 * being 'noticed' then pass a <tt>false</tt> value. 631 * 632 * @param sendPresence true if an initial available presence will be sent while logging in. 633 */ 634 public void setSendPresence(boolean sendPresence) { 635 this.sendPresence = sendPresence; 636 } 637 638 /** 639 * Returns true if the roster will be loaded from the server when logging in. This 640 * is the common behaviour for clients but sometimes clients may want to differ this 641 * or just never do it if not interested in rosters. 642 * 643 * @return true if the roster will be loaded from the server when logging in. 644 */ 645 public boolean isRosterLoadedAtLogin() { 646 return rosterLoadedAtLogin; 647 } 648 649 /** 650 * Sets if the roster will be loaded from the server when logging in. This 651 * is the common behaviour for clients but sometimes clients may want to differ this 652 * or just never do it if not interested in rosters. 653 * 654 * @param rosterLoadedAtLogin if the roster will be loaded from the server when logging in. 655 */ 656 public void setRosterLoadedAtLogin(boolean rosterLoadedAtLogin) { 657 this.rosterLoadedAtLogin = rosterLoadedAtLogin; 658 } 659 660 /** 661 * Returns a CallbackHandler to obtain information, such as the password or 662 * principal information during the SASL authentication. A CallbackHandler 663 * will be used <b>ONLY</b> if no password was specified during the login while 664 * using SASL authentication. 665 * 666 * @return a CallbackHandler to obtain information, such as the password or 667 * principal information during the SASL authentication. 668 */ 669 public CallbackHandler getCallbackHandler() { 670 return callbackHandler; 671 } 672 673 /** 674 * Sets a CallbackHandler to obtain information, such as the password or 675 * principal information during the SASL authentication. A CallbackHandler 676 * will be used <b>ONLY</b> if no password was specified during the login while 677 * using SASL authentication. 678 * 679 * @param callbackHandler to obtain information, such as the password or 680 * principal information during the SASL authentication. 681 */ 682 public void setCallbackHandler(CallbackHandler callbackHandler) { 683 this.callbackHandler = callbackHandler; 684 } 685 686 /** 687 * Returns the socket factory used to create new xmppConnection sockets. 688 * This is useful when connecting through SOCKS5 proxies. 689 * 690 * @return socketFactory used to create new sockets. 691 */ 692 public SocketFactory getSocketFactory() { 693 return this.socketFactory; 694 } 695 696 public List<HostAddress> getHostAddresses() { 697 return Collections.unmodifiableList(hostAddresses); 698 } 699 700 /** 701 * An enumeration for TLS security modes that are available when making a connection 702 * to the XMPP server. 703 */ 704 public static enum SecurityMode { 705 706 /** 707 * Securirty via TLS encryption is required in order to connect. If the server 708 * does not offer TLS or if the TLS negotiaton fails, the connection to the server 709 * will fail. 710 */ 711 required, 712 713 /** 714 * Security via TLS encryption is used whenever it's available. This is the 715 * default setting. 716 */ 717 enabled, 718 719 /** 720 * Security via TLS encryption is disabled and only un-encrypted connections will 721 * be used. If only TLS encryption is available from the server, the connection 722 * will fail. 723 */ 724 disabled 725 } 726 727 /** 728 * Returns the username to use when trying to reconnect to the server. 729 * 730 * @return the username to use when trying to reconnect to the server. 731 */ 732 String getUsername() { 733 return this.username; 734 } 735 736 /** 737 * Returns the password to use when trying to reconnect to the server. 738 * 739 * @return the password to use when trying to reconnect to the server. 740 */ 741 String getPassword() { 742 return this.password; 743 } 744 745 /** 746 * Returns the resource to use when trying to reconnect to the server. 747 * 748 * @return the resource to use when trying to reconnect to the server. 749 */ 750 String getResource() { 751 return resource; 752 } 753 754 boolean isRosterVersioningAvailable(){ 755 return isRosterVersioningAvailable; 756 } 757 758 void setRosterVersioningAvailable(boolean enabled){ 759 isRosterVersioningAvailable = enabled; 760 } 761 762 /** 763 * Returns true if an available presence should be sent when logging in while reconnecting. 764 * 765 * @return true if an available presence should be sent when logging in while reconnecting 766 */ 767 boolean isSendPresence() { 768 return sendPresence; 769 } 770 771 void setLoginInfo(String username, String password, String resource) { 772 this.username = username; 773 this.password = password; 774 this.resource = resource; 775 } 776 777 private void initHostAddresses(String host, int port) { 778 hostAddresses = new ArrayList<HostAddress>(1); 779 HostAddress hostAddress; 780 try { 781 hostAddress = new HostAddress(host, port); 782 } catch (Exception e) { 783 throw new IllegalStateException(e); 784 } 785 hostAddresses.add(hostAddress); 786 } 787 } 788