Commit Graph

118 Commits

Author SHA1 Message Date
Florian Schmaus a1630d033e Add support for DNSSEC/DANE
This closes the cycle which started with a GSOC 2015 project under the
umbrella of the XSF adding DNSSEC/DANE support to MiniDNS.

Fixes SMACK-366.
2016-10-31 10:45:38 +01:00
Florian Schmaus c379ae07d5 Initialize the Key Store
as otherwhise the following could happen:

WARNING: Connection XMPPTCPConnection[not-authenticated] (0) closed with error
java.security.KeyStoreException: Uninitialized keystore
	at java.security.KeyStore.aliases(KeyStore.java:1233)
	at sun.security.ssl.SunX509KeyManagerImpl.<init>(SunX509KeyManagerImpl.java:127)
	at sun.security.ssl.KeyManagerFactoryImpl$SunX509.engineInit(KeyManagerFactoryImpl.java:70)
	at javax.net.ssl.KeyManagerFactory.init(KeyManagerFactory.java:256)
	at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:739)
	at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1000(XMPPTCPConnection.java:146)
	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1026)
	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:960)
	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:975)
	at java.lang.Thread.run(Thread.java:745)

org.jivesoftware.smack.SmackException: java.security.KeyStoreException: Uninitialized keystore
  org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1033)
  org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:960)
  org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:975)
  java.lang.Thread.run(Thread.java:745)
java.security.KeyStoreException: Uninitialized keystore
  java.security.KeyStore.aliases(KeyStore.java:1233)
  sun.security.ssl.SunX509KeyManagerImpl.<init>(SunX509KeyManagerImpl.java:127)
  sun.security.ssl.KeyManagerFactoryImpl$SunX509.engineInit(KeyManagerFactoryImpl.java:70)
  javax.net.ssl.KeyManagerFactory.init(KeyManagerFactory.java:256)
  org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:739)
  org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1000(XMPPTCPConnection.java:146)
  org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1026)
  org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:960)
  org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:975)
  java.lang.Thread.run(Thread.java:745)
2016-10-20 21:54:24 +02:00
Florian Schmaus 73fcbc6b27 Do not re-use the Socket after connect() failed
Fixes SMACK-724.
2016-06-21 21:23:30 +02:00
Florian Schmaus 30861fb7ce Add comment about dropping SM state on stream errors.
Related to SMACK-696.
2016-06-15 09:19:25 +02:00
Florian Schmaus 08c93da56a Delay notifyConnectionError in writer shutdown 2016-06-09 09:20:09 +02:00
Florian Schmaus 8deac592fb Finer logs in XMPPTCPConnection.shutdown() 2016-06-09 09:20:09 +02:00
Florian Schmaus 90f52fcc3b Suppress 'unused' warning in XMPPTCPConnection 2016-05-22 22:50:49 +02:00
Florian Schmaus 4c63cfafd7 Rework support for Proxy connections
in order to improve support for Tor connections.

This makes it possible to establish a connection to an .onion domain by
manually setting host and port in the ConnectionConfiguration and
configuring a Socks5Proxy pointing to a Tor node.

Fixes SMACK-720.
2016-05-10 18:57:04 +02:00
Florian Schmaus b94b2586e2 Smack 4.1.7
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQF8BAABCgBmBQJXD/2lXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
 ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQxMzU3QjAxODY1QjI1MDNDMTg0NTNEMjA4
 Q0FDMkE5Njc4NTQ4RTM1AAoJEIysKpZ4VI41rggH/0DjBLpCfTSdjjKGFNChc+1V
 dW9PaPGFUiPuTt3T2NEa74jGYe4PsPpy5zDsJ8uYi2aq3LAiCQvfk+F5LXjRJFoa
 eftz0GtPvfP42oFg8wyDAebFtb0OtE7aJueSRkYGhA1+kzHBbJ9s6TxqDWcB0UWC
 puLh/DEWDFGX5njln+l10O7b10G0+bSrvece22eP0sQIv4hvZJoPQ5rOpCR1wibL
 ldp6wXI6C/b/oQS9MjHq9SV10S+5GykBqN/UzcFnwRVHLbasqnXeNFLGOnMtx0g9
 DmOolAYKGBN5m7m0rqEj9R+OyNgtefV8sCHE69iNAlpQhbmTqPd5rIhIXIII4U4=
 =yWKV
 -----END PGP SIGNATURE-----

Merge tag '4.1.7'

Smack 4.1.7
2016-04-14 22:30:34 +02:00
Tomas Nosek cf3024668e Fix XMPPTCPConnection.setEnabledSSL(Protocols|Ciphers)
The problem caused by opening input/ output stream before setting ssl
parameters to SSLSession and fixed by changing order of this operations.

Fixes SMACK-712.

Minor-Modifications-By: Florian Schmaus <flo@geekplace.eu>
2016-02-17 09:18:36 +01:00
Florian Schmaus 5c00172f6a Remove log statement
was added to diagnose an issue, should have never made it into master.
2016-02-10 14:54:32 +01:00
Florian Schmaus e0cbb95b5d Check callbackHandler/keystorePath for null
before using it.
2016-01-23 14:16:38 +01:00
Florian Schmaus d5c7eb7349 Remove unnecessary code in XMPPTCPConnection 2016-01-23 14:16:37 +01:00
Florian Schmaus 085c3469e9 Fix XMPPTCPConnection.proceedTLSReceived()
The method was changed in c6594aec2f, but
this change causes issues if Smack is used on Android *without* a custom
SSLContext:

Caused by: java.security.KeyStoreException: java.security.NoSuchAlgorithmException: KeyStore jks implementation not found
 at java.security.KeyStore.getInstance(KeyStore.java:119)
 at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:697)

Caused by: java.security.NoSuchAlgorithmException: KeyManagerFactory SunX509 implementation not found
 at org.apache.harmony.security.fortress.Engine.notFound(Engine.java:177)
 at org.apache.harmony.security.fortress.Engine.getInstance(Engine.java:151)
 at javax.net.ssl.KeyManagerFactory.getInstance(KeyManagerFactory.java:77)
 at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:708)
2016-01-23 14:16:37 +01:00
Florian Schmaus 85e818cffb Smack 4.1.6
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQF8BAABCgBmBQJWo2DDXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
 ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQxMzU3QjAxODY1QjI1MDNDMTg0NTNEMjA4
 Q0FDMkE5Njc4NTQ4RTM1AAoJEIysKpZ4VI41Q0AH/22s1WOI0mgFjQnuSRoZwtNQ
 WN7eudnKlnknmNrJwPcbW1EYO/kNj1SQnqv7ed2aVpyeFFOf1/CUIgq57K1hBjA0
 gTVtv0vK9pABZOmYY5UYURF6AZqKC2s5grHzOgIQbEhT0IOxc/Kz3/ubRxYwvxQl
 lKenkNw75NMViylC0wFQc673SUuwPKyS3PjFm44ASxhbHNIexqagsxNU3MICmCWr
 vGuyv2pGuVvVbILdqqoRGJhucHUs8HnYjA/H1lAlXH4FE0k3EXnjtztHaiLXQoxC
 I2MbunwlVWcE5099V85wcgBbtMWqgljyz+Yh8MmkPojZTVnWjYPUWybK4G8TREg=
 =1rYD
 -----END PGP SIGNATURE-----

Merge tag '4.1.6'

Smack 4.1.6
2016-01-23 13:27:16 +01:00
Florian Schmaus 57838f1ffe Enable Stream Management by default
Fixes SMACK-655.
2016-01-10 18:57:19 +01:00
Florian Schmaus 7845f21465 Only create the socket once
in XMPPTCPConnection.connectUsingConfiguration().
2016-01-10 18:34:54 +01:00
Florian Schmaus 7a8d66e9e6 Improve logging of failed connection attempts
also improve XMPPTCPConnection.connectUsingConfiguration(): Try further
hostAddresses if getAllByName failes.

Fixes SMACK-711
2016-01-10 18:34:54 +01:00
Florian Schmaus 45feaecdf7 Make XMPPError imutable and add stanza reference 2015-12-09 10:48:52 +01:00
Florian Schmaus 352e422562 Drop SM state *before* binding the resource
as otherwise <bind/> and <session/> may be duplicated on reconnect.

Fixes SMACK-706.
2015-12-03 13:47:08 +01:00
Florian Schmaus 8dcb3c11ff Smack 4.1.5
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQF8BAABCgBmBQJWUjTuXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
 ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQxMzU3QjAxODY1QjI1MDNDMTg0NTNEMjA4
 Q0FDMkE5Njc4NTQ4RTM1AAoJEIysKpZ4VI41zp8H/iRB0CtFvxVBFwRpP2HB0Iyc
 VzdxJTVXgJ7s8V3Us2Gmm0chUvs1wybshIdZ090NX7huZ4F1rWrOP7qt9S4soKgX
 LNdKTKTTNJ61jktLkG1HjA8yJr1Zu+XFK10Ne8997N9TnhbcVYAhsuTb8SRE8dlE
 G1Qihe2guJCCnWJhz9bsCXyAFt/fM5rSb/sgs/kXkE1W5bYeMHpFMvqMfab8NPBP
 fkt/NSxfqLfrRJneynnSwGSvRitDxpfRCcxLktTdDO31eryayIyiQIhaUhFYIGJQ
 tKx0/7HdCkgdUueBdtoQ/O02rjJ+kYqN2F3CErcIbB//3R6WKNF61XzOY81egYc=
 =dklO
 -----END PGP SIGNATURE-----

Merge tag '4.1.5'

Smack 4.1.5
2015-11-22 23:14:02 +01:00
Florian Schmaus cc758b8f59 Use ackedStanzasCount instead of handledCount in processHandledCount
for the initial size of the ackedStanzas list.

Thanks to Juan Antonio for reporting.
2015-10-21 17:51:08 +02:00
Florian Schmaus 9c9d1f893a Typo in XMPPTCPConnection s/ResumptiodDefault/ResumptionDefault/ 2015-10-21 16:04:26 +02:00
Florian Schmaus 640849dac5 Revert "Typo in XMPPTCPConnection s/ResumptiodDefault/ResumptionDefault/"
This reverts commit 7ceb5f09df.

Somehow 7ceb5f09 introduced from the master branch into the 4.1 branch.
2015-10-21 16:04:26 +02:00
Florian Schmaus f5115f4666 Empty unacknowledgedStanzas when 'resumed' is received
by changing

stanzasToResend.addAll(unacknowledgedStanzas);

to

unacknowledgedStanzas.drainTo(stanzasToResend);

Also use sendStanzaInternal to call the callbacks, which also requires
the smEnabledSyncPoint to got signaled.

Fixes SMACK-700. Thanks to Juan Antonio for reporting this.
2015-10-21 16:04:02 +02:00
Florian Schmaus 4f39c5b9c9 Remove not thrown NotConnectedException in XMPPTCPConnection 2015-09-26 12:42:35 +02:00
Florian Schmaus 7ceb5f09df Typo in XMPPTCPConnection s/ResumptiodDefault/ResumptionDefault/ 2015-09-26 12:42:35 +02:00
Florian Schmaus 8aa3f94c90 Drop stream state after stream error
Fixes SMACK-696.
2015-08-26 21:55:02 +02:00
Florian Schmaus d54dafc499 Don't return if securityMode is 'disabled'
in afterFeaturesReceived. As this will cause
maybeCompressFeaturesReceived.reportSuccess() never to be called if the
server announces 'starttls' but security mode is set to 'disabled' and
if 'compression' is also announced.

Fixes SMACK-678.
2015-06-25 11:07:25 +02:00
Florian Schmaus 576980097e Request SM ack when re-sending after stream resumption
Fixes SMACK-667.
2015-05-19 14:21:52 +02:00
Florian Schmaus dabbb40de6 Fix isSmResumptionPossible() returning wrong values
The cases where reversed. Change the condition for better readability.

Also fix int and long handling in the computation of
maxResumptionMillies.

Fixes SMACK-654.
2015-04-07 08:51:03 +02:00
Florian Schmaus 3b6891b0d0 Fix integer overflow if no max resumption time
is specified by client and server.

Fixes SMACK-653.
2015-04-07 08:51:03 +02:00
Florian Schmaus 5e86db4f80 Substitute 'packet' with 'stanza(/packet)' in javadoc 2015-03-21 09:36:28 +01:00
Florian Schmaus 92c76d1023 Only reset smSessionId if the stream is no longer resumeable 2015-03-10 13:17:18 +01:00
Florian Schmaus ed4fa3390f Add XMPPConnection.sendStanza(Stanza)
and deprecate sendPacket().
2015-03-04 21:46:44 +01:00
Florian Schmaus 96bb37f924 Fix counting bug Stream Management implementation
Previously Smack would put messages in the unacknowledgedStanzas queue
after it received the 'enabled' element, when it should do so right
after sending the 'enable' stream element.

Imagine a session where '-->' denotes "received from server" and '<--'
"sent to server"

<-- enable
--> iq roster push set
--> presence some presence
<-- iq roster push result
--> enabled

then Smack would not add the iq roster push result stanza to the
unacknowledgedStanzas queue.

This fixes the issue by initializing the unacknowledgedStanzas queue
when the writer thread encounters a 'Enable' stream element.

The additional 'instanceof' invocation in the writer thread should not
be a big performance issue, since the existing "instanceof Stanza" check
should be the common case and the "instanceof Enable" is an exclusive
alternative to this case.
2015-03-02 16:17:47 +01:00
Florian Schmaus 75ec271c6c Rename PacketListener to StanzaListener
and add the PacketListener as deprecated interface.
2015-03-02 15:49:56 +01:00
Florian Schmaus d4a6d8e653 Rename PacketFilter (and implementing classes) and PacketExtension
to StanzaFilter and ExtensionElement.
2015-02-28 13:49:38 +01:00
Florian Schmaus 4b7a396b9b Improve logging wrt XMPPTCPConnection.shutdownDone 2015-02-26 08:27:19 +01:00
Florian Schmaus 90969e252a Improve the bundle and defer mechanism
Instead of always bundling when the queue is empty, only bundle once the
queue has become empty and then only if it has been become empty again.

The previous algorithm would also bundle and defer the last element
found in the queue. This is not the case now.
2015-02-22 10:51:44 +01:00
Florian Schmaus 8b0ccd7420 Minor javadoc fixes and improvements 2015-02-22 10:41:53 +01:00
Florian Schmaus bfcb403673 Fix Stream Management ack listner invocation
aborting to early, because of a 'return' statement, when 'continue'
should be used.

Thanks to Daniele Ricci for reporting this bug.
2015-02-19 23:01:38 +01:00
Florian Schmaus 5f4374ec26 Use host(name) to construct the SSLSocket
in XMPPTCPConnection.

So that the hostname and not the IP is available to the SSLSocket and
the SSLSession, which handed over to HostnameVerifier. This leaves the
HostnameVerifier with the

- name of the XMPP service (first argument of verify(String, SSLSession)
- name of the used host (found in the SSLSession)

allowing more complex verification mechanisms performed by the
HostnameVerifier.
2015-02-19 12:14:16 +01:00
Florian Schmaus d415661e35 Add BundleAndDeferCallback to smack-tcp 2015-02-19 12:14:10 +01:00
Florian Schmaus aa8daba1cf Add StreamManagemtCounterError
to allow graceful connectionClosedOnError() disconnects, since we
received a bunch of reports where the counter seems wrong, which is
causing a NPE in a thread pool executor, causing the VM or Android App
to terminate.

Now we throw the StreamManagementCounterError instead.
2015-02-18 12:07:44 +01:00
Florian Schmaus 7897fca876 Add comment about Stream Management's unacked stanzas queue 2015-02-18 11:59:45 +01:00
Florian Schmaus 57c1b57b7c s/ a XMPP/ an XMPP/ 2015-02-12 12:13:19 +01:00
Florian Schmaus 96e3d5c533 Add XMPPTCPConnection(CharSequence, String) constructor 2015-02-09 07:35:16 +01:00
Florian Schmaus 1630b44b8d Reset smSessionId on XMPPTCPConnection.disconnect() 2015-02-09 07:35:15 +01:00
Florian Schmaus 3b8f4c144e Add missing space in log statement within XMPPTCPConnection 2015-02-09 07:35:15 +01:00