1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 18:59:41 +02:00

Merge branch '4.1'

Conflicts:
	smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java
	version.gradle
This commit is contained in:
Florian Schmaus 2015-05-24 22:36:11 +02:00
commit 01f08e87c2
7 changed files with 82 additions and 56 deletions

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smack.packet;
import java.util.Locale;
import org.jivesoftware.smack.packet.id.StanzaIdUtil;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.TypedCloneable;
import org.jivesoftware.smack.util.XmlStringBuilder;
@ -259,6 +260,18 @@ public final class Presence extends Stanza implements TypedCloneable<Presence> {
return new Presence(this);
}
/**
* Clone this presence and set a newly generated stanza ID as the clone's ID.
*
* @return a "clone" of this presence with a different stanza ID.
* @since 4.1.2
*/
public Presence cloneWithNewId() {
Presence clone = clone();
clone.setStanzaId(StanzaIdUtil.newStanzaId());
return clone;
}
/**
* An enum to represent the presence type. Note that presence type is often confused
* with presence mode. Generally, if a user is signed in to a server, they have a presence

View file

@ -359,6 +359,23 @@ public abstract class Stanza implements TopLevelStreamElement {
}
}
/**
* Add the given extension and override eventually existing extensions with the same name and
* namespace.
*
* @param extension the extension element to add.
* @return one of the removed extensions or <code>null</code> if there are none.
* @since 4.1.2
*/
public ExtensionElement overrideExtension(ExtensionElement extension) {
if (extension == null) return null;
synchronized (packetExtensions) {
ExtensionElement removedExtension = removeExtension(extension);
addExtension(extension);
return removedExtension;
}
}
/**
* Adds a collection of stanza(/packet) extensions to the packet. Does nothing if extensions is null.
*

View file

@ -201,7 +201,10 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
private final void authenticate() throws SmackException, NotConnectedException, InterruptedException {
byte[] authenticationBytes = getAuthenticationText();
String authenticationText;
if (authenticationBytes != null) {
// Some SASL mechanisms do return an empty array (e.g. EXTERNAL from javax), so check that
// the array is not-empty. Mechanisms are allowed to return either 'null' or an empty array
// if there is no authentication text.
if (authenticationBytes != null && authenticationBytes.length > 0) {
authenticationText = Base64.encodeToString(authenticationBytes);
} else {
// RFC6120 6.4.2 "If the initiating entity needs to send a zero-length initial response,
@ -215,7 +218,8 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
/**
* Should return the initial response of the SASL mechanism. The returned byte array will be
* send base64 encoded to the server. SASL mechanism are free to return <code>null</code> here.
* send base64 encoded to the server. SASL mechanism are free to return <code>null</code> or an
* empty array here.
*
* @return the initial response or null
* @throws SmackException