mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 22:12:05 +01:00
Compare commits
126 commits
1df0763f92
...
4f2d8e8d4c
Author | SHA1 | Date | |
---|---|---|---|
|
4f2d8e8d4c | ||
|
b52e02740b | ||
|
e9ca16ed12 | ||
|
8d74873925 | ||
|
4eb5869860 | ||
|
39b211cde3 | ||
|
602aafe119 | ||
|
b0729d83a8 | ||
|
aab48570c9 | ||
|
c9ea1c11b6 | ||
|
6ec654ad1e | ||
|
1fee87b24d | ||
|
5e43ef550f | ||
|
64db6e3ebc | ||
|
aa49743ef8 | ||
|
8cd0a9f5ce | ||
|
6af38482de | ||
|
469d4fb0dc | ||
|
cd33b885ae | ||
|
a806595a77 | ||
|
6b14fcab75 | ||
|
6011d566cf | ||
|
5cd77ec741 | ||
|
70cb9e8a94 | ||
|
ba5c2e46d8 | ||
|
65c363b19d | ||
|
fc191e4e19 | ||
|
b541397119 | ||
|
6a78e4ad09 | ||
|
a36251ff7d | ||
|
0c397294e1 | ||
|
920b686f29 | ||
|
642f5bde61 | ||
|
64c82ca0cf | ||
|
c95c8264da | ||
|
8a91021a0e | ||
|
3d4e7938a7 | ||
|
5493a22e44 | ||
|
961882ff7f | ||
|
36c7521ca2 | ||
|
b0abfe1bba | ||
|
2b1097a743 | ||
|
fbddd074bc | ||
|
6b3e41d591 | ||
|
35c645e24b | ||
|
aff6283798 | ||
|
b7709f583d | ||
|
138725a22f | ||
|
aefbb28875 | ||
|
c484b72fb7 | ||
|
0c4b5d3ff9 | ||
|
cd10d1b40c | ||
|
533695c1b4 | ||
|
252cea1149 | ||
|
e6433a6870 | ||
|
8c57d34b97 | ||
|
4736d080a1 | ||
|
525db827a9 | ||
|
e04a3877fb | ||
|
92f4aadfdc | ||
|
72e11ebf71 | ||
|
33d735a42e | ||
|
b58511d624 | ||
|
5844bee1c3 | ||
|
a39d44ed1f | ||
|
406daa78f7 | ||
|
61713c500c | ||
|
2dab49f048 | ||
|
9d64af26b7 | ||
|
d07d46bbdc | ||
|
eb31479913 | ||
|
ed807d5954 | ||
|
64a2db3f19 | ||
|
4381d04831 | ||
|
b8f23eb371 | ||
|
800c771700 | ||
|
4fefa92e40 | ||
|
b276b89916 | ||
|
ddf96828e4 | ||
|
35cd1a8f88 | ||
|
47178fd27d | ||
|
9520aa7d90 | ||
|
11a486d84d | ||
|
f91598e10c | ||
|
ad8eeebc0d | ||
|
d75cd2acb8 | ||
|
adc159186c | ||
|
73941629f3 | ||
|
2779187d8c | ||
|
c564c89c40 | ||
|
f2b44f65d9 | ||
|
9d1b88a877 | ||
|
61cb73ee37 | ||
|
14142a0ef2 | ||
|
b7905d585d | ||
|
17ac41c8cb | ||
|
7cf0112487 | ||
|
c7b429535b | ||
|
f9114f780d | ||
|
4adbd21a0f | ||
|
3bef905ef5 | ||
|
ba6968fc79 | ||
|
48f5e349b9 | ||
|
7d6891c077 | ||
|
ae44af5d63 | ||
|
d4d2a7a6d8 | ||
|
bca3821343 | ||
|
33f59fd7ed | ||
|
687c4f35aa | ||
|
1c262471e5 | ||
|
3c4610d500 | ||
|
19521174f4 | ||
af77543544 | |||
|
1a1a67a2c5 | ||
|
d881395d05 | ||
|
4e90db3191 | ||
|
8b0248c346 | ||
|
4aacdc5154 | ||
|
cd40455b62 | ||
|
fe3214291d | ||
|
9261d6485e | ||
|
ce4f85acf8 | ||
|
bda3901910 | ||
|
070aa8e28e | ||
|
86b48fbf00 | ||
|
a7b3303f3e |
414 changed files with 4330 additions and 1940 deletions
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
|
@ -12,7 +12,11 @@ jobs:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java: [ 1.8, 11 ]
|
java:
|
||||||
|
- 11
|
||||||
|
- 15
|
||||||
|
env:
|
||||||
|
PRIMARY_JAVA_VERSION: 11
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
@ -76,12 +80,12 @@ jobs:
|
||||||
|
|
||||||
# Javadoc
|
# Javadoc
|
||||||
- name: Javadoc
|
- name: Javadoc
|
||||||
if: ${{ matrix.java == 11 }}
|
if: ${{ matrix.java == env.PRIMARY_JAVA_VERSION }}
|
||||||
run: ${PATH_TO_GRADLE} javadocAll --stacktrace
|
run: ${PATH_TO_GRADLE} javadocAll --stacktrace
|
||||||
|
|
||||||
# Test Coverage Report
|
# Test Coverage Report
|
||||||
- name: Jacoco Test Coverage
|
- name: Jacoco Test Coverage
|
||||||
if: ${{ matrix.java == 1.8 }}
|
if: ${{ matrix.java == env.PRIMARY_JAVA_VERSION }}
|
||||||
run: ${PATH_TO_GRADLE} jacocoRootReport coveralls
|
run: ${PATH_TO_GRADLE} jacocoRootReport coveralls
|
||||||
env:
|
env:
|
||||||
COVERALLS_REPO_TOKEN: S2ecSJja2cKJa9yv45C8ZFPohXuRrTXKd
|
COVERALLS_REPO_TOKEN: S2ecSJja2cKJa9yv45C8ZFPohXuRrTXKd
|
||||||
|
|
20
README.md
20
README.md
|
@ -6,12 +6,12 @@ Smack
|
||||||
About
|
About
|
||||||
-----
|
-----
|
||||||
|
|
||||||
[Smack] is an open source, highly modular, easy to use, XMPP client library written in Java for Java SE compatible JVMs and Android.
|
[Smack] is an open-source, highly modular, easy to use, XMPP client library written in Java for Java SE compatible JVMs and Android.
|
||||||
|
|
||||||
A pure Java library, it can be embedded into your applications to create anything from a full XMPP instant messaging client to simple XMPP integrations such as sending notification messages and presence-enabling devices.
|
Being a pure Java library, it can be embedded into your applications to create anything from a full XMPP instant messaging client to simple XMPP integrations such as sending notification messages and presence-enabling devices.
|
||||||
Smack and XMPP allows you to easily exchange data, in various ways e.g. fire-and-forget, publish-subscribe, between human and non-human endpoints (M2M, IoT, …).
|
Smack and XMPP allow you to easily exchange data in various ways e.g., fire-and-forget, publish-subscribe, between human and non-human endpoints (M2M, IoT, …).
|
||||||
|
|
||||||
More information are provided by the [Overview](documentation/overview.md).
|
More information is provided by the [Overview](documentation/overview.md).
|
||||||
|
|
||||||
Getting started
|
Getting started
|
||||||
---------------
|
---------------
|
||||||
|
@ -23,7 +23,7 @@ Instructions on how to use Smack in your Java or Android project are provided in
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Most of Smack is governed by the Apache License 2.0 (SPDX License Identifier: Apache 2.0). This license requires that the contents of a NOICE text file are shown "…within a display generated by the Derivative Works, if and wherever such third-party notices normally appear.".
|
Most of Smack is governed by the Apache License 2.0 (SPDX License Identifier: Apache 2.0). This license requires that the contents of a NOTICE text file are shown "…within a display generated by the Derivative Works, if and wherever such third-party notices normally appear.".
|
||||||
|
|
||||||
Smack comes which such a NOTICE file. Moreover, since `smack-core` is licensed under the Apache License 2.0, the conditions apply to every project using Smack. The content of Smack's NOTICE file can conveniently be retrieved using `Smack.getNoticeStream()`.
|
Smack comes which such a NOTICE file. Moreover, since `smack-core` is licensed under the Apache License 2.0, the conditions apply to every project using Smack. The content of Smack's NOTICE file can conveniently be retrieved using `Smack.getNoticeStream()`.
|
||||||
|
|
||||||
|
@ -32,10 +32,12 @@ Some subprojects of Smack are governed by other licenses. Please refer to the in
|
||||||
Professional Services
|
Professional Services
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
Smack is a collaborative effort of many open source, professionally and spare-time, paid and unpaid, contributors.
|
Smack is a collaborative effort of many people.
|
||||||
While we try to provide the best possible XMPP library for Android and Java SE compatible execution environments by following state of the art software engineering practices, the API may not always perfectly fit your requirements.
|
Some are paid, e.g., by their employer or a third party, for their contributions.
|
||||||
We welcome contributions and encourage discussion about how Smack can be further improved.
|
But many contribute in their spare time for free.
|
||||||
We also provide **paid services** ranging from **XMPP/Smack related consulting** to **designing and developing features** in order to accommodate your needs.
|
While we try to provide the best possible XMPP library for Android and Java SE-compatible execution environments by following state-of-the-art software engineering practices, the API may not always perfectly fit your requirements.
|
||||||
|
Hence welcome contributions and encourage discussion about how Smack can be further improved.
|
||||||
|
We also provide **paid services** ranging from **XMPP/Smack related consulting** to **designing and developing features** to accommodate your needs.
|
||||||
Please contact [Florian Schmaus](mailto:flo@geekplace.eu) for further information.
|
Please contact [Florian Schmaus](mailto:flo@geekplace.eu) for further information.
|
||||||
|
|
||||||
Bug Reporting
|
Bug Reporting
|
||||||
|
|
65
build.gradle
65
build.gradle
|
@ -5,20 +5,40 @@ buildscript {
|
||||||
maven { url 'https://dl.bintray.com/content/aalmiray/kordamp' }
|
maven { url 'https://dl.bintray.com/content/aalmiray/kordamp' }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'org.kordamp:markdown-gradle-plugin:1.0.0'
|
|
||||||
classpath 'org.kordamp.gradle:clirr-gradle-plugin:0.2.2'
|
classpath 'org.kordamp.gradle:clirr-gradle-plugin:0.2.2'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'ru.vyarus.animalsniffer' version '1.5.0'
|
id 'ru.vyarus.animalsniffer' version '1.5.0'
|
||||||
id 'net.ltgt.errorprone' version '1.1.1'
|
id 'net.ltgt.errorprone' version '1.3.0'
|
||||||
// Use e.g. "gradle <task> taskTree" to show its dependency tree.
|
// Use e.g. "gradle <task> taskTree" to show its dependency tree.
|
||||||
id 'com.dorongold.task-tree' version '1.5'
|
id 'com.dorongold.task-tree' version '1.5'
|
||||||
id 'com.github.kt3k.coveralls' version '2.10.2'
|
id 'com.github.kt3k.coveralls' version '2.10.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'org.kordamp.gradle.markdown'
|
ext {
|
||||||
|
java11Projects = [
|
||||||
|
':smack-integration-test',
|
||||||
|
':smack-omemo-signal-integration-test',
|
||||||
|
':smack-repl',
|
||||||
|
':smack-websocket-java11',
|
||||||
|
].collect { project(it) }
|
||||||
|
java11Projects += getRootProject()
|
||||||
|
java8Projects = allprojects - java11Projects
|
||||||
|
}
|
||||||
|
|
||||||
|
configure (java8Projects) {
|
||||||
|
ext {
|
||||||
|
javaCompatilibity = JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configure (java11Projects) {
|
||||||
|
ext {
|
||||||
|
javaCompatilibity = JavaVersion.VERSION_11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply plugin: 'java-library'
|
apply plugin: 'java-library'
|
||||||
|
@ -34,7 +54,7 @@ allprojects {
|
||||||
isSnapshot = version.endsWith('-SNAPSHOT')
|
isSnapshot = version.endsWith('-SNAPSHOT')
|
||||||
gitCommit = getGitCommit()
|
gitCommit = getGitCommit()
|
||||||
javadocAllDir = new File(buildDir, 'javadoc')
|
javadocAllDir = new File(buildDir, 'javadoc')
|
||||||
documentationDir = new File(buildDir, 'documentation')
|
documentationDir = new File(projectDir, 'documentation')
|
||||||
releasedocsDir = new File(buildDir, 'releasedocs')
|
releasedocsDir = new File(buildDir, 'releasedocs')
|
||||||
rootConfigDir = new File(rootDir, 'config')
|
rootConfigDir = new File(rootDir, 'config')
|
||||||
sonatypeCredentialsAvailable = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')
|
sonatypeCredentialsAvailable = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')
|
||||||
|
@ -125,9 +145,12 @@ allprojects {
|
||||||
jxmppVersion = '[1.0.0, 1.0.999]'
|
jxmppVersion = '[1.0.0, 1.0.999]'
|
||||||
miniDnsVersion = '[1.0.0, 1.0.999]'
|
miniDnsVersion = '[1.0.0, 1.0.999]'
|
||||||
smackMinAndroidSdk = 19
|
smackMinAndroidSdk = 19
|
||||||
junitVersion = '5.6.2'
|
junitVersion = '5.7.1'
|
||||||
commonsIoVersion = '2.6'
|
commonsIoVersion = '2.6'
|
||||||
bouncyCastleVersion = '1.65'
|
bouncyCastleVersion = '1.68'
|
||||||
|
guavaVersion = '30.1-jre'
|
||||||
|
mockitoVersion = '3.7.7'
|
||||||
|
orgReflectionsVersion = '0.9.11'
|
||||||
|
|
||||||
if (project.hasProperty("useSonatype")) {
|
if (project.hasProperty("useSonatype")) {
|
||||||
useSonatype = project.getProperty("useSonatype").toBoolean()
|
useSonatype = project.getProperty("useSonatype").toBoolean()
|
||||||
|
@ -135,7 +158,6 @@ allprojects {
|
||||||
// Default to true
|
// Default to true
|
||||||
useSonatype = true
|
useSonatype = true
|
||||||
}
|
}
|
||||||
javaCompatilibity = JavaVersion.VERSION_1_8
|
|
||||||
javaMajor = javaCompatilibity.getMajorVersion()
|
javaMajor = javaCompatilibity.getMajorVersion()
|
||||||
}
|
}
|
||||||
group = 'org.igniterealtime.smack'
|
group = 'org.igniterealtime.smack'
|
||||||
|
@ -218,6 +240,8 @@ allprojects {
|
||||||
// Disabled but should be re-enabled at some point
|
// Disabled but should be re-enabled at some point
|
||||||
//'-Xep:InconsistentCapitalization:OFF',
|
//'-Xep:InconsistentCapitalization:OFF',
|
||||||
'-Xep:MixedMutabilityReturnType:OFF',
|
'-Xep:MixedMutabilityReturnType:OFF',
|
||||||
|
// TODO: Re-enable once Smack's minimum Android SDK level is 26 or higher.
|
||||||
|
'-Xep:JavaUtilDate:OFF',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,7 +254,7 @@ allprojects {
|
||||||
}
|
}
|
||||||
|
|
||||||
jacoco {
|
jacoco {
|
||||||
toolVersion = "0.8.3"
|
toolVersion = "0.8.6"
|
||||||
}
|
}
|
||||||
|
|
||||||
jacocoTestReport {
|
jacocoTestReport {
|
||||||
|
@ -248,7 +272,10 @@ allprojects {
|
||||||
// since the one paramater addStringOption doesn't seem to
|
// since the one paramater addStringOption doesn't seem to
|
||||||
// work, we extra add '-quiet', which is added anyway by
|
// work, we extra add '-quiet', which is added anyway by
|
||||||
// gradle.
|
// gradle.
|
||||||
options.addStringOption('Xdoclint:all', '-quiet')
|
// TODO: This enables all doclint check but
|
||||||
|
// 'missing'. Re-enable 'missing' once every public API in
|
||||||
|
// Smack has a javadoc comment.
|
||||||
|
options.addStringOption('Xdoclint:accessibility,html,reference,syntax', '-quiet')
|
||||||
|
|
||||||
// Treat warnings as errors.
|
// Treat warnings as errors.
|
||||||
// See also https://bugs.openjdk.java.net/browse/JDK-8200363
|
// See also https://bugs.openjdk.java.net/browse/JDK-8200363
|
||||||
|
@ -260,6 +287,9 @@ allprojects {
|
||||||
tasks.withType(Javadoc) {
|
tasks.withType(Javadoc) {
|
||||||
options.addStringOption('-release', javaMajor)
|
options.addStringOption('-release', javaMajor)
|
||||||
|
|
||||||
|
// The -no-modules-directories javadoc option was removed in Java 13
|
||||||
|
// See https://bugs.openjdk.java.net/browse/JDK-8215582
|
||||||
|
if (JavaVersion.current() < JavaVersion.VERSION_13) {
|
||||||
// Fix for javadoc search. If not set, the search result would direct to
|
// Fix for javadoc search. If not set, the search result would direct to
|
||||||
// javadoc/undefined/org/jivesoftware/smack/altconnections/HttpLookupMethod.html
|
// javadoc/undefined/org/jivesoftware/smack/altconnections/HttpLookupMethod.html
|
||||||
// instead of
|
// instead of
|
||||||
|
@ -267,6 +297,7 @@ allprojects {
|
||||||
// https://stackoverflow.com/a/53732633/194894
|
// https://stackoverflow.com/a/53732633/194894
|
||||||
options.addBooleanOption("-no-module-directories", true)
|
options.addBooleanOption("-no-module-directories", true)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
options.compilerArgs.addAll([
|
options.compilerArgs.addAll([
|
||||||
'--release', javaMajor,
|
'--release', javaMajor,
|
||||||
|
@ -287,13 +318,13 @@ tasks.withType(Javadoc) {
|
||||||
// The smack-extensions subproject uses mockito in its fest
|
// The smack-extensions subproject uses mockito in its fest
|
||||||
// fixtures, and we want to have mockito also available in
|
// fixtures, and we want to have mockito also available in
|
||||||
// test, so we use API here.
|
// test, so we use API here.
|
||||||
testFixturesApi "org.mockito:mockito-core:3.3.3"
|
testFixturesApi "org.mockito:mockito-core:${mockitoVersion}"
|
||||||
|
|
||||||
// To mock final classes
|
// To mock final classes
|
||||||
testImplementation 'org.mockito:mockito-inline:3.3.3'
|
testImplementation "org.mockito:mockito-inline:${mockitoVersion}"
|
||||||
testImplementation 'com.jamesmurty.utils:java-xmlbuilder:1.2'
|
testImplementation 'com.jamesmurty.utils:java-xmlbuilder:1.2'
|
||||||
|
|
||||||
errorprone 'com.google.errorprone:error_prone_core:2.3.4'
|
errorprone 'com.google.errorprone:error_prone_core:2.5.1'
|
||||||
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
|
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +366,7 @@ task javadocAll(type: Javadoc) {
|
||||||
linkSource = true
|
linkSource = true
|
||||||
use = true
|
use = true
|
||||||
links = [
|
links = [
|
||||||
"https://docs.oracle.com/javase/${javaMajor}/docs/api/",
|
"https://docs.oracle.com/en/java/javase/${javaMajor}/docs/api/",
|
||||||
"https://jxmpp.org/releases/${staticJxmppVersion}/javadoc/",
|
"https://jxmpp.org/releases/${staticJxmppVersion}/javadoc/",
|
||||||
"https://minidns.org/releases/${staticMiniDnsVersion}/javadoc/",
|
"https://minidns.org/releases/${staticMiniDnsVersion}/javadoc/",
|
||||||
] as String[]
|
] as String[]
|
||||||
|
@ -369,13 +400,7 @@ task prepareReleasedocs(type: Copy) {
|
||||||
filter(ReplaceTokens, tokens: [version: version, releasedate: builtDate, targetCompatibility: targetCompatibility.toString()])
|
filter(ReplaceTokens, tokens: [version: version, releasedate: builtDate, targetCompatibility: targetCompatibility.toString()])
|
||||||
}
|
}
|
||||||
|
|
||||||
markdownToHtml {
|
task distributionZip(type: Zip, dependsOn: [javadocAll, prepareReleasedocs]) {
|
||||||
sourceDir = new File(projectDir, "/documentation")
|
|
||||||
outputDir documentationDir
|
|
||||||
configuration = [tables: true, fencedCodeBlocks: true]
|
|
||||||
}
|
|
||||||
|
|
||||||
task distributionZip(type: Zip, dependsOn: [javadocAll, prepareReleasedocs, markdownToHtml]) {
|
|
||||||
classifier builtDate
|
classifier builtDate
|
||||||
into ('javadoc') {
|
into ('javadoc') {
|
||||||
from(javadocAllDir)
|
from(javadocAllDir)
|
||||||
|
|
|
@ -28,7 +28,7 @@ Currently supported XEPs of smack-im
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
||||||
| Name | XEP | Version | Description |
|
| Name | XEP | Version | Description |
|
||||||
|---------------------------------------------|--------------------------------------------------------|-----------|-----------------------------------|--
|
|---------------------------------------------|--------------------------------------------------------|-----------|-----------------------------------|
|
||||||
| Roster Versioning | [XEP-0237](https://xmpp.org/extensions/xep-0237.html) | n/a | Efficient roster synchronization. |
|
| Roster Versioning | [XEP-0237](https://xmpp.org/extensions/xep-0237.html) | n/a | Efficient roster synchronization. |
|
||||||
|
|
||||||
Smack Extensions and currently supported XEPs of smack-extensions
|
Smack Extensions and currently supported XEPs of smack-extensions
|
||||||
|
|
|
@ -15,12 +15,7 @@ cd "`dirname "${SCRIPTDIR}"`" > /dev/null
|
||||||
SCRIPTDIR="`pwd`";
|
SCRIPTDIR="`pwd`";
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
||||||
SMACK_DIR=$(readlink "${SCRIPTDIR}"/..)
|
SMACK_DIR=$(realpath "${SCRIPTDIR}"/..)
|
||||||
|
|
||||||
FIND_ALL_JAVA_SRC="find ${SMACK_DIR} \
|
|
||||||
-type f \
|
|
||||||
-name *.java \
|
|
||||||
-print"
|
|
||||||
|
|
||||||
declare -A SMACK_EXCEPTIONS
|
declare -A SMACK_EXCEPTIONS
|
||||||
SMACK_EXCEPTIONS[NotConnectedException]="if the XMPP connection is not connected."
|
SMACK_EXCEPTIONS[NotConnectedException]="if the XMPP connection is not connected."
|
||||||
|
@ -71,7 +66,8 @@ SMACK_EXCEPTIONS[FailedNonzaException]="if an XMPP protocol failure was received
|
||||||
|
|
||||||
MODE=""
|
MODE=""
|
||||||
|
|
||||||
while getopts dm: OPTION "$@"; do
|
SMACK_DIR=$(realpath "${SCRIPTDIR}"/..)
|
||||||
|
while getopts dm:p: OPTION "$@"; do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
d)
|
d)
|
||||||
set -x
|
set -x
|
||||||
|
@ -79,6 +75,9 @@ while getopts dm: OPTION "$@"; do
|
||||||
m)
|
m)
|
||||||
MODE=${OPTARG}
|
MODE=${OPTARG}
|
||||||
;;
|
;;
|
||||||
|
p)
|
||||||
|
SMACK_DIR=${OPTARG}
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown option ${OPTION}"
|
echo "Unknown option ${OPTION}"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -86,26 +85,43 @@ while getopts dm: OPTION "$@"; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
JAVA_SOURCES_LIST=$(mktemp)
|
||||||
|
onExit() {
|
||||||
|
rm "${JAVA_SOURCES_LIST}"
|
||||||
|
}
|
||||||
|
trap onExit EXIT
|
||||||
|
|
||||||
|
find ${SMACK_DIR} \
|
||||||
|
-type f \
|
||||||
|
-name "*.java" \
|
||||||
|
-print > "${JAVA_SOURCES_LIST}"
|
||||||
|
|
||||||
|
NPROC=$(nproc)
|
||||||
|
|
||||||
sed_sources() {
|
sed_sources() {
|
||||||
sedScript=${1}
|
sedScript=${1}
|
||||||
${FIND_ALL_JAVA_SRC} |\
|
|
||||||
xargs sed \
|
xargs \
|
||||||
|
--max-procs="${NPROC}" \
|
||||||
|
--max-args=8 \
|
||||||
|
-- \
|
||||||
|
sed \
|
||||||
--in-place \
|
--in-place \
|
||||||
--follow-symlinks \
|
--follow-symlinks \
|
||||||
--regexp-extended \
|
--regexp-extended \
|
||||||
"${sedScript}"
|
"${sedScript}" < "${JAVA_SOURCES_LIST}"
|
||||||
}
|
}
|
||||||
|
|
||||||
show_affected() {
|
show_affected() {
|
||||||
echo ${!SMACK_EXCEPTIONS{@}}
|
echo ${!SMACK_EXCEPTIONS{@}}
|
||||||
for exception in ${!SMACK_EXCEPTIONS[@]}; do
|
for exception in ${!SMACK_EXCEPTIONS[@]}; do
|
||||||
${FIND_ALL_JAVA_SRC} |\
|
xargs grep " \* @throws $exception$" < "${JAVA_SOURCES_LIST}"
|
||||||
xargs grep " \* @throws $exception$" || true
|
|
||||||
done
|
done
|
||||||
for exception in ${!SMACK_EXCEPTIONS[@]}; do
|
for exception in ${!SMACK_EXCEPTIONS[@]}; do
|
||||||
count=$(${FIND_ALL_JAVA_SRC} |\
|
local count
|
||||||
xargs grep " \* @throws $exception$" | wc -l)
|
count=$(<"${JAVA_SOURCES_LIST}" xargs grep " \* @throws $exception$" |\
|
||||||
echo "$exception $count"
|
wc -l)
|
||||||
|
echo "$exception $count"q
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -113,7 +129,7 @@ show_affected() {
|
||||||
fix_affected() {
|
fix_affected() {
|
||||||
for exception in "${!SMACK_EXCEPTIONS[@]}"; do
|
for exception in "${!SMACK_EXCEPTIONS[@]}"; do
|
||||||
exceptionJavadoc=${SMACK_EXCEPTIONS[${exception}]}
|
exceptionJavadoc=${SMACK_EXCEPTIONS[${exception}]}
|
||||||
sed_sources "s;@throws ((\w*\.)?${exception})\$;@throws \1 ${exceptionJavadoc};"
|
sed_sources "s;@throws ((\w*\.)?${exception}) ?\$;@throws \1 ${exceptionJavadoc};"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
resources/intellij/Smack Import Order.xml
Normal file
18
resources/intellij/Smack Import Order.xml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<code_scheme name="Smack" version="173">
|
||||||
|
<JavaCodeStyleSettings>
|
||||||
|
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="10000" />
|
||||||
|
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="1000" />
|
||||||
|
<option name="IMPORT_LAYOUT_TABLE">
|
||||||
|
<value>
|
||||||
|
<package name="" withSubpackages="true" static="true" />
|
||||||
|
<emptyLine />
|
||||||
|
<package name="java" withSubpackages="true" static="false" />
|
||||||
|
<package name="javax" withSubpackages="true" static="false" />
|
||||||
|
<emptyLine />
|
||||||
|
<package name="org.jivesoftware" withSubpackages="true" static="false" />
|
||||||
|
<emptyLine />
|
||||||
|
<package name="" withSubpackages="true" static="false" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
</JavaCodeStyleSettings>
|
||||||
|
</code_scheme>
|
|
@ -14,15 +14,35 @@
|
||||||
AbstractXMPPConnection connection = new XMPPTCPConnection("mtucker", "password", "jabber.org");
|
AbstractXMPPConnection connection = new XMPPTCPConnection("mtucker", "password", "jabber.org");
|
||||||
connection.connect().login();
|
connection.connect().login();
|
||||||
|
|
||||||
Message message = new Message("jsmith@igniterealtime.org", "Howdy! How are you?");
|
Message message = connection.getStanzaFactory()
|
||||||
|
.buildMessageStanza()
|
||||||
|
.to("jsmith@igniterealtime.org")
|
||||||
|
.setBody("Howdy! How are you?")
|
||||||
|
.build();
|
||||||
|
|
||||||
connection.sendStanza(message);
|
connection.sendStanza(message);
|
||||||
|
|
||||||
|
connection.disconnect();
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>Smack doesn't force you to code at the protcol level of XMPP. The library provides intelligent higher level constructs, often called {@link org.jivesoftware.smack.Manager}, which let you program more efficiently. Other examples of those constructs are the Chat and Roster classes.</p>
|
<p>Smack doesn't force you to code at the protcol level of XMPP. The library provides intelligent higher level constructs, often called {@link org.jivesoftware.smack.Manager}, which let you program more efficiently. Other examples of those constructs are the Chat and Roster classes.</p>
|
||||||
|
|
||||||
<p>Smack comes with APIs for easy machine-to-machine communication. You can set any number of properties on each message, including properties that are Java objects.</p>
|
<p>Smack comes with APIs for easy machine-to-machine communication. You can set any number of properties on each message, including properties that are Java objects.</p>
|
||||||
|
|
||||||
<p>Smack is open-source under the Apache License 2.0, which means you can incorporate Smack into your commercial or non-commercial applications.</p>
|
<h2>License</h2>
|
||||||
|
|
||||||
|
<p>Smack is open-source and most parts are under the Apache License
|
||||||
|
2.0, which means you can incorporate Smack into your commercial or
|
||||||
|
non-commercial applications. Some parts of Smack may be under a
|
||||||
|
different open-source license. Please refer to the individual
|
||||||
|
subprojects for their license statement.</p>
|
||||||
|
|
||||||
|
<p>Note that the Apache License 2.0 requires that the contents of a
|
||||||
|
NOICE text file are shown "…within a display generated by the
|
||||||
|
Derivative Works, if and wherever such third-party notices normally
|
||||||
|
appear.". Smack comes with such a NOTICE file. The content of
|
||||||
|
Smack's NOTICE file can conveniently be retrieved using
|
||||||
|
{@link org.jivesoftware.smack.Smack#getNoticeStream}.</p>
|
||||||
|
|
||||||
<h2>About XMPP</h2>
|
<h2>About XMPP</h2>
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,44 @@ hr {
|
||||||
|
|
||||||
<div id="pageBody">
|
<div id="pageBody">
|
||||||
|
|
||||||
|
<h2>4.4.2 -- <span style="font-weight: normal;">2021-03-25</span></h2>
|
||||||
|
|
||||||
|
<h2> Bug
|
||||||
|
</h2>
|
||||||
|
<ul>
|
||||||
|
<li>[<a href='https://igniterealtime.atlassian.net/browse/SMACK-903'>SMACK-903</a>] - StaxXmlPullParser.getNamespace() may throws IllegalArgumentException
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://igniterealtime.atlassian.net/browse/SMACK-904'>SMACK-904</a>] - XEP-0096 file transfer fails because of a hidden ClastCastException
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2>4.4.1 -- <span style="font-weight: normal;">2021-03-03</span></h2>
|
||||||
|
|
||||||
|
<h2> Bug
|
||||||
|
</h2>
|
||||||
|
<ul>
|
||||||
|
<li>[<a href='https://igniterealtime.atlassian.net/browse/SMACK-895'>SMACK-895</a>] - BoBIQ#getIQChildElementBuilder throws NPE when the BoB data does not contain ‘max-age’.
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://igniterealtime.atlassian.net/browse/SMACK-896'>SMACK-896</a>] - BoBDataExtension is missing getter for BoBData and ContentId
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://igniterealtime.atlassian.net/browse/SMACK-897'>SMACK-897</a>] - DirectoryRosterStore.readEntry() should also catch IllegalArgumentException
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://igniterealtime.atlassian.net/browse/SMACK-898'>SMACK-898</a>] - AbstractProvider should also consider TypeVariable
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://igniterealtime.atlassian.net/browse/SMACK-899'>SMACK-899</a>] - NullPointerException in EntityCapsManager.addCapsExtension
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://igniterealtime.atlassian.net/browse/SMACK-900'>SMACK-900</a>] - NPE in DataForm.Builder.addItem()
|
||||||
|
</li>
|
||||||
|
<li>[<a href='https://igniterealtime.atlassian.net/browse/SMACK-902'>SMACK-902</a>] - DataFormProvider should retrieve the type of fields from <reported/> elements if possible
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2> Improvement
|
||||||
|
</h2>
|
||||||
|
<ul>
|
||||||
|
<li>[<a href='https://igniterealtime.atlassian.net/browse/SMACK-901'>SMACK-901</a>] - BoBDataExtension.from() should also allow IQs
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<h2>4.4.0 -- <span style="font-weight: normal;">2020-12-06</span></h2>
|
<h2>4.4.0 -- <span style="font-weight: normal;">2020-12-06</span></h2>
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ include 'smack-core',
|
||||||
'smack-openpgp',
|
'smack-openpgp',
|
||||||
'smack-websocket',
|
'smack-websocket',
|
||||||
'smack-websocket-okhttp',
|
'smack-websocket-okhttp',
|
||||||
|
'smack-websocket-java11',
|
||||||
'smack-xmlparser',
|
'smack-xmlparser',
|
||||||
'smack-xmlparser-stax',
|
'smack-xmlparser-stax',
|
||||||
'smack-xmlparser-xpp3'
|
'smack-xmlparser-xpp3'
|
||||||
|
|
|
@ -4,8 +4,8 @@ Extra Smack extensions for Android."""
|
||||||
// Note that the test dependencies (junit, …) are inferred from the
|
// Note that the test dependencies (junit, …) are inferred from the
|
||||||
// sourceSet.test of the core subproject
|
// sourceSet.test of the core subproject
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':smack-android')
|
api project(':smack-android')
|
||||||
compile project(':smack-extensions')
|
api project(':smack-extensions')
|
||||||
|
|
||||||
// Add the Android jar to the Eclipse .classpath.
|
// Add the Android jar to the Eclipse .classpath.
|
||||||
compileClasspath files(androidBootClasspath)
|
compileClasspath files(androidBootClasspath)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2017 Florian Schmaus
|
* Copyright © 2014-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -19,7 +19,6 @@ package org.jivesoftware.smackx.ping.android;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
@ -80,6 +79,12 @@ public final class ServerPingWithAlarmManager extends Manager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the instance of this manager for the given connection.
|
||||||
|
*
|
||||||
|
* @param connection the connection.
|
||||||
|
* @return the instance of this manager for the given connection.
|
||||||
|
*/
|
||||||
public static synchronized ServerPingWithAlarmManager getInstanceFor(XMPPConnection connection) {
|
public static synchronized ServerPingWithAlarmManager getInstanceFor(XMPPConnection connection) {
|
||||||
ServerPingWithAlarmManager serverPingWithAlarmManager = INSTANCES.get(connection);
|
ServerPingWithAlarmManager serverPingWithAlarmManager = INSTANCES.get(connection);
|
||||||
if (serverPingWithAlarmManager == null) {
|
if (serverPingWithAlarmManager == null) {
|
||||||
|
@ -105,6 +110,11 @@ public final class ServerPingWithAlarmManager extends Manager {
|
||||||
mEnabled = enabled;
|
mEnabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this manager is enabled.
|
||||||
|
*
|
||||||
|
* @return <code>true</code> if this manager is enabled, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return mEnabled;
|
return mEnabled;
|
||||||
}
|
}
|
||||||
|
@ -113,14 +123,14 @@ public final class ServerPingWithAlarmManager extends Manager {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
LOGGER.fine("Ping Alarm broadcast received");
|
LOGGER.fine("Ping Alarm broadcast received");
|
||||||
Set<Entry<XMPPConnection, ServerPingWithAlarmManager>> managers;
|
Set<Map.Entry<XMPPConnection, ServerPingWithAlarmManager>> managers;
|
||||||
synchronized (ServerPingWithAlarmManager.class) {
|
synchronized (ServerPingWithAlarmManager.class) {
|
||||||
// Make a copy to avoid ConcurrentModificationException when
|
// Make a copy to avoid ConcurrentModificationException when
|
||||||
// iterating directly over INSTANCES and the Set is modified
|
// iterating directly over INSTANCES and the Set is modified
|
||||||
// concurrently by creating a new ServerPingWithAlarmManager.
|
// concurrently by creating a new ServerPingWithAlarmManager.
|
||||||
managers = new HashSet<>(INSTANCES.entrySet());
|
managers = new HashSet<>(INSTANCES.entrySet());
|
||||||
}
|
}
|
||||||
for (Entry<XMPPConnection, ServerPingWithAlarmManager> entry : managers) {
|
for (Map.Entry<XMPPConnection, ServerPingWithAlarmManager> entry : managers) {
|
||||||
XMPPConnection connection = entry.getKey();
|
XMPPConnection connection = entry.getKey();
|
||||||
if (entry.getValue().isEnabled()) {
|
if (entry.getValue().isEnabled()) {
|
||||||
LOGGER.fine("Calling pingServerIfNecessary for connection "
|
LOGGER.fine("Calling pingServerIfNecessary for connection "
|
||||||
|
|
|
@ -14,13 +14,13 @@ dependencies {
|
||||||
// Android version is smaller then 21. Note that we deliberatly do
|
// Android version is smaller then 21. Note that we deliberatly do
|
||||||
// not add this to smack-minidns, as this dependency may also be
|
// not add this to smack-minidns, as this dependency may also be
|
||||||
// used in non-Android projects.
|
// used in non-Android projects.
|
||||||
compile "org.minidns:minidns-android21:$miniDnsVersion"
|
implementation "org.minidns:minidns-android21:$miniDnsVersion"
|
||||||
|
|
||||||
// androidProjects lists all projects that are checked to compile against android.jar
|
// androidProjects lists all projects that are checked to compile against android.jar
|
||||||
// Filter out the optional Smack dependencies from androidProjects
|
// Filter out the optional Smack dependencies from androidProjects
|
||||||
(androidProjects - androidOptionalProjects)
|
(androidProjects - androidOptionalProjects)
|
||||||
.each { project ->
|
.each { project ->
|
||||||
compile project
|
api project
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the Android jar to the Eclipse .classpath.
|
// Add the Android jar to the Eclipse .classpath.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2018 Florian Schmaus
|
* Copyright © 2014-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -39,8 +39,8 @@ public class AndroidSmackInitializer implements SmackInitializer {
|
||||||
@Override
|
@Override
|
||||||
public List<Exception> initialize() {
|
public List<Exception> initialize() {
|
||||||
SmackConfiguration.setDefaultHostnameVerifier(new StrictHostnameVerifier());
|
SmackConfiguration.setDefaultHostnameVerifier(new StrictHostnameVerifier());
|
||||||
Base64.setEncoder(AndroidBase64Encoder.getInstance());
|
Base64.setEncoder(AndroidBase64Encoder.INSTANCE);
|
||||||
Base64UrlSafeEncoder.setEncoder(AndroidBase64UrlSafeEncoder.getInstance());
|
Base64UrlSafeEncoder.setEncoder(AndroidBase64UrlSafeEncoder.INSTANCE);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2019 Florian Schmaus
|
* Copyright © 2014-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -24,7 +24,10 @@ import android.util.Base64;
|
||||||
*/
|
*/
|
||||||
public final class AndroidBase64Encoder implements org.jivesoftware.smack.util.stringencoder.Base64.Encoder {
|
public final class AndroidBase64Encoder implements org.jivesoftware.smack.util.stringencoder.Base64.Encoder {
|
||||||
|
|
||||||
private static AndroidBase64Encoder instance = new AndroidBase64Encoder();
|
/**
|
||||||
|
* An instance of this encoder.
|
||||||
|
*/
|
||||||
|
public static AndroidBase64Encoder INSTANCE = new AndroidBase64Encoder();
|
||||||
|
|
||||||
private static final int BASE64_ENCODER_FLAGS = Base64.NO_WRAP;
|
private static final int BASE64_ENCODER_FLAGS = Base64.NO_WRAP;
|
||||||
|
|
||||||
|
@ -32,10 +35,6 @@ public final class AndroidBase64Encoder implements org.jivesoftware.smack.util.s
|
||||||
// Use getInstance()
|
// Use getInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AndroidBase64Encoder getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] decode(String string) {
|
public byte[] decode(String string) {
|
||||||
return Base64.decode(string, Base64.DEFAULT);
|
return Base64.decode(string, Base64.DEFAULT);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2019 Florian Schmaus
|
* Copyright © 2014-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -22,9 +22,16 @@ import org.jivesoftware.smack.util.stringencoder.StringEncoder;
|
||||||
|
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An URL-safe Base64 encoder.
|
||||||
|
* @author Florian Schmaus
|
||||||
|
*/
|
||||||
public final class AndroidBase64UrlSafeEncoder implements StringEncoder<String> {
|
public final class AndroidBase64UrlSafeEncoder implements StringEncoder<String> {
|
||||||
|
|
||||||
private static AndroidBase64UrlSafeEncoder instance = new AndroidBase64UrlSafeEncoder();
|
/**
|
||||||
|
* An instance of this encoder.
|
||||||
|
*/
|
||||||
|
public static AndroidBase64UrlSafeEncoder INSTANCE = new AndroidBase64UrlSafeEncoder();
|
||||||
|
|
||||||
private static final int BASE64_ENCODER_FLAGS = Base64.URL_SAFE | Base64.NO_WRAP;
|
private static final int BASE64_ENCODER_FLAGS = Base64.URL_SAFE | Base64.NO_WRAP;
|
||||||
|
|
||||||
|
@ -32,10 +39,6 @@ public final class AndroidBase64UrlSafeEncoder implements StringEncoder<String>
|
||||||
// Use getInstance()
|
// Use getInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AndroidBase64UrlSafeEncoder getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String encode(String string) {
|
public String encode(String string) {
|
||||||
return Base64.encodeToString(string.getBytes(StandardCharsets.UTF_8), BASE64_ENCODER_FLAGS);
|
return Base64.encodeToString(string.getBytes(StandardCharsets.UTF_8), BASE64_ENCODER_FLAGS);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2017 Florian Schmaus
|
* Copyright © 2014-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -34,6 +34,11 @@ import android.util.Log;
|
||||||
*/
|
*/
|
||||||
public class AndroidDebugger extends AbstractDebugger {
|
public class AndroidDebugger extends AbstractDebugger {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new Smack debugger for Android.
|
||||||
|
*
|
||||||
|
* @param connection the connection to debug.
|
||||||
|
*/
|
||||||
public AndroidDebugger(XMPPConnection connection) {
|
public AndroidDebugger(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@ Smack BOSH API.
|
||||||
This API is considered beta quality."""
|
This API is considered beta quality."""
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':smack-core')
|
api project(':smack-core')
|
||||||
// See https://issues.igniterealtime.org/browse/SMACK-858 and
|
// See https://issues.igniterealtime.org/browse/SMACK-858 and
|
||||||
// comment in version.gradle why the specify the version this way.
|
// comment in version.gradle why the specify the version this way.
|
||||||
compile 'org.igniterealtime.jbosh:jbosh:[0.9.1,0.9.999]'
|
implementation 'org.igniterealtime.jbosh:jbosh:[0.9.1,0.9.999]'
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,10 @@ ext {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':smack-xmlparser')
|
api project(':smack-xmlparser')
|
||||||
compile "org.jxmpp:jxmpp-core:$jxmppVersion"
|
api "org.jxmpp:jxmpp-core:$jxmppVersion"
|
||||||
compile "org.jxmpp:jxmpp-jid:$jxmppVersion"
|
api "org.jxmpp:jxmpp-jid:$jxmppVersion"
|
||||||
compile "org.minidns:minidns-core:$miniDnsVersion"
|
api "org.minidns:minidns-core:$miniDnsVersion"
|
||||||
|
|
||||||
testFixturesImplementation project(':smack-xmlparser-stax')
|
testFixturesImplementation project(':smack-xmlparser-stax')
|
||||||
testFixturesImplementation project(':smack-xmlparser-xpp3')
|
testFixturesImplementation project(':smack-xmlparser-xpp3')
|
||||||
|
@ -33,7 +33,7 @@ dependencies {
|
||||||
testFixturesApi "org.assertj:assertj-core:3.11.1"
|
testFixturesApi "org.assertj:assertj-core:3.11.1"
|
||||||
testFixturesApi "org.xmlunit:xmlunit-assertj:$xmlUnitVersion"
|
testFixturesApi "org.xmlunit:xmlunit-assertj:$xmlUnitVersion"
|
||||||
testFixturesApi 'org.hamcrest:hamcrest-library:2.2'
|
testFixturesApi 'org.hamcrest:hamcrest-library:2.2'
|
||||||
testFixturesApi 'com.google.guava:guava:28.2-jre'
|
testFixturesApi "com.google.guava:guava:${guavaVersion}"
|
||||||
}
|
}
|
||||||
|
|
||||||
class CreateFileTask extends DefaultTask {
|
class CreateFileTask extends DefaultTask {
|
||||||
|
|
|
@ -74,7 +74,6 @@ import org.jivesoftware.smack.packet.AbstractStreamOpen;
|
||||||
import org.jivesoftware.smack.packet.Bind;
|
import org.jivesoftware.smack.packet.Bind;
|
||||||
import org.jivesoftware.smack.packet.ErrorIQ;
|
import org.jivesoftware.smack.packet.ErrorIQ;
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.Mechanisms;
|
import org.jivesoftware.smack.packet.Mechanisms;
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
|
@ -92,6 +91,7 @@ import org.jivesoftware.smack.packet.StartTls;
|
||||||
import org.jivesoftware.smack.packet.StreamError;
|
import org.jivesoftware.smack.packet.StreamError;
|
||||||
import org.jivesoftware.smack.packet.StreamOpen;
|
import org.jivesoftware.smack.packet.StreamOpen;
|
||||||
import org.jivesoftware.smack.packet.TopLevelStreamElement;
|
import org.jivesoftware.smack.packet.TopLevelStreamElement;
|
||||||
|
import org.jivesoftware.smack.packet.XmlElement;
|
||||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||||
import org.jivesoftware.smack.packet.id.StanzaIdSource;
|
import org.jivesoftware.smack.packet.id.StanzaIdSource;
|
||||||
import org.jivesoftware.smack.parsing.ParsingExceptionCallback;
|
import org.jivesoftware.smack.parsing.ParsingExceptionCallback;
|
||||||
|
@ -239,7 +239,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
|
|
||||||
protected final Lock connectionLock = new ReentrantLock();
|
protected final Lock connectionLock = new ReentrantLock();
|
||||||
|
|
||||||
protected final Map<QName, FullyQualifiedElement> streamFeatures = new HashMap<>();
|
protected final Map<QName, XmlElement> streamFeatures = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The full JID of the authenticated user, as returned by the resource binding response of the server.
|
* The full JID of the authenticated user, as returned by the resource binding response of the server.
|
||||||
|
@ -377,6 +377,8 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
|
|
||||||
private final Map<QName, IQRequestHandler> setIqRequestHandler = new HashMap<>();
|
private final Map<QName, IQRequestHandler> setIqRequestHandler = new HashMap<>();
|
||||||
private final Map<QName, IQRequestHandler> getIqRequestHandler = new HashMap<>();
|
private final Map<QName, IQRequestHandler> getIqRequestHandler = new HashMap<>();
|
||||||
|
private final Set<String> iqRequestHandlerNamespaces = new CopyOnWriteArraySet<>();
|
||||||
|
private final Map<String, Integer> iqRequestHandlerNamespacesReferenceCounters = new HashMap<>();
|
||||||
|
|
||||||
private final StanzaFactory stanzaFactory;
|
private final StanzaFactory stanzaFactory;
|
||||||
|
|
||||||
|
@ -1407,6 +1409,13 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
return successNonza;
|
return successNonza;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void maybeNotifyDebuggerAboutIncoming(TopLevelStreamElement incomingTopLevelStreamElement) {
|
||||||
|
final SmackDebugger debugger = this.debugger;
|
||||||
|
if (debugger != null) {
|
||||||
|
debugger.onIncomingStreamElement(incomingTopLevelStreamElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected final void parseAndProcessNonza(XmlPullParser parser) throws IOException, XmlPullParserException, SmackParsingException {
|
protected final void parseAndProcessNonza(XmlPullParser parser) throws IOException, XmlPullParserException, SmackParsingException {
|
||||||
ParserUtils.assertAtStartTag(parser);
|
ParserUtils.assertAtStartTag(parser);
|
||||||
|
|
||||||
|
@ -1435,6 +1444,8 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
|
|
||||||
Nonza nonza = nonzaProvider.parse(parser, incomingStreamXmlEnvironment);
|
Nonza nonza = nonzaProvider.parse(parser, incomingStreamXmlEnvironment);
|
||||||
|
|
||||||
|
maybeNotifyDebuggerAboutIncoming(nonza);
|
||||||
|
|
||||||
for (NonzaCallback nonzaCallback : nonzaCallbacks) {
|
for (NonzaCallback nonzaCallback : nonzaCallbacks) {
|
||||||
nonzaCallback.onNonzaReceived(nonza);
|
nonzaCallback.onNonzaReceived(nonza);
|
||||||
}
|
}
|
||||||
|
@ -1474,10 +1485,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
protected void processStanza(final Stanza stanza) throws InterruptedException {
|
protected void processStanza(final Stanza stanza) throws InterruptedException {
|
||||||
assert stanza != null;
|
assert stanza != null;
|
||||||
|
|
||||||
final SmackDebugger debugger = this.debugger;
|
maybeNotifyDebuggerAboutIncoming(stanza);
|
||||||
if (debugger != null) {
|
|
||||||
debugger.onIncomingStreamElement(stanza);
|
|
||||||
}
|
|
||||||
|
|
||||||
lastStanzaReceived = System.currentTimeMillis();
|
lastStanzaReceived = System.currentTimeMillis();
|
||||||
// Deliver the incoming packet to listeners.
|
// Deliver the incoming packet to listeners.
|
||||||
|
@ -1518,15 +1526,18 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
throw new IllegalStateException("Should only encounter IQ type 'get' or 'set'");
|
throw new IllegalStateException("Should only encounter IQ type 'get' or 'set'");
|
||||||
}
|
}
|
||||||
if (iqRequestHandler == null) {
|
if (iqRequestHandler == null) {
|
||||||
|
final String iqNamespace = key.getNamespaceURI();
|
||||||
StanzaError.Condition replyCondition;
|
StanzaError.Condition replyCondition;
|
||||||
switch (unknownIqRequestReplyMode) {
|
switch (unknownIqRequestReplyMode) {
|
||||||
case doNotReply:
|
case doNotReply:
|
||||||
return;
|
return;
|
||||||
case replyFeatureNotImplemented:
|
case reply:
|
||||||
|
boolean isKnownNamespace = iqRequestHandlerNamespaces.contains(iqNamespace);
|
||||||
|
if (isKnownNamespace) {
|
||||||
replyCondition = StanzaError.Condition.feature_not_implemented;
|
replyCondition = StanzaError.Condition.feature_not_implemented;
|
||||||
break;
|
} else {
|
||||||
case replyServiceUnavailable:
|
|
||||||
replyCondition = StanzaError.Condition.service_unavailable;
|
replyCondition = StanzaError.Condition.service_unavailable;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
|
@ -1848,7 +1859,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
XmlPullParser.Event eventType = parser.next();
|
XmlPullParser.Event eventType = parser.next();
|
||||||
|
|
||||||
if (eventType == XmlPullParser.Event.START_ELEMENT && parser.getDepth() == initialDepth + 1) {
|
if (eventType == XmlPullParser.Event.START_ELEMENT && parser.getDepth() == initialDepth + 1) {
|
||||||
FullyQualifiedElement streamFeature = null;
|
XmlElement streamFeature = null;
|
||||||
String name = parser.getName();
|
String name = parser.getName();
|
||||||
String namespace = parser.getNamespace();
|
String namespace = parser.getNamespace();
|
||||||
switch (name) {
|
switch (name) {
|
||||||
|
@ -1917,7 +1928,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <F extends FullyQualifiedElement> F getFeature(QName qname) {
|
public <F extends XmlElement> F getFeature(QName qname) {
|
||||||
return (F) streamFeatures.get(qname);
|
return (F) streamFeatures.get(qname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1926,7 +1937,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
return streamFeatures.containsKey(qname);
|
return streamFeatures.containsKey(qname);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addStreamFeature(FullyQualifiedElement feature) {
|
protected void addStreamFeature(XmlElement feature) {
|
||||||
QName key = feature.getQName();
|
QName key = feature.getQName();
|
||||||
streamFeatures.put(key, feature);
|
streamFeatures.put(key, feature);
|
||||||
}
|
}
|
||||||
|
@ -2037,18 +2048,35 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
@Override
|
@Override
|
||||||
public IQRequestHandler registerIQRequestHandler(final IQRequestHandler iqRequestHandler) {
|
public IQRequestHandler registerIQRequestHandler(final IQRequestHandler iqRequestHandler) {
|
||||||
final QName key = iqRequestHandler.getQName();
|
final QName key = iqRequestHandler.getQName();
|
||||||
|
IQRequestHandler previous;
|
||||||
switch (iqRequestHandler.getType()) {
|
switch (iqRequestHandler.getType()) {
|
||||||
case set:
|
case set:
|
||||||
synchronized (setIqRequestHandler) {
|
synchronized (setIqRequestHandler) {
|
||||||
return setIqRequestHandler.put(key, iqRequestHandler);
|
previous = setIqRequestHandler.put(key, iqRequestHandler);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case get:
|
case get:
|
||||||
synchronized (getIqRequestHandler) {
|
synchronized (getIqRequestHandler) {
|
||||||
return getIqRequestHandler.put(key, iqRequestHandler);
|
previous = getIqRequestHandler.put(key, iqRequestHandler);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Only IQ type of 'get' and 'set' allowed");
|
throw new IllegalArgumentException("Only IQ type of 'get' and 'set' allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String iqNamespace = key.getNamespaceURI();
|
||||||
|
synchronized (iqRequestHandlerNamespacesReferenceCounters) {
|
||||||
|
Integer newValue;
|
||||||
|
Integer counter = iqRequestHandlerNamespacesReferenceCounters.get(iqNamespace);
|
||||||
|
if (counter == null) {
|
||||||
|
iqRequestHandlerNamespaces.add(iqNamespace);
|
||||||
|
newValue = 0;
|
||||||
|
} else {
|
||||||
|
newValue = counter.intValue() + 1;
|
||||||
|
}
|
||||||
|
iqRequestHandlerNamespacesReferenceCounters.put(iqNamespace, newValue);
|
||||||
|
}
|
||||||
|
return previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2059,19 +2087,38 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQRequestHandler unregisterIQRequestHandler(String element, String namespace, IQ.Type type) {
|
public IQRequestHandler unregisterIQRequestHandler(String element, String namespace, IQ.Type type) {
|
||||||
|
IQRequestHandler unregisteredHandler;
|
||||||
final QName key = new QName(namespace, element);
|
final QName key = new QName(namespace, element);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case set:
|
case set:
|
||||||
synchronized (setIqRequestHandler) {
|
synchronized (setIqRequestHandler) {
|
||||||
return setIqRequestHandler.remove(key);
|
unregisteredHandler = setIqRequestHandler.remove(key);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case get:
|
case get:
|
||||||
synchronized (getIqRequestHandler) {
|
synchronized (getIqRequestHandler) {
|
||||||
return getIqRequestHandler.remove(key);
|
unregisteredHandler = getIqRequestHandler.remove(key);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Only IQ type of 'get' and 'set' allowed");
|
throw new IllegalArgumentException("Only IQ type of 'get' and 'set' allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (unregisteredHandler == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (iqRequestHandlerNamespacesReferenceCounters) {
|
||||||
|
int newValue = iqRequestHandlerNamespacesReferenceCounters.get(namespace).intValue() - 1;
|
||||||
|
if (newValue == 0) {
|
||||||
|
iqRequestHandlerNamespacesReferenceCounters.remove(namespace);
|
||||||
|
iqRequestHandlerNamespaces.remove(namespace);
|
||||||
|
} else {
|
||||||
|
iqRequestHandlerNamespacesReferenceCounters.put(namespace, newValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return unregisteredHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long lastStanzaReceived;
|
private long lastStanzaReceived;
|
||||||
|
@ -2214,7 +2261,8 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
* @return a String representing the corresponding stream end tag.
|
* @return a String representing the corresponding stream end tag.
|
||||||
*/
|
*/
|
||||||
protected String onStreamOpen(XmlPullParser parser) {
|
protected String onStreamOpen(XmlPullParser parser) {
|
||||||
assert StreamOpen.ETHERX_JABBER_STREAMS_NAMESPACE.equals(parser.getNamespace());
|
assert StreamOpen.ETHERX_JABBER_STREAMS_NAMESPACE.equals(parser.getNamespace()) : parser.getNamespace()
|
||||||
|
+ " is not " + StreamOpen.ETHERX_JABBER_STREAMS_NAMESPACE;
|
||||||
assert StreamOpen.UNPREFIXED_ELEMENT.equals(parser.getName());
|
assert StreamOpen.UNPREFIXED_ELEMENT.equals(parser.getName());
|
||||||
|
|
||||||
streamId = parser.getAttributeValue("id");
|
streamId = parser.getAttributeValue("id");
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.jivesoftware.smack.sasl.core.ScramSha1PlusMechanism;
|
||||||
import org.jivesoftware.smack.sasl.packet.SaslNonza;
|
import org.jivesoftware.smack.sasl.packet.SaslNonza;
|
||||||
import org.jivesoftware.smack.sasl.packet.SaslNonza.SASLFailure;
|
import org.jivesoftware.smack.sasl.packet.SaslNonza.SASLFailure;
|
||||||
import org.jivesoftware.smack.sasl.packet.SaslNonza.Success;
|
import org.jivesoftware.smack.sasl.packet.SaslNonza.Success;
|
||||||
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
|
|
||||||
import org.jxmpp.jid.DomainBareJid;
|
import org.jxmpp.jid.DomainBareJid;
|
||||||
import org.jxmpp.jid.EntityBareJid;
|
import org.jxmpp.jid.EntityBareJid;
|
||||||
|
@ -184,7 +185,7 @@ public final class SASLAuthentication {
|
||||||
SASLMechanism authenticate(String username, String password, EntityBareJid authzid, SSLSession sslSession)
|
SASLMechanism authenticate(String username, String password, EntityBareJid authzid, SSLSession sslSession)
|
||||||
throws XMPPErrorException, SASLErrorException, IOException,
|
throws XMPPErrorException, SASLErrorException, IOException,
|
||||||
InterruptedException, SmackSaslException, NotConnectedException, NoResponseException {
|
InterruptedException, SmackSaslException, NotConnectedException, NoResponseException {
|
||||||
final SASLMechanism mechanism = selectMechanism(authzid);
|
final SASLMechanism mechanism = selectMechanism(authzid, password);
|
||||||
final CallbackHandler callbackHandler = configuration.getCallbackHandler();
|
final CallbackHandler callbackHandler = configuration.getCallbackHandler();
|
||||||
final String host = connection.getHost();
|
final String host = connection.getHost();
|
||||||
final DomainBareJid xmppServiceDomain = connection.getXMPPServiceDomain();
|
final DomainBareJid xmppServiceDomain = connection.getXMPPServiceDomain();
|
||||||
|
@ -249,7 +250,6 @@ public final class SASLAuthentication {
|
||||||
* Notification message saying that SASL authentication was successful. The next step
|
* Notification message saying that SASL authentication was successful. The next step
|
||||||
* would be to bind the resource.
|
* would be to bind the resource.
|
||||||
* @param success result of the authentication.
|
* @param success result of the authentication.
|
||||||
* @throws SmackException if Smack detected an exceptional situation.
|
|
||||||
* @throws InterruptedException if the calling thread was interrupted.
|
* @throws InterruptedException if the calling thread was interrupted.
|
||||||
* @throws NotConnectedException if the XMPP connection is not connected.
|
* @throws NotConnectedException if the XMPP connection is not connected.
|
||||||
* @throws SmackSaslException if a SASL specific error occurred.
|
* @throws SmackSaslException if a SASL specific error occurred.
|
||||||
|
@ -312,35 +312,49 @@ public final class SASLAuthentication {
|
||||||
return lastUsedMech.getName();
|
return lastUsedMech.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private SASLMechanism selectMechanism(EntityBareJid authzid) throws SmackException.SmackSaslException {
|
private SASLMechanism selectMechanism(EntityBareJid authzid, String password) throws SmackException.SmackSaslException {
|
||||||
|
final boolean passwordAvailable = StringUtils.isNotEmpty(password);
|
||||||
|
|
||||||
Iterator<SASLMechanism> it = REGISTERED_MECHANISMS.iterator();
|
Iterator<SASLMechanism> it = REGISTERED_MECHANISMS.iterator();
|
||||||
final List<String> serverMechanisms = getServerMechanisms();
|
final List<String> serverMechanisms = getServerMechanisms();
|
||||||
if (serverMechanisms.isEmpty()) {
|
if (serverMechanisms.isEmpty()) {
|
||||||
LOGGER.warning("Server did not report any SASL mechanisms");
|
LOGGER.warning("Server did not report any SASL mechanisms");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> skipReasons = new ArrayList<>();
|
||||||
|
|
||||||
// Iterate in SASL Priority order over registered mechanisms
|
// Iterate in SASL Priority order over registered mechanisms
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
SASLMechanism mechanism = it.next();
|
SASLMechanism mechanism = it.next();
|
||||||
String mechanismName = mechanism.getName();
|
String mechanismName = mechanism.getName();
|
||||||
|
|
||||||
|
if (!serverMechanisms.contains(mechanismName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
synchronized (BLACKLISTED_MECHANISMS) {
|
synchronized (BLACKLISTED_MECHANISMS) {
|
||||||
if (BLACKLISTED_MECHANISMS.contains(mechanismName)) {
|
if (BLACKLISTED_MECHANISMS.contains(mechanismName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!configuration.isEnabledSaslMechanism(mechanismName)) {
|
if (!configuration.isEnabledSaslMechanism(mechanismName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (authzid != null) {
|
|
||||||
if (!mechanism.authzidSupported()) {
|
if (authzid != null && !mechanism.authzidSupported()) {
|
||||||
LOGGER.fine("Skipping " + mechanism + " because authzid is required by not supported by this SASL mechanism");
|
skipReasons.add("Skipping " + mechanism + " because authzid is required by not supported by this SASL mechanism");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mechanism.requiresPassword() && !passwordAvailable) {
|
||||||
|
skipReasons.add("Skipping " + mechanism + " because a password is required for it, but none was provided to the connection configuration");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (serverMechanisms.contains(mechanismName)) {
|
|
||||||
// Create a new instance of the SASLMechanism for every authentication attempt.
|
// Create a new instance of the SASLMechanism for every authentication attempt.
|
||||||
return mechanism.instanceForAuthentication(connection, configuration);
|
return mechanism.instanceForAuthentication(connection, configuration);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (BLACKLISTED_MECHANISMS) {
|
synchronized (BLACKLISTED_MECHANISMS) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
|
@ -349,7 +363,8 @@ public final class SASLAuthentication {
|
||||||
"Server announced mechanisms: " + serverMechanisms + ". " +
|
"Server announced mechanisms: " + serverMechanisms + ". " +
|
||||||
"Registered SASL mechanisms with Smack: " + REGISTERED_MECHANISMS + ". " +
|
"Registered SASL mechanisms with Smack: " + REGISTERED_MECHANISMS + ". " +
|
||||||
"Enabled SASL mechanisms for this connection: " + configuration.getEnabledSaslMechanisms() + ". " +
|
"Enabled SASL mechanisms for this connection: " + configuration.getEnabledSaslMechanisms() + ". " +
|
||||||
"Blacklisted SASL mechanisms: " + BLACKLISTED_MECHANISMS + '.'
|
"Blacklisted SASL mechanisms: " + BLACKLISTED_MECHANISMS + ". " +
|
||||||
|
"Skip reasons: " + skipReasons
|
||||||
);
|
);
|
||||||
// @formatter;on
|
// @formatter;on
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2020 Florian Schmaus
|
* Copyright 2020-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -19,6 +19,8 @@ package org.jivesoftware.smack;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.util.FileUtils;
|
||||||
|
|
||||||
public class Smack {
|
public class Smack {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(Smack.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(Smack.class.getName());
|
||||||
|
@ -38,8 +40,20 @@ public class Smack {
|
||||||
|
|
||||||
private static final String NOTICE_RESOURCE = SMACK_PACKAGE + "/NOTICE";
|
private static final String NOTICE_RESOURCE = SMACK_PACKAGE + "/NOTICE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the stream of the NOTICE file of Smack.
|
||||||
|
* <p>
|
||||||
|
* This license of Smack requires that the contents of this NOTICE text file are shown "…within a display generated by
|
||||||
|
* the Derivative Works, if and wherever such third-party notices normally appear.".
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @return the stream of the NOTICE file of Smack.
|
||||||
|
* @since 4.4.0
|
||||||
|
*/
|
||||||
public static InputStream getNoticeStream() {
|
public static InputStream getNoticeStream() {
|
||||||
return ClassLoader.getSystemResourceAsStream(NOTICE_RESOURCE);
|
InputStream res = FileUtils.getInputStreamForClasspathFile(NOTICE_RESOURCE);
|
||||||
|
assert res != null;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ensureInitialized() {
|
public static void ensureInitialized() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2018-2020 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software, 2018-2021 Florian Schmaus.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -343,11 +343,10 @@ public final class SmackConfiguration {
|
||||||
|
|
||||||
public enum UnknownIqRequestReplyMode {
|
public enum UnknownIqRequestReplyMode {
|
||||||
doNotReply,
|
doNotReply,
|
||||||
replyFeatureNotImplemented,
|
reply,
|
||||||
replyServiceUnavailable,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UnknownIqRequestReplyMode unknownIqRequestReplyMode = UnknownIqRequestReplyMode.replyFeatureNotImplemented;
|
private static UnknownIqRequestReplyMode unknownIqRequestReplyMode = UnknownIqRequestReplyMode.reply;
|
||||||
|
|
||||||
public static UnknownIqRequestReplyMode getUnknownIqRequestReplyMode() {
|
public static UnknownIqRequestReplyMode getUnknownIqRequestReplyMode() {
|
||||||
return unknownIqRequestReplyMode;
|
return unknownIqRequestReplyMode;
|
||||||
|
|
|
@ -343,7 +343,7 @@ public final class StanzaCollector implements AutoCloseable {
|
||||||
*
|
*
|
||||||
* @param packet the stanza to process.
|
* @param packet the stanza to process.
|
||||||
*/
|
*/
|
||||||
protected void processStanza(Stanza packet) {
|
void processStanza(Stanza packet) {
|
||||||
if (packetFilter == null || packetFilter.accept(packet)) {
|
if (packetFilter == null || packetFilter.accept(packet)) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (resultQueue.size() == maxQueueSize) {
|
if (resultQueue.size() == maxQueueSize) {
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.jivesoftware.smack.filter.IQReplyFilter;
|
||||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||||
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
|
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smack.packet.MessageBuilder;
|
import org.jivesoftware.smack.packet.MessageBuilder;
|
||||||
|
@ -36,6 +35,7 @@ import org.jivesoftware.smack.packet.Presence;
|
||||||
import org.jivesoftware.smack.packet.PresenceBuilder;
|
import org.jivesoftware.smack.packet.PresenceBuilder;
|
||||||
import org.jivesoftware.smack.packet.Stanza;
|
import org.jivesoftware.smack.packet.Stanza;
|
||||||
import org.jivesoftware.smack.packet.StanzaFactory;
|
import org.jivesoftware.smack.packet.StanzaFactory;
|
||||||
|
import org.jivesoftware.smack.packet.XmlElement;
|
||||||
import org.jivesoftware.smack.util.Consumer;
|
import org.jivesoftware.smack.util.Consumer;
|
||||||
import org.jivesoftware.smack.util.Predicate;
|
import org.jivesoftware.smack.util.Predicate;
|
||||||
import org.jivesoftware.smack.util.XmppElementUtil;
|
import org.jivesoftware.smack.util.XmppElementUtil;
|
||||||
|
@ -583,7 +583,7 @@ public interface XMPPConnection {
|
||||||
*/
|
*/
|
||||||
// TODO: Remove in Smack 4.5.
|
// TODO: Remove in Smack 4.5.
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default <F extends FullyQualifiedElement> F getFeature(String element, String namespace) {
|
default <F extends XmlElement> F getFeature(String element, String namespace) {
|
||||||
QName qname = new QName(namespace, element);
|
QName qname = new QName(namespace, element);
|
||||||
return getFeature(qname);
|
return getFeature(qname);
|
||||||
}
|
}
|
||||||
|
@ -597,7 +597,7 @@ public interface XMPPConnection {
|
||||||
* @return a stanza extensions of the feature or <code>null</code>
|
* @return a stanza extensions of the feature or <code>null</code>
|
||||||
* @since 4.4
|
* @since 4.4
|
||||||
*/
|
*/
|
||||||
<F extends FullyQualifiedElement> F getFeature(QName qname);
|
<F extends XmlElement> F getFeature(QName qname);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the feature stanza extensions for a given stream feature of the
|
* Get the feature stanza extensions for a given stream feature of the
|
||||||
|
@ -608,7 +608,7 @@ public interface XMPPConnection {
|
||||||
* @return a stanza extensions of the feature or <code>null</code>
|
* @return a stanza extensions of the feature or <code>null</code>
|
||||||
* @since 4.4
|
* @since 4.4
|
||||||
*/
|
*/
|
||||||
default <F extends FullyQualifiedElement> F getFeature(Class<F> featureClass) {
|
default <F extends XmlElement> F getFeature(Class<F> featureClass) {
|
||||||
QName qname = XmppElementUtil.getQNameFor(featureClass);
|
QName qname = XmppElementUtil.getQNameFor(featureClass);
|
||||||
return getFeature(qname);
|
return getFeature(qname);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
|
|
||||||
private boolean featuresReceived;
|
private boolean featuresReceived;
|
||||||
|
|
||||||
protected boolean streamResumed;
|
private boolean streamResumed;
|
||||||
|
|
||||||
private GraphVertex<State> currentStateVertex;
|
private GraphVertex<State> currentStateVertex;
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
walkStateGraph(walkStateGraphContext);
|
walkStateGraph(walkStateGraphContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WalkStateGraphContext.Builder buildNewWalkTo(Class<? extends StateDescriptor> finalStateClass) {
|
private WalkStateGraphContext.Builder buildNewWalkTo(Class<? extends StateDescriptor> finalStateClass) {
|
||||||
return WalkStateGraphContext.builder(currentStateVertex.getElement().getStateDescriptor().getClass(), finalStateClass);
|
return WalkStateGraphContext.builder(currentStateVertex.getElement().getStateDescriptor().getClass(), finalStateClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
revertedState.resetState();
|
revertedState.resetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void walkStateGraph(WalkStateGraphContext walkStateGraphContext)
|
private void walkStateGraph(WalkStateGraphContext walkStateGraphContext)
|
||||||
throws XMPPException, IOException, SmackException, InterruptedException {
|
throws XMPPException, IOException, SmackException, InterruptedException {
|
||||||
// Save a copy of the current state
|
// Save a copy of the current state
|
||||||
GraphVertex<State> previousStateVertex = currentStateVertex;
|
GraphVertex<State> previousStateVertex = currentStateVertex;
|
||||||
|
@ -491,7 +491,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SSLSession getSSLSession() {
|
private SSLSession getSSLSession() {
|
||||||
final XmppClientToServerTransport transport = activeTransport;
|
final XmppClientToServerTransport transport = activeTransport;
|
||||||
if (transport == null) {
|
if (transport == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -505,7 +505,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
notifyWaitingThreads();
|
notifyWaitingThreads();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void parseAndProcessElement(String element) {
|
private void parseAndProcessElement(String element) {
|
||||||
try {
|
try {
|
||||||
XmlPullParser parser = PacketParserUtils.getParserFor(element);
|
XmlPullParser parser = PacketParserUtils.getParserFor(element);
|
||||||
|
|
||||||
|
@ -556,11 +556,11 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected synchronized void prepareToWaitForFeaturesReceived() {
|
private synchronized void prepareToWaitForFeaturesReceived() {
|
||||||
featuresReceived = false;
|
featuresReceived = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void waitForFeaturesReceived(String waitFor)
|
private void waitForFeaturesReceived(String waitFor)
|
||||||
throws InterruptedException, SmackException, XMPPException {
|
throws InterruptedException, SmackException, XMPPException {
|
||||||
waitForConditionOrThrowConnectionException(() -> featuresReceived, waitFor);
|
waitForConditionOrThrowConnectionException(() -> featuresReceived, waitFor);
|
||||||
}
|
}
|
||||||
|
@ -571,7 +571,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
return streamOpenAndCloseFactory.createStreamOpen(to, from, id, lang);
|
return streamOpenAndCloseFactory.createStreamOpen(to, from, id, lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void newStreamOpenWaitForFeaturesSequence(String waitFor) throws InterruptedException,
|
private void newStreamOpenWaitForFeaturesSequence(String waitFor) throws InterruptedException,
|
||||||
SmackException, XMPPException {
|
SmackException, XMPPException {
|
||||||
prepareToWaitForFeaturesReceived();
|
prepareToWaitForFeaturesReceived();
|
||||||
|
|
||||||
|
@ -1028,7 +1028,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
return connectionStateMachineListeners.remove(connectionStateMachineListener);
|
return connectionStateMachineListeners.remove(connectionStateMachineListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void invokeConnectionStateMachineListener(ConnectionStateEvent connectionStateEvent) {
|
private void invokeConnectionStateMachineListener(ConnectionStateEvent connectionStateEvent) {
|
||||||
if (connectionStateMachineListeners.isEmpty()) {
|
if (connectionStateMachineListeners.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1056,7 +1056,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
|
||||||
walkStateGraph(walkStateGraphContext);
|
walkStateGraph(walkStateGraphContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String, Object> getFilterStats() {
|
private Map<String, Object> getFilterStats() {
|
||||||
Collection<XmppInputOutputFilter> filters;
|
Collection<XmppInputOutputFilter> filters;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (inputOutputFilters.isEmpty() && previousInputOutputFilters != null) {
|
if (inputOutputFilters.isEmpty() && previousInputOutputFilters != null) {
|
||||||
|
|
|
@ -54,8 +54,6 @@ public abstract class XmppClientToServerTransport {
|
||||||
|
|
||||||
public abstract SSLSession getSslSession();
|
public abstract SSLSession getSslSession();
|
||||||
|
|
||||||
public abstract boolean isConnected();
|
|
||||||
|
|
||||||
public boolean isTransportSecured() {
|
public boolean isTransportSecured() {
|
||||||
return getSslSession() != null;
|
return getSslSession() != null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2015 Florian Schmaus
|
* Copyright 2015-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -44,11 +44,20 @@ public abstract class AbstractListFilter implements StanzaFilter {
|
||||||
* @param filters the filters to add.
|
* @param filters the filters to add.
|
||||||
*/
|
*/
|
||||||
protected AbstractListFilter(StanzaFilter... filters) {
|
protected AbstractListFilter(StanzaFilter... filters) {
|
||||||
|
this(new ArrayList<StanzaFilter>(Arrays.asList(filters)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an filter using the specified filters.
|
||||||
|
*
|
||||||
|
* @param filters the filters to add.
|
||||||
|
*/
|
||||||
|
protected AbstractListFilter(List<StanzaFilter> filters) {
|
||||||
Objects.requireNonNull(filters, "Parameter must not be null.");
|
Objects.requireNonNull(filters, "Parameter must not be null.");
|
||||||
for (StanzaFilter filter : filters) {
|
for (StanzaFilter filter : filters) {
|
||||||
Objects.requireNonNull(filter, "Parameter must not be null.");
|
Objects.requireNonNull(filter, "Parameter must not be null.");
|
||||||
}
|
}
|
||||||
this.filters = new ArrayList<StanzaFilter>(Arrays.asList(filters));
|
this.filters = filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software.
|
* Copyright 2003-2007 Jive Software, 2021 Florian Schmaus.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
package org.jivesoftware.smack.filter;
|
package org.jivesoftware.smack.filter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.Stanza;
|
import org.jivesoftware.smack.packet.Stanza;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,6 +46,15 @@ public class AndFilter extends AbstractListFilter implements StanzaFilter {
|
||||||
super(filters);
|
super(filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an AND filter using the specified filters.
|
||||||
|
*
|
||||||
|
* @param filters the filters to add.
|
||||||
|
*/
|
||||||
|
public AndFilter(List<StanzaFilter> filters) {
|
||||||
|
super(filters);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(Stanza packet) {
|
public boolean accept(Stanza packet) {
|
||||||
for (StanzaFilter filter : filters) {
|
for (StanzaFilter filter : filters) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2020 Florian Schmaus
|
* Copyright 2020-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,6 +20,7 @@ import javax.xml.namespace.QName;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smack.packet.Stanza;
|
import org.jivesoftware.smack.packet.Stanza;
|
||||||
|
import org.jivesoftware.smack.packet.XmlElement;
|
||||||
import org.jivesoftware.smack.util.XmppElementUtil;
|
import org.jivesoftware.smack.util.XmppElementUtil;
|
||||||
|
|
||||||
public class ExtensionElementFilter<E extends ExtensionElement> implements StanzaFilter {
|
public class ExtensionElementFilter<E extends ExtensionElement> implements StanzaFilter {
|
||||||
|
@ -34,7 +35,7 @@ public class ExtensionElementFilter<E extends ExtensionElement> implements Stanz
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean accept(Stanza stanza) {
|
public final boolean accept(Stanza stanza) {
|
||||||
ExtensionElement extensionElement = stanza.getExtension(extensionElementQName);
|
XmlElement extensionElement = stanza.getExtension(extensionElementQName);
|
||||||
if (extensionElement == null) {
|
if (extensionElement == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.jivesoftware.smack.util.Objects;
|
||||||
* @author Alexander Wenckus
|
* @author Alexander Wenckus
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("BadImport")
|
||||||
public final class IQTypeFilter extends FlexibleStanzaTypeFilter<IQ> {
|
public final class IQTypeFilter extends FlexibleStanzaTypeFilter<IQ> {
|
||||||
|
|
||||||
public static final StanzaFilter GET = new IQTypeFilter(Type.get);
|
public static final StanzaFilter GET = new IQTypeFilter(Type.get);
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.jivesoftware.smack.packet.Message.Type;
|
||||||
* @see org.jivesoftware.smack.packet.Message.Type
|
* @see org.jivesoftware.smack.packet.Message.Type
|
||||||
* @author Ward Harold
|
* @author Ward Harold
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("BadImport")
|
||||||
public final class MessageTypeFilter extends FlexibleStanzaTypeFilter<Message> {
|
public final class MessageTypeFilter extends FlexibleStanzaTypeFilter<Message> {
|
||||||
|
|
||||||
public static final StanzaFilter NORMAL = new MessageTypeFilter(Type.normal);
|
public static final StanzaFilter NORMAL = new MessageTypeFilter(Type.normal);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2014 Florian Schmaus
|
* Copyright 2014-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -24,6 +24,7 @@ import org.jivesoftware.smack.util.Objects;
|
||||||
* A filter for Presence types. Returns true only if the stanza is an Presence stanza and it matches the type provided in the
|
* A filter for Presence types. Returns true only if the stanza is an Presence stanza and it matches the type provided in the
|
||||||
* constructor.
|
* constructor.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("BadImport")
|
||||||
public final class PresenceTypeFilter extends FlexibleStanzaTypeFilter<Presence> {
|
public final class PresenceTypeFilter extends FlexibleStanzaTypeFilter<Presence> {
|
||||||
|
|
||||||
public static final PresenceTypeFilter AVAILABLE = new PresenceTypeFilter(Type.available);
|
public static final PresenceTypeFilter AVAILABLE = new PresenceTypeFilter(Type.available);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2015 Florian Schmaus
|
* Copyright 2015-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
package org.jivesoftware.smack.iqrequest;
|
package org.jivesoftware.smack.iqrequest;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.IQ.Type;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience class to create IQ requests handlers.
|
* Convenience class to create IQ requests handlers.
|
||||||
|
@ -26,10 +25,10 @@ public abstract class AbstractIqRequestHandler implements IQRequestHandler {
|
||||||
|
|
||||||
private final String element;
|
private final String element;
|
||||||
private final String namespace;
|
private final String namespace;
|
||||||
private final Type type;
|
private final IQ.Type type;
|
||||||
private final Mode mode;
|
private final Mode mode;
|
||||||
|
|
||||||
protected AbstractIqRequestHandler(String element, String namespace, Type type, Mode mode) {
|
protected AbstractIqRequestHandler(String element, String namespace, IQ.Type type, Mode mode) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case set:
|
case set:
|
||||||
case get:
|
case get:
|
||||||
|
@ -52,7 +51,7 @@ public abstract class AbstractIqRequestHandler implements IQRequestHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type getType() {
|
public IQ.Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2014-2015 Florian Schmaus
|
* Copyright 2014-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -32,18 +32,18 @@ public class AbstractError {
|
||||||
|
|
||||||
protected final String textNamespace;
|
protected final String textNamespace;
|
||||||
protected final Map<String, String> descriptiveTexts;
|
protected final Map<String, String> descriptiveTexts;
|
||||||
protected final List<ExtensionElement> extensions;
|
protected final List<XmlElement> extensions;
|
||||||
|
|
||||||
|
|
||||||
protected AbstractError(Map<String, String> descriptiveTexts) {
|
protected AbstractError(Map<String, String> descriptiveTexts) {
|
||||||
this(descriptiveTexts, null);
|
this(descriptiveTexts, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractError(Map<String, String> descriptiveTexts, List<ExtensionElement> extensions) {
|
protected AbstractError(Map<String, String> descriptiveTexts, List<XmlElement> extensions) {
|
||||||
this(descriptiveTexts, null, extensions);
|
this(descriptiveTexts, null, extensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractError(Map<String, String> descriptiveTexts, String textNamespace, List<ExtensionElement> extensions) {
|
protected AbstractError(Map<String, String> descriptiveTexts, String textNamespace, List<XmlElement> extensions) {
|
||||||
if (descriptiveTexts != null) {
|
if (descriptiveTexts != null) {
|
||||||
this.descriptiveTexts = descriptiveTexts;
|
this.descriptiveTexts = descriptiveTexts;
|
||||||
} else {
|
} else {
|
||||||
|
@ -108,7 +108,7 @@ public class AbstractError {
|
||||||
* @param <PE> type of the ExtensionElement.
|
* @param <PE> type of the ExtensionElement.
|
||||||
* @return the extension, or <code>null</code> if it doesn't exist.
|
* @return the extension, or <code>null</code> if it doesn't exist.
|
||||||
*/
|
*/
|
||||||
public <PE extends ExtensionElement> PE getExtension(String elementName, String namespace) {
|
public <PE extends XmlElement> PE getExtension(String elementName, String namespace) {
|
||||||
return PacketUtil.extensionElementFrom(extensions, elementName, namespace);
|
return PacketUtil.extensionElementFrom(extensions, elementName, namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ public class AbstractError {
|
||||||
public abstract static class Builder<B extends Builder<B>> {
|
public abstract static class Builder<B extends Builder<B>> {
|
||||||
protected String textNamespace;
|
protected String textNamespace;
|
||||||
protected Map<String, String> descriptiveTexts;
|
protected Map<String, String> descriptiveTexts;
|
||||||
protected List<ExtensionElement> extensions;
|
protected List<XmlElement> extensions;
|
||||||
|
|
||||||
public B setDescriptiveTexts(Map<String, String> descriptiveTexts) {
|
public B setDescriptiveTexts(Map<String, String> descriptiveTexts) {
|
||||||
if (descriptiveTexts == null) {
|
if (descriptiveTexts == null) {
|
||||||
|
@ -173,7 +173,7 @@ public class AbstractError {
|
||||||
return getThis();
|
return getThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public B setExtensions(List<ExtensionElement> extensions) {
|
public B setExtensions(List<XmlElement> extensions) {
|
||||||
if (this.extensions == null) {
|
if (this.extensions == null) {
|
||||||
this.extensions = extensions;
|
this.extensions = extensions;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ public class AbstractError {
|
||||||
return getThis();
|
return getThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public B addExtension(ExtensionElement extension) {
|
public B addExtension(XmlElement extension) {
|
||||||
if (extensions == null) {
|
if (extensions == null) {
|
||||||
extensions = new ArrayList<>();
|
extensions = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,12 @@ public abstract class AbstractIqBuilder<IB extends AbstractIqBuilder<IB>> extend
|
||||||
super(stanzaId);
|
super(stanzaId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Deprecate and use corresponding method in IqData instead.
|
||||||
public static IqData createResponse(IqView request) {
|
public static IqData createResponse(IqView request) {
|
||||||
return createResponse(request, IQ.ResponseType.result);
|
return createResponse(request, IQ.ResponseType.result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Deprecate and use corresponding method in IqData instead.
|
||||||
public static IqData createErrorResponse(IqView request) {
|
public static IqData createErrorResponse(IqView request) {
|
||||||
return createResponse(request, IQ.ResponseType.error);
|
return createResponse(request, IQ.ResponseType.error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2015-2016 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software, 2015-2021 Florian Schmaus.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
package org.jivesoftware.smack.packet;
|
package org.jivesoftware.smack.packet;
|
||||||
|
|
||||||
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
import org.jxmpp.jid.EntityFullJid;
|
import org.jxmpp.jid.EntityFullJid;
|
||||||
import org.jxmpp.jid.parts.Resourcepart;
|
import org.jxmpp.jid.parts.Resourcepart;
|
||||||
|
|
||||||
|
@ -73,6 +75,7 @@ public final class Bind extends IQ {
|
||||||
|
|
||||||
public static final class Feature implements ExtensionElement {
|
public static final class Feature implements ExtensionElement {
|
||||||
|
|
||||||
|
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||||
public static final Feature INSTANCE = new Feature();
|
public static final Feature INSTANCE = new Feature();
|
||||||
|
|
||||||
private Feature() {
|
private Feature() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2018 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software, 2018-2021 Florian Schmaus.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -17,21 +17,16 @@
|
||||||
package org.jivesoftware.smack.packet;
|
package org.jivesoftware.smack.packet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface to represent extension elements.
|
* Interface to represent XMPP extension elements. Unlike {@link XmlElement}, every non-abstract class that implements
|
||||||
|
* {@link ExtensionElement} must have a static final QNAME member of the type {@link javax.xml.namespace.QName}. This
|
||||||
|
* allows type-safe functions like {@link StanzaView#getExtension(Class)}. Hence this is a marker interface.
|
||||||
* <p>
|
* <p>
|
||||||
* An extension element is an XML subdocument
|
* Use this class when implementing new extension elements when possible. This means that every instance of your
|
||||||
* with a root element name and namespace. Extension elements are used to provide
|
* implemented class must represent an XML element of the same qualified name.
|
||||||
* extended functionality beyond what is in the base XMPP specification. Examples of
|
|
||||||
* extensions elements include message events, message properties, and extra presence data.
|
|
||||||
* IQ stanzas have limited support for extension elements.
|
|
||||||
* <p>
|
|
||||||
* This class is used primarily for extended content in XMPP Stanzas, to act as so called "extension elements". For more
|
|
||||||
* information see <a href="https://tools.ietf.org/html/rfc6120#section-8.4">RFC 6120 § 8.4 Extended Content</a>.
|
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @see org.jivesoftware.smack.provider.ExtensionElementProvider
|
* @see <a href="https://tools.ietf.org/html/rfc6120#section-8.4">RFC 6120 § 8.4 Extended Content</a>
|
||||||
* @author Matt Tucker
|
|
||||||
*/
|
*/
|
||||||
public interface ExtensionElement extends FullyQualifiedElement {
|
public interface ExtensionElement extends XmlElement {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ public abstract class IQ extends Stanza implements IqView {
|
||||||
|
|
||||||
xml.append(iqChildElement);
|
xml.append(iqChildElement);
|
||||||
|
|
||||||
List<ExtensionElement> extensionsXml = getExtensions();
|
List<XmlElement> extensionsXml = getExtensions();
|
||||||
if (iqChildElement.isEmptyElement) {
|
if (iqChildElement.isEmptyElement) {
|
||||||
if (extensionsXml.isEmpty()) {
|
if (extensionsXml.isEmpty()) {
|
||||||
xml.closeEmptyElement();
|
xml.closeEmptyElement();
|
||||||
|
|
|
@ -46,4 +46,12 @@ public final class IqData extends AbstractIqBuilder<IqData> {
|
||||||
public Stanza build() {
|
public Stanza build() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IqData createResponseData(IqView request) {
|
||||||
|
return createResponse(request, IQ.ResponseType.result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IqData createErrorResponseDAta(IqView request) {
|
||||||
|
return createResponse(request, IQ.ResponseType.error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,7 +344,7 @@ public final class Message extends MessageOrPresence<MessageBuilder>
|
||||||
@Deprecated
|
@Deprecated
|
||||||
// TODO: Remove when stanza builder is ready.
|
// TODO: Remove when stanza builder is ready.
|
||||||
public boolean removeBody(Body body) {
|
public boolean removeBody(Body body) {
|
||||||
ExtensionElement removedElement = removeExtension(body);
|
XmlElement removedElement = removeExtension(body);
|
||||||
return removedElement != null;
|
return removedElement != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2019-2020 Florian Schmaus
|
* Copyright 2003-2007 Jive Software, 2019-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -150,9 +150,9 @@ public interface MessageView extends StanzaView {
|
||||||
* @since 3.0.2
|
* @since 3.0.2
|
||||||
*/
|
*/
|
||||||
default Set<Message.Body> getBodies() {
|
default Set<Message.Body> getBodies() {
|
||||||
List<ExtensionElement> bodiesList = getExtensions(Message.Body.QNAME);
|
List<XmlElement> bodiesList = getExtensions(Message.Body.QNAME);
|
||||||
Set<Message.Body> resultSet = new HashSet<>(bodiesList.size());
|
Set<Message.Body> resultSet = new HashSet<>(bodiesList.size());
|
||||||
for (ExtensionElement extensionElement : bodiesList) {
|
for (XmlElement extensionElement : bodiesList) {
|
||||||
Message.Body body = (Message.Body) extensionElement;
|
Message.Body body = (Message.Body) extensionElement;
|
||||||
resultSet.add(body);
|
resultSet.add(body);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.jivesoftware.smack.packet;
|
||||||
* <p>
|
* <p>
|
||||||
* Please note that usage of this interface is <b>discouraged</b>. The reason is that every XML element is fully
|
* Please note that usage of this interface is <b>discouraged</b>. The reason is that every XML element is fully
|
||||||
* qualified, i.e., it is qualified by a namespace. The namespace may not be explicitly given, but instead, is inherited
|
* qualified, i.e., it is qualified by a namespace. The namespace may not be explicitly given, but instead, is inherited
|
||||||
* from an outer element. Use {@link FullyQualifiedElement} instead when possible.
|
* from an outer element. Use {@link XmlElement} instead when possible.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public interface NamedElement extends Element {
|
public interface NamedElement extends Element {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2020 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software, 2020-2021 Florian Schmaus.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -319,7 +319,7 @@ public final class Presence extends MessageOrPresence<PresenceBuilder>
|
||||||
buf.attribute("type", type);
|
buf.attribute("type", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ExtensionElement> extensions = getExtensions();
|
List<XmlElement> extensions = getExtensions();
|
||||||
if (status == null
|
if (status == null
|
||||||
&& priority == null
|
&& priority == null
|
||||||
&& (mode == null || mode == Mode.available)
|
&& (mode == null || mode == Mode.available)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2015-2020 Florian Schmaus.
|
* Copyright 2015-2021 Florian Schmaus.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -41,7 +41,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
* @author Florian Schmaus
|
* @author Florian Schmaus
|
||||||
*/
|
*/
|
||||||
public final class StandardExtensionElement implements ExtensionElement {
|
public final class StandardExtensionElement implements XmlElement {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String namespace;
|
private final String namespace;
|
||||||
|
|
|
@ -64,7 +64,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
protected static final String DEFAULT_LANGUAGE =
|
protected static final String DEFAULT_LANGUAGE =
|
||||||
java.util.Locale.getDefault().getLanguage().toLowerCase(Locale.US);
|
java.util.Locale.getDefault().getLanguage().toLowerCase(Locale.US);
|
||||||
|
|
||||||
private final MultiMap<QName, ExtensionElement> extensionElements;
|
private final MultiMap<QName, XmlElement> extensionElements;
|
||||||
|
|
||||||
// Assume that all stanzas Smack handles are in the client namespace, since Smack is an XMPP client library. We can
|
// Assume that all stanzas Smack handles are in the client namespace, since Smack is an XMPP client library. We can
|
||||||
// change this behavior later if it is required.
|
// change this behavior later if it is required.
|
||||||
|
@ -284,18 +284,18 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final List<ExtensionElement> getExtensions() {
|
public final List<XmlElement> getExtensions() {
|
||||||
synchronized (extensionElements) {
|
synchronized (extensionElements) {
|
||||||
// No need to create a new list, values() will already create a new one for us
|
// No need to create a new list, values() will already create a new one for us
|
||||||
return extensionElements.values();
|
return extensionElements.values();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final MultiMap<QName, ExtensionElement> getExtensionsMap() {
|
public final MultiMap<QName, XmlElement> getExtensionsMap() {
|
||||||
return cloneExtensionsMap();
|
return cloneExtensionsMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
final MultiMap<QName, ExtensionElement> cloneExtensionsMap() {
|
final MultiMap<QName, XmlElement> cloneExtensionsMap() {
|
||||||
synchronized (extensionElements) {
|
synchronized (extensionElements) {
|
||||||
return extensionElements.clone();
|
return extensionElements.clone();
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
* @return a set of all matching extensions.
|
* @return a set of all matching extensions.
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
public final List<ExtensionElement> getExtensions(String elementName, String namespace) {
|
public final List<XmlElement> getExtensions(String elementName, String namespace) {
|
||||||
requireNotNullNorEmpty(elementName, "elementName must not be null nor empty");
|
requireNotNullNorEmpty(elementName, "elementName must not be null nor empty");
|
||||||
requireNotNullNorEmpty(namespace, "namespace must not be null nor empty");
|
requireNotNullNorEmpty(namespace, "namespace must not be null nor empty");
|
||||||
QName key = new QName(namespace, elementName);
|
QName key = new QName(namespace, elementName);
|
||||||
|
@ -320,8 +320,8 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final List<ExtensionElement> getExtensions(QName qname) {
|
public final List<XmlElement> getExtensions(QName qname) {
|
||||||
List<ExtensionElement> res;
|
List<XmlElement> res;
|
||||||
synchronized (extensionElements) {
|
synchronized (extensionElements) {
|
||||||
res = extensionElements.getAll(qname);
|
res = extensionElements.getAll(qname);
|
||||||
}
|
}
|
||||||
|
@ -344,7 +344,8 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
* @param namespace the namespace of the extension that is desired.
|
* @param namespace the namespace of the extension that is desired.
|
||||||
* @return the stanza extension with the given namespace.
|
* @return the stanza extension with the given namespace.
|
||||||
*/
|
*/
|
||||||
public final ExtensionElement getExtension(String namespace) {
|
// TODO: Mark this method as deprecated in favor of getExtension(QName).
|
||||||
|
public final XmlElement getExtension(String namespace) {
|
||||||
return PacketUtil.extensionElementFrom(getExtensions(), null, namespace);
|
return PacketUtil.extensionElementFrom(getExtensions(), null, namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,12 +362,12 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
* @param namespace the XML element namespace of the extension.
|
* @param namespace the XML element namespace of the extension.
|
||||||
* @return the extension, or <code>null</code> if it doesn't exist.
|
* @return the extension, or <code>null</code> if it doesn't exist.
|
||||||
*/
|
*/
|
||||||
public final ExtensionElement getExtensionElement(String elementName, String namespace) {
|
public final XmlElement getExtensionElement(String elementName, String namespace) {
|
||||||
if (namespace == null) {
|
if (namespace == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
QName key = new QName(namespace, elementName);
|
QName key = new QName(namespace, elementName);
|
||||||
ExtensionElement packetExtension = getExtension(key);
|
XmlElement packetExtension = getExtension(key);
|
||||||
if (packetExtension == null) {
|
if (packetExtension == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -390,7 +391,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final ExtensionElement getExtension(QName qname) {
|
public final XmlElement getExtension(QName qname) {
|
||||||
synchronized (extensionElements) {
|
synchronized (extensionElements) {
|
||||||
return extensionElements.getFirst(qname);
|
return extensionElements.getFirst(qname);
|
||||||
}
|
}
|
||||||
|
@ -400,13 +401,13 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
* Adds a stanza extension to the packet. Does nothing if extension is null.
|
* Adds a stanza extension to the packet. Does nothing if extension is null.
|
||||||
* <p>
|
* <p>
|
||||||
* Please note that although this method is not yet marked as deprecated, it is recommended to use
|
* Please note that although this method is not yet marked as deprecated, it is recommended to use
|
||||||
* {@link StanzaBuilder#addExtension(ExtensionElement)} instead.
|
* {@link StanzaBuilder#addExtension(XmlElement)} instead.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param extension a stanza extension.
|
* @param extension a stanza extension.
|
||||||
*/
|
*/
|
||||||
// TODO: Mark this as deprecated once StanzaBuilder is ready and all call sites are gone.
|
// TODO: Mark this as deprecated once StanzaBuilder is ready and all call sites are gone.
|
||||||
public final void addExtension(ExtensionElement extension) {
|
public final void addExtension(XmlElement extension) {
|
||||||
if (extension == null) return;
|
if (extension == null) return;
|
||||||
QName key = extension.getQName();
|
QName key = extension.getQName();
|
||||||
synchronized (extensionElements) {
|
synchronized (extensionElements) {
|
||||||
|
@ -419,7 +420,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
* namespace.
|
* namespace.
|
||||||
* <p>
|
* <p>
|
||||||
* Please note that although this method is not yet marked as deprecated, it is recommended to use
|
* Please note that although this method is not yet marked as deprecated, it is recommended to use
|
||||||
* {@link StanzaBuilder#overrideExtension(ExtensionElement)} instead.
|
* {@link StanzaBuilder#overrideExtension(XmlElement)} instead.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param extension the extension element to add.
|
* @param extension the extension element to add.
|
||||||
|
@ -427,13 +428,13 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
* @since 4.1.2
|
* @since 4.1.2
|
||||||
*/
|
*/
|
||||||
// TODO: Mark this as deprecated once StanzaBuilder is ready and all call sites are gone.
|
// TODO: Mark this as deprecated once StanzaBuilder is ready and all call sites are gone.
|
||||||
public final ExtensionElement overrideExtension(ExtensionElement extension) {
|
public final XmlElement overrideExtension(XmlElement extension) {
|
||||||
if (extension == null) return null;
|
if (extension == null) return null;
|
||||||
synchronized (extensionElements) {
|
synchronized (extensionElements) {
|
||||||
// Note that we need to use removeExtension(String, String) here. If would use
|
// Note that we need to use removeExtension(String, String) here. If would use
|
||||||
// removeExtension(ExtensionElement) then we would remove based on the equality of ExtensionElement, which
|
// removeExtension(ExtensionElement) then we would remove based on the equality of ExtensionElement, which
|
||||||
// is not what we want in this case.
|
// is not what we want in this case.
|
||||||
ExtensionElement removedExtension = removeExtension(extension.getElementName(), extension.getNamespace());
|
XmlElement removedExtension = removeExtension(extension.getElementName(), extension.getNamespace());
|
||||||
addExtension(extension);
|
addExtension(extension);
|
||||||
return removedExtension;
|
return removedExtension;
|
||||||
}
|
}
|
||||||
|
@ -445,9 +446,9 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
* @param extensions a collection of stanza extensions
|
* @param extensions a collection of stanza extensions
|
||||||
*/
|
*/
|
||||||
// TODO: Mark this as deprecated once StanzaBuilder is ready and all call sites are gone.
|
// TODO: Mark this as deprecated once StanzaBuilder is ready and all call sites are gone.
|
||||||
public final void addExtensions(Collection<? extends ExtensionElement> extensions) {
|
public final void addExtensions(Collection<? extends XmlElement> extensions) {
|
||||||
if (extensions == null) return;
|
if (extensions == null) return;
|
||||||
for (ExtensionElement packetExtension : extensions) {
|
for (XmlElement packetExtension : extensions) {
|
||||||
addExtension(packetExtension);
|
addExtension(packetExtension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -476,7 +477,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
@Override
|
@Override
|
||||||
public final boolean hasExtension(String namespace) {
|
public final boolean hasExtension(String namespace) {
|
||||||
synchronized (extensionElements) {
|
synchronized (extensionElements) {
|
||||||
for (ExtensionElement packetExtension : extensionElements.values()) {
|
for (XmlElement packetExtension : extensionElements.values()) {
|
||||||
if (packetExtension.getNamespace().equals(namespace)) {
|
if (packetExtension.getNamespace().equals(namespace)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -493,7 +494,7 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
* @return the removed stanza extension or null.
|
* @return the removed stanza extension or null.
|
||||||
*/
|
*/
|
||||||
// TODO: Mark this as deprecated once StanzaBuilder is ready and all call sites are gone.
|
// TODO: Mark this as deprecated once StanzaBuilder is ready and all call sites are gone.
|
||||||
public final ExtensionElement removeExtension(String elementName, String namespace) {
|
public final XmlElement removeExtension(String elementName, String namespace) {
|
||||||
QName key = new QName(namespace, elementName);
|
QName key = new QName(namespace, elementName);
|
||||||
synchronized (extensionElements) {
|
synchronized (extensionElements) {
|
||||||
return extensionElements.remove(key);
|
return extensionElements.remove(key);
|
||||||
|
@ -509,10 +510,10 @@ public abstract class Stanza implements StanzaView, TopLevelStreamElement {
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
// TODO: Remove in Smack 4.5.
|
// TODO: Remove in Smack 4.5.
|
||||||
public final ExtensionElement removeExtension(ExtensionElement extension) {
|
public final XmlElement removeExtension(XmlElement extension) {
|
||||||
QName key = extension.getQName();
|
QName key = extension.getQName();
|
||||||
synchronized (extensionElements) {
|
synchronized (extensionElements) {
|
||||||
List<ExtensionElement> list = extensionElements.getAll(key);
|
List<XmlElement> list = extensionElements.getAll(key);
|
||||||
boolean removed = list.remove(extension);
|
boolean removed = list.remove(extension);
|
||||||
if (removed) {
|
if (removed) {
|
||||||
return extension;
|
return extension;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2019-2020 Florian Schmaus
|
* Copyright 2019-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -44,7 +44,7 @@ public abstract class StanzaBuilder<B extends StanzaBuilder<B>> implements Stanz
|
||||||
|
|
||||||
String language;
|
String language;
|
||||||
|
|
||||||
MultiMap<QName, ExtensionElement> extensionElements = new MultiMap<>();
|
MultiMap<QName, XmlElement> extensionElements = new MultiMap<>();
|
||||||
|
|
||||||
protected StanzaBuilder(StanzaBuilder<?> other) {
|
protected StanzaBuilder(StanzaBuilder<?> other) {
|
||||||
stanzaIdSource = other.stanzaIdSource;
|
stanzaIdSource = other.stanzaIdSource;
|
||||||
|
@ -156,13 +156,13 @@ public abstract class StanzaBuilder<B extends StanzaBuilder<B>> implements Stanz
|
||||||
return getThis();
|
return getThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final B addExtension(ExtensionElement extensionElement) {
|
public final B addExtension(XmlElement extensionElement) {
|
||||||
QName key = extensionElement.getQName();
|
QName key = extensionElement.getQName();
|
||||||
extensionElements.put(key, extensionElement);
|
extensionElements.put(key, extensionElement);
|
||||||
return getThis();
|
return getThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final B addOptExtensions(Collection<? extends ExtensionElement> extensionElements) {
|
public final B addOptExtensions(Collection<? extends XmlElement> extensionElements) {
|
||||||
if (extensionElements == null) {
|
if (extensionElements == null) {
|
||||||
return getThis();
|
return getThis();
|
||||||
}
|
}
|
||||||
|
@ -170,14 +170,14 @@ public abstract class StanzaBuilder<B extends StanzaBuilder<B>> implements Stanz
|
||||||
return addExtensions(extensionElements);
|
return addExtensions(extensionElements);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final B addExtensions(Collection<? extends ExtensionElement> extensionElements) {
|
public final B addExtensions(Collection<? extends XmlElement> extensionElements) {
|
||||||
for (ExtensionElement extensionElement : extensionElements) {
|
for (XmlElement extensionElement : extensionElements) {
|
||||||
addExtension(extensionElement);
|
addExtension(extensionElement);
|
||||||
}
|
}
|
||||||
return getThis();
|
return getThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final B overrideExtension(ExtensionElement extensionElement) {
|
public final B overrideExtension(XmlElement extensionElement) {
|
||||||
QName key = extensionElement.getQName();
|
QName key = extensionElement.getQName();
|
||||||
extensionElements.remove(key);
|
extensionElements.remove(key);
|
||||||
extensionElements.put(key, extensionElement);
|
extensionElements.put(key, extensionElement);
|
||||||
|
@ -214,17 +214,17 @@ public abstract class StanzaBuilder<B extends StanzaBuilder<B>> implements Stanz
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final ExtensionElement getExtension(QName qname) {
|
public final XmlElement getExtension(QName qname) {
|
||||||
return extensionElements.getFirst(qname);
|
return extensionElements.getFirst(qname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final List<ExtensionElement> getExtensions() {
|
public final List<XmlElement> getExtensions() {
|
||||||
return extensionElements.values();
|
return extensionElements.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final List<ExtensionElement> getExtensions(QName qname) {
|
public final List<XmlElement> getExtensions(QName qname) {
|
||||||
return extensionElements.getAll(qname);
|
return extensionElements.getAll(qname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2015-2019 Florian Schmaus
|
* Copyright 2003-2007 Jive Software, 2015-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -22,6 +22,8 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
import org.jivesoftware.smack.util.Objects;
|
import org.jivesoftware.smack.util.Objects;
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
@ -74,6 +76,8 @@ public class StanzaError extends AbstractError implements ExtensionElement {
|
||||||
|
|
||||||
public static final String ERROR = "error";
|
public static final String ERROR = "error";
|
||||||
|
|
||||||
|
public static final QName QNAME = new QName(StreamOpen.CLIENT_NAMESPACE, ERROR);
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(StanzaError.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(StanzaError.class.getName());
|
||||||
static final Map<Condition, Type> CONDITION_TO_TYPE = new HashMap<Condition, Type>();
|
static final Map<Condition, Type> CONDITION_TO_TYPE = new HashMap<Condition, Type>();
|
||||||
|
|
||||||
|
@ -121,7 +125,7 @@ public class StanzaError extends AbstractError implements ExtensionElement {
|
||||||
* @param extensions list of stanza extensions
|
* @param extensions list of stanza extensions
|
||||||
*/
|
*/
|
||||||
public StanzaError(Condition condition, String conditionText, String errorGenerator, Type type, Map<String, String> descriptiveTexts,
|
public StanzaError(Condition condition, String conditionText, String errorGenerator, Type type, Map<String, String> descriptiveTexts,
|
||||||
List<ExtensionElement> extensions) {
|
List<XmlElement> extensions) {
|
||||||
super(descriptiveTexts, ERROR_CONDITION_AND_TEXT_NAMESPACE, extensions);
|
super(descriptiveTexts, ERROR_CONDITION_AND_TEXT_NAMESPACE, extensions);
|
||||||
this.condition = Objects.requireNonNull(condition, "condition must not be null");
|
this.condition = Objects.requireNonNull(condition, "condition must not be null");
|
||||||
// Some implementations may send the condition as non-empty element containing the empty string, that is
|
// Some implementations may send the condition as non-empty element containing the empty string, that is
|
||||||
|
@ -199,12 +203,12 @@ public class StanzaError extends AbstractError implements ExtensionElement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getElementName() {
|
public String getElementName() {
|
||||||
return ERROR;
|
return QNAME.getLocalPart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNamespace() {
|
public String getNamespace() {
|
||||||
return StreamOpen.CLIENT_NAMESPACE;
|
return QNAME.getNamespaceURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2019-2020 Florian Schmaus
|
* Copyright 2019-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -61,7 +61,7 @@ public interface StanzaView extends XmlLangElement {
|
||||||
*/
|
*/
|
||||||
StanzaError getError();
|
StanzaError getError();
|
||||||
|
|
||||||
ExtensionElement getExtension(QName qname);
|
XmlElement getExtension(QName qname);
|
||||||
|
|
||||||
default boolean hasExtension(QName qname) {
|
default boolean hasExtension(QName qname) {
|
||||||
return getExtension(qname) != null;
|
return getExtension(qname) != null;
|
||||||
|
@ -78,7 +78,7 @@ public interface StanzaView extends XmlLangElement {
|
||||||
* @return true if a stanza extension exists, false otherwise.
|
* @return true if a stanza extension exists, false otherwise.
|
||||||
*/
|
*/
|
||||||
default boolean hasExtension(String namespace) {
|
default boolean hasExtension(String namespace) {
|
||||||
for (ExtensionElement packetExtension : getExtensions()) {
|
for (XmlElement packetExtension : getExtensions()) {
|
||||||
if (packetExtension.getNamespace().equals(namespace)) {
|
if (packetExtension.getNamespace().equals(namespace)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public interface StanzaView extends XmlLangElement {
|
||||||
|
|
||||||
default <E extends ExtensionElement> E getExtension(Class<E> extensionElementClass) {
|
default <E extends ExtensionElement> E getExtension(Class<E> extensionElementClass) {
|
||||||
QName qname = XmppElementUtil.getQNameFor(extensionElementClass);
|
QName qname = XmppElementUtil.getQNameFor(extensionElementClass);
|
||||||
ExtensionElement extensionElement = getExtension(qname);
|
XmlElement extensionElement = getExtension(qname);
|
||||||
|
|
||||||
if (extensionElement == null) {
|
if (extensionElement == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -103,9 +103,9 @@ public interface StanzaView extends XmlLangElement {
|
||||||
*
|
*
|
||||||
* @return a list of all extension elements of this stanza.
|
* @return a list of all extension elements of this stanza.
|
||||||
*/
|
*/
|
||||||
List<ExtensionElement> getExtensions();
|
List<XmlElement> getExtensions();
|
||||||
|
|
||||||
List<ExtensionElement> getExtensions(QName qname);
|
List<XmlElement> getExtensions(QName qname);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all extension elements of the given type. Returns the empty list if there a none.
|
* Return all extension elements of the given type. Returns the empty list if there a none.
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class StreamError extends AbstractError implements Nonza {
|
||||||
private final Condition condition;
|
private final Condition condition;
|
||||||
private final String conditionText;
|
private final String conditionText;
|
||||||
|
|
||||||
public StreamError(Condition condition, String conditionText, Map<String, String> descriptiveTexts, List<ExtensionElement> extensions) {
|
public StreamError(Condition condition, String conditionText, Map<String, String> descriptiveTexts, List<XmlElement> extensions) {
|
||||||
super(descriptiveTexts, extensions);
|
super(descriptiveTexts, extensions);
|
||||||
// Some implementations may send the condition as non-empty element containing the empty string, that is
|
// Some implementations may send the condition as non-empty element containing the empty string, that is
|
||||||
// <condition xmlns='foo'></condition>, in this case the parser may calls this constructor with the empty string
|
// <condition xmlns='foo'></condition>, in this case the parser may calls this constructor with the empty string
|
||||||
|
|
|
@ -20,6 +20,6 @@ package org.jivesoftware.smack.packet;
|
||||||
* A XMPP top level stream element. This is either a stanza ({@link Stanza}) or
|
* A XMPP top level stream element. This is either a stanza ({@link Stanza}) or
|
||||||
* just a plain stream element ({@link Nonza}).
|
* just a plain stream element ({@link Nonza}).
|
||||||
*/
|
*/
|
||||||
public interface TopLevelStreamElement extends FullyQualifiedElement {
|
public interface TopLevelStreamElement extends XmlElement {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2018-2019 Florian Schmaus
|
* Copyright 2018-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -18,7 +18,23 @@ package org.jivesoftware.smack.packet;
|
||||||
|
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
public interface FullyQualifiedElement extends NamedElement, XmlLangElement {
|
/**
|
||||||
|
* Interface to represent XML elements. Every XML element in XMPP has a qualified XML name ({@link QName}). This name
|
||||||
|
* can be obtained via {@link #getQName()}.
|
||||||
|
* <p>
|
||||||
|
* XMPP uses "extension elements", i.e. XML elements, to provide extended functionality beyond what is in the base XMPP
|
||||||
|
* specification. Examples of extensions elements include message events, message properties, and extra presence data.
|
||||||
|
* IQ stanzas have limited support for extension elements. See {@link ExtensionElement} for more information about XMPP
|
||||||
|
* extension elements.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* It is recommend to use {@link ExtensionElement} over this class when creating new extension elements.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @see org.jivesoftware.smack.provider.ExtensionElementProvider
|
||||||
|
* @since 4.5
|
||||||
|
*/
|
||||||
|
public interface XmlElement extends NamedElement, XmlLangElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the root element XML namespace.
|
* Returns the root element XML namespace.
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2019-2020 Florian Schmaus
|
* Copyright 2019-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -34,12 +34,24 @@ public class SmackParsingException extends Exception {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated, do not import.
|
||||||
|
* @deprecated do not import.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.6.
|
||||||
public static class SmackTextParseException extends SmackParsingException {
|
public static class SmackTextParseException extends SmackParsingException {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated, do not use.
|
||||||
|
* @param parsingException the exception.
|
||||||
|
* @deprecated do not use, simply throw ParseException.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public SmackTextParseException(ParseException parsingException) {
|
public SmackTextParseException(ParseException parsingException) {
|
||||||
super(parsingException);
|
super(parsingException);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,15 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smack.provider;
|
package org.jivesoftware.smack.provider;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.lang.reflect.TypeVariable;
|
import java.lang.reflect.TypeVariable;
|
||||||
|
import java.text.ParseException;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.Element;
|
import org.jivesoftware.smack.packet.Element;
|
||||||
|
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||||
|
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||||
|
|
||||||
public class AbstractProvider<E extends Element> {
|
public class AbstractProvider<E extends Element> {
|
||||||
|
|
||||||
|
@ -55,4 +59,51 @@ public class AbstractProvider<E extends Element> {
|
||||||
public final Class<E> getElementClass() {
|
public final Class<E> getElementClass() {
|
||||||
return elementClass;
|
return elementClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final class TextParseException extends SmackParsingException {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final ParseException parseException;
|
||||||
|
|
||||||
|
private TextParseException(ParseException parseException) {
|
||||||
|
super(parseException);
|
||||||
|
this.parseException = parseException;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParseException getParseException() {
|
||||||
|
return parseException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class NumberFormatParseException extends SmackParsingException {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private NumberFormatParseException(NumberFormatException numberFormatException) {
|
||||||
|
super(numberFormatException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected interface WrappableParser<E> {
|
||||||
|
E parse() throws XmlPullParserException, IOException, SmackParsingException, ParseException;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static <E> E wrapExceptions(WrappableParser<E> parser)
|
||||||
|
throws XmlPullParserException, IOException, SmackParsingException {
|
||||||
|
E e;
|
||||||
|
try {
|
||||||
|
e = parser.parse();
|
||||||
|
} catch (ParseException parseException) {
|
||||||
|
throw new TextParseException(parseException);
|
||||||
|
} catch (NumberFormatException numberFormatException) {
|
||||||
|
throw new NumberFormatParseException(numberFormatException);
|
||||||
|
}
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.XmlElement;
|
||||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
@ -41,9 +41,9 @@ import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||||
* <b>smack.properties</b> file. Then they will be automatically picked up and used to parse
|
* <b>smack.properties</b> file. Then they will be automatically picked up and used to parse
|
||||||
* any child elements.
|
* any child elements.
|
||||||
*
|
*
|
||||||
* <pre>
|
|
||||||
* For example, given the following message
|
* For example, given the following message
|
||||||
*
|
*
|
||||||
|
* <pre>
|
||||||
* <message from='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo>
|
* <message from='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo>
|
||||||
* <event xmlns='http://jabber.org/protocol/pubsub#event>
|
* <event xmlns='http://jabber.org/protocol/pubsub#event>
|
||||||
* <items node='princely_musings'>
|
* <items node='princely_musings'>
|
||||||
|
@ -57,6 +57,7 @@ import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||||
* </items>
|
* </items>
|
||||||
* </event>
|
* </event>
|
||||||
* </message>
|
* </message>
|
||||||
|
* </pre>
|
||||||
*
|
*
|
||||||
* I would have a classes
|
* I would have a classes
|
||||||
* <code>ItemsProvider</code> extends {@link EmbeddedExtensionProvider}
|
* <code>ItemsProvider</code> extends {@link EmbeddedExtensionProvider}
|
||||||
|
@ -67,6 +68,7 @@ import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||||
* These classes are then registered in the meta-inf/smack.providers file
|
* These classes are then registered in the meta-inf/smack.providers file
|
||||||
* as follows.
|
* as follows.
|
||||||
*
|
*
|
||||||
|
* <pre>
|
||||||
* <extensionProvider>
|
* <extensionProvider>
|
||||||
* <elementName>items</elementName>
|
* <elementName>items</elementName>
|
||||||
* <namespace>http://jabber.org/protocol/pubsub#event</namespace>
|
* <namespace>http://jabber.org/protocol/pubsub#event</namespace>
|
||||||
|
@ -77,12 +79,11 @@ import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||||
* <namespace>http://jabber.org/protocol/pubsub#event</namespace>
|
* <namespace>http://jabber.org/protocol/pubsub#event</namespace>
|
||||||
* <className>org.jivesoftware.smackx.provider.ItemProvider</className>
|
* <className>org.jivesoftware.smackx.provider.ItemProvider</className>
|
||||||
* </extensionProvider>
|
* </extensionProvider>
|
||||||
*
|
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author Robin Collier
|
* @author Robin Collier
|
||||||
*/
|
*/
|
||||||
public abstract class EmbeddedExtensionProvider<PE extends ExtensionElement> extends ExtensionElementProvider<PE> {
|
public abstract class EmbeddedExtensionProvider<PE extends XmlElement> extends ExtensionElementProvider<PE> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final PE parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
public final PE parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
||||||
|
@ -95,7 +96,7 @@ public abstract class EmbeddedExtensionProvider<PE extends ExtensionElement> ext
|
||||||
attMap.put(parser.getAttributeName(i), parser.getAttributeValue(i));
|
attMap.put(parser.getAttributeName(i), parser.getAttributeValue(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ExtensionElement> extensions = new ArrayList<>();
|
List<XmlElement> extensions = new ArrayList<>();
|
||||||
XmlPullParser.Event event;
|
XmlPullParser.Event event;
|
||||||
do {
|
do {
|
||||||
event = parser.next();
|
event = parser.next();
|
||||||
|
@ -109,5 +110,5 @@ public abstract class EmbeddedExtensionProvider<PE extends ExtensionElement> ext
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract PE createReturnExtension(String currentElement, String currentNamespace,
|
protected abstract PE createReturnExtension(String currentElement, String currentNamespace,
|
||||||
Map<String, String> attributeMap, List<? extends ExtensionElement> content);
|
Map<String, String> attributeMap, List<? extends XmlElement> content);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
package org.jivesoftware.smack.provider;
|
package org.jivesoftware.smack.provider;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.XmlElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract class for parsing custom extensions elements. Each ExtensionElementProvider must
|
* An abstract class for parsing custom extensions elements. Each ExtensionElementProvider must
|
||||||
|
@ -26,6 +26,6 @@ import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
*
|
*
|
||||||
* @author Matt Tucker
|
* @author Matt Tucker
|
||||||
*/
|
*/
|
||||||
public abstract class ExtensionElementProvider<EE extends ExtensionElement> extends Provider<EE> {
|
public abstract class ExtensionElementProvider<E extends XmlElement> extends Provider<E> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package org.jivesoftware.smack.provider;
|
package org.jivesoftware.smack.provider;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.ParseException;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.IqData;
|
import org.jivesoftware.smack.packet.IqData;
|
||||||
|
@ -50,7 +51,7 @@ public abstract class IQProvider<I extends IQ> extends IqProvider<I> {
|
||||||
final int initialDepth = parser.getDepth();
|
final int initialDepth = parser.getDepth();
|
||||||
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
|
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
|
||||||
|
|
||||||
I e = parse(parser, initialDepth, xmlEnvironment);
|
I e = wrapExceptions(() -> parse(parser, initialDepth, xmlEnvironment));
|
||||||
|
|
||||||
// XPP3 calling convention assert: Parser should be at end tag of the consumed/parsed element
|
// XPP3 calling convention assert: Parser should be at end tag of the consumed/parsed element
|
||||||
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
|
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
|
||||||
|
@ -59,11 +60,12 @@ public abstract class IQProvider<I extends IQ> extends IqProvider<I> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
|
public final I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
|
||||||
throws XmlPullParserException, IOException, SmackParsingException {
|
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
|
||||||
// Old-style IQ parsers do not need IqData.
|
// Old-style IQ parsers do not need IqData.
|
||||||
return parse(parser, initialDepth, xmlEnvironment);
|
return parse(parser, initialDepth, xmlEnvironment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract I parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException;
|
public abstract I parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||||
|
throws XmlPullParserException, IOException, SmackParsingException, ParseException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2019 Florian Schmaus
|
* Copyright © 2014-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -26,10 +26,22 @@ import org.jivesoftware.smack.util.ParserUtils;
|
||||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parsing with introspection poses a security threat and results in mutable classes and is therefore discouraged.
|
||||||
|
* @deprecated use a proper parser.
|
||||||
|
*/
|
||||||
|
// TODO: Remove in Smack 4.6.
|
||||||
|
@Deprecated
|
||||||
public class IntrospectionProvider{
|
public class IntrospectionProvider{
|
||||||
|
|
||||||
// Unfortunately, we have to create two introspection providers, with the exactly the same code here
|
// Unfortunately, we have to create two introspection providers, with the exactly the same code here
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parsing with introspection poses a security threat and results in mutable classes and is therefore discouraged.
|
||||||
|
* @deprecated use a proper parser.
|
||||||
|
*/
|
||||||
|
// TODO: Remove in Smack 4.6.
|
||||||
|
@Deprecated
|
||||||
public abstract static class IQIntrospectionProvider<I extends IQ> extends IQProvider<I> {
|
public abstract static class IQIntrospectionProvider<I extends IQ> extends IQProvider<I> {
|
||||||
private final Class<I> elementClass;
|
private final Class<I> elementClass;
|
||||||
|
|
||||||
|
@ -51,6 +63,12 @@ public class IntrospectionProvider{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parsing with introspection poses a security threat and results in mutable classes and is therefore discouraged.
|
||||||
|
* @deprecated use a proper parser.
|
||||||
|
*/
|
||||||
|
// TODO: Remove in Smack 4.6.
|
||||||
|
@Deprecated
|
||||||
public abstract static class PacketExtensionIntrospectionProvider<PE extends ExtensionElement> extends ExtensionElementProvider<PE> {
|
public abstract static class PacketExtensionIntrospectionProvider<PE extends ExtensionElement> extends ExtensionElementProvider<PE> {
|
||||||
private final Class<PE> elementClass;
|
private final Class<PE> elementClass;
|
||||||
|
|
||||||
|
@ -117,7 +135,7 @@ public class IntrospectionProvider{
|
||||||
* @param type the type of the property.
|
* @param type the type of the property.
|
||||||
* @param value the encode String value to decode.
|
* @param value the encode String value to decode.
|
||||||
* @return the String value decoded into the specified type.
|
* @return the String value decoded into the specified type.
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException if the provided class was not found.
|
||||||
*/
|
*/
|
||||||
private static Object decode(Class<?> type, String value) throws ClassNotFoundException {
|
private static Object decode(Class<?> type, String value) throws ClassNotFoundException {
|
||||||
String name = type.getName();
|
String name = type.getName();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2019 Florian Schmaus
|
* Copyright 2019-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
package org.jivesoftware.smack.provider;
|
package org.jivesoftware.smack.provider;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.ParseException;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.IqData;
|
import org.jivesoftware.smack.packet.IqData;
|
||||||
|
@ -37,10 +38,12 @@ public abstract class IqProvider<I extends IQ> extends AbstractProvider<I> {
|
||||||
final int initialDepth = parser.getDepth();
|
final int initialDepth = parser.getDepth();
|
||||||
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
|
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
|
||||||
|
|
||||||
return parse(parser, initialDepth, iqData, xmlEnvironment);
|
I i = wrapExceptions(() -> parse(parser, initialDepth, iqData, xmlEnvironment));
|
||||||
|
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
|
public abstract I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
|
||||||
throws XmlPullParserException, IOException, SmackParsingException;
|
throws XmlPullParserException, IOException, SmackParsingException, ParseException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2019 Florian Schmaus
|
* Copyright © 2014-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
package org.jivesoftware.smack.provider;
|
package org.jivesoftware.smack.provider;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.ParseException;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.Element;
|
import org.jivesoftware.smack.packet.Element;
|
||||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||||
|
@ -50,12 +51,13 @@ public abstract class Provider<E extends Element> extends AbstractProvider<E> {
|
||||||
final int initialDepth = parser.getDepth();
|
final int initialDepth = parser.getDepth();
|
||||||
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
|
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
|
||||||
|
|
||||||
E e = parse(parser, initialDepth, xmlEnvironment);
|
E e = wrapExceptions(() -> parse(parser, initialDepth, xmlEnvironment));
|
||||||
|
|
||||||
// XPP3 calling convention assert: Parser should be at end tag of the consumed/parsed element
|
// XPP3 calling convention assert: Parser should be at end tag of the consumed/parsed element
|
||||||
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
|
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract E parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException;
|
public abstract E parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||||
|
throws XmlPullParserException, IOException, SmackParsingException, ParseException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smack.proxy;
|
package org.jivesoftware.smack.proxy;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.Proxy;
|
||||||
|
import java.net.SocketAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class which stores proxy information such as proxy type, host, port,
|
* Class which stores proxy information such as proxy type, host, port,
|
||||||
* authentication etc.
|
* authentication etc.
|
||||||
|
@ -44,19 +48,10 @@ public class ProxyInfo {
|
||||||
this.proxyPort = pPort;
|
this.proxyPort = pPort;
|
||||||
this.proxyUsername = pUser;
|
this.proxyUsername = pUser;
|
||||||
this.proxyPassword = pPass;
|
this.proxyPassword = pPass;
|
||||||
switch (proxyType) {
|
this.proxySocketConnection =
|
||||||
case HTTP:
|
ProxySocketConnection
|
||||||
proxySocketConnection = new HTTPProxySocketConnection(this);
|
.forProxyType(proxyType)
|
||||||
break;
|
.apply(this);
|
||||||
case SOCKS4:
|
|
||||||
proxySocketConnection = new Socks4ProxySocketConnection(this);
|
|
||||||
break;
|
|
||||||
case SOCKS5:
|
|
||||||
proxySocketConnection = new Socks5ProxySocketConnection(this);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProxyInfo forHttpProxy(String pHost, int pPort, String pUser,
|
public static ProxyInfo forHttpProxy(String pHost, int pPort, String pUser,
|
||||||
|
@ -74,6 +69,18 @@ public class ProxyInfo {
|
||||||
return new ProxyInfo(ProxyType.SOCKS5, pHost, pPort, pUser, pPass);
|
return new ProxyInfo(ProxyType.SOCKS5, pHost, pPort, pUser, pPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Proxy.Type getJavaProxyType() {
|
||||||
|
switch (proxyType) {
|
||||||
|
case HTTP:
|
||||||
|
return Proxy.Type.HTTP;
|
||||||
|
case SOCKS4:
|
||||||
|
case SOCKS5:
|
||||||
|
return Proxy.Type.SOCKS;
|
||||||
|
default:
|
||||||
|
throw new AssertionError("Invalid proxy type: " + proxyType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ProxyType getProxyType() {
|
public ProxyType getProxyType() {
|
||||||
return proxyType;
|
return proxyType;
|
||||||
}
|
}
|
||||||
|
@ -97,4 +104,11 @@ public class ProxyInfo {
|
||||||
public ProxySocketConnection getProxySocketConnection() {
|
public ProxySocketConnection getProxySocketConnection() {
|
||||||
return proxySocketConnection;
|
return proxySocketConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Proxy toJavaProxy() {
|
||||||
|
final SocketAddress proxySocketAddress = new InetSocketAddress(proxyAddress, proxyPort);
|
||||||
|
final Proxy.Type type = getJavaProxyType();
|
||||||
|
return new Proxy(type, proxySocketAddress);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smack.proxy;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.util.Function;
|
||||||
|
|
||||||
public interface ProxySocketConnection {
|
public interface ProxySocketConnection {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,4 +36,16 @@ public interface ProxySocketConnection {
|
||||||
void connect(Socket socket, String host, int port, int timeout)
|
void connect(Socket socket, String host, int port, int timeout)
|
||||||
throws IOException;
|
throws IOException;
|
||||||
|
|
||||||
|
static Function<ProxySocketConnection, ProxyInfo> forProxyType(ProxyInfo.ProxyType proxyType) {
|
||||||
|
switch (proxyType) {
|
||||||
|
case HTTP:
|
||||||
|
return HTTPProxySocketConnection::new;
|
||||||
|
case SOCKS4:
|
||||||
|
return Socks4ProxySocketConnection::new;
|
||||||
|
case SOCKS5:
|
||||||
|
return Socks5ProxySocketConnection::new;
|
||||||
|
default:
|
||||||
|
throw new AssertionError("Unknown proxy type: " + proxyType);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2014-2019 Florian Schmaus
|
* Copyright 2003-2007 Jive Software, 2014-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -311,6 +311,10 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean requiresPassword() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isAuthenticationSuccessful() {
|
public boolean isAuthenticationSuccessful() {
|
||||||
return authenticationSuccessful;
|
return authenticationSuccessful;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2014-2020 Florian Schmaus
|
* Copyright 2014-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -26,7 +26,6 @@ import java.util.Random;
|
||||||
|
|
||||||
import javax.security.auth.callback.CallbackHandler;
|
import javax.security.auth.callback.CallbackHandler;
|
||||||
|
|
||||||
import org.jivesoftware.smack.SmackException;
|
|
||||||
import org.jivesoftware.smack.SmackException.SmackSaslException;
|
import org.jivesoftware.smack.SmackException.SmackSaslException;
|
||||||
import org.jivesoftware.smack.sasl.SASLMechanism;
|
import org.jivesoftware.smack.sasl.SASLMechanism;
|
||||||
import org.jivesoftware.smack.util.ByteUtils;
|
import org.jivesoftware.smack.util.ByteUtils;
|
||||||
|
@ -263,6 +262,7 @@ public abstract class ScramMechanism extends SASLMechanism {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the channel binding data.
|
||||||
*
|
*
|
||||||
* @return the Channel Binding data.
|
* @return the Channel Binding data.
|
||||||
* @throws SmackSaslException if a SASL specific error occurred.
|
* @throws SmackSaslException if a SASL specific error occurred.
|
||||||
|
@ -361,7 +361,7 @@ public abstract class ScramMechanism extends SASLMechanism {
|
||||||
* @param key TODO javadoc me please
|
* @param key TODO javadoc me please
|
||||||
* @param str TODO javadoc me please
|
* @param str TODO javadoc me please
|
||||||
* @return the HMAC-SHA1 value of the input.
|
* @return the HMAC-SHA1 value of the input.
|
||||||
* @throws SmackException if Smack detected an exceptional situation.
|
* @throws SmackSaslException if Smack detected an exceptional situation.
|
||||||
*/
|
*/
|
||||||
private byte[] hmac(byte[] key, byte[] str) throws SmackSaslException {
|
private byte[] hmac(byte[] key, byte[] str) throws SmackSaslException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -41,6 +41,19 @@ public final class FileUtils {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FileUtils.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(FileUtils.class.getName());
|
||||||
|
|
||||||
|
public static InputStream getInputStreamForClasspathFile(String path) {
|
||||||
|
return getInputStreamForClasspathFile(path, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static InputStream getInputStreamForClasspathFile(String path, ClassLoader loader) {
|
||||||
|
try {
|
||||||
|
return getStreamForClasspathFile(path, loader);
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOGGER.log(Level.FINE, "Suppressed IOException in getInputStreamForClasspathFile", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static InputStream getStreamForClasspathFile(String path, ClassLoader loader) throws IOException {
|
public static InputStream getStreamForClasspathFile(String path, ClassLoader loader) throws IOException {
|
||||||
// Get an array of class loaders to try loading the providers files from.
|
// Get an array of class loaders to try loading the providers files from.
|
||||||
List<ClassLoader> classLoaders = getClassLoaders();
|
List<ClassLoader> classLoaders = getClassLoaders();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2015-2020 Florian Schmaus
|
* Copyright © 2015-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -22,7 +22,6 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -251,7 +250,7 @@ public class MultiMap<K, V> {
|
||||||
|
|
||||||
public MultiMap<K, V> asUnmodifiableMultiMap() {
|
public MultiMap<K, V> asUnmodifiableMultiMap() {
|
||||||
LinkedHashMap<K, List<V>> mapCopy = new LinkedHashMap<>(map.size());
|
LinkedHashMap<K, List<V>> mapCopy = new LinkedHashMap<>(map.size());
|
||||||
for (Entry<K, List<V>> entry : map.entrySet()) {
|
for (Map.Entry<K, List<V>> entry : map.entrySet()) {
|
||||||
K key = entry.getKey();
|
K key = entry.getKey();
|
||||||
List<V> values = entry.getValue();
|
List<V> values = entry.getValue();
|
||||||
|
|
||||||
|
@ -266,7 +265,7 @@ public class MultiMap<K, V> {
|
||||||
Map<K, List<V>> clonedMap = new LinkedHashMap<>(map.size());
|
Map<K, List<V>> clonedMap = new LinkedHashMap<>(map.size());
|
||||||
|
|
||||||
// TODO: Use Map.forEach() once Smack's minimum Android API is 24 or higher.
|
// TODO: Use Map.forEach() once Smack's minimum Android API is 24 or higher.
|
||||||
for (Entry<K, List<V>> entry : map.entrySet()) {
|
for (Map.Entry<K, List<V>> entry : map.entrySet()) {
|
||||||
List<V> clonedList = CollectionUtil.newListWith(entry.getValue());
|
List<V> clonedList = CollectionUtil.newListWith(entry.getValue());
|
||||||
clonedMap.put(entry.getKey(), clonedList);
|
clonedMap.put(entry.getKey(), clonedList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ import org.jivesoftware.smack.packet.StanzaError;
|
||||||
import org.jivesoftware.smack.packet.StartTls;
|
import org.jivesoftware.smack.packet.StartTls;
|
||||||
import org.jivesoftware.smack.packet.StreamError;
|
import org.jivesoftware.smack.packet.StreamError;
|
||||||
import org.jivesoftware.smack.packet.UnparsedIQ;
|
import org.jivesoftware.smack.packet.UnparsedIQ;
|
||||||
|
import org.jivesoftware.smack.packet.XmlElement;
|
||||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||||
import org.jivesoftware.smack.parsing.StandardExtensionElementProvider;
|
import org.jivesoftware.smack.parsing.StandardExtensionElementProvider;
|
||||||
|
@ -183,7 +184,7 @@ public class PacketParserUtils {
|
||||||
message.setError(parseError(parser, messageXmlEnvironment));
|
message.setError(parseError(parser, messageXmlEnvironment));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ExtensionElement extensionElement = parseExtensionElement(elementName, namespace, parser, messageXmlEnvironment);
|
XmlElement extensionElement = parseExtensionElement(elementName, namespace, parser, messageXmlEnvironment);
|
||||||
message.addExtension(extensionElement);
|
message.addExtension(extensionElement);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -474,7 +475,7 @@ public class PacketParserUtils {
|
||||||
// Be extra robust: Skip PacketExtensions that cause Exceptions, instead of
|
// Be extra robust: Skip PacketExtensions that cause Exceptions, instead of
|
||||||
// failing completely here. See SMACK-390 for more information.
|
// failing completely here. See SMACK-390 for more information.
|
||||||
try {
|
try {
|
||||||
ExtensionElement extensionElement = parseExtensionElement(elementName, namespace, parser, presenceXmlEnvironment);
|
XmlElement extensionElement = parseExtensionElement(elementName, namespace, parser, presenceXmlEnvironment);
|
||||||
presence.addExtension(extensionElement);
|
presence.addExtension(extensionElement);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.log(Level.WARNING, "Failed to parse extension element in Presence stanza: " + presence, e);
|
LOGGER.log(Level.WARNING, "Failed to parse extension element in Presence stanza: " + presence, e);
|
||||||
|
@ -701,7 +702,7 @@ public class PacketParserUtils {
|
||||||
*/
|
*/
|
||||||
public static StreamError parseStreamError(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
public static StreamError parseStreamError(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
||||||
final int initialDepth = parser.getDepth();
|
final int initialDepth = parser.getDepth();
|
||||||
List<ExtensionElement> extensions = new ArrayList<>();
|
List<XmlElement> extensions = new ArrayList<>();
|
||||||
Map<String, String> descriptiveTexts = null;
|
Map<String, String> descriptiveTexts = null;
|
||||||
StreamError.Condition condition = null;
|
StreamError.Condition condition = null;
|
||||||
String conditionText = null;
|
String conditionText = null;
|
||||||
|
@ -765,7 +766,7 @@ public class PacketParserUtils {
|
||||||
final int initialDepth = parser.getDepth();
|
final int initialDepth = parser.getDepth();
|
||||||
Map<String, String> descriptiveTexts = null;
|
Map<String, String> descriptiveTexts = null;
|
||||||
XmlEnvironment stanzaErrorXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
|
XmlEnvironment stanzaErrorXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
|
||||||
List<ExtensionElement> extensions = new ArrayList<>();
|
List<XmlElement> extensions = new ArrayList<>();
|
||||||
StanzaError.Builder builder = StanzaError.getBuilder();
|
StanzaError.Builder builder = StanzaError.getBuilder();
|
||||||
|
|
||||||
// Parse the error header
|
// Parse the error header
|
||||||
|
@ -825,7 +826,7 @@ public class PacketParserUtils {
|
||||||
* @throws IOException if an I/O error occurred.
|
* @throws IOException if an I/O error occurred.
|
||||||
* @throws SmackParsingException if the Smack parser (provider) encountered invalid input.
|
* @throws SmackParsingException if the Smack parser (provider) encountered invalid input.
|
||||||
*/
|
*/
|
||||||
public static ExtensionElement parseExtensionElement(String elementName, String namespace,
|
public static XmlElement parseExtensionElement(String elementName, String namespace,
|
||||||
XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
||||||
ParserUtils.assertAtStartTag(parser);
|
ParserUtils.assertAtStartTag(parser);
|
||||||
// See if a provider is registered to handle the extension.
|
// See if a provider is registered to handle the extension.
|
||||||
|
@ -907,7 +908,7 @@ public class PacketParserUtils {
|
||||||
|
|
||||||
public static void addExtensionElement(StanzaBuilder<?> stanzaBuilder, XmlPullParser parser, String elementName,
|
public static void addExtensionElement(StanzaBuilder<?> stanzaBuilder, XmlPullParser parser, String elementName,
|
||||||
String namespace, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
String namespace, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
||||||
ExtensionElement extensionElement = parseExtensionElement(elementName, namespace, parser, outerXmlEnvironment);
|
XmlElement extensionElement = parseExtensionElement(elementName, namespace, parser, outerXmlEnvironment);
|
||||||
stanzaBuilder.addExtension(extensionElement);
|
stanzaBuilder.addExtension(extensionElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -919,18 +920,18 @@ public class PacketParserUtils {
|
||||||
|
|
||||||
public static void addExtensionElement(Stanza packet, XmlPullParser parser, String elementName,
|
public static void addExtensionElement(Stanza packet, XmlPullParser parser, String elementName,
|
||||||
String namespace, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
String namespace, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
||||||
ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser, outerXmlEnvironment);
|
XmlElement packetExtension = parseExtensionElement(elementName, namespace, parser, outerXmlEnvironment);
|
||||||
packet.addExtension(packetExtension);
|
packet.addExtension(packetExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addExtensionElement(Collection<ExtensionElement> collection, XmlPullParser parser, XmlEnvironment outerXmlEnvironment)
|
public static void addExtensionElement(Collection<XmlElement> collection, XmlPullParser parser, XmlEnvironment outerXmlEnvironment)
|
||||||
throws XmlPullParserException, IOException, SmackParsingException {
|
throws XmlPullParserException, IOException, SmackParsingException {
|
||||||
addExtensionElement(collection, parser, parser.getName(), parser.getNamespace(), outerXmlEnvironment);
|
addExtensionElement(collection, parser, parser.getName(), parser.getNamespace(), outerXmlEnvironment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addExtensionElement(Collection<ExtensionElement> collection, XmlPullParser parser,
|
public static void addExtensionElement(Collection<XmlElement> collection, XmlPullParser parser,
|
||||||
String elementName, String namespace, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
String elementName, String namespace, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
||||||
ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser, outerXmlEnvironment);
|
XmlElement packetExtension = parseExtensionElement(elementName, namespace, parser, outerXmlEnvironment);
|
||||||
collection.add(packetExtension);
|
collection.add(packetExtension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2020 Florian Schmaus
|
* Copyright © 2014-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -18,7 +18,7 @@ package org.jivesoftware.smack.util;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.XmlElement;
|
||||||
|
|
||||||
public class PacketUtil {
|
public class PacketUtil {
|
||||||
|
|
||||||
|
@ -33,9 +33,9 @@ public class PacketUtil {
|
||||||
* @return the extension element
|
* @return the extension element
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <PE extends ExtensionElement> PE extensionElementFrom(Collection<ExtensionElement> collection,
|
public static <PE extends XmlElement> PE extensionElementFrom(Collection<XmlElement> collection,
|
||||||
String element, String namespace) {
|
String element, String namespace) {
|
||||||
for (ExtensionElement packetExtension : collection) {
|
for (XmlElement packetExtension : collection) {
|
||||||
if ((element == null || packetExtension.getElementName().equals(
|
if ((element == null || packetExtension.getElementName().equals(
|
||||||
element))
|
element))
|
||||||
&& packetExtension.getNamespace().equals(namespace)) {
|
&& packetExtension.getNamespace().equals(namespace)) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2019 Florian Schmaus
|
* Copyright © 2014-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -30,7 +30,6 @@ import org.jivesoftware.smack.datatypes.UInt32;
|
||||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||||
import org.jivesoftware.smack.parsing.SmackParsingException.RequiredAttributeMissingException;
|
import org.jivesoftware.smack.parsing.SmackParsingException.RequiredAttributeMissingException;
|
||||||
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
|
|
||||||
import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException;
|
import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException;
|
||||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||||
|
@ -308,30 +307,23 @@ public class ParserUtils {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date getDateFromOptionalXep82String(String dateString) throws SmackTextParseException {
|
public static Date getDateFromOptionalXep82String(String dateString) throws ParseException {
|
||||||
if (dateString == null) {
|
if (dateString == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return getDateFromXep82String(dateString);
|
return getDateFromXep82String(dateString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date getDateFromXep82String(String dateString) throws SmackTextParseException {
|
public static Date getDateFromXep82String(String dateString) throws ParseException {
|
||||||
try {
|
|
||||||
return XmppDateTime.parseXEP0082Date(dateString);
|
return XmppDateTime.parseXEP0082Date(dateString);
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new SmackParsingException.SmackTextParseException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date getDateFromString(String dateString) throws SmackTextParseException {
|
public static Date getDateFromString(String dateString) throws ParseException {
|
||||||
try {
|
|
||||||
return XmppDateTime.parseDate(dateString);
|
return XmppDateTime.parseDate(dateString);
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new SmackParsingException.SmackTextParseException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date getDateFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException {
|
public static Date getDateFromNextText(XmlPullParser parser)
|
||||||
|
throws XmlPullParserException, IOException, ParseException {
|
||||||
String dateString = parser.nextText();
|
String dateString = parser.nextText();
|
||||||
return getDateFromString(dateString);
|
return getDateFromString(dateString);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2016-2019 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software, 2016-2021 Florian Schmaus.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -47,4 +47,8 @@ public class RandomUtil {
|
||||||
public static int nextSecureRandomInt() {
|
public static int nextSecureRandomInt() {
|
||||||
return SECURE_RANDOM.get().nextInt();
|
return SECURE_RANDOM.get().nextInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void fillWithSecureRandom(byte[] bytes) {
|
||||||
|
SECURE_RANDOM.get().nextBytes(bytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.Element;
|
import org.jivesoftware.smack.packet.Element;
|
||||||
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
|
||||||
import org.jivesoftware.smack.packet.NamedElement;
|
import org.jivesoftware.smack.packet.NamedElement;
|
||||||
|
import org.jivesoftware.smack.packet.XmlElement;
|
||||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||||
|
|
||||||
import org.jxmpp.util.XmppDateTime;
|
import org.jxmpp.util.XmppDateTime;
|
||||||
|
@ -42,7 +42,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
||||||
effectiveXmlEnvironment = null;
|
effectiveXmlEnvironment = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmlStringBuilder(FullyQualifiedElement pe) {
|
public XmlStringBuilder(XmlElement pe) {
|
||||||
this(pe, null);
|
this(pe, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
||||||
halfOpenElement(e.getElementName());
|
halfOpenElement(e.getElementName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmlStringBuilder(FullyQualifiedElement element, XmlEnvironment enclosingXmlEnvironment) {
|
public XmlStringBuilder(XmlElement element, XmlEnvironment enclosingXmlEnvironment) {
|
||||||
sb = new LazyStringBuilder();
|
sb = new LazyStringBuilder();
|
||||||
halfOpenElement(element);
|
halfOpenElement(element);
|
||||||
|
|
||||||
|
@ -516,7 +516,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
||||||
return escape(text.toString());
|
return escape(text.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected XmlStringBuilder prelude(FullyQualifiedElement pe) {
|
protected XmlStringBuilder prelude(XmlElement pe) {
|
||||||
return prelude(pe.getElementName(), pe.getNamespace());
|
return prelude(pe.getElementName(), pe.getNamespace());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,4 +64,13 @@ public class XmlUtil {
|
||||||
|
|
||||||
return stringWriter.toString();
|
return stringWriter.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isClarkNotation(String text) {
|
||||||
|
if (text.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: This is currently a mediocre heuristic to check for clark notation.
|
||||||
|
return text.charAt(0) == '{';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2018-2020 Florian Schmaus
|
* Copyright 2018-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -24,19 +24,19 @@ import java.util.logging.Logger;
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
|
||||||
import org.jivesoftware.smack.packet.StandardExtensionElement;
|
import org.jivesoftware.smack.packet.StandardExtensionElement;
|
||||||
|
import org.jivesoftware.smack.packet.XmlElement;
|
||||||
import org.jivesoftware.smack.provider.ProviderManager;
|
import org.jivesoftware.smack.provider.ProviderManager;
|
||||||
|
|
||||||
import org.jxmpp.util.cache.LruCache;
|
import org.jxmpp.util.cache.LruCache;
|
||||||
|
|
||||||
public class XmppElementUtil {
|
public class XmppElementUtil {
|
||||||
|
|
||||||
private static final LruCache<Class<? extends FullyQualifiedElement>, QName> CLASS_TO_QNAME_CACHE = new LruCache<>(512);
|
private static final LruCache<Class<? extends XmlElement>, QName> CLASS_TO_QNAME_CACHE = new LruCache<>(512);
|
||||||
|
|
||||||
public static final Logger LOGGER = Logger.getLogger(XmppElementUtil.class.getName());
|
public static final Logger LOGGER = Logger.getLogger(XmppElementUtil.class.getName());
|
||||||
|
|
||||||
public static QName getQNameFor(Class<? extends FullyQualifiedElement> fullyQualifiedElement) {
|
public static QName getQNameFor(Class<? extends XmlElement> fullyQualifiedElement) {
|
||||||
QName qname = CLASS_TO_QNAME_CACHE.get(fullyQualifiedElement);
|
QName qname = CLASS_TO_QNAME_CACHE.get(fullyQualifiedElement);
|
||||||
if (qname != null) {
|
if (qname != null) {
|
||||||
return qname;
|
return qname;
|
||||||
|
@ -72,24 +72,24 @@ public class XmppElementUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <E extends ExtensionElement> List<E> getElementsFrom(
|
public static <E extends ExtensionElement> List<E> getElementsFrom(
|
||||||
MultiMap<QName, ExtensionElement> elementMap, Class<E> extensionElementClass) {
|
MultiMap<QName, XmlElement> elementMap, Class<E> extensionElementClass) {
|
||||||
QName qname = XmppElementUtil.getQNameFor(extensionElementClass);
|
QName qname = XmppElementUtil.getQNameFor(extensionElementClass);
|
||||||
|
|
||||||
List<ExtensionElement> extensionElements = elementMap.getAll(qname);
|
List<XmlElement> extensionElements = elementMap.getAll(qname);
|
||||||
|
|
||||||
if (extensionElements.isEmpty()) {
|
if (extensionElements.isEmpty()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<E> res = new ArrayList<>(extensionElements.size());
|
List<E> res = new ArrayList<>(extensionElements.size());
|
||||||
for (ExtensionElement extensionElement : extensionElements) {
|
for (XmlElement extensionElement : extensionElements) {
|
||||||
E e = castOrThrow(extensionElement, extensionElementClass);
|
E e = castOrThrow(extensionElement, extensionElementClass);
|
||||||
res.add(e);
|
res.add(e);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <E extends ExtensionElement> E castOrThrow(ExtensionElement extensionElement, Class<E> extensionElementClass) {
|
public static <E extends ExtensionElement> E castOrThrow(XmlElement extensionElement, Class<E> extensionElementClass) {
|
||||||
if (!extensionElementClass.isInstance(extensionElement)) {
|
if (!extensionElementClass.isInstance(extensionElement)) {
|
||||||
final QName qname = getQNameFor(extensionElementClass);
|
final QName qname = getQNameFor(extensionElementClass);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2020 Florian Schmaus
|
* Copyright 2020-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -32,6 +32,10 @@ public interface RemoteConnectionEndpoint {
|
||||||
|
|
||||||
String getDescription();
|
String getDescription();
|
||||||
|
|
||||||
|
default String getRawString() {
|
||||||
|
return toString();
|
||||||
|
}
|
||||||
|
|
||||||
class InetSocketAddressCoupling<RCE extends RemoteConnectionEndpoint> {
|
class InetSocketAddressCoupling<RCE extends RemoteConnectionEndpoint> {
|
||||||
private final RCE connectionEndpoint;
|
private final RCE connectionEndpoint;
|
||||||
private final InetSocketAddress inetSocketAddress;
|
private final InetSocketAddress inetSocketAddress;
|
||||||
|
|
|
@ -104,6 +104,8 @@ public class Base32 {
|
||||||
for (int j = 0; j < blocklen; j++)
|
for (int j = 0; j < blocklen; j++)
|
||||||
ds.writeByte((byte) (t[j] & 0xFF));
|
ds.writeByte((byte) (t[j] & 0xFF));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
// This should not happen.
|
||||||
|
throw new AssertionError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class ConnectionConfigurationTest {
|
||||||
|
|
||||||
private static final class DummyConnectionConfiguration extends ConnectionConfiguration {
|
private static final class DummyConnectionConfiguration extends ConnectionConfiguration {
|
||||||
|
|
||||||
protected DummyConnectionConfiguration(Builder builder) {
|
DummyConnectionConfiguration(Builder builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class StreamErrorTest {
|
||||||
assertNotNull(error);
|
assertNotNull(error);
|
||||||
assertEquals(Condition.conflict, error.getCondition());
|
assertEquals(Condition.conflict, error.getCondition());
|
||||||
assertEquals("Replaced by new connection", error.getDescriptiveText());
|
assertEquals("Replaced by new connection", error.getDescriptiveText());
|
||||||
ExtensionElement appSpecificElement = error.getExtension("appSpecificElement", "myns");
|
XmlElement appSpecificElement = error.getExtension("appSpecificElement", "myns");
|
||||||
assertNotNull(appSpecificElement);
|
assertNotNull(appSpecificElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,17 +20,14 @@ import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.StanzaError.Condition;
|
|
||||||
import org.jivesoftware.smack.packet.StanzaError.Type;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class XMPPErrorTest {
|
public class XMPPErrorTest {
|
||||||
@Test
|
@Test
|
||||||
public void testConditionHasDefaultTypeMapping() throws NoSuchFieldException, IllegalAccessException {
|
public void testConditionHasDefaultTypeMapping() throws NoSuchFieldException, IllegalAccessException {
|
||||||
Map<Condition, Type> conditionToTypeMap = StanzaError.CONDITION_TO_TYPE;
|
Map<StanzaError.Condition, StanzaError.Type> conditionToTypeMap = StanzaError.CONDITION_TO_TYPE;
|
||||||
assertEquals("CONDITION_TO_TYPE map is likely out of sync with Condition enum",
|
assertEquals("CONDITION_TO_TYPE map is likely out of sync with Condition enum",
|
||||||
Condition.values().length,
|
StanzaError.Condition.values().length,
|
||||||
conditionToTypeMap.size());
|
conditionToTypeMap.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright 2021 Florian Schmaus.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.jivesoftware.smack.provider;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.ParseException;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
|
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||||
|
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||||
|
import org.jivesoftware.smack.test.util.SmackTestUtil;
|
||||||
|
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||||
|
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class AbstractProviderTest {
|
||||||
|
|
||||||
|
private static final ExtensionElementProvider<ExtensionElement> NUMBER_FORMAT_THROWING_PROVIDER = new ExtensionElementProvider<ExtensionElement>() {
|
||||||
|
@Override
|
||||||
|
public ExtensionElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||||
|
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
|
||||||
|
throw new NumberFormatException();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final String MESSAGE = "dummy message";
|
||||||
|
private static final int VALUE = 14768234;
|
||||||
|
private static final ExtensionElementProvider<ExtensionElement> PARSE_EXCEPTION_THROWING_PROVIDER = new ExtensionElementProvider<ExtensionElement>() {
|
||||||
|
@Override
|
||||||
|
public ExtensionElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||||
|
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
|
||||||
|
throw new ParseException(MESSAGE, VALUE);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrapsNumberFormatException() throws XmlPullParserException, IOException {
|
||||||
|
XmlPullParser parser = SmackTestUtil.createDummyParser();
|
||||||
|
assertThrows(AbstractProvider.NumberFormatParseException.class,
|
||||||
|
() -> NUMBER_FORMAT_THROWING_PROVIDER.parse(parser));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrapsParseException() throws XmlPullParserException, IOException {
|
||||||
|
XmlPullParser parser = SmackTestUtil.createDummyParser();
|
||||||
|
AbstractProvider.TextParseException testParseException = assertThrows(AbstractProvider.TextParseException.class,
|
||||||
|
() -> PARSE_EXCEPTION_THROWING_PROVIDER.parse(parser));
|
||||||
|
ParseException parseException = testParseException.getParseException();
|
||||||
|
assertEquals(MESSAGE, parseException.getMessage());
|
||||||
|
assertEquals(VALUE, parseException.getErrorOffset());
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,7 +24,6 @@ import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.IQ.Type;
|
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smack.packet.Stanza;
|
import org.jivesoftware.smack.packet.Stanza;
|
||||||
|
|
||||||
|
@ -58,7 +57,7 @@ public class ThreadedDummyConnection extends DummyConnection {
|
||||||
replyPacket.setStanzaId(packet.getStanzaId());
|
replyPacket.setStanzaId(packet.getStanzaId());
|
||||||
replyPacket.setTo(packet.getFrom());
|
replyPacket.setTo(packet.getFrom());
|
||||||
if (replyPacket.getType() == null) {
|
if (replyPacket.getType() == null) {
|
||||||
replyPacket.setType(Type.result);
|
replyPacket.setType(IQ.Type.result);
|
||||||
}
|
}
|
||||||
|
|
||||||
new ProcessQueue(replyQ).start();
|
new ProcessQueue(replyQ).start();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2019 Florian Schmaus
|
* Copyright 2019-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -30,6 +30,7 @@ import javax.xml.namespace.QName;
|
||||||
import org.jivesoftware.smack.packet.Element;
|
import org.jivesoftware.smack.packet.Element;
|
||||||
import org.jivesoftware.smack.parsing.SmackParsingException;
|
import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||||
import org.jivesoftware.smack.provider.Provider;
|
import org.jivesoftware.smack.provider.Provider;
|
||||||
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||||
import org.jivesoftware.smack.xml.XmlPullParserFactory;
|
import org.jivesoftware.smack.xml.XmlPullParserFactory;
|
||||||
|
@ -125,6 +126,11 @@ public class SmackTestUtil {
|
||||||
return parser;
|
return parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static XmlPullParser createDummyParser() throws XmlPullParserException, IOException {
|
||||||
|
String dummyElement = "<empty-element/>";
|
||||||
|
return PacketParserUtils.getParserFor(dummyElement);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static <E extends Element, P extends Provider<E>> P providerClassToProvider(Class<P> providerClass) {
|
private static <E extends Element, P extends Provider<E>> P providerClassToProvider(Class<P> providerClass) {
|
||||||
P provider;
|
P provider;
|
||||||
|
|
|
@ -4,6 +4,6 @@ Inspect the exchanged XMPP stanzas.
|
||||||
Connect your favourite slf4j backend of choice to get output inside of it"""
|
Connect your favourite slf4j backend of choice to get output inside of it"""
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':smack-core')
|
api project(':smack-core')
|
||||||
compile 'org.slf4j:slf4j-api:[1.7,1.8)'
|
implementation 'org.slf4j:slf4j-api:[1.7,1.8)'
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,5 @@ Smack GUI debugger.
|
||||||
Inspect the exchanged XMPP stanzas."""
|
Inspect the exchanged XMPP stanzas."""
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':smack-core')
|
api project(':smack-core')
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ otherwise carefully considered for deployment. The API may change even
|
||||||
between patch versions."""
|
between patch versions."""
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':smack-core')
|
api project(':smack-core')
|
||||||
compile project(':smack-extensions')
|
api project(':smack-extensions')
|
||||||
|
|
||||||
compile "org.hsluv:hsluv:0.2"
|
implementation "org.hsluv:hsluv:0.2"
|
||||||
|
|
||||||
testFixturesApi(testFixtures(project(":smack-extensions")))
|
testFixturesApi(testFixtures(project(":smack-extensions")))
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,7 +339,7 @@ public final class CarbonManager extends Manager {
|
||||||
|
|
||||||
IQ setIQ = carbonsEnabledIQ(new_state);
|
IQ setIQ = carbonsEnabledIQ(new_state);
|
||||||
|
|
||||||
connection().createStanzaCollectorAndSend(setIQ).nextResultOrThrow();
|
connection().sendIqRequestAndWaitForResponse(setIQ);
|
||||||
enabled_state = new_state;
|
enabled_state = new_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2013-2014 Georg Lukas, 2020 Florian Schmaus
|
* Copyright 2013-2014 Georg Lukas, 2020-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,9 +16,12 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.carbons.packet;
|
package org.jivesoftware.smackx.carbons.packet;
|
||||||
|
|
||||||
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smack.packet.MessageBuilder;
|
import org.jivesoftware.smack.packet.MessageBuilder;
|
||||||
|
import org.jivesoftware.smack.packet.XmlElement;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.forward.packet.Forwarded;
|
import org.jivesoftware.smackx.forward.packet.Forwarded;
|
||||||
|
@ -34,7 +37,7 @@ import org.jivesoftware.smackx.forward.packet.Forwarded;
|
||||||
*
|
*
|
||||||
* @author Georg Lukas
|
* @author Georg Lukas
|
||||||
*/
|
*/
|
||||||
public class CarbonExtension implements ExtensionElement {
|
public class CarbonExtension implements XmlElement {
|
||||||
public static final String NAMESPACE = Carbon.NAMESPACE;
|
public static final String NAMESPACE = Carbon.NAMESPACE;
|
||||||
|
|
||||||
private final Direction dir;
|
private final Direction dir;
|
||||||
|
@ -136,6 +139,7 @@ public class CarbonExtension implements ExtensionElement {
|
||||||
public static final class Private implements ExtensionElement {
|
public static final class Private implements ExtensionElement {
|
||||||
public static final Private INSTANCE = new Private();
|
public static final Private INSTANCE = new Private();
|
||||||
public static final String ELEMENT = "private";
|
public static final String ELEMENT = "private";
|
||||||
|
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||||
|
|
||||||
private Private() {
|
private Private() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2013-2014 Georg Lukas, 2020 Florian Schmaus.
|
* Copyright 2013-2014 Georg Lukas, 2020-2021 Florian Schmaus.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
package org.jivesoftware.smackx.carbons.provider;
|
package org.jivesoftware.smackx.carbons.provider;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.ParseException;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||||
|
@ -40,7 +41,8 @@ import org.jivesoftware.smackx.forward.provider.ForwardedProvider;
|
||||||
public class CarbonManagerProvider extends ExtensionElementProvider<CarbonExtension> {
|
public class CarbonManagerProvider extends ExtensionElementProvider<CarbonExtension> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CarbonExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
public CarbonExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
|
||||||
|
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
|
||||||
Direction dir = Direction.valueOf(parser.getName());
|
Direction dir = Direction.valueOf(parser.getName());
|
||||||
Forwarded<Message> fwd = null;
|
Forwarded<Message> fwd = null;
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
package org.jivesoftware.smackx.chat_markers.filter;
|
package org.jivesoftware.smackx.chat_markers.filter;
|
||||||
|
|
||||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
|
||||||
import org.jivesoftware.smack.packet.Stanza;
|
import org.jivesoftware.smack.packet.Stanza;
|
||||||
|
import org.jivesoftware.smack.packet.XmlElement;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.chatstates.ChatState;
|
import org.jivesoftware.smackx.chatstates.ChatState;
|
||||||
import org.jivesoftware.smackx.chatstates.ChatStateManager;
|
import org.jivesoftware.smackx.chatstates.ChatStateManager;
|
||||||
|
@ -56,7 +56,7 @@ public final class EligibleForChatMarkerFilter extends StanzaExtensionFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (super.accept(message)) {
|
if (super.accept(message)) {
|
||||||
ExtensionElement extension = message.getExtension(ChatStateManager.NAMESPACE);
|
XmlElement extension = message.getExtension(ChatStateManager.NAMESPACE);
|
||||||
String chatStateElementName = extension.getElementName();
|
String chatStateElementName = extension.getElementName();
|
||||||
|
|
||||||
ChatState state;
|
ChatState state;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2015 Florian Schmaus
|
* Copyright © 2014-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.csi.packet;
|
package org.jivesoftware.smackx.csi.packet;
|
||||||
|
|
||||||
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smack.packet.Nonza;
|
import org.jivesoftware.smack.packet.Nonza;
|
||||||
|
|
||||||
|
@ -77,12 +79,19 @@ public class ClientStateIndication {
|
||||||
public static final Feature INSTANCE = new Feature();
|
public static final Feature INSTANCE = new Feature();
|
||||||
public static final String ELEMENT = "csi";
|
public static final String ELEMENT = "csi";
|
||||||
|
|
||||||
|
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||||
|
|
||||||
private Feature() {
|
private Feature() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getElementName() {
|
public String getElementName() {
|
||||||
return ELEMENT;
|
return QNAME.getLocalPart();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNamespace() {
|
||||||
|
return QNAME.getNamespaceURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,9 +99,5 @@ public class ClientStateIndication {
|
||||||
return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
|
return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getNamespace() {
|
|
||||||
return NAMESPACE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2019 Florian Schmaus
|
* Copyright 2019-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -31,7 +31,6 @@ import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.StanzaError;
|
import org.jivesoftware.smack.packet.StanzaError;
|
||||||
import org.jivesoftware.smack.packet.StanzaError.Condition;
|
import org.jivesoftware.smack.packet.StanzaError.Condition;
|
||||||
import org.jivesoftware.smack.packet.StanzaError.Type;
|
|
||||||
import org.jivesoftware.smack.util.RandomUtil;
|
import org.jivesoftware.smack.util.RandomUtil;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
|
@ -89,7 +88,7 @@ public final class DnsOverXmppManager extends Manager {
|
||||||
response = resolver.resolve(query);
|
response = resolver.resolve(query);
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
StanzaError errorBuilder = StanzaError.getBuilder()
|
StanzaError errorBuilder = StanzaError.getBuilder()
|
||||||
.setType(Type.CANCEL)
|
.setType(StanzaError.Type.CANCEL)
|
||||||
.setCondition(Condition.internal_server_error)
|
.setCondition(Condition.internal_server_error)
|
||||||
.setDescriptiveEnText("Exception while resolving your DNS query", exception)
|
.setDescriptiveEnText("Exception while resolving your DNS query", exception)
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package org.jivesoftware.smackx.fallback_indication;
|
package org.jivesoftware.smackx.fallback_indication;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.fallback_indication.element.FallbackIndicationElement;
|
import org.jivesoftware.smackx.fallback_indication.element.FallbackIndicationElement;
|
||||||
|
|
||||||
public interface FallbackIndicationListener {
|
public interface FallbackIndicationListener {
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smack.packet.MessageBuilder;
|
import org.jivesoftware.smack.packet.MessageBuilder;
|
||||||
import org.jivesoftware.smack.packet.Stanza;
|
import org.jivesoftware.smack.packet.Stanza;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jivesoftware.smackx.fallback_indication.element.FallbackIndicationElement;
|
import org.jivesoftware.smackx.fallback_indication.element.FallbackIndicationElement;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.jivesoftware.smack.parsing.SmackParsingException;
|
||||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.fallback_indication.element.FallbackIndicationElement;
|
import org.jivesoftware.smackx.fallback_indication.element.FallbackIndicationElement;
|
||||||
|
|
||||||
public class FallbackIndicationElementProvider extends ExtensionElementProvider<FallbackIndicationElement> {
|
public class FallbackIndicationElementProvider extends ExtensionElementProvider<FallbackIndicationElement> {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2017 Paul Schaub
|
* Copyright © 2017 Paul Schaub, 2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.hashes.element;
|
||||||
|
|
||||||
import static org.jivesoftware.smack.util.Objects.requireNonNull;
|
import static org.jivesoftware.smack.util.Objects.requireNonNull;
|
||||||
|
|
||||||
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||||
|
@ -34,6 +36,8 @@ public class HashElement implements ExtensionElement {
|
||||||
public static final String ELEMENT = "hash";
|
public static final String ELEMENT = "hash";
|
||||||
public static final String ATTR_ALGO = "algo";
|
public static final String ATTR_ALGO = "algo";
|
||||||
|
|
||||||
|
public static final QName QNAME = new QName(HashManager.NAMESPACE.V2.toString(), ELEMENT);
|
||||||
|
|
||||||
private final HashManager.ALGORITHM algorithm;
|
private final HashManager.ALGORITHM algorithm;
|
||||||
private final byte[] hash;
|
private final byte[] hash;
|
||||||
private final String hashB64;
|
private final String hashB64;
|
||||||
|
@ -89,7 +93,12 @@ public class HashElement implements ExtensionElement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getElementName() {
|
public String getElementName() {
|
||||||
return ELEMENT;
|
return QNAME.getLocalPart();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNamespace() {
|
||||||
|
return QNAME.getNamespaceURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -102,11 +111,6 @@ public class HashElement implements ExtensionElement {
|
||||||
return sb;
|
return sb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getNamespace() {
|
|
||||||
return HashManager.NAMESPACE.V2.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (other == null || !(other instanceof HashElement)) {
|
if (other == null || !(other instanceof HashElement)) {
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.hoxt.packet;
|
package org.jivesoftware.smackx.hoxt.packet;
|
||||||
|
|
||||||
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.NamedElement;
|
import org.jivesoftware.smack.packet.NamedElement;
|
||||||
|
@ -161,6 +163,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
||||||
public static class Data extends HoxExtensionElement {
|
public static class Data extends HoxExtensionElement {
|
||||||
|
|
||||||
public static final String ELEMENT = "data";
|
public static final String ELEMENT = "data";
|
||||||
|
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||||
|
|
||||||
private final NamedElement child;
|
private final NamedElement child;
|
||||||
|
|
||||||
|
@ -210,6 +213,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
||||||
public static class Text extends HoxExtensionElement {
|
public static class Text extends HoxExtensionElement {
|
||||||
|
|
||||||
public static final String ELEMENT = "text";
|
public static final String ELEMENT = "text";
|
||||||
|
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||||
|
|
||||||
private final String text;
|
private final String text;
|
||||||
|
|
||||||
|
@ -252,6 +256,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
||||||
public static class Base64 extends HoxExtensionElement {
|
public static class Base64 extends HoxExtensionElement {
|
||||||
|
|
||||||
public static final String ELEMENT = "base64";
|
public static final String ELEMENT = "base64";
|
||||||
|
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||||
|
|
||||||
private final String text;
|
private final String text;
|
||||||
|
|
||||||
|
@ -294,6 +299,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
||||||
public static class Xml extends HoxExtensionElement {
|
public static class Xml extends HoxExtensionElement {
|
||||||
|
|
||||||
public static final String ELEMENT = "xml";
|
public static final String ELEMENT = "xml";
|
||||||
|
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||||
|
|
||||||
private final String text;
|
private final String text;
|
||||||
|
|
||||||
|
@ -336,6 +342,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
||||||
public static class ChunkedBase64 extends HoxExtensionElement {
|
public static class ChunkedBase64 extends HoxExtensionElement {
|
||||||
|
|
||||||
public static final String ELEMENT = "chunkedBase64";
|
public static final String ELEMENT = "chunkedBase64";
|
||||||
|
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||||
|
|
||||||
private final String streamId;
|
private final String streamId;
|
||||||
|
|
||||||
|
@ -379,6 +386,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
||||||
public static class Ibb extends HoxExtensionElement {
|
public static class Ibb extends HoxExtensionElement {
|
||||||
|
|
||||||
public static final String ELEMENT = "ibb";
|
public static final String ELEMENT = "ibb";
|
||||||
|
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
|
||||||
|
|
||||||
private final String sid;
|
private final String sid;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2014 Andriy Tsykholyas, 2015 Florian Schmaus
|
* Copyright 2014 Andriy Tsykholyas, 2015-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.hoxt.packet;
|
package org.jivesoftware.smackx.hoxt.packet;
|
||||||
|
|
||||||
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smack.util.Objects;
|
import org.jivesoftware.smack.util.Objects;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
@ -36,6 +38,8 @@ public class Base64BinaryChunk implements ExtensionElement {
|
||||||
public static final String ATTRIBUTE_LAST = "last";
|
public static final String ATTRIBUTE_LAST = "last";
|
||||||
public static final String ATTRIBUTE_NR = "nr";
|
public static final String ATTRIBUTE_NR = "nr";
|
||||||
|
|
||||||
|
public static final QName QNAME = new QName(HOXTManager.NAMESPACE, ELEMENT_CHUNK);
|
||||||
|
|
||||||
private final String streamId;
|
private final String streamId;
|
||||||
private final boolean last;
|
private final boolean last;
|
||||||
private final String text;
|
private final String text;
|
||||||
|
@ -108,12 +112,12 @@ public class Base64BinaryChunk implements ExtensionElement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getElementName() {
|
public String getElementName() {
|
||||||
return ELEMENT_CHUNK;
|
return QNAME.getLocalPart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNamespace() {
|
public String getNamespace() {
|
||||||
return HOXTManager.NAMESPACE;
|
return QNAME.getNamespaceURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -37,6 +36,7 @@ import javax.net.ssl.HttpsURLConnection;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.SSLSocketFactory;
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.AbstractXMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.ConnectionListener;
|
import org.jivesoftware.smack.ConnectionListener;
|
||||||
import org.jivesoftware.smack.Manager;
|
import org.jivesoftware.smack.Manager;
|
||||||
|
@ -45,6 +45,7 @@ import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||||
|
import org.jivesoftware.smack.proxy.ProxyInfo;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||||
|
@ -417,7 +418,7 @@ public final class HttpFileUploadManager extends Manager {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
||||||
return connection.createStanzaCollectorAndSend(slotRequest).nextResultOrThrow();
|
return connection.sendIqRequestAndWaitForResponse(slotRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTlsContext(SSLContext tlsContext) {
|
public void setTlsContext(SSLContext tlsContext) {
|
||||||
|
@ -429,15 +430,15 @@ public final class HttpFileUploadManager extends Manager {
|
||||||
|
|
||||||
private void upload(InputStream iStream, long fileSize, Slot slot, UploadProgressListener listener) throws IOException {
|
private void upload(InputStream iStream, long fileSize, Slot slot, UploadProgressListener listener) throws IOException {
|
||||||
final URL putUrl = slot.getPutUrl();
|
final URL putUrl = slot.getPutUrl();
|
||||||
|
final XMPPConnection connection = connection();
|
||||||
final HttpURLConnection urlConnection = (HttpURLConnection) putUrl.openConnection();
|
final HttpURLConnection urlConnection = createURLConnection(connection, putUrl);
|
||||||
|
|
||||||
urlConnection.setRequestMethod("PUT");
|
urlConnection.setRequestMethod("PUT");
|
||||||
urlConnection.setUseCaches(false);
|
urlConnection.setUseCaches(false);
|
||||||
urlConnection.setDoOutput(true);
|
urlConnection.setDoOutput(true);
|
||||||
urlConnection.setFixedLengthStreamingMode(fileSize);
|
urlConnection.setFixedLengthStreamingMode(fileSize);
|
||||||
urlConnection.setRequestProperty("Content-Type", "application/octet-stream");
|
urlConnection.setRequestProperty("Content-Type", "application/octet-stream");
|
||||||
for (Entry<String, String> header : slot.getHeaders().entrySet()) {
|
for (Map.Entry<String, String> header : slot.getHeaders().entrySet()) {
|
||||||
urlConnection.setRequestProperty(header.getKey(), header.getValue());
|
urlConnection.setRequestProperty(header.getKey(), header.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,6 +504,30 @@ public final class HttpFileUploadManager extends Manager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static HttpURLConnection createURLConnection(XMPPConnection connection, URL putUrl) throws IOException {
|
||||||
|
Objects.requireNonNull(connection);
|
||||||
|
Objects.requireNonNull(putUrl);
|
||||||
|
ProxyInfo proxyInfo = fetchProxyInfo(connection);
|
||||||
|
if (proxyInfo != null) {
|
||||||
|
return createProxiedURLConnection(proxyInfo, putUrl);
|
||||||
|
}
|
||||||
|
return (HttpURLConnection) putUrl.openConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HttpURLConnection createProxiedURLConnection(ProxyInfo proxyInfo, URL putUrl) throws IOException {
|
||||||
|
Objects.requireNonNull(proxyInfo);
|
||||||
|
Objects.requireNonNull(putUrl);
|
||||||
|
return (HttpURLConnection) putUrl.openConnection(proxyInfo.toJavaProxy());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ProxyInfo fetchProxyInfo(XMPPConnection connection) {
|
||||||
|
if (!(connection instanceof AbstractXMPPConnection)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
AbstractXMPPConnection xmppConnection = (AbstractXMPPConnection) connection;
|
||||||
|
return xmppConnection.getConfiguration().getProxyInfo();
|
||||||
|
}
|
||||||
|
|
||||||
public static UploadService.Version namespaceToVersion(String namespace) {
|
public static UploadService.Version namespaceToVersion(String namespace) {
|
||||||
UploadService.Version version;
|
UploadService.Version version;
|
||||||
switch (namespace) {
|
switch (namespace) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2016 Florian Schmaus
|
* Copyright 2016-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -22,7 +22,6 @@ import org.jivesoftware.smack.Manager;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.IQ.Type;
|
|
||||||
|
|
||||||
import org.jivesoftware.smackx.iot.provisioning.IoTProvisioningManager;
|
import org.jivesoftware.smackx.iot.provisioning.IoTProvisioningManager;
|
||||||
|
|
||||||
|
@ -70,7 +69,7 @@ public abstract class IoTManager extends Manager {
|
||||||
|
|
||||||
protected abstract class IoTIqRequestHandler extends AbstractIqRequestHandler {
|
protected abstract class IoTIqRequestHandler extends AbstractIqRequestHandler {
|
||||||
|
|
||||||
protected IoTIqRequestHandler(String element, String namespace, Type type, Mode mode) {
|
protected IoTIqRequestHandler(String element, String namespace, IQ.Type type, Mode mode) {
|
||||||
super(element, namespace, type, mode);
|
super(element, namespace, type, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Iterator;
|
||||||
import org.jivesoftware.smackx.iot.control.ThingControlRequest;
|
import org.jivesoftware.smackx.iot.control.ThingControlRequest;
|
||||||
import org.jivesoftware.smackx.iot.data.ThingMomentaryReadOutRequest;
|
import org.jivesoftware.smackx.iot.data.ThingMomentaryReadOutRequest;
|
||||||
import org.jivesoftware.smackx.iot.discovery.element.Tag;
|
import org.jivesoftware.smackx.iot.discovery.element.Tag;
|
||||||
import org.jivesoftware.smackx.iot.discovery.element.Tag.Type;
|
|
||||||
import org.jivesoftware.smackx.iot.element.NodeInfo;
|
import org.jivesoftware.smackx.iot.element.NodeInfo;
|
||||||
|
|
||||||
public final class Thing {
|
public final class Thing {
|
||||||
|
@ -112,35 +111,35 @@ public final class Thing {
|
||||||
|
|
||||||
public Builder setSerialNumber(String sn) {
|
public Builder setSerialNumber(String sn) {
|
||||||
final String name = "SN";
|
final String name = "SN";
|
||||||
Tag tag = new Tag(name, Type.str, sn);
|
Tag tag = new Tag(name, Tag.Type.str, sn);
|
||||||
metaTags.put(name, tag);
|
metaTags.put(name, tag);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setKey(String key) {
|
public Builder setKey(String key) {
|
||||||
final String name = "KEY";
|
final String name = "KEY";
|
||||||
Tag tag = new Tag(name, Type.str, key);
|
Tag tag = new Tag(name, Tag.Type.str, key);
|
||||||
metaTags.put(name, tag);
|
metaTags.put(name, tag);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setManufacturer(String manufacturer) {
|
public Builder setManufacturer(String manufacturer) {
|
||||||
final String name = "MAN";
|
final String name = "MAN";
|
||||||
Tag tag = new Tag(name, Type.str, manufacturer);
|
Tag tag = new Tag(name, Tag.Type.str, manufacturer);
|
||||||
metaTags.put(name, tag);
|
metaTags.put(name, tag);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setModel(String model) {
|
public Builder setModel(String model) {
|
||||||
final String name = "MODEL";
|
final String name = "MODEL";
|
||||||
Tag tag = new Tag(name, Type.str, model);
|
Tag tag = new Tag(name, Tag.Type.str, model);
|
||||||
metaTags.put(name, tag);
|
metaTags.put(name, tag);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setVersion(String version) {
|
public Builder setVersion(String version) {
|
||||||
final String name = "V";
|
final String name = "V";
|
||||||
Tag tag = new Tag(name, Type.num, version);
|
Tag tag = new Tag(name, Tag.Type.num, version);
|
||||||
metaTags.put(name, tag);
|
metaTags.put(name, tag);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ public final class IoTControlManager extends IoTManager {
|
||||||
public IoTSetResponse setUsingIq(FullJid jid, Collection<? extends SetData> data) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
public IoTSetResponse setUsingIq(FullJid jid, Collection<? extends SetData> data) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
IoTSetRequest request = new IoTSetRequest(data);
|
IoTSetRequest request = new IoTSetRequest(data);
|
||||||
request.setTo(jid);
|
request.setTo(jid);
|
||||||
IoTSetResponse response = connection().createStanzaCollectorAndSend(request).nextResultOrThrow();
|
IoTSetResponse response = connection().sendIqRequestAndWaitForResponse(request);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2016-2019 Florian Schmaus
|
* Copyright © 2016-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -18,10 +18,10 @@ package org.jivesoftware.smackx.iot.control.element;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.XmlElement;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
public abstract class SetData implements ExtensionElement {
|
public abstract class SetData implements XmlElement {
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
BOOL,
|
BOOL,
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue