Merge upstream
This commit is contained in:
commit
aeab6504a7
|
@ -963,52 +963,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
replyTimeout = timeout;
|
replyTimeout = timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the default value used to determine if new connection will reply to unknown IQ requests. The pre-configured
|
|
||||||
* default is 'true'.
|
|
||||||
*
|
|
||||||
* @param replyToUnkownIqDefault
|
|
||||||
* @see #setReplyToUnknownIq(boolean)
|
|
||||||
* @deprecated Use {@link SmackConfiguration#setUnknownIqRequestReplyMode(org.jivesoftware.smack.SmackConfiguration.UnknownIqRequestReplyMode)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
// TODO Remove in Smack 4.3
|
|
||||||
public static void setReplyToUnknownIqDefault(boolean replyToUnkownIqDefault) {
|
|
||||||
SmackConfiguration.UnknownIqRequestReplyMode mode;
|
|
||||||
if (replyToUnkownIqDefault) {
|
|
||||||
mode = SmackConfiguration.UnknownIqRequestReplyMode.replyServiceUnavailable;
|
|
||||||
} else {
|
|
||||||
mode = SmackConfiguration.UnknownIqRequestReplyMode.doNotReply;
|
|
||||||
}
|
|
||||||
SmackConfiguration.setUnknownIqRequestReplyMode(mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
private SmackConfiguration.UnknownIqRequestReplyMode unknownIqRequestReplyMode = SmackConfiguration.getUnknownIqRequestReplyMode();
|
private SmackConfiguration.UnknownIqRequestReplyMode unknownIqRequestReplyMode = SmackConfiguration.getUnknownIqRequestReplyMode();
|
||||||
|
|
||||||
public void setUnknownIqRequestReplyMode(UnknownIqRequestReplyMode unknownIqRequestReplyMode) {
|
public void setUnknownIqRequestReplyMode(UnknownIqRequestReplyMode unknownIqRequestReplyMode) {
|
||||||
this.unknownIqRequestReplyMode = Objects.requireNonNull(unknownIqRequestReplyMode, "Mode must not be null");
|
this.unknownIqRequestReplyMode = Objects.requireNonNull(unknownIqRequestReplyMode, "Mode must not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set if Smack will automatically send
|
|
||||||
* {@link org.jivesoftware.smack.packet.XMPPError.Condition#feature_not_implemented} when a request IQ without a
|
|
||||||
* registered {@link IQRequestHandler} is received.
|
|
||||||
*
|
|
||||||
* @param replyToUnknownIq
|
|
||||||
* @deprecated use {@link #setUnknownIqRequestReplyMode(UnknownIqRequestReplyMode)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
// TODO Remove in Smack 4.3
|
|
||||||
public void setReplyToUnknownIq(boolean replyToUnknownIq) {
|
|
||||||
SmackConfiguration.UnknownIqRequestReplyMode mode;
|
|
||||||
if (replyToUnknownIq) {
|
|
||||||
mode = SmackConfiguration.UnknownIqRequestReplyMode.replyServiceUnavailable;
|
|
||||||
} else {
|
|
||||||
mode = SmackConfiguration.UnknownIqRequestReplyMode.doNotReply;
|
|
||||||
}
|
|
||||||
unknownIqRequestReplyMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void parseAndProcessStanza(XmlPullParser parser) throws Exception {
|
protected void parseAndProcessStanza(XmlPullParser parser) throws Exception {
|
||||||
ParserUtils.assertAtStartTag(parser);
|
ParserUtils.assertAtStartTag(parser);
|
||||||
int parserDepth = parser.getDepth();
|
int parserDepth = parser.getDepth();
|
||||||
|
@ -1476,12 +1436,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
streamFeatures.put(key, feature);
|
streamFeatures.put(key, feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
||||||
StanzaListener callback) throws NotConnectedException, InterruptedException {
|
StanzaListener callback) throws NotConnectedException, InterruptedException {
|
||||||
sendStanzaWithResponseCallback(stanza, replyFilter, callback, null);
|
sendStanzaWithResponseCallback(stanza, replyFilter, callback, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
||||||
StanzaListener callback, ExceptionCallback exceptionCallback)
|
StanzaListener callback, ExceptionCallback exceptionCallback)
|
||||||
|
@ -1571,7 +1533,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("FutureReturnValueIgnored")
|
@SuppressWarnings({ "FutureReturnValueIgnored", "deprecation" })
|
||||||
@Override
|
@Override
|
||||||
public void sendStanzaWithResponseCallback(Stanza stanza, final StanzaFilter replyFilter,
|
public void sendStanzaWithResponseCallback(Stanza stanza, final StanzaFilter replyFilter,
|
||||||
final StanzaListener callback, final ExceptionCallback exceptionCallback,
|
final StanzaListener callback, final ExceptionCallback exceptionCallback,
|
||||||
|
@ -1624,18 +1586,21 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||||
sendStanza(stanza);
|
sendStanza(stanza);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback)
|
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback)
|
||||||
throws NotConnectedException, InterruptedException {
|
throws NotConnectedException, InterruptedException {
|
||||||
sendIqWithResponseCallback(iqRequest, callback, null);
|
sendIqWithResponseCallback(iqRequest, callback, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
|
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
|
||||||
ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException {
|
ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException {
|
||||||
sendIqWithResponseCallback(iqRequest, callback, exceptionCallback, getReplyTimeout());
|
sendIqWithResponseCallback(iqRequest, callback, exceptionCallback, getReplyTimeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback,
|
public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback,
|
||||||
final ExceptionCallback exceptionCallback, long timeout)
|
final ExceptionCallback exceptionCallback, long timeout)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2014 Florian Schmaus
|
* Copyright © 2014-2017 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,12 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smack;
|
package org.jivesoftware.smack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface has been deprecated. Please use org.jivesoftware.smack.util.ExceptionCallback instead.
|
||||||
|
*
|
||||||
|
* @deprecated use {@link org.jivesoftware.smack.util.ExceptionCallback} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public interface ExceptionCallback {
|
public interface ExceptionCallback {
|
||||||
|
|
||||||
public void processException(Exception exception);
|
public void processException(Exception exception);
|
||||||
|
|
|
@ -345,8 +345,7 @@ public final class SmackConfiguration {
|
||||||
replyServiceUnavailable,
|
replyServiceUnavailable,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Change to replyFeatureNotImplemented in Smack 4.3
|
private static UnknownIqRequestReplyMode unknownIqRequestReplyMode = UnknownIqRequestReplyMode.replyFeatureNotImplemented;
|
||||||
private static UnknownIqRequestReplyMode unknownIqRequestReplyMode = UnknownIqRequestReplyMode.replyServiceUnavailable;
|
|
||||||
|
|
||||||
public static UnknownIqRequestReplyMode getUnknownIqRequestReplyMode() {
|
public static UnknownIqRequestReplyMode getUnknownIqRequestReplyMode() {
|
||||||
return unknownIqRequestReplyMode;
|
return unknownIqRequestReplyMode;
|
||||||
|
|
|
@ -106,15 +106,10 @@ public abstract class SmackFuture<V, E extends Exception> implements Future<V>,
|
||||||
return getOrThrowExecutionException();
|
return getOrThrowExecutionException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized final V getOrThrow() throws E {
|
public synchronized final V getOrThrow() throws E, InterruptedException {
|
||||||
while (result == null && exception == null && !cancelled) {
|
while (result == null && exception == null && !cancelled) {
|
||||||
try {
|
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exception != null) {
|
if (exception != null) {
|
||||||
throw exception;
|
throw exception;
|
||||||
|
|
|
@ -428,7 +428,6 @@ public interface XMPPConnection {
|
||||||
*/
|
*/
|
||||||
public boolean hasFeature(String element, String namespace);
|
public boolean hasFeature(String element, String namespace);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send an IQ request asynchronously. The connection's default reply timeout will be used.
|
* Send an IQ request asynchronously. The connection's default reply timeout will be used.
|
||||||
*
|
*
|
||||||
|
@ -447,7 +446,8 @@ public interface XMPPConnection {
|
||||||
public SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request, long timeout);
|
public SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request, long timeout);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a stanza asynchronously, waiting for exactly one response stanza using the given reply filter. The connection's default reply timeout will be used.
|
* Send a stanza asynchronously, waiting for exactly one response stanza using the given reply filter. The
|
||||||
|
* connection's default reply timeout will be used.
|
||||||
*
|
*
|
||||||
* @param stanza the stanza to send.
|
* @param stanza the stanza to send.
|
||||||
* @param replyFilter the filter used for the response stanza.
|
* @param replyFilter the filter used for the response stanza.
|
||||||
|
@ -478,8 +478,10 @@ public interface XMPPConnection {
|
||||||
* @param callback the callback invoked if there is a response (required)
|
* @param callback the callback invoked if there is a response (required)
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
|
* @deprecated use {@link #sendAsync(Stanza, StanzaFilter)} instead.
|
||||||
*/
|
*/
|
||||||
// TODO: Mark deprecated in favor of the new SmackFuture based async API.
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.4.
|
||||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
||||||
StanzaListener callback) throws NotConnectedException, InterruptedException;
|
StanzaListener callback) throws NotConnectedException, InterruptedException;
|
||||||
|
|
||||||
|
@ -497,10 +499,12 @@ public interface XMPPConnection {
|
||||||
* @param exceptionCallback the callback invoked if there is an exception (optional)
|
* @param exceptionCallback the callback invoked if there is an exception (optional)
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
|
* @deprecated use {@link #sendAsync(Stanza, StanzaFilter)} instead.
|
||||||
*/
|
*/
|
||||||
// TODO: Mark deprecated in favor of the new SmackFuture based async API. And do not forget to mark smack.ExceptionCallback deprecated too.
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.4.
|
||||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, StanzaListener callback,
|
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, StanzaListener callback,
|
||||||
ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
|
@SuppressWarnings("deprecation") ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a stanza and wait asynchronously for a response by using <code>replyFilter</code>.
|
* Send a stanza and wait asynchronously for a response by using <code>replyFilter</code>.
|
||||||
|
@ -517,10 +521,12 @@ public interface XMPPConnection {
|
||||||
* @param timeout the timeout in milliseconds to wait for a response
|
* @param timeout the timeout in milliseconds to wait for a response
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
|
* @deprecated use {@link #sendAsync(Stanza, StanzaFilter, long)} instead.
|
||||||
*/
|
*/
|
||||||
// TODO: Mark deprecated in favor of the new SmackFuture based async API.
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.4.
|
||||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
||||||
final StanzaListener callback, final ExceptionCallback exceptionCallback,
|
final StanzaListener callback, @SuppressWarnings("deprecation") final ExceptionCallback exceptionCallback,
|
||||||
long timeout) throws NotConnectedException, InterruptedException;
|
long timeout) throws NotConnectedException, InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -532,8 +538,10 @@ public interface XMPPConnection {
|
||||||
* @param callback the callback invoked if there is result response (required)
|
* @param callback the callback invoked if there is result response (required)
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
|
* @deprecated use {@link #sendIqRequestAsync(IQ)} instead.
|
||||||
*/
|
*/
|
||||||
// TODO: Mark deprecated in favor of the new SmackFuture based async API.
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.4.
|
||||||
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback) throws NotConnectedException, InterruptedException;
|
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback) throws NotConnectedException, InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -549,10 +557,12 @@ public interface XMPPConnection {
|
||||||
* @param exceptionCallback the callback invoked if there is an Exception optional
|
* @param exceptionCallback the callback invoked if there is an Exception optional
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
|
* @deprecated use {@link #sendIqRequestAsync(IQ)} instead.
|
||||||
*/
|
*/
|
||||||
// TODO: Mark deprecated in favor of the new SmackFuture based async API.
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.4.
|
||||||
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
|
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
|
||||||
ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
|
@SuppressWarnings("deprecation") ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a IQ stanza and invoke <code>callback</code> if there is a result of
|
* Send a IQ stanza and invoke <code>callback</code> if there is a result of
|
||||||
|
@ -568,10 +578,12 @@ public interface XMPPConnection {
|
||||||
* @param timeout the timeout in milliseconds to wait for a response
|
* @param timeout the timeout in milliseconds to wait for a response
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
|
* @deprecated use {@link #sendIqRequestAsync(IQ, long)} instead.
|
||||||
*/
|
*/
|
||||||
// TODO: Mark deprecated in favor of the new SmackFuture based async API.
|
@Deprecated
|
||||||
|
// TODO: Remove in Smack 4.4.
|
||||||
public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback,
|
public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback,
|
||||||
final ExceptionCallback exceptionCallback, long timeout)
|
@SuppressWarnings("deprecation") final ExceptionCallback exceptionCallback, long timeout)
|
||||||
throws NotConnectedException, InterruptedException;
|
throws NotConnectedException, InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2015 Florian Schmaus
|
* Copyright 2003-2007 Jive Software, 2015-2017 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,7 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smack.packet;
|
package org.jivesoftware.smack.packet;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -102,50 +101,6 @@ public class XMPPError extends AbstractError {
|
||||||
private final Type type;
|
private final Type type;
|
||||||
private final Stanza stanza;
|
private final Stanza stanza;
|
||||||
|
|
||||||
// TODO: Deprecated constructors
|
|
||||||
// deprecate in 4.3
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new XMPPError.
|
|
||||||
*
|
|
||||||
* @param condition
|
|
||||||
* @deprecated use {@link Builder} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public XMPPError(Condition condition) {
|
|
||||||
this(condition, null, null, null, null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new XMPPError.
|
|
||||||
*
|
|
||||||
* @param condition
|
|
||||||
* @param applicationSpecificCondition
|
|
||||||
* @deprecated use {@link Builder} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public XMPPError(Condition condition, ExtensionElement applicationSpecificCondition) {
|
|
||||||
this(condition, null, null, null, null, Arrays.asList(applicationSpecificCondition), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new error with the specified type, condition and message.
|
|
||||||
* This constructor is used when the condition is not recognized automatically by XMPPError
|
|
||||||
* i.e. there is not a defined instance of ErrorCondition or it does not apply the default
|
|
||||||
* specification.
|
|
||||||
*
|
|
||||||
* @param type the error type.
|
|
||||||
* @param condition the error condition.
|
|
||||||
* @param descriptiveTexts
|
|
||||||
* @param extensions list of stanza(/packet) extensions
|
|
||||||
* @deprecated use {@link Builder} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public XMPPError(Condition condition, String conditionText, String errorGenerator, Type type, Map<String, String> descriptiveTexts,
|
|
||||||
List<ExtensionElement> extensions) {
|
|
||||||
this(condition, conditionText, errorGenerator, type, descriptiveTexts, extensions, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new error with the specified type, condition and message.
|
* Creates a new error with the specified type, condition and message.
|
||||||
* This constructor is used when the condition is not recognized automatically by XMPPError
|
* This constructor is used when the condition is not recognized automatically by XMPPError
|
||||||
|
|
|
@ -303,7 +303,7 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
|
||||||
protected abstract SASLMechanism newInstance();
|
protected abstract SASLMechanism newInstance();
|
||||||
|
|
||||||
protected static byte[] toBytes(String string) {
|
protected static byte[] toBytes(String string) {
|
||||||
return StringUtils.toBytes(string);
|
return StringUtils.toUtf8Bytes(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class MD5 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] bytes(String string) {
|
public static byte[] bytes(String string) {
|
||||||
return bytes(StringUtils.toBytes(string));
|
return bytes(StringUtils.toUtf8Bytes(string));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String hex(byte[] bytes) {
|
public static String hex(byte[] bytes) {
|
||||||
|
@ -50,7 +50,7 @@ public class MD5 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String hex(String string) {
|
public static String hex(String string) {
|
||||||
return hex(StringUtils.toBytes(string));
|
return hex(StringUtils.toUtf8Bytes(string));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class SHA1 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] bytes(String string) {
|
public static byte[] bytes(String string) {
|
||||||
return bytes(StringUtils.toBytes(string));
|
return bytes(StringUtils.toUtf8Bytes(string));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String hex(byte[] bytes) {
|
public static String hex(byte[] bytes) {
|
||||||
|
@ -51,7 +51,7 @@ public class SHA1 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String hex(String string) {
|
public static String hex(String string) {
|
||||||
return hex(StringUtils.toBytes(string));
|
return hex(StringUtils.toUtf8Bytes(string));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,19 +41,6 @@ public class StringUtils {
|
||||||
|
|
||||||
public static final char[] HEX_CHARS = "0123456789abcdef".toCharArray();
|
public static final char[] HEX_CHARS = "0123456789abcdef".toCharArray();
|
||||||
|
|
||||||
/**
|
|
||||||
* Escape <code>input</code> for XML.
|
|
||||||
*
|
|
||||||
* @param input the input to escape.
|
|
||||||
* @return the XML escaped variant of <code>input</code>.
|
|
||||||
* @deprecated use {@link #escapeForXml(CharSequence)} instead.
|
|
||||||
*/
|
|
||||||
// Remove in 4.3.
|
|
||||||
@Deprecated
|
|
||||||
public static CharSequence escapeForXML(CharSequence input) {
|
|
||||||
return escapeForXml(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Escape <code>input</code> for XML.
|
* Escape <code>input</code> for XML.
|
||||||
*
|
*
|
||||||
|
@ -257,7 +244,7 @@ public class StringUtils {
|
||||||
return new String(hexChars);
|
return new String(hexChars);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] toBytes(String string) {
|
public static byte[] toUtf8Bytes(String string) {
|
||||||
try {
|
try {
|
||||||
return string.getBytes(StringUtils.UTF8);
|
return string.getBytes(StringUtils.UTF8);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright © 2016 Florian Schmaus
|
* Copyright © 2016-2017 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.packet.Presence.Mode;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.jxmpp.jid.JidTestUtil;
|
import org.jxmpp.jid.JidTestUtil;
|
||||||
import org.jxmpp.stringprep.XmppStringprepException;
|
|
||||||
|
|
||||||
public class ToStringTest {
|
public class ToStringTest {
|
||||||
|
|
||||||
|
@ -43,7 +42,7 @@ public class ToStringTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void iqTest() throws XmppStringprepException {
|
public void iqTest() {
|
||||||
Bind bindIq = Bind.newResult(JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE);
|
Bind bindIq = Bind.newResult(JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE);
|
||||||
bindIq.setStanzaId("bind-id");
|
bindIq.setStanzaId("bind-id");
|
||||||
String string = bindIq.toString();
|
String string = bindIq.toString();
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.jxmpp.stringprep.XmppStringprepException;
|
||||||
public class DigestMd5SaslTest extends AbstractSaslTest {
|
public class DigestMd5SaslTest extends AbstractSaslTest {
|
||||||
|
|
||||||
protected static final String challenge = "realm=\"xmpp.org\",nonce=\"jgGgnz+cQcmyVaAs2n88kQ==\",qop=\"auth\",charset=utf-8,algorithm=md5-sess";
|
protected static final String challenge = "realm=\"xmpp.org\",nonce=\"jgGgnz+cQcmyVaAs2n88kQ==\",qop=\"auth\",charset=utf-8,algorithm=md5-sess";
|
||||||
protected static final byte[] challengeBytes = StringUtils.toBytes(challenge);
|
protected static final byte[] challengeBytes = StringUtils.toUtf8Bytes(challenge);
|
||||||
|
|
||||||
public DigestMd5SaslTest(SASLMechanism saslMechanism) {
|
public DigestMd5SaslTest(SASLMechanism saslMechanism) {
|
||||||
super(saslMechanism);
|
super(saslMechanism);
|
||||||
|
|
|
@ -23,11 +23,11 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
import org.jivesoftware.smack.AbstractConnectionListener;
|
import org.jivesoftware.smack.AbstractConnectionListener;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.ExceptionCallback;
|
|
||||||
import org.jivesoftware.smack.Manager;
|
import org.jivesoftware.smack.Manager;
|
||||||
import org.jivesoftware.smack.SmackException;
|
import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||||
|
import org.jivesoftware.smack.SmackFuture;
|
||||||
import org.jivesoftware.smack.StanzaListener;
|
import org.jivesoftware.smack.StanzaListener;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
||||||
|
@ -42,6 +42,8 @@ import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||||
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.Stanza;
|
import org.jivesoftware.smack.packet.Stanza;
|
||||||
|
import org.jivesoftware.smack.util.ExceptionCallback;
|
||||||
|
import org.jivesoftware.smack.util.SuccessCallback;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.carbons.packet.Carbon;
|
import org.jivesoftware.smackx.carbons.packet.Carbon;
|
||||||
import org.jivesoftware.smackx.carbons.packet.CarbonExtension;
|
import org.jivesoftware.smackx.carbons.packet.CarbonExtension;
|
||||||
|
@ -245,10 +247,9 @@ public final class CarbonManager extends Manager {
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param exceptionCallback the optional exception callback.
|
* @param exceptionCallback the optional exception callback.
|
||||||
* @throws InterruptedException if the thread got interrupted while this action is performed.
|
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
public void enableCarbonsAsync(ExceptionCallback exceptionCallback) throws InterruptedException {
|
public void enableCarbonsAsync(ExceptionCallback<Exception> exceptionCallback) {
|
||||||
sendUseCarbons(true, exceptionCallback);
|
sendUseCarbons(true, exceptionCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,29 +263,24 @@ public final class CarbonManager extends Manager {
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param exceptionCallback the optional exception callback.
|
* @param exceptionCallback the optional exception callback.
|
||||||
* @throws InterruptedException if the thread got interrupted while this action is performed.
|
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
public void disableCarbonsAsync(ExceptionCallback exceptionCallback) throws InterruptedException {
|
public void disableCarbonsAsync(ExceptionCallback<Exception> exceptionCallback) {
|
||||||
sendUseCarbons(false, exceptionCallback);
|
sendUseCarbons(false, exceptionCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendUseCarbons(final boolean use, ExceptionCallback exceptionCallback) throws InterruptedException {
|
private void sendUseCarbons(final boolean use, ExceptionCallback<Exception> exceptionCallback) {
|
||||||
IQ setIQ = carbonsEnabledIQ(use);
|
IQ setIQ = carbonsEnabledIQ(use);
|
||||||
|
|
||||||
try {
|
SmackFuture<IQ, Exception> future = connection().sendIqRequestAsync(setIQ);
|
||||||
connection().sendIqWithResponseCallback(setIQ, new StanzaListener() {
|
|
||||||
|
future.onSuccess(new SuccessCallback<IQ>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processStanza(Stanza packet) {
|
public void onSuccess(IQ result) {
|
||||||
enabled_state = use;
|
enabled_state = use;
|
||||||
}
|
}
|
||||||
}, exceptionCallback);
|
}).onError(exceptionCallback);
|
||||||
}
|
|
||||||
catch (NotConnectedException e) {
|
|
||||||
if (exceptionCallback != null) {
|
|
||||||
exceptionCallback.processException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.hashes;
|
package org.jivesoftware.smackx.hashes;
|
||||||
|
|
||||||
|
import static org.jivesoftware.smack.util.StringUtils.encodeHex;
|
||||||
|
import static org.jivesoftware.smack.util.StringUtils.toUtf8Bytes;
|
||||||
import static org.jivesoftware.smackx.hashes.HashManager.ALGORITHM.BLAKE2B160;
|
import static org.jivesoftware.smackx.hashes.HashManager.ALGORITHM.BLAKE2B160;
|
||||||
import static org.jivesoftware.smackx.hashes.HashManager.ALGORITHM.BLAKE2B256;
|
import static org.jivesoftware.smackx.hashes.HashManager.ALGORITHM.BLAKE2B256;
|
||||||
import static org.jivesoftware.smackx.hashes.HashManager.ALGORITHM.BLAKE2B384;
|
import static org.jivesoftware.smackx.hashes.HashManager.ALGORITHM.BLAKE2B384;
|
||||||
|
@ -31,8 +33,6 @@ import static org.jivesoftware.smackx.hashes.HashManager.ALGORITHM.SHA_256;
|
||||||
import static org.jivesoftware.smackx.hashes.HashManager.ALGORITHM.SHA_384;
|
import static org.jivesoftware.smackx.hashes.HashManager.ALGORITHM.SHA_384;
|
||||||
import static org.jivesoftware.smackx.hashes.HashManager.ALGORITHM.SHA_512;
|
import static org.jivesoftware.smackx.hashes.HashManager.ALGORITHM.SHA_512;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.NoSuchProviderException;
|
import java.security.NoSuchProviderException;
|
||||||
|
@ -44,7 +44,6 @@ import java.util.WeakHashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Manager;
|
import org.jivesoftware.smack.Manager;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
|
||||||
|
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jivesoftware.smackx.hashes.element.HashElement;
|
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||||
|
@ -52,7 +51,10 @@ import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manager that can be used to determine support for hash functions.
|
* Manager that can be used to determine support for hash functions. By default the Manager announces support for
|
||||||
|
* XEP-0300, as well as for the recommended set of hash algorithms. Those contain SHA256, SHA384, SHA512, SHA3-256,
|
||||||
|
* SHA3-384, SHA3-512, BLAKE2B256, BLAKE2B384 and BLAKE2B512. Those algorithms got recommended here:
|
||||||
|
* <a href="https://xmpp.org/extensions/xep-0300.html#recommendations">https://xmpp.org/extensions/xep-0300.html#recommendations</a>.
|
||||||
*/
|
*/
|
||||||
public final class HashManager extends Manager {
|
public final class HashManager extends Manager {
|
||||||
|
|
||||||
|
@ -88,9 +90,7 @@ public final class HashManager extends Manager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor of the HashManager.
|
* Constructor of the HashManager.
|
||||||
* By default the Manager announces support for XEP-0300, as well as for the RECOMMENDED set of hash algorithms.
|
*
|
||||||
* Those contain SHA256, SHA384, SHA512, SHA3-256, SHA3-384, SHA3-512, BLAKE2B256, BLAKE2B384 and BLAKE2B512.
|
|
||||||
* Those algorithms got recommended here: https://xmpp.org/extensions/xep-0300.html#recommendations
|
|
||||||
* @param connection connection
|
* @param connection connection
|
||||||
*/
|
*/
|
||||||
private HashManager(XMPPConnection connection) {
|
private HashManager(XMPPConnection connection) {
|
||||||
|
@ -122,9 +122,9 @@ public final class HashManager extends Manager {
|
||||||
/**
|
/**
|
||||||
* Get an instance of the HashManager for the given connection.
|
* Get an instance of the HashManager for the given connection.
|
||||||
* @param connection
|
* @param connection
|
||||||
* @return
|
* @return the manager for the given connection.
|
||||||
*/
|
*/
|
||||||
public HashManager getInstanceFor(XMPPConnection connection) {
|
public static synchronized HashManager getInstanceFor(XMPPConnection connection) {
|
||||||
HashManager hashManager = INSTANCES.get(connection);
|
HashManager hashManager = INSTANCES.get(connection);
|
||||||
if (hashManager == null) {
|
if (hashManager == null) {
|
||||||
hashManager = new HashManager(connection);
|
hashManager = new HashManager(connection);
|
||||||
|
@ -142,26 +142,36 @@ public final class HashManager extends Manager {
|
||||||
return PREFIX_NS_ALGO + algorithm.toString();
|
return PREFIX_NS_ALGO + algorithm.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ALGORITHM { // RECOMMENDATION:
|
enum AlgorithmRecommendation {
|
||||||
MD5 ("md5"), // MUST NOT use this
|
unknown,
|
||||||
SHA_1 ("sha-1"), // SHOULD NOT use this
|
must_not,
|
||||||
SHA_224 ("sha-224"),
|
should_not,
|
||||||
SHA_256 ("sha-256"), // MUST use this
|
should,
|
||||||
SHA_384 ("sha-384"),
|
must,
|
||||||
SHA_512 ("sha-512"), // SHOULD use this
|
}
|
||||||
SHA3_224 ("sha3-224"),
|
|
||||||
SHA3_256 ("sha3-256"), // MUST use this
|
public enum ALGORITHM {
|
||||||
SHA3_384 ("sha3-384"),
|
MD5 ("md5", AlgorithmRecommendation.must_not),
|
||||||
SHA3_512 ("sha3-512"), // SHOULD use this
|
SHA_1 ("sha-1", AlgorithmRecommendation.should_not),
|
||||||
BLAKE2B160("id-blake2b160"),
|
SHA_224 ("sha-224", AlgorithmRecommendation.unknown),
|
||||||
BLAKE2B256("id-blake2b256"), // MUST use this
|
SHA_256 ("sha-256", AlgorithmRecommendation.must),
|
||||||
BLAKE2B384("id-blake2b384"),
|
SHA_384 ("sha-384", AlgorithmRecommendation.unknown),
|
||||||
BLAKE2B512("id-blake2b512"); // SHOULD use this
|
SHA_512 ("sha-512", AlgorithmRecommendation.should),
|
||||||
|
SHA3_224 ("sha3-224", AlgorithmRecommendation.unknown),
|
||||||
|
SHA3_256 ("sha3-256", AlgorithmRecommendation.must),
|
||||||
|
SHA3_384 ("sha3-384", AlgorithmRecommendation.unknown),
|
||||||
|
SHA3_512 ("sha3-512", AlgorithmRecommendation.should),
|
||||||
|
BLAKE2B160("id-blake2b160", AlgorithmRecommendation.unknown),
|
||||||
|
BLAKE2B256("id-blake2b256", AlgorithmRecommendation.must),
|
||||||
|
BLAKE2B384("id-blake2b384", AlgorithmRecommendation.unknown),
|
||||||
|
BLAKE2B512("id-blake2b512", AlgorithmRecommendation.should);
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
private final AlgorithmRecommendation recommendation;
|
||||||
|
|
||||||
ALGORITHM(String name) {
|
ALGORITHM(String name, AlgorithmRecommendation recommendation) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.recommendation = recommendation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,10 +183,16 @@ public final class HashManager extends Manager {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AlgorithmRecommendation getRecommendation() {
|
||||||
|
return recommendation;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compensational method for static 'valueOf' function.
|
* Compensational method for static 'valueOf' function.
|
||||||
|
*
|
||||||
* @param s
|
* @param s
|
||||||
* @return
|
* @return the algorithm for the given string.
|
||||||
|
* @throws IllegalArgumentException if no algorithm for the given string is known.
|
||||||
*/
|
*/
|
||||||
public static ALGORITHM valueOfName(String s) {
|
public static ALGORITHM valueOfName(String s) {
|
||||||
for (ALGORITHM a : ALGORITHM.values()) {
|
for (ALGORITHM a : ALGORITHM.values()) {
|
||||||
|
@ -190,16 +206,17 @@ public final class HashManager extends Manager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the hash sum of data using algorithm.
|
* Calculate the hash sum of data using algorithm.
|
||||||
* @param algorithm
|
*
|
||||||
* @param data
|
* @param algorithm the algorithm to use.
|
||||||
* @return
|
* @param data the data to calculate the hash for.
|
||||||
|
* @return the hash value produced by the given algorithm for the given data.
|
||||||
*/
|
*/
|
||||||
public static byte[] hash(ALGORITHM algorithm, byte[] data) {
|
public static byte[] hash(ALGORITHM algorithm, byte[] data) {
|
||||||
return getMessageDigest(algorithm).digest(data);
|
return getMessageDigest(algorithm).digest(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] hash(ALGORITHM algorithm, String data) {
|
public static byte[] hash(ALGORITHM algorithm, String data) {
|
||||||
return hash(algorithm, utf8(data));
|
return hash(algorithm, toUtf8Bytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MessageDigest getMessageDigest(ALGORITHM algorithm) {
|
public static MessageDigest getMessageDigest(ALGORITHM algorithm) {
|
||||||
|
@ -249,7 +266,7 @@ public final class HashManager extends Manager {
|
||||||
md = MessageDigest.getInstance("BLAKE2b-512", PROVIDER);
|
md = MessageDigest.getInstance("BLAKE2b-512", PROVIDER);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new AssertionError("Invalid enum value.");
|
throw new AssertionError("Invalid enum value: " + algorithm);
|
||||||
}
|
}
|
||||||
return md;
|
return md;
|
||||||
} catch (NoSuchAlgorithmException | NoSuchProviderException e) {
|
} catch (NoSuchAlgorithmException | NoSuchProviderException e) {
|
||||||
|
@ -262,15 +279,15 @@ public final class HashManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] md5(String data) {
|
public static byte[] md5(String data) {
|
||||||
return md5(utf8(data));
|
return md5(toUtf8Bytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String md5HexString(byte[] data) {
|
public static String md5HexString(byte[] data) {
|
||||||
return hex(md5(data));
|
return encodeHex(md5(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String md5HexString(String data) {
|
public static String md5HexString(String data) {
|
||||||
return hex(md5(data));
|
return encodeHex(md5(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha_1(byte[] data) {
|
public static byte[] sha_1(byte[] data) {
|
||||||
|
@ -278,15 +295,15 @@ public final class HashManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha_1(String data) {
|
public static byte[] sha_1(String data) {
|
||||||
return sha_1(utf8(data));
|
return sha_1(toUtf8Bytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha_1HexString(byte[] data) {
|
public static String sha_1HexString(byte[] data) {
|
||||||
return hex(sha_1(data));
|
return encodeHex(sha_1(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha_1HexString(String data) {
|
public static String sha_1HexString(String data) {
|
||||||
return hex(sha_1(data));
|
return encodeHex(sha_1(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha_224(byte[] data) {
|
public static byte[] sha_224(byte[] data) {
|
||||||
|
@ -294,15 +311,15 @@ public final class HashManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha_224(String data) {
|
public static byte[] sha_224(String data) {
|
||||||
return sha_224(utf8(data));
|
return sha_224(toUtf8Bytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha_224HexString(byte[] data) {
|
public static String sha_224HexString(byte[] data) {
|
||||||
return hex(sha_224(data));
|
return encodeHex(sha_224(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha_224HexString(String data) {
|
public static String sha_224HexString(String data) {
|
||||||
return hex(sha_224(data));
|
return encodeHex(sha_224(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha_256(byte[] data) {
|
public static byte[] sha_256(byte[] data) {
|
||||||
|
@ -310,15 +327,15 @@ public final class HashManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha_256(String data) {
|
public static byte[] sha_256(String data) {
|
||||||
return sha_256(utf8(data));
|
return sha_256(toUtf8Bytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha_256HexString(byte[] data) {
|
public static String sha_256HexString(byte[] data) {
|
||||||
return hex(sha_256(data));
|
return encodeHex(sha_256(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha_256HexString(String data) {
|
public static String sha_256HexString(String data) {
|
||||||
return hex(sha_256(data));
|
return encodeHex(sha_256(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha_384(byte[] data) {
|
public static byte[] sha_384(byte[] data) {
|
||||||
|
@ -326,15 +343,15 @@ public final class HashManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha_384(String data) {
|
public static byte[] sha_384(String data) {
|
||||||
return sha_384(utf8(data));
|
return sha_384(toUtf8Bytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha_384HexString(byte[] data) {
|
public static String sha_384HexString(byte[] data) {
|
||||||
return hex(sha_384(data));
|
return encodeHex(sha_384(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha_384HexString(String data) {
|
public static String sha_384HexString(String data) {
|
||||||
return hex(sha_384(data));
|
return encodeHex(sha_384(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha_512(byte[] data) {
|
public static byte[] sha_512(byte[] data) {
|
||||||
|
@ -342,15 +359,15 @@ public final class HashManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha_512(String data) {
|
public static byte[] sha_512(String data) {
|
||||||
return sha_512(utf8(data));
|
return sha_512(toUtf8Bytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha_512HexString(byte[] data) {
|
public static String sha_512HexString(byte[] data) {
|
||||||
return hex(sha_512(data));
|
return encodeHex(sha_512(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha_512HexString(String data) {
|
public static String sha_512HexString(String data) {
|
||||||
return hex(sha_512(data));
|
return encodeHex(sha_512(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha3_224(byte[] data) {
|
public static byte[] sha3_224(byte[] data) {
|
||||||
|
@ -358,15 +375,15 @@ public final class HashManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha3_224(String data) {
|
public static byte[] sha3_224(String data) {
|
||||||
return sha3_224(utf8(data));
|
return sha3_224(toUtf8Bytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha3_224HexString(byte[] data) {
|
public static String sha3_224HexString(byte[] data) {
|
||||||
return hex(sha3_224(data));
|
return encodeHex(sha3_224(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha3_224HexString(String data) {
|
public static String sha3_224HexString(String data) {
|
||||||
return hex(sha3_224(data));
|
return encodeHex(sha3_224(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha3_256(byte[] data) {
|
public static byte[] sha3_256(byte[] data) {
|
||||||
|
@ -374,15 +391,15 @@ public final class HashManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha3_256(String data) {
|
public static byte[] sha3_256(String data) {
|
||||||
return sha3_256(utf8(data));
|
return sha3_256(toUtf8Bytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha3_256HexString(byte[] data) {
|
public static String sha3_256HexString(byte[] data) {
|
||||||
return hex(sha3_256(data));
|
return encodeHex(sha3_256(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha3_256HexString(String data) {
|
public static String sha3_256HexString(String data) {
|
||||||
return hex(sha3_256(data));
|
return encodeHex(sha3_256(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha3_384(byte[] data) {
|
public static byte[] sha3_384(byte[] data) {
|
||||||
|
@ -390,15 +407,15 @@ public final class HashManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha3_384(String data) {
|
public static byte[] sha3_384(String data) {
|
||||||
return sha3_384(utf8(data));
|
return sha3_384(toUtf8Bytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha3_384HexString(byte[] data) {
|
public static String sha3_384HexString(byte[] data) {
|
||||||
return hex(sha3_384(data));
|
return encodeHex(sha3_384(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha3_384HexString(String data) {
|
public static String sha3_384HexString(String data) {
|
||||||
return hex(sha3_384(data));
|
return encodeHex(sha3_384(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha3_512(byte[] data) {
|
public static byte[] sha3_512(byte[] data) {
|
||||||
|
@ -406,15 +423,15 @@ public final class HashManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] sha3_512(String data) {
|
public static byte[] sha3_512(String data) {
|
||||||
return sha3_512(utf8(data));
|
return sha3_512(toUtf8Bytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha3_512HexString(byte[] data) {
|
public static String sha3_512HexString(byte[] data) {
|
||||||
return hex(sha3_512(data));
|
return encodeHex(sha3_512(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sha3_512HexString(String data) {
|
public static String sha3_512HexString(String data) {
|
||||||
return hex(sha3_512(data));
|
return encodeHex(sha3_512(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] blake2b160(byte[] data) {
|
public static byte[] blake2b160(byte[] data) {
|
||||||
|
@ -422,15 +439,15 @@ public final class HashManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] blake2b160(String data) {
|
public static byte[] blake2b160(String data) {
|
||||||
return blake2b160(utf8(data));
|
return blake2b160(toUtf8Bytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String blake2b160HexString(byte[] data) {
|
public static String blake2b160HexString(byte[] data) {
|
||||||
return hex(blake2b160(data));
|
return encodeHex(blake2b160(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String blake2b160HexString(String data) {
|
public static String blake2b160HexString(String data) {
|
||||||
return hex(blake2b160(data));
|
return encodeHex(blake2b160(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] blake2b256(byte[] data) {
|
public static byte[] blake2b256(byte[] data) {
|
||||||
|
@ -438,15 +455,15 @@ public final class HashManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] blake2b256(String data) {
|
public static byte[] blake2b256(String data) {
|
||||||
return blake2b256(utf8(data));
|
return blake2b256(toUtf8Bytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String blake2b256HexString(byte[] data) {
|
public static String blake2b256HexString(byte[] data) {
|
||||||
return hex(blake2b256(data));
|
return encodeHex(blake2b256(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String blake2b256HexString(String data) {
|
public static String blake2b256HexString(String data) {
|
||||||
return hex(blake2b256(data));
|
return encodeHex(blake2b256(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] blake2b384(byte[] data) {
|
public static byte[] blake2b384(byte[] data) {
|
||||||
|
@ -454,15 +471,15 @@ public final class HashManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] blake2b384(String data) {
|
public static byte[] blake2b384(String data) {
|
||||||
return blake2b384(utf8(data));
|
return blake2b384(toUtf8Bytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String blake2b384HexString(byte[] data) {
|
public static String blake2b384HexString(byte[] data) {
|
||||||
return hex(blake2b384(data));
|
return encodeHex(blake2b384(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String blake2b384HexString(String data) {
|
public static String blake2b384HexString(String data) {
|
||||||
return hex(blake2b384(data));
|
return encodeHex(blake2b384(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] blake2b512(byte[] data) {
|
public static byte[] blake2b512(byte[] data) {
|
||||||
|
@ -470,32 +487,15 @@ public final class HashManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] blake2b512(String data) {
|
public static byte[] blake2b512(String data) {
|
||||||
return blake2b512(utf8(data));
|
return blake2b512(toUtf8Bytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String blake2b512HexString(byte[] data) {
|
public static String blake2b512HexString(byte[] data) {
|
||||||
return hex(blake2b512(data));
|
return encodeHex(blake2b512(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String blake2b512HexString(String data) {
|
public static String blake2b512HexString(String data) {
|
||||||
return hex(blake2b512(data));
|
return encodeHex(blake2b512(data));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Encode a byte array in HEX.
|
|
||||||
* @param hash
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String hex(byte[] hash) {
|
|
||||||
return new BigInteger(1, hash).toString(16);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] utf8(String data) {
|
|
||||||
try {
|
|
||||||
return data.getBytes(StringUtils.UTF8);
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
throw new AssertionError(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,8 @@ public class HashElement implements ExtensionElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the hash algorithm used in this HashElement.
|
* Return the hash algorithm used in this HashElement.
|
||||||
* @return algorithm
|
*
|
||||||
|
* @return algorithm the algorithm.
|
||||||
*/
|
*/
|
||||||
public HashManager.ALGORITHM getAlgorithm() {
|
public HashManager.ALGORITHM getAlgorithm() {
|
||||||
return algorithm;
|
return algorithm;
|
||||||
|
@ -70,7 +71,8 @@ public class HashElement implements ExtensionElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the checksum as a byte array.
|
* Return the checksum as a byte array.
|
||||||
* @return
|
*
|
||||||
|
* @return the hash.
|
||||||
*/
|
*/
|
||||||
public byte[] getHash() {
|
public byte[] getHash() {
|
||||||
return hash;
|
return hash;
|
||||||
|
@ -78,7 +80,8 @@ public class HashElement implements ExtensionElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the checksum as a base16 (hex) string.
|
* Return the checksum as a base16 (hex) string.
|
||||||
* @return
|
*
|
||||||
|
* @return the hash.
|
||||||
*/
|
*/
|
||||||
public String getHashB64() {
|
public String getHashB64() {
|
||||||
return hashB64;
|
return hashB64;
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class UploadService {
|
||||||
enum Version {
|
enum Version {
|
||||||
v0_2,
|
v0_2,
|
||||||
v0_3,
|
v0_3,
|
||||||
};
|
}
|
||||||
|
|
||||||
private final DomainBareJid address;
|
private final DomainBareJid address;
|
||||||
private final Version version;
|
private final Version version;
|
||||||
|
|
|
@ -607,23 +607,6 @@ public final class MamManager extends Manager {
|
||||||
return serviceDiscoveryManager.supportsFeature(myBareJid, MamElements.NAMESPACE);
|
return serviceDiscoveryManager.supportsFeature(myBareJid, MamElements.NAMESPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if Message Archive Management is supported by the server.
|
|
||||||
*
|
|
||||||
* @return true if Message Archive Management is supported by the server.
|
|
||||||
* @throws NotConnectedException
|
|
||||||
* @throws XMPPErrorException
|
|
||||||
* @throws NoResponseException
|
|
||||||
* @throws InterruptedException
|
|
||||||
* @depreacted use {@link #isSupported()} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
// TODO Remove in Smack 4.3
|
|
||||||
public boolean isSupportedByServer()
|
|
||||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
|
||||||
return ServiceDiscoveryManager.getInstanceFor(connection()).serverSupportsFeature(MamElements.NAMESPACE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static DataForm getNewMamForm() {
|
private static DataForm getNewMamForm() {
|
||||||
FormField field = new FormField(FormField.FORM_TYPE);
|
FormField field = new FormField(FormField.FORM_TYPE);
|
||||||
field.setType(FormField.Type.hidden);
|
field.setType(FormField.Type.hidden);
|
||||||
|
|
|
@ -146,6 +146,7 @@ public class MultiUserChatLight {
|
||||||
* for the newly created chat.
|
* for the newly created chat.
|
||||||
* @return new Chat for sending private messages to a given room occupant.
|
* @return new Chat for sending private messages to a given room occupant.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
// Do not re-use Chat API, which was designed for XMPP-IM 1:1 chats and not MUClight private chats.
|
// Do not re-use Chat API, which was designed for XMPP-IM 1:1 chats and not MUClight private chats.
|
||||||
public org.jivesoftware.smack.chat.Chat createPrivateChat(EntityJid occupant, ChatMessageListener listener) {
|
public org.jivesoftware.smack.chat.Chat createPrivateChat(EntityJid occupant, ChatMessageListener listener) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class MUCLightBlockingIQProvider extends IQProvider<MUCLightBlockingIQ> {
|
||||||
return mucLightBlockingIQ;
|
return mucLightBlockingIQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMap<Jid, Boolean> parseBlocking(XmlPullParser parser, HashMap<Jid, Boolean> map)
|
private static HashMap<Jid, Boolean> parseBlocking(XmlPullParser parser, HashMap<Jid, Boolean> map)
|
||||||
throws XmppStringprepException, XmlPullParserException, IOException {
|
throws XmppStringprepException, XmlPullParserException, IOException {
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
map = new HashMap<>();
|
map = new HashMap<>();
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class MUCLightInfoIQProvider extends IQProvider<MUCLightInfoIQ> {
|
||||||
return new MUCLightInfoIQ(version, new MUCLightRoomConfiguration(roomName, subject, customConfigs), occupants);
|
return new MUCLightInfoIQ(version, new MUCLightRoomConfiguration(roomName, subject, customConfigs), occupants);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMap<Jid, MUCLightAffiliation> iterateOccupants(XmlPullParser parser) throws Exception {
|
private static HashMap<Jid, MUCLightAffiliation> iterateOccupants(XmlPullParser parser) throws Exception {
|
||||||
HashMap<Jid, MUCLightAffiliation> occupants = new HashMap<>();
|
HashMap<Jid, MUCLightAffiliation> occupants = new HashMap<>();
|
||||||
int depth = parser.getDepth();
|
int depth = parser.getDepth();
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class HashElementTest extends SmackTestSuite {
|
||||||
@Test
|
@Test
|
||||||
public void stanzaTest() throws Exception {
|
public void stanzaTest() throws Exception {
|
||||||
String message = "Hello World!";
|
String message = "Hello World!";
|
||||||
HashElement element = HashManager.calculateHashElement(SHA_256, HashManager.utf8(message));
|
HashElement element = HashManager.calculateHashElement(SHA_256, StringUtils.toUtf8Bytes(message));
|
||||||
String expected = "<hash xmlns='urn:xmpp:hashes:2' algo='sha-256'>f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk=</hash>";
|
String expected = "<hash xmlns='urn:xmpp:hashes:2' algo='sha-256'>f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk=</hash>";
|
||||||
assertEquals(expected, element.toXML().toString());
|
assertEquals(expected, element.toXML().toString());
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.jivesoftware.smackx.hashes;
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
|
|
||||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ public class HashTest extends SmackTestSuite {
|
||||||
|
|
||||||
private byte[] array() {
|
private byte[] array() {
|
||||||
if (testArray == null) {
|
if (testArray == null) {
|
||||||
testArray = HashManager.utf8(testString);
|
testArray = StringUtils.toUtf8Bytes(testString);
|
||||||
}
|
}
|
||||||
return testArray;
|
return testArray;
|
||||||
}
|
}
|
||||||
|
@ -56,103 +57,103 @@ public class HashTest extends SmackTestSuite {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void hashTest() {
|
public void hashTest() {
|
||||||
assertEquals(md5sum, HashManager.hex(HashManager.hash(HashManager.ALGORITHM.MD5, array())));
|
assertEquals(md5sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.MD5, array())));
|
||||||
assertEquals(sha1sum, HashManager.hex(HashManager.hash(HashManager.ALGORITHM.SHA_1, array())));
|
assertEquals(sha1sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA_1, array())));
|
||||||
assertEquals(sha224sum, HashManager.hex(HashManager.hash(HashManager.ALGORITHM.SHA_224, array())));
|
assertEquals(sha224sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA_224, array())));
|
||||||
assertEquals(sha256sum, HashManager.hex(HashManager.hash(HashManager.ALGORITHM.SHA_256, array())));
|
assertEquals(sha256sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA_256, array())));
|
||||||
assertEquals(sha384sum, HashManager.hex(HashManager.hash(HashManager.ALGORITHM.SHA_384, array())));
|
assertEquals(sha384sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA_384, array())));
|
||||||
assertEquals(sha512sum, HashManager.hex(HashManager.hash(HashManager.ALGORITHM.SHA_512, array())));
|
assertEquals(sha512sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA_512, array())));
|
||||||
assertEquals(sha3_224sum, HashManager.hex(HashManager.hash(HashManager.ALGORITHM.SHA3_224, array())));
|
assertEquals(sha3_224sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA3_224, array())));
|
||||||
assertEquals(sha3_256sum, HashManager.hex(HashManager.hash(HashManager.ALGORITHM.SHA3_256, array())));
|
assertEquals(sha3_256sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA3_256, array())));
|
||||||
assertEquals(sha3_384sum, HashManager.hex(HashManager.hash(HashManager.ALGORITHM.SHA3_384, array())));
|
assertEquals(sha3_384sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA3_384, array())));
|
||||||
assertEquals(sha3_512sum, HashManager.hex(HashManager.hash(HashManager.ALGORITHM.SHA3_512, array())));
|
assertEquals(sha3_512sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.SHA3_512, array())));
|
||||||
assertEquals(b2_160sum, HashManager.hex(HashManager.hash(HashManager.ALGORITHM.BLAKE2B160, array())));
|
assertEquals(b2_160sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.BLAKE2B160, array())));
|
||||||
assertEquals(b2_256sum, HashManager.hex(HashManager.hash(HashManager.ALGORITHM.BLAKE2B256, array())));
|
assertEquals(b2_256sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.BLAKE2B256, array())));
|
||||||
assertEquals(b2_384sum, HashManager.hex(HashManager.hash(HashManager.ALGORITHM.BLAKE2B384, array())));
|
assertEquals(b2_384sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.BLAKE2B384, array())));
|
||||||
assertEquals(b2_512sum, HashManager.hex(HashManager.hash(HashManager.ALGORITHM.BLAKE2B512, array())));
|
assertEquals(b2_512sum, StringUtils.encodeHex(HashManager.hash(HashManager.ALGORITHM.BLAKE2B512, array())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void md5Test() {
|
public void md5Test() {
|
||||||
String actual = HashManager.hex(HashManager.md5(array()));
|
String actual = StringUtils.encodeHex(HashManager.md5(array()));
|
||||||
assertEquals(md5sum, actual);
|
assertEquals(md5sum, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sha1Test() {
|
public void sha1Test() {
|
||||||
String actual = HashManager.hex(HashManager.sha_1(array()));
|
String actual = StringUtils.encodeHex(HashManager.sha_1(array()));
|
||||||
assertEquals(sha1sum, actual);
|
assertEquals(sha1sum, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sha224Test() {
|
public void sha224Test() {
|
||||||
String actual = HashManager.hex(HashManager.sha_224(array()));
|
String actual = StringUtils.encodeHex(HashManager.sha_224(array()));
|
||||||
assertEquals(sha224sum, actual);
|
assertEquals(sha224sum, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sha256Test() {
|
public void sha256Test() {
|
||||||
String actual = HashManager.hex(HashManager.sha_256(array()));
|
String actual = StringUtils.encodeHex(HashManager.sha_256(array()));
|
||||||
assertEquals(sha256sum, actual);
|
assertEquals(sha256sum, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sha384Test() {
|
public void sha384Test() {
|
||||||
String actual = HashManager.hex(HashManager.sha_384(array()));
|
String actual = StringUtils.encodeHex(HashManager.sha_384(array()));
|
||||||
assertEquals(sha384sum, actual);
|
assertEquals(sha384sum, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sha512Test() {
|
public void sha512Test() {
|
||||||
String actual = HashManager.hex(HashManager.sha_512(array()));
|
String actual = StringUtils.encodeHex(HashManager.sha_512(array()));
|
||||||
assertEquals(sha512sum, actual);
|
assertEquals(sha512sum, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sha3_224Test() {
|
public void sha3_224Test() {
|
||||||
String actual = HashManager.hex(HashManager.sha3_224(array()));
|
String actual = StringUtils.encodeHex(HashManager.sha3_224(array()));
|
||||||
assertEquals(sha3_224sum, actual);
|
assertEquals(sha3_224sum, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sha3_256Test() {
|
public void sha3_256Test() {
|
||||||
String actual = HashManager.hex(HashManager.sha3_256(array()));
|
String actual = StringUtils.encodeHex(HashManager.sha3_256(array()));
|
||||||
assertEquals(sha3_256sum, actual);
|
assertEquals(sha3_256sum, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sha3_384Test() {
|
public void sha3_384Test() {
|
||||||
String actual = HashManager.hex(HashManager.sha3_384(array()));
|
String actual = StringUtils.encodeHex(HashManager.sha3_384(array()));
|
||||||
assertEquals(sha3_384sum, actual);
|
assertEquals(sha3_384sum, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sha3_512Test() {
|
public void sha3_512Test() {
|
||||||
String actual = HashManager.hex(HashManager.sha3_512(array()));
|
String actual = StringUtils.encodeHex(HashManager.sha3_512(array()));
|
||||||
assertEquals(sha3_512sum, actual);
|
assertEquals(sha3_512sum, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void blake2b160Test() {
|
public void blake2b160Test() {
|
||||||
String actual = HashManager.hex(HashManager.blake2b160(array()));
|
String actual = StringUtils.encodeHex(HashManager.blake2b160(array()));
|
||||||
assertEquals(b2_160sum, actual);
|
assertEquals(b2_160sum, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void blake2b256Test() {
|
public void blake2b256Test() {
|
||||||
String actual = HashManager.hex(HashManager.blake2b256(array()));
|
String actual = StringUtils.encodeHex(HashManager.blake2b256(array()));
|
||||||
assertEquals(b2_256sum, actual);
|
assertEquals(b2_256sum, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void blake2b384Test() {
|
public void blake2b384Test() {
|
||||||
String actual = HashManager.hex(HashManager.blake2b384(array()));
|
String actual = StringUtils.encodeHex(HashManager.blake2b384(array()));
|
||||||
assertEquals(b2_384sum, actual);
|
assertEquals(b2_384sum, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void blake2b512Test() {
|
public void blake2b512Test() {
|
||||||
String actual = HashManager.hex(HashManager.blake2b512(array()));
|
String actual = StringUtils.encodeHex(HashManager.blake2b512(array()));
|
||||||
assertEquals(b2_512sum, actual);
|
assertEquals(b2_512sum, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ public final class Chat extends Manager {
|
||||||
public void send(CharSequence message) throws NotConnectedException, InterruptedException {
|
public void send(CharSequence message) throws NotConnectedException, InterruptedException {
|
||||||
Message stanza = new Message();
|
Message stanza = new Message();
|
||||||
stanza.setBody(message);
|
stanza.setBody(message);
|
||||||
|
stanza.setType(Message.Type.chat);
|
||||||
send(stanza);
|
send(stanza);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ public interface BytestreamManager {
|
||||||
*
|
*
|
||||||
* @param initiatorJID the JID of the user the listener should be removed
|
* @param initiatorJID the JID of the user the listener should be removed
|
||||||
*/
|
*/
|
||||||
public void removeIncomingBytestreamListener(String initiatorJID);
|
public void removeIncomingBytestreamListener(Jid initiatorJID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Establishes a bytestream with the given user and returns the session to send/receive data
|
* Establishes a bytestream with the given user and returns the session to send/receive data
|
||||||
|
|
|
@ -282,9 +282,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
|
||||||
* @param initiatorJID the JID of the user the listener should be removed
|
* @param initiatorJID the JID of the user the listener should be removed
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
// TODO: Change argument to Jid in Smack 4.3.
|
public void removeIncomingBytestreamListener(Jid initiatorJID) {
|
||||||
@SuppressWarnings("CollectionIncompatibleType")
|
|
||||||
public void removeIncomingBytestreamListener(String initiatorJID) {
|
|
||||||
this.userListeners.remove(initiatorJID);
|
this.userListeners.remove(initiatorJID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -245,10 +245,8 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
||||||
*
|
*
|
||||||
* @param initiatorJID the JID of the user the listener should be removed
|
* @param initiatorJID the JID of the user the listener should be removed
|
||||||
*/
|
*/
|
||||||
// TODO: Change parameter to Jid in Smack 4.3.
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("CollectionIncompatibleType")
|
public void removeIncomingBytestreamListener(Jid initiatorJID) {
|
||||||
public void removeIncomingBytestreamListener(String initiatorJID) {
|
|
||||||
this.userListeners.remove(initiatorJID);
|
this.userListeners.remove(initiatorJID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -408,9 +408,7 @@ public final class EntityCapsManager extends Manager {
|
||||||
* @param user
|
* @param user
|
||||||
* the user (Full JID)
|
* the user (Full JID)
|
||||||
*/
|
*/
|
||||||
// TODO: Change parameter type to Jid in Smack 4.3.
|
public static void removeUserCapsNode(Jid user) {
|
||||||
@SuppressWarnings("CollectionIncompatibleType")
|
|
||||||
public static void removeUserCapsNode(String user) {
|
|
||||||
// While JID_TO_NODEVER_CHACHE has the generic types <Jid, NodeVerHash>, it is ok to call remove with String
|
// While JID_TO_NODEVER_CHACHE has the generic types <Jid, NodeVerHash>, it is ok to call remove with String
|
||||||
// arguments, since the same Jid and String representations would be equal and have the same hash code.
|
// arguments, since the same Jid and String representations would be equal and have the same hash code.
|
||||||
JID_TO_NODEVER_CACHE.remove(user);
|
JID_TO_NODEVER_CACHE.remove(user);
|
||||||
|
|
|
@ -205,16 +205,9 @@ public final class AdHocCommandManager extends Manager {
|
||||||
public void registerCommand(String node, String name, final Class<? extends LocalCommand> clazz) {
|
public void registerCommand(String node, String name, final Class<? extends LocalCommand> clazz) {
|
||||||
registerCommand(node, name, new LocalCommandFactory() {
|
registerCommand(node, name, new LocalCommandFactory() {
|
||||||
@Override
|
@Override
|
||||||
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException {
|
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
|
||||||
try {
|
|
||||||
return clazz.getConstructor().newInstance();
|
return clazz.getConstructor().newInstance();
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException | InvocationTargetException | NoSuchMethodException
|
|
||||||
| SecurityException e) {
|
|
||||||
// TODO: Throw those method in Smack 4.3.
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +354,15 @@ public final class AdHocCommandManager extends Manager {
|
||||||
try {
|
try {
|
||||||
// Create a new instance of the command with the
|
// Create a new instance of the command with the
|
||||||
// corresponding sessioid
|
// corresponding sessioid
|
||||||
LocalCommand command = newInstanceOfCmd(commandNode, sessionId);
|
LocalCommand command;
|
||||||
|
try {
|
||||||
|
command = newInstanceOfCmd(commandNode, sessionId);
|
||||||
|
}
|
||||||
|
catch (InstantiationException | IllegalAccessException | IllegalArgumentException
|
||||||
|
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||||
|
XMPPError.Builder xmppError = XMPPError.getBuilder().setCondition(XMPPError.Condition.internal_server_error).setDescriptiveEnText(e.getMessage());
|
||||||
|
return respondError(response, xmppError);
|
||||||
|
}
|
||||||
|
|
||||||
response.setType(IQ.Type.result);
|
response.setType(IQ.Type.result);
|
||||||
command.setData(response);
|
command.setData(response);
|
||||||
|
@ -627,26 +628,22 @@ public final class AdHocCommandManager extends Manager {
|
||||||
* @param sessionID the session id of this execution.
|
* @param sessionID the session id of this execution.
|
||||||
* @return the command instance to execute.
|
* @return the command instance to execute.
|
||||||
* @throws XMPPErrorException if there is problem creating the new instance.
|
* @throws XMPPErrorException if there is problem creating the new instance.
|
||||||
|
* @throws SecurityException
|
||||||
|
* @throws NoSuchMethodException
|
||||||
|
* @throws InvocationTargetException
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
* @throws InstantiationException
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
private LocalCommand newInstanceOfCmd(String commandNode, String sessionID)
|
||||||
private LocalCommand newInstanceOfCmd(String commandNode, String sessionID) throws XMPPErrorException
|
throws XMPPErrorException, InstantiationException, IllegalAccessException, IllegalArgumentException,
|
||||||
{
|
InvocationTargetException, NoSuchMethodException, SecurityException {
|
||||||
AdHocCommandInfo commandInfo = commands.get(commandNode);
|
AdHocCommandInfo commandInfo = commands.get(commandNode);
|
||||||
LocalCommand command;
|
LocalCommand command = commandInfo.getCommandInstance();
|
||||||
try {
|
|
||||||
command = commandInfo.getCommandInstance();
|
|
||||||
command.setSessionID(sessionID);
|
command.setSessionID(sessionID);
|
||||||
command.setName(commandInfo.getName());
|
command.setName(commandInfo.getName());
|
||||||
command.setNode(commandInfo.getNode());
|
command.setNode(commandInfo.getNode());
|
||||||
}
|
|
||||||
catch (InstantiationException e) {
|
|
||||||
throw new XMPPErrorException(XMPPError.getBuilder(
|
|
||||||
XMPPError.Condition.internal_server_error));
|
|
||||||
}
|
|
||||||
catch (IllegalAccessException e) {
|
|
||||||
throw new XMPPErrorException(XMPPError.getBuilder(
|
|
||||||
XMPPError.Condition.internal_server_error));
|
|
||||||
}
|
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,7 +677,7 @@ public final class AdHocCommandManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalCommand getCommandInstance() throws InstantiationException,
|
public LocalCommand getCommandInstance() throws InstantiationException,
|
||||||
IllegalAccessException
|
IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException
|
||||||
{
|
{
|
||||||
return factory.getInstance();
|
return factory.getInstance();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.commands;
|
package org.jivesoftware.smackx.commands;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A factory for creating local commands. It's useful in cases where instantiation
|
* A factory for creating local commands. It's useful in cases where instantiation
|
||||||
* of a command is more complicated than just using the default constructor. For example,
|
* of a command is more complicated than just using the default constructor. For example,
|
||||||
|
@ -34,7 +36,11 @@ public interface LocalCommandFactory {
|
||||||
* @return a LocalCommand instance.
|
* @return a LocalCommand instance.
|
||||||
* @throws InstantiationException if creating an instance failed.
|
* @throws InstantiationException if creating an instance failed.
|
||||||
* @throws IllegalAccessException if creating an instance is not allowed.
|
* @throws IllegalAccessException if creating an instance is not allowed.
|
||||||
|
* @throws SecurityException
|
||||||
|
* @throws NoSuchMethodException
|
||||||
|
* @throws InvocationTargetException
|
||||||
|
* @throws IllegalArgumentException
|
||||||
*/
|
*/
|
||||||
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException;
|
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,11 +236,10 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
private void establishBytestreamSession(XMPPConnection connection)
|
private void establishBytestreamSession(XMPPConnection connection)
|
||||||
throws SmackException.NotConnectedException, InterruptedException {
|
throws SmackException.NotConnectedException, InterruptedException {
|
||||||
Socks5Proxy.getSocks5Proxy().addTransfer(ourDstAddr);
|
Socks5Proxy.getSocks5Proxy().addTransfer(ourDstAddr);
|
||||||
JingleS5BTransportManager transportManager = JingleS5BTransportManager.getInstanceFor(connection);
|
|
||||||
this.ourSelectedCandidate = connectToCandidates(MAX_TIMEOUT);
|
this.ourSelectedCandidate = connectToCandidates(MAX_TIMEOUT);
|
||||||
|
|
||||||
if (ourSelectedCandidate == CANDIDATE_FAILURE) {
|
if (ourSelectedCandidate == CANDIDATE_FAILURE) {
|
||||||
connection.createStanzaCollectorAndSend(transportManager.createCandidateError(this));
|
connection.createStanzaCollectorAndSend(JingleS5BTransportManager.createCandidateError(this));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +247,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
throw new AssertionError("MUST NOT BE NULL.");
|
throw new AssertionError("MUST NOT BE NULL.");
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.createStanzaCollectorAndSend(transportManager.createCandidateUsed(this, ourSelectedCandidate));
|
connection.createStanzaCollectorAndSend(JingleS5BTransportManager.createCandidateUsed(this, ourSelectedCandidate));
|
||||||
connectIfReady();
|
connectIfReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +280,6 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
|
|
||||||
@SuppressWarnings("ReferenceEquality")
|
@SuppressWarnings("ReferenceEquality")
|
||||||
private void connectIfReady() {
|
private void connectIfReady() {
|
||||||
final JingleS5BTransportManager jingleS5BTransportManager = JingleS5BTransportManager.getInstanceFor(getParent().getParent().getJingleManager().getConnection());
|
|
||||||
final JingleSession session = getParent().getParent();
|
final JingleSession session = getParent().getParent();
|
||||||
|
|
||||||
if (ourSelectedCandidate == null || theirSelectedCandidate == null) {
|
if (ourSelectedCandidate == null || theirSelectedCandidate == null) {
|
||||||
|
@ -331,7 +329,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
session.getJingleManager().getConnection().createStanzaCollectorAndSend(jingleS5BTransportManager.createProxyError(JingleS5BTransport.this));
|
session.getJingleManager().getConnection().createStanzaCollectorAndSend(JingleS5BTransportManager.createProxyError(JingleS5BTransport.this));
|
||||||
} catch (SmackException.NotConnectedException | InterruptedException e1) {
|
} catch (SmackException.NotConnectedException | InterruptedException e1) {
|
||||||
LOGGER.log(Level.SEVERE, "Could not send proxy error: " + e, e);
|
LOGGER.log(Level.SEVERE, "Could not send proxy error: " + e, e);
|
||||||
}
|
}
|
||||||
|
@ -344,7 +342,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
|
|
||||||
if (isProxy) {
|
if (isProxy) {
|
||||||
LOGGER.log(Level.INFO, "Send candidate-activate.");
|
LOGGER.log(Level.INFO, "Send candidate-activate.");
|
||||||
JingleElement candidateActivate = jingleS5BTransportManager.createCandidateActivated((JingleS5BTransport) nominated.getParent(), nominated);
|
JingleElement candidateActivate = JingleS5BTransportManager.createCandidateActivated((JingleS5BTransport) nominated.getParent(), nominated);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
session.getJingleManager().getConnection().createStanzaCollectorAndSend(candidateActivate)
|
session.getJingleManager().getConnection().createStanzaCollectorAndSend(candidateActivate)
|
||||||
|
|
|
@ -465,7 +465,7 @@ public class MultiUserChat {
|
||||||
* @deprecated use {@link #createOrJoin(MucEnterConfiguration)} instead.
|
* @deprecated use {@link #createOrJoin(MucEnterConfiguration)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public MucCreateConfigFormHandle createOrJoin(Resourcepart nickname, String password, DiscussionHistory history, long timeout)
|
public MucCreateConfigFormHandle createOrJoin(Resourcepart nickname, String password, @SuppressWarnings("deprecation") DiscussionHistory history, long timeout)
|
||||||
throws NoResponseException, XMPPErrorException, InterruptedException, MucAlreadyJoinedException, NotConnectedException, NotAMucServiceException {
|
throws NoResponseException, XMPPErrorException, InterruptedException, MucAlreadyJoinedException, NotConnectedException, NotAMucServiceException {
|
||||||
MucEnterConfiguration.Builder builder = getEnterConfigurationBuilder(nickname).withPassword(
|
MucEnterConfiguration.Builder builder = getEnterConfigurationBuilder(nickname).withPassword(
|
||||||
password).timeoutAfter(timeout);
|
password).timeoutAfter(timeout);
|
||||||
|
@ -666,7 +666,7 @@ public class MultiUserChat {
|
||||||
public void join(
|
public void join(
|
||||||
Resourcepart nickname,
|
Resourcepart nickname,
|
||||||
String password,
|
String password,
|
||||||
DiscussionHistory history,
|
@SuppressWarnings("deprecation") DiscussionHistory history,
|
||||||
long timeout)
|
long timeout)
|
||||||
throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException, NotAMucServiceException {
|
throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException, NotAMucServiceException {
|
||||||
MucEnterConfiguration.Builder builder = getEnterConfigurationBuilder(nickname).withPassword(
|
MucEnterConfiguration.Builder builder = getEnterConfigurationBuilder(nickname).withPassword(
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
|
||||||
* to true, otherwise it will be null.
|
* to true, otherwise it will be null.
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* <h3>An Item created to send to a node (via {@link LeafNode#send()} or {@link LeafNode#publish()}</h3>
|
* <h3>An Item created to send to a node (via {@link LeafNode#publish()} or {@link LeafNode#publish()}</h3>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>The id is optional, since the server will generate one if necessary, but should be used if it is
|
* <li>The id is optional, since the server will generate one if necessary, but should be used if it is
|
||||||
* meaningful in the context of the node. This value must be unique within the node that it is sent to, since
|
* meaningful in the context of the node. This value must be unique within the node that it is sent to, since
|
||||||
|
@ -57,8 +57,8 @@ public class Item extends NodeExtension
|
||||||
* Create an empty <tt>Item</tt> with no id. This is a valid item for nodes which are configured
|
* Create an empty <tt>Item</tt> with no id. This is a valid item for nodes which are configured
|
||||||
* so that {@link ConfigureForm#isDeliverPayloads()} is false. In most cases an id will be generated by the server.
|
* so that {@link ConfigureForm#isDeliverPayloads()} is false. In most cases an id will be generated by the server.
|
||||||
* For nodes configured with {@link ConfigureForm#isDeliverPayloads()} and {@link ConfigureForm#isPersistItems()}
|
* For nodes configured with {@link ConfigureForm#isDeliverPayloads()} and {@link ConfigureForm#isPersistItems()}
|
||||||
* set to false, no <tt>Item</tt> is sent to the node, you have to use {@link LeafNode#send()} or {@link LeafNode#publish()}
|
* set to false, no <tt>Item</tt> is sent to the node, you have to use the {@link LeafNode#publish()}
|
||||||
* methods in this case.
|
* method in this case.
|
||||||
*/
|
*/
|
||||||
public Item()
|
public Item()
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
|
||||||
* to true, otherwise it will be null.</li>
|
* to true, otherwise it will be null.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* <h3>An Item created to send to a node (via {@link LeafNode#send()} or {@link LeafNode#publish()}</h3>
|
* <h3>An Item created to send to a node (via {@link LeafNode#publish()}</h3>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>The id is optional, since the server will generate one if necessary, but should be used if it is
|
* <li>The id is optional, since the server will generate one if necessary, but should be used if it is
|
||||||
* meaningful in the context of the node. This value must be unique within the node that it is sent to, since
|
* meaningful in the context of the node. This value must be unique within the node that it is sent to, since
|
||||||
|
|
|
@ -272,8 +272,8 @@ public final class DeliveryReceiptManager extends Manager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables automatic requests of delivery receipts for outgoing messages of
|
* Enables automatic requests of delivery receipts for outgoing messages of
|
||||||
* {@link Message.Type#normal}, {@link Message.Type#chat} or {@link Message.Type#headline}, and
|
* {@link org.jivesoftware.smack.packet.Message.Type#normal}, {@link org.jivesoftware.smack.packet.Message.Type#chat} or {@link org.jivesoftware.smack.packet.Message.Type#headline}, and
|
||||||
* with a {@link Message.Body} extension.
|
* with a {@link org.jivesoftware.smack.packet.Message.Body} extension.
|
||||||
*
|
*
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
* @see #dontAutoAddDeliveryReceiptRequests()
|
* @see #dontAutoAddDeliveryReceiptRequests()
|
||||||
|
|
|
@ -35,13 +35,13 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.AbstractConnectionListener;
|
import org.jivesoftware.smack.AbstractConnectionListener;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.ExceptionCallback;
|
|
||||||
import org.jivesoftware.smack.Manager;
|
import org.jivesoftware.smack.Manager;
|
||||||
import org.jivesoftware.smack.SmackException;
|
import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
|
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
|
||||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||||
import org.jivesoftware.smack.SmackException.NotLoggedInException;
|
import org.jivesoftware.smack.SmackException.NotLoggedInException;
|
||||||
|
import org.jivesoftware.smack.SmackFuture;
|
||||||
import org.jivesoftware.smack.StanzaListener;
|
import org.jivesoftware.smack.StanzaListener;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
||||||
|
@ -63,7 +63,9 @@ import org.jivesoftware.smack.roster.packet.RosterPacket.Item;
|
||||||
import org.jivesoftware.smack.roster.packet.RosterVer;
|
import org.jivesoftware.smack.roster.packet.RosterVer;
|
||||||
import org.jivesoftware.smack.roster.packet.SubscriptionPreApproval;
|
import org.jivesoftware.smack.roster.packet.SubscriptionPreApproval;
|
||||||
import org.jivesoftware.smack.roster.rosterstore.RosterStore;
|
import org.jivesoftware.smack.roster.rosterstore.RosterStore;
|
||||||
|
import org.jivesoftware.smack.util.ExceptionCallback;
|
||||||
import org.jivesoftware.smack.util.Objects;
|
import org.jivesoftware.smack.util.Objects;
|
||||||
|
import org.jivesoftware.smack.util.SuccessCallback;
|
||||||
|
|
||||||
import org.jxmpp.jid.BareJid;
|
import org.jxmpp.jid.BareJid;
|
||||||
import org.jxmpp.jid.EntityBareJid;
|
import org.jxmpp.jid.EntityBareJid;
|
||||||
|
@ -428,7 +430,11 @@ public final class Roster extends Manager {
|
||||||
packet.setVersion(rosterStore.getRosterVersion());
|
packet.setVersion(rosterStore.getRosterVersion());
|
||||||
}
|
}
|
||||||
rosterState = RosterState.loading;
|
rosterState = RosterState.loading;
|
||||||
connection.sendIqWithResponseCallback(packet, new RosterResultListener(), new ExceptionCallback() {
|
|
||||||
|
SmackFuture<IQ, Exception> future = connection.sendIqRequestAsync(packet);
|
||||||
|
|
||||||
|
future.onSuccess(new RosterResultListener()).onError(new ExceptionCallback<Exception>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processException(Exception exception) {
|
public void processException(Exception exception) {
|
||||||
rosterState = RosterState.uninitialized;
|
rosterState = RosterState.uninitialized;
|
||||||
|
@ -443,6 +449,7 @@ public final class Roster extends Manager {
|
||||||
listener.onRosterLoadingFailed(exception);
|
listener.onRosterLoadingFailed(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1565,10 +1572,10 @@ public final class Roster extends Manager {
|
||||||
/**
|
/**
|
||||||
* Handles Roster results as described in <a href="https://tools.ietf.org/html/rfc6121#section-2.1.4">RFC 6121 2.1.4</a>.
|
* Handles Roster results as described in <a href="https://tools.ietf.org/html/rfc6121#section-2.1.4">RFC 6121 2.1.4</a>.
|
||||||
*/
|
*/
|
||||||
private class RosterResultListener implements StanzaListener {
|
private class RosterResultListener implements SuccessCallback<IQ> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processStanza(Stanza packet) {
|
public void onSuccess(IQ packet) {
|
||||||
final XMPPConnection connection = connection();
|
final XMPPConnection connection = connection();
|
||||||
LOGGER.log(Level.FINE, "RosterResultListener received {}", packet);
|
LOGGER.log(Level.FINE, "RosterResultListener received {}", packet);
|
||||||
Collection<Jid> addedEntries = new ArrayList<>();
|
Collection<Jid> addedEntries = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in New Issue