Commit Graph

375 Commits

Author SHA1 Message Date
Florian Schmaus 4aacdc5154 Add smack-websocket-java11
This also lifts a bunch of logic from smack-websocket-okhttp into
smack-websocket. Furthermore, the following subprojects require now
Java 11:
- smack-integration-test
- smack-omemo-signal-integration-test
- smack-repl
- smack-websocket-java11

Related tracking issue: SMACK-835
2021-02-14 20:34:40 +01:00
Florian Schmaus a7b3303f3e Bump ErrorProne to 2.5.1 and refactor Providers a bit
This also resulted in a refactoring of the Providers and parsing
Exceptions. NumberFormatException and ParseException can now be thrown
directly, the wrapping in a SmackParsingException is down at a higher
layer, i.e. in AbstractProvider.
2021-01-29 09:26:15 +01:00
Florian Schmaus 35a71f0131 Merge branch '4.4' 2021-01-06 13:51:38 +01:00
Florian Schmaus fcc372754e Fix NPE in BoBIQ by adding XmlStringBuilder.optIntAttribute(String, Integer)
The method was missing and hence BoBIQ used optIntAttribute(String,
int) instead, which resulted in an NPE if the Integer was null.

Fixes SMACK-895.
2021-01-06 13:45:13 +01:00
Florian Schmaus d8642847ea Smack 4.4.0
-----BEGIN PGP SIGNATURE-----
 
 iQGTBAABCgB9FiEEl3UFnzoh3OFr5PuuIjmn6PWFIFIFAl/Msl5fFIAAAAAALgAo
 aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDk3
 NzUwNTlGM0EyMURDRTE2QkU0RkJBRTIyMzlBN0U4RjU4NTIwNTIACgkQIjmn6PWF
 IFIq8gf9GZp0Cl9Gr+seA/C8nczE/cNRKfHnDR224klbjlGrnojb+bL2QgeKG6wN
 u/eL3+UMus8uw3+R8NKARawqt/r6mbk4bgdGEbzoByLO6iiPYTr7TuZmTOQyZa5L
 tMNkFIvfvMzDeDDqI4z4uTgT3s7YBg0d4BT7cL8T6RaZGHF57OxqhWnKxMuaiTXH
 HJzVTPrtAcYg17QZl5+mrhiWyynE5+4QGeluYHlh7vvsniwNOqrwO1vWHg2BX003
 DjaHK+6oLjKxVljCklXxE7Wsx0VcMrBfv2qZwW3Q4ZzZVcrAn8TC4HrUtR8DL176
 DpGlEhmmdr3xKKX0JQ9RmIod+xSabw==
 =4wGX
 -----END PGP SIGNATURE-----

Merge tag '4.4.0'

Smack 4.4.0
2020-12-06 12:16:44 +01:00
Florian Schmaus a4bb5bfda8 [ibb] Use UInt16 for 'seq' and fix its handling
Fixes a off-by-one error when incrementing 'seq'. Thanks to Kim
Alvefur <zash@zash.se> for spotting this.
2020-12-05 23:04:17 +01:00
Florian Schmaus 1a963cc794 Merge branch '4.4' 2020-11-25 20:57:44 +01:00
Florian Schmaus 02c9058c3d [core] Remove @SuppressWarnings for parseContentDepthWithRoundtrip()
Also use the most specific return type in the method's signature.
2020-11-25 20:55:05 +01:00
Florian Schmaus ca497a2199 [core] Fix parseContentDepthWithRoundtrip() and add tests 2020-11-25 20:55:05 +01:00
Florian Schmaus 5782fff2a4 Merge branch '4.4' 2020-09-23 21:42:51 +02:00
Florian Schmaus 15e3d267f6 Add Pair utility class 2020-09-23 19:46:01 +02:00
Florian Schmaus b857f33ac3 Merge branch '4.4' 2020-09-20 14:12:37 +02:00
Florian Schmaus 525ee09ea1 [tcp] Do not send SM ack after we send a </stream:stream>
Do net put an ack to the queue if it has already been shutdown. Some
servers, like ejabberd, like to request an ack even after we have send
a stream close (and hance the queue was shutdown). If we would not
check here, then the ack would dangle around in the queue, and be send
on the next re-connection attempt even before the stream open.

See the following trace of the MUC bookmarks integration test. The
fact that it is a MUC test does not matter, but this test does
disconnect the connection and reconnect it. Not how the server,
ejabberd in this case, requests an SM ack by sending an <r/> even
though we already send the </stream:stream>:

22:22:05 SENT (4):
<iq id='MD4UC-61' type='set'>
  <query xmlns='jabber:iq:private'>
    <storage xmlns='storage:bookmarks'>
      <conference name='Smack Inttest: 7in7j' autojoin='true' jid='y9jcn5@conference.salem.geekplace.eu'>
        <nick>
          Nick-P2VXD7
        </nick>
      </conference>
    </storage>
  </query>
</iq>
22:22:05 RECV (4):
<r xmlns='urn:xmpp:sm:3'/>
22:22:05 SENT (4):
<a xmlns='urn:xmpp:sm:3' h='29'/>
22:22:05 RECV (4):
<message to='sinttest-7in7j-4@salem.geekplace.eu' from='sinttest-7in7j-4@salem.geekplace.eu' type='headline'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='storage:bookmarks'>
      <item id='current'>
        <storage xmlns='storage:bookmarks'>
          <conference name='Smack Inttest: 7in7j' autojoin='true' jid='y9jcn5@conference.salem.geekplace.eu'>
            <nick>
              Nick-P2VXD7
            </nick>
          </conference>
        </storage>
      </item>
    </items>
  </event>
  <addresses xmlns='http://jabber.org/protocol/address'>
    <address jid='sinttest-7in7j-4@salem.geekplace.eu/1415073683806426185213090' type='replyto'/>
  </addresses>
</message>
22:22:05 RECV (4):
<iq xml:lang='en-US' to='sinttest-7in7j-4@salem.geekplace.eu/1415073683806426185213090' from='sinttest-7in7j-4@salem.geekplace.eu' type='result' id='MD4UC-61'/>
22:22:05 SENT (4):
<presence id='6MS6J-20' type='unavailable'/>
<a xmlns='urn:xmpp:sm:3' h='31'/>
<!-- We have closed the stream -->
</stream:stream>
<!-- But the server still requests an SM ack -->
22:22:05 RECV (4):
<r xmlns='urn:xmpp:sm:3'/>
22:22:05 RECV (4):
</stream:stream>
22:22:05 XMPPConnection closed (XMPPTCPConnection[sinttest-7in7j-4@salem.geekplace.eu/1415073683806426185213090] (4))
22:22:05 SENT (4):
<a xmlns='urn:xmpp:sm:3' h='31'/>
22:22:05 SENT (4):
<stream:stream xmlns='jabber:client' to='salem.geekplace.eu' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='sinttest-7in7j-4@salem.geekplace.eu' xml:lang='en-US'>
22:22:05 RECV (4): ?xml version='1.0'?>
<stream:stream id='3379123514446782311' ver
22:22:05 RECV (4): sion='1.0' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client'>
<stream:error>
  <invalid-xml xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>
</stream:error>
</stream:stream>
22:22:05 XMPPConnection closed due to an exception (XMPPTCPConnection[sinttest-7in7j-4@salem.geekplace.eu/1415073683806426185213090] (4))
org.jivesoftware.smack.XMPPException$StreamErrorException: invalid-xml You can read more about the meaning of this stream error at http://xmpp.org/rfcs/rfc6120.html#streams-error-conditions
<stream:error><invalid-xml xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error>
	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:981)
	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$700(XMPPTCPConnection.java:913)
	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:936)
	at java.base/java.lang.Thread.run(Thread.java:834)
2020-09-18 14:36:26 +02:00
Florian Schmaus b7824f008d Introduce and use XmlStringBuilder.text()
Smack currently does unnecessary escaping of XML text, where it
escapes e.g. '"' to '&quot;'. This bloats the stanza size, especially
if JSON payloads are involved.

Fixes SMACK-892 (although there are probably still places where
XmlStringBuilder.escape() is used when XmlStringBuild.text() could
have been used).
2020-09-17 14:20:11 +02:00
Florian Schmaus 525f27abf1 Merge branch '4.4' 2020-08-29 16:39:15 +02:00
Florian Schmaus d06e9499e8 [core] Add XmppElementUtil.castOrThrow(ExtensionElement, Class)
This method throws an IllegalStateException if the provided extension
element is not of the expected type and hints users towards potential
causes.
2020-08-29 16:29:22 +02:00
adiaholic 7ed29b9d5f Introduce websocket module into smack 2020-08-28 23:40:40 +05:30
Florian Schmaus 1aab0b8aac [core] Add cache to XmppElementUtil.getQNameFor(Class) 2020-08-28 09:47:09 +02:00
Florian Schmaus 2a9671ca93 [core] Change type of XmlStringBuilder cosntructor to FullyQualifiedElement
There is no reason we should do this only for ExtensionElements, this
behavior is sane for every FulllyQualifiedElement.
2020-08-26 11:35:22 +02:00
Aditya Borikar 7796b367cc Position parser at START_ELEMENT before parsing
This PR aims to provide parseXrdLinkReferencesFor() method the ability
to parse forward to the first START_ELEMENT tag.The HttpLookupMethodTest
tests the HttpLookupMethod class by parsing String. This makes use of
PacketParserUtils.getParserFor(String), which already does forward
winding to reach START_ELEMENT. However when fetching endpoints from a
remote host meta data, PacketParserUtils.getParserFor(InputStream) is
used which doesn't do winding in any form. And thus, even though
HttpLookupMethodTest tests pass, this implementation would crash while
parsing remote host-meta.
2020-08-07 15:01:53 +05:30
Florian Schmaus 2b423b911e Merge branch 'master' of github.com:igniterealtime/Smack 2020-07-18 21:47:06 +02:00
Paul Schaub bb3c491e0c
StringUtils: Fix typo and expose unambiguous alphabet as string 2020-07-15 22:15:38 +02:00
Florian Schmaus d3a99a133a [core] Fix log/exception message of XmppElementUtil
The Class.toString() already prefixes the resulting string with "class
", no need to state it explicitly in the log message that this is a
class.
2020-07-13 08:50:10 +02:00
Florian Schmaus 3f9ca68134 Delete TypedCloneable 2020-06-14 17:38:51 +02:00
Florian Schmaus 57961a8cc1 Remove SynchronizationPoint
This continues the design started with e98d42790 ("SmackReactor/NIO,
Java8/Android19, Pretty print XML, FSM connections"), where the
exceptions that caused an operation to fail, are not recorded within
SynchronizationPoint but within the connection instance itself.
2020-05-31 19:48:47 +02:00
Florian Schmaus f5448c5faa [core] Rework TLS logic
This moves the logic in AbstractXMPPConnection.getSmackTlsContext()
into the ConnectionConfiguration constructor.

Also introduce SslContextFactory and use it in
ConnectionConfiguration.
2020-05-25 15:41:57 +02:00
Florian Schmaus d65f2c932e Bump Error Prone version to 2.3.4 and fix new bug patterns 2020-05-24 21:10:01 +02:00
Florian Schmaus 9a8ee3c8e3 [core] Improve NumberUtil's exception message and fix javadoc 2020-05-24 13:08:03 +02:00
Florian Schmaus dfdd0acf91 Introduce AbstractStats 2020-05-18 09:15:14 +02:00
Florian Schmaus 77e26fc575 Re-work data form API
Apply builder pattern to form fields and replace getVariable() with
getFieldName(). Refer to the field name as "field name" instead of
"variable" everyone, just as XEP-0004 does.

Improve the high-level form API: introduce FilledForm and FillableForm
which perform stronger validation and consistency checks.

Also add FormFieldRegistry to enable processing of 'submit' forms
where the form field types are omitted.

Smack also now does omit the form field type declaration on 'submit'
type forms, as it is allowed by XEP-0004.
2020-05-13 20:14:41 +02:00
Florian Schmaus ad13effe41
Merge pull request #382 from vanitasvitae/typo
Fix typo in XmppElementUtil
2020-04-13 23:03:34 +02:00
Florian Schmaus 5114f6dfa4 core: remove deprecated methods in PacketUtil
Those where deprecated in 2015 with 8409dddff ("Add
PacketUtil.extensionElementFrom()"), and in 2017 with
2288825b1 ("Retain smack-core API").
2020-04-13 21:25:28 +02:00
Florian Schmaus c49999b933 core: add shortcut via hash in EqualsUtil
Return false as soon as the hashed value does not match. This is
sound, since every class that implements equals(Object) should also
implement hashCode().
2020-04-13 20:40:10 +02:00
Paul Schaub 905d5dc102
Fix typo in XmppElementUtil 2020-04-13 18:18:31 +02:00
Florian Schmaus 8b0de5ff85 Introduce TLSUtils.setEnabledTlsProtocolsToRecommended(B builder)
And deprecate no longer recommended methods.

Thanks to Milan Kral <milan.kral@azet.sk> for the initial PR which
triggered this commit.
2020-04-05 22:28:01 +02:00
Florian Schmaus 62916b8490 Improve exception message of XmppElementUtil.getQNameFor() 2020-04-05 22:08:10 +02:00
Florian Schmaus 14c351397d Implement message stanza <thread/> and <subject/> as ExtensionElement
Fixes SMACK-852.
2020-04-05 18:58:13 +02:00
Florian Schmaus f9fb4d7627 Remove deprecated XmlStringBuilder.rightAngelBracket()
This method was marked deprecated with bbf89c65b ("Fix typo in
XmlStringBuilder, it's not an Angel"). Now it is time to remove it.
2020-04-05 17:26:21 +02:00
Florian Schmaus cc636fff21 Introduce Smack's Modular Connection Architecture
This is a complete redesign of what was previously
XmppNioTcpConnection. The new architecture allows to extend an XMPP
client to server (c2s) connection with new transport bindings and
other extensions.
2020-04-04 13:03:31 +02:00
Florian Schmaus 39a833166a Add workaround for truststores in JKS format when using Java >= 9 2020-03-13 16:40:46 +01:00
Florian Schmaus 00dd77b346 Try to guess the default truststore and path
Tested with OpenJDK 8 and 11. The 'JKS' fallback is for OpenJDK 11.
2020-03-09 13:39:19 +01:00
Florian Schmaus 6440f322fe Ensure a X509TrustManager is set 2020-03-09 10:12:43 +01:00
Florian Schmaus 961e56a47c proxy: modernize code by using (ByteArrayOutput|DataInput)Stream 2020-02-23 19:12:54 +01:00
adiaholic ee3d25751d Correct ALPHABET in `BASE32.java` 2020-01-28 20:19:42 +05:30
Florian Schmaus eb4c2c5572 s/occured/occurred/ 2019-10-30 12:02:36 +01:00
Florian Schmaus 2915101843 Use isEmpty() in StringUtils.requireNullOrNotEmpty() 2019-10-30 11:56:55 +01:00
Florian Schmaus 69767e9538 Rename AbstractIqBuilder subclasses to their designated names 2019-10-29 19:34:18 +01:00
Florian Schmaus 6e32305987 Apply builder pattern to DiscoverInfo
This is the first transformation of an IQ type to the builder type.
2019-10-29 11:14:55 +01:00
Florian Schmaus e2d206e741 Introduce XMPPConnection.add(Message|Presence)Interceptor
add deprecate addStanzaInterceptor().
2019-10-25 21:41:55 +02:00
Florian Schmaus 5db6191110 Introduce StanzaBuilder
As first step to immutable Stanza types.
2019-10-25 21:41:55 +02:00