1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-16 17:22:06 +01:00

Compare commits

..

No commits in common. "eecd5b70d3428e19028e51f4ef56f9800833c24f" and "9de2b983c8dfc9e339547b074050ccefe742086d" have entirely different histories.

90 changed files with 163 additions and 204 deletions

View file

@ -22,12 +22,11 @@ before_install:
- wget https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-all.zip
- unzip -q gradle-${GRADLE_VERSION}-all.zip
- export PATH="$(pwd)/gradle-${GRADLE_VERSION}/bin:$PATH"
- sudo apt-get install graphviz
addons:
apt:
update: true
packages:
- graphviz
install: gradle assemble --stacktrace

View file

@ -382,7 +382,7 @@ subprojects {
apply plugin: 'org.kordamp.gradle.clirr'
checkstyle {
toolVersion = '8.22'
toolVersion = '8.10'
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'

View file

@ -212,9 +212,5 @@
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="true"/>
</module>
<module name="MissingJavadocPackage"/>
<module name="UnnecessaryParentheses"/>
<module name="UnnecessarySemicolonInEnumeration"/>
<module name="UnnecessarySemicolonInTryWithResources"/>
</module>
</module>

View file

@ -65,11 +65,11 @@ public final class BOSHConfiguration extends ConnectionConfiguration {
}
public String getProxyAddress() {
return proxy != null ? proxy.getProxyAddress() : null;
return (proxy != null ? proxy.getProxyAddress() : null);
}
public int getProxyPort() {
return proxy != null ? proxy.getProxyPort() : 8080;
return (proxy != null ? proxy.getProxyPort() : 8080);
}
public boolean isUsingHTTPS() {

View file

@ -755,7 +755,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
hostAddresses = DNSUtil.resolveXMPPServiceDomain(dnsName, failedAddresses, config.getDnssecMode());
}
// Either the populated host addresses are not empty *or* there must be at least one failed address.
assert !hostAddresses.isEmpty() || !failedAddresses.isEmpty();
assert (!hostAddresses.isEmpty() || !failedAddresses.isEmpty());
return failedAddresses;
}
@ -788,7 +788,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
@Override
public final void sendStanza(Stanza stanza) throws NotConnectedException, InterruptedException {
Objects.requireNonNull(stanza, "Stanza must not be null");
assert stanza instanceof Message || stanza instanceof Presence || stanza instanceof IQ;
assert (stanza instanceof Message || stanza instanceof Presence || stanza instanceof IQ);
throwNotConnectedExceptionIfAppropriate();
switch (fromMode) {
@ -1275,7 +1275,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* @throws InterruptedException
*/
protected void processStanza(final Stanza stanza) throws InterruptedException {
assert stanza != null;
assert (stanza != null);
final SmackDebugger debugger = this.debugger;
if (debugger != null) {
@ -1892,7 +1892,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
@Override
public final String toString() {
EntityFullJid localEndpoint = getUser();
String localEndpointString = localEndpoint == null ? "not-authenticated" : localEndpoint.toString();
String localEndpointString = (localEndpoint == null ? "not-authenticated" : localEndpoint.toString());
return getClass().getSimpleName() + '[' + localEndpointString + "] (" + getConnectionCounter() + ')';
}

View file

@ -209,7 +209,7 @@ public abstract class ConnectionConfiguration {
compressionEnabled = builder.compressionEnabled;
// If the enabledSaslmechanisms are set, then they must not be empty
assert enabledSaslMechanisms == null || !enabledSaslMechanisms.isEmpty();
assert (enabledSaslMechanisms != null ? !enabledSaslMechanisms.isEmpty() : true);
if (dnssecMode != DnssecMode.disabled && customSSLContext != null) {
throw new IllegalStateException("You can not use a custom SSL context with DNSSEC enabled");

View file

@ -447,5 +447,6 @@ public final class ReconnectionManager {
* Policy using fixed amount of time between reconnection attempts.
*/
FIXED_DELAY,
;
}
}

View file

@ -88,7 +88,7 @@ public abstract class SmackFuture<V, E extends Exception> implements Future<V>,
}
private V getOrThrowExecutionException() throws ExecutionException {
assert result != null || exception != null || cancelled;
assert (result != null || exception != null || cancelled);
if (result != null) {
return result;
}
@ -96,7 +96,7 @@ public abstract class SmackFuture<V, E extends Exception> implements Future<V>,
throw new ExecutionException(exception);
}
assert cancelled;
assert (cancelled);
throw new CancellationException();
}

View file

@ -172,7 +172,7 @@ public class SmackReactor {
LOGGER.info(this + " shut down after " + shutDownDelay + "ms");
} else {
boolean contained = reactorThreads.remove(this);
assert contained;
assert (contained);
}
}
}

View file

@ -79,7 +79,7 @@ public class SynchronizationPoint<E extends Exception> {
*/
public Exception sendAndWaitForResponse(TopLevelStreamElement request) throws NoResponseException,
NotConnectedException, InterruptedException {
assert state == State.Initial;
assert (state == State.Initial);
connectionLock.lock();
try {
if (request != null) {

View file

@ -56,7 +56,7 @@ public class Java7ZlibInputOutputStream extends XMPPInputOutputStream {
} catch (NoSuchMethodException e) {
}
method = m;
supported = method != null;
supported = (method != null);
}
public Java7ZlibInputOutputStream() {

View file

@ -95,7 +95,7 @@ public final class ZlibXmppCompressionFactory extends XmppCompressionFactory {
}
// There is an invariant of Deflater/Inflater that input should only be set if needsInput() return true.
assert compressor.needsInput();
assert (compressor.needsInput());
final byte[] compressorInputBuffer;
final int compressorInputBufferOffset, compressorInputBufferLength;

View file

@ -86,12 +86,12 @@ public abstract class SmackDebugger {
*/
public final Reader newConnectionReader(Reader reader) {
XmlPrettyPrinter xmlPrettyPrinter = XmlPrettyPrinter.builder()
.setPrettyWriter(sb -> incomingStreamSink(sb))
.setPrettyWriter((sb) -> incomingStreamSink(sb))
.build();
incomingStreamSplitterForPrettyPrinting = new XmppXmlSplitter(xmlPrettyPrinter);
ObservableReader observableReader = new ObservableReader(reader);
observableReader.addReaderListener(readString -> {
observableReader.addReaderListener((readString) -> {
try {
incomingStreamSplitterForPrettyPrinting.append(readString);
}
@ -113,12 +113,12 @@ public abstract class SmackDebugger {
*/
public final Writer newConnectionWriter(Writer writer) {
XmlPrettyPrinter xmlPrettyPrinter = XmlPrettyPrinter.builder()
.setPrettyWriter(sb -> outgoingStreamSink(sb))
.setPrettyWriter((sb) -> outgoingStreamSink(sb))
.build();
outgoingStreamSplitterForPrettyPrinting = new XmppXmlSplitter(xmlPrettyPrinter);
ObservableWriter observableWriter = new ObservableWriter(writer);
observableWriter.addWriterListener(writtenString -> {
observableWriter.addWriterListener((writtenString) -> {
try {
outgoingStreamSplitterForPrettyPrinting.append(writtenString);
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2017-2019 Florian Schmaus.
* Copyright 2017-2018 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,6 +28,7 @@ public abstract class AbstractJidTypeFilter implements StanzaFilter {
domainFull,
domainBare,
any,
;
}
protected final JidType jidType;

View file

@ -178,7 +178,7 @@ public abstract class AbstractXmppStateMachineConnection extends AbstractXMPPCon
if (initialStateDescriptor.getClass() == walkStateGraphContext.finalStateClass) {
// If this is used as final state, then it should be marked as such.
assert initialStateDescriptor.isFinalState();
assert (initialStateDescriptor.isFinalState());
// We reached the final state.
invokeConnectionStateMachineListener(new ConnectionStateEvent.FinalStateReached(initialState));
@ -578,7 +578,7 @@ public abstract class AbstractXmppStateMachineConnection extends AbstractXMPPCon
@Override
protected TransitionIntoResult transitionInto(WalkStateGraphContext walkStateGraphContext) {
assert walkFromDisconnectToAuthenticated == null;
assert (walkFromDisconnectToAuthenticated == null);
if (getStateDescriptor().getClass() == walkStateGraphContext.finalStateClass) {
// If this is the final state, then record the walk so far.
walkFromDisconnectToAuthenticated = new ArrayList<>(walkStateGraphContext.walkedStateGraphPath);
@ -780,7 +780,7 @@ public abstract class AbstractXmppStateMachineConnection extends AbstractXMPPCon
if (walkFromDisconnectToAuthenticated != null) {
// If there was already a previous walk to ConnectedButUnauthenticated, then the context of the current
// walk must not start from the 'Disconnected' state.
assert walkStateGraphContext.walkedStateGraphPath.get(0).stateDescriptor.getClass() != DisconnectedStateDescriptor.class;
assert (walkStateGraphContext.walkedStateGraphPath.get(0).stateDescriptor.getClass() != DisconnectedStateDescriptor.class);
walkFromDisconnectToAuthenticated.addAll(walkStateGraphContext.walkedStateGraphPath);
} else {
walkFromDisconnectToAuthenticated = new ArrayList<>(walkStateGraphContext.walkedStateGraphPath.size() + 1);

View file

@ -326,7 +326,7 @@ public class StateDescriptorGraph {
private static <E> List<GraphVertex<E>> topologicalSort(Collection<GraphVertex<E>> vertexes) {
List<GraphVertex<E>> res = new ArrayList<>();
dfs(vertexes, vertex -> res.add(0, vertex), null);
dfs(vertexes, (vertex) -> res.add(0, vertex), null);
return res;
}
@ -365,7 +365,7 @@ public class StateDescriptorGraph {
PrintWriter dotOut, boolean breakStateName) {
dotOut.append("digraph {\n");
dfs(vertexes,
finishedVertex -> {
(finishedVertex) -> {
boolean isMultiVisitState = finishedVertex.element.isMultiVisitState();
boolean isFinalState = finishedVertex.element.isFinalState();
boolean isNotImplemented = finishedVertex.element.isNotImplemented();

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2019 Florian Schmaus
* Copyright © 2014 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -119,6 +119,6 @@ public class StreamOpen implements Nonza {
public enum StreamContentNamespace {
client,
server,
server;
}
}

View file

@ -152,7 +152,7 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
this.password = password;
this.authorizationId = authzid;
this.sslSession = sslSession;
assert authorizationId == null || authzidSupported();
assert (authorizationId == null || authzidSupported());
authenticateInternal();
authenticate();
}
@ -179,7 +179,7 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
this.serviceName = serviceName;
this.authorizationId = authzid;
this.sslSession = sslSession;
assert authorizationId == null || authzidSupported();
assert (authorizationId == null || authzidSupported());
authenticateInternal(cbh);
authenticate();
}

View file

@ -228,7 +228,7 @@ public abstract class ScramMechanism extends SASLMechanism {
}
String cbName = getChannelBindingName();
assert StringUtils.isNotEmpty(cbName);
assert (StringUtils.isNotEmpty(cbName));
return cbName + ',' + authzidPortion + ",";
}

View file

@ -233,7 +233,7 @@ public class DNSUtil {
}
for (SRVRecord r : bucket) {
running_total += r.getWeight() + zeroWeight;
running_total += (r.getWeight() + zeroWeight);
totals[count] = running_total;
count++;
}

View file

@ -148,7 +148,7 @@ public class MultiMap<K, V> {
if (res == null) {
return null;
}
assert !res.isEmpty();
assert (!res.isEmpty());
return res.iterator().next();
}

View file

@ -40,7 +40,7 @@ public class NumberUtil {
throw new IllegalArgumentException("unsigned 32-bit integers can't be negative");
}
if (value > ((1L << 32) - 1)) {
throw new IllegalArgumentException("unsigned 32-bit integers can't be greater than 2^32 - 1");
throw new IllegalArgumentException("unsigned 32-bit integers can't be greater then 2^32 - 1");
}
return value;
}

View file

@ -137,7 +137,7 @@ public class PacketParserUtils {
*/
public static Message parseMessage(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
ParserUtils.assertAtStartTag(parser);
assert parser.getName().equals(Message.ELEMENT);
assert (parser.getName().equals(Message.ELEMENT));
XmlEnvironment messageXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
final int initialDepth = parser.getDepth();
@ -218,7 +218,7 @@ public class PacketParserUtils {
* @throws IOException
*/
public static String parseElementText(XmlPullParser parser) throws XmlPullParserException, IOException {
assert parser.getEventType() == XmlPullParser.Event.START_ELEMENT;
assert (parser.getEventType() == XmlPullParser.Event.START_ELEMENT);
String res;
// Advance to the text of the Element
XmlPullParser.Event event = parser.next();
@ -263,7 +263,7 @@ public class PacketParserUtils {
public static CharSequence parseElement(XmlPullParser parser,
boolean fullNamespaces) throws XmlPullParserException,
IOException {
assert parser.getEventType() == XmlPullParser.Event.START_ELEMENT;
assert (parser.getEventType() == XmlPullParser.Event.START_ELEMENT);
return parseContentDepth(parser, parser.getDepth(), fullNamespaces);
}
@ -631,7 +631,7 @@ public class PacketParserUtils {
*/
public static Compress.Feature parseCompressionFeature(XmlPullParser parser)
throws IOException, XmlPullParserException {
assert parser.getEventType() == XmlPullParser.Event.START_ELEMENT;
assert (parser.getEventType() == XmlPullParser.Event.START_ELEMENT);
String name;
final int initialDepth = parser.getDepth();
List<String> methods = new LinkedList<>();
@ -660,8 +660,8 @@ public class PacketParserUtils {
break;
}
}
assert parser.getEventType() == XmlPullParser.Event.END_ELEMENT;
assert parser.getDepth() == initialDepth;
assert (parser.getEventType() == XmlPullParser.Event.END_ELEMENT);
assert (parser.getDepth() == initialDepth);
return new Compress.Feature(methods);
}
@ -679,7 +679,7 @@ public class PacketParserUtils {
String text = parser.nextText();
String previousValue = descriptiveTexts.put(xmllang, text);
assert previousValue == null;
assert (previousValue == null);
return descriptiveTexts;
}
@ -704,7 +704,7 @@ public class PacketParserUtils {
descriptiveTexts = parseDescriptiveTexts(parser, descriptiveTexts);
}
else {
assert condition == null;
assert (condition == null);
condition = parser.getName();
}
break;
@ -875,8 +875,8 @@ public class PacketParserUtils {
public static StartTls parseStartTlsFeature(XmlPullParser parser)
throws XmlPullParserException, IOException {
ParserUtils.assertAtStartTag(parser);
assert parser.getNamespace().equals(StartTls.NAMESPACE);
assert (parser.getEventType() == XmlPullParser.Event.START_ELEMENT);
assert (parser.getNamespace().equals(StartTls.NAMESPACE));
int initalDepth = parser.getDepth();
boolean required = false;
outerloop: while (true) {
@ -900,7 +900,7 @@ public class PacketParserUtils {
break;
}
}
ParserUtils.assertAtEndTag(parser);
assert (parser.getEventType() == XmlPullParser.Event.END_ELEMENT);
return new StartTls(required);
}

View file

@ -50,7 +50,7 @@ public class ParserUtils {
public static final String JID = "jid";
public static void assertAtStartTag(XmlPullParser parser) throws XmlPullParserException {
assert parser.getEventType() == XmlPullParser.Event.START_ELEMENT;
assert (parser.getEventType() == XmlPullParser.Event.START_ELEMENT);
}
public static void assertAtStartTag(XmlPullParser parser, String name) throws XmlPullParserException {
@ -59,7 +59,7 @@ public class ParserUtils {
}
public static void assertAtEndTag(XmlPullParser parser) throws XmlPullParserException {
assert parser.getEventType() == XmlPullParser.Event.END_ELEMENT;
assert (parser.getEventType() == XmlPullParser.Event.END_ELEMENT);
}
public static void forwardToEndTagOfDepth(XmlPullParser parser, int depth)

View file

@ -1,53 +0,0 @@
/**
*
* Copyright 2019 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smack.util;
import java.lang.reflect.InvocationTargetException;
import java.security.Provider;
import java.security.Security;
import org.jxmpp.util.cache.LruCache;
public class SecurityUtil {
private static final LruCache<Class<? extends Provider>, Void> INSERTED_PROVIDERS_CACHE = new LruCache<>(8);
public static void ensureProviderAtFirstPosition(Class<? extends Provider> providerClass) {
if (INSERTED_PROVIDERS_CACHE.containsKey(providerClass)) {
return;
}
Provider provider;
try {
provider = providerClass.getDeclaredConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) {
throw new IllegalArgumentException(e);
}
String providerName = provider.getName();
int installedPosition ;
synchronized (Security.class) {
Security.removeProvider(providerName);
installedPosition = Security.insertProviderAt(provider, 1);
}
assert installedPosition == 1;
INSERTED_PROVIDERS_CACHE.put(providerClass, null);
}
}

View file

@ -110,6 +110,7 @@ public class StringUtils {
forAttribute,
forAttributeApos,
forText,
;
}
/**

View file

@ -180,7 +180,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
}
public XmlStringBuilder halfOpenElement(String name) {
assert StringUtils.isNotEmpty(name);
assert (StringUtils.isNotEmpty(name));
sb.append('<').append(name);
return this;
}

View file

@ -111,7 +111,7 @@ public class HostAddress {
public void setException(InetAddress inetAddress, Exception exception) {
Exception old = exceptions.put(inetAddress, exception);
assert old == null;
assert (old == null);
}
/**

View file

@ -114,14 +114,14 @@ public class SmackTestUtil {
public static XmlPullParser getParserFor(String xml, QName startTagQName, XmlPullParserKind parserKind)
throws XmlPullParserException, IOException {
XmlPullParser parser = getParserFor(xml, parserKind);
forwardParserToStartElement(parser, p -> p.getQName().equals(startTagQName));
forwardParserToStartElement(parser, (p) -> p.getQName().equals(startTagQName));
return parser;
}
public static XmlPullParser getParserFor(String xml, String startTagLocalpart, XmlPullParserKind parserKind)
throws XmlPullParserException, IOException {
XmlPullParser parser = getParserFor(xml, parserKind);
forwardParserToStartElement(parser, p -> p.getName().equals(startTagLocalpart));
forwardParserToStartElement(parser, (p) -> p.getName().equals(startTagLocalpart));
return parser;
}

View file

@ -138,7 +138,7 @@ public final class CarbonManager extends Manager {
// also reset here.
enabled_state = false;
boolean removed = connection().removeSyncStanzaListener(carbonsListener);
assert removed;
assert (removed);
}
@Override
public void authenticated(XMPPConnection connection, boolean resumed) {

View file

@ -62,7 +62,7 @@ public final class EligibleForChatMarkerFilter extends StanzaExtensionFilter {
ChatState state;
try {
state = ChatState.valueOf(chatStateElementName);
return state == ChatState.active;
return (state == ChatState.active);
}
catch (Exception ex) {
return false;

View file

@ -35,6 +35,7 @@ import static org.jivesoftware.smackx.hashes.HashManager.ALGORITHM.SHA_512;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.Security;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@ -42,7 +43,7 @@ import java.util.WeakHashMap;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.util.SecurityUtil;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.hashes.element.HashElement;
@ -57,9 +58,7 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
public final class HashManager extends Manager {
static {
// Remove any BC providers and add a fresh one.
// This is done, since older Android versions ship with a crippled BC provider.
SecurityUtil.ensureProviderAtFirstPosition(BouncyCastleProvider.class);
Security.addProvider(new BouncyCastleProvider());
}
public static final String PREFIX_NS_ALGO = "urn:xmpp:hash-function-text-names:";

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2017-2019 Florian Schmaus
* Copyright 2017 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,5 +22,6 @@ public enum MessageProcessingHintType {
no_store,
no_copy,
store,
;
}

View file

@ -134,7 +134,7 @@ public final class HttpFileUploadManager extends Manager {
}
private static UploadService uploadServiceFrom(DiscoverInfo discoverInfo) {
assert containsHttpFileUploadNamespace(discoverInfo);
assert (containsHttpFileUploadNamespace(discoverInfo));
UploadService.Version version;
if (discoverInfo.containsFeature(NAMESPACE)) {

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2016-2019 Florian Schmaus
* Copyright 2016 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -316,7 +316,7 @@ public final class IoTProvisioningManager extends Manager {
return null;
}
Jid jid = discoverInfos.get(0).getFrom();
assert jid.isDomainBareJid();
assert (jid.isDomainBareJid());
return jid.asDomainBareJid();
}
@ -341,7 +341,7 @@ public final class IoTProvisioningManager extends Manager {
IoTIsFriend iotIsFriend = new IoTIsFriend(friendInQuestion);
iotIsFriend.setTo(provisioningServer);
IoTIsFriendResponse response = connection().createStanzaCollectorAndSend(iotIsFriend).nextResultOrThrow();
assert response.getJid().equals(friendInQuestion);
assert (response.getJid().equals(friendInQuestion));
boolean isFriend = response.getIsFriendResult();
if (!isFriend) {
// Cache the negative is friend response.

View file

@ -39,6 +39,7 @@ public class MamPrefsIQ extends IQ {
always,
never,
roster,
;
}
/**

View file

@ -48,7 +48,7 @@ public class MamResultFilter extends FlexibleStanzaTypeFilter<Message> {
}
String resultQueryId = mamResultExtension.getQueryId();
return (queryId == null && resultQueryId == null) || (queryId != null && queryId.equals(resultQueryId));
return ((queryId == null && resultQueryId == null) || (queryId != null && queryId.equals(resultQueryId)));
}
}

View file

@ -65,7 +65,7 @@ public class AbstractHttpOverXmppProviderTest {
IQ iq = provider.parse(parser);
assertTrue(iq instanceof HttpOverXmppResp);
HttpOverXmppResp body = (HttpOverXmppResp) iq;
HttpOverXmppResp body = ((HttpOverXmppResp) iq);
checkHeaders(body.getHeaders(), expectedHeaders);
}
@ -85,7 +85,7 @@ public class AbstractHttpOverXmppProviderTest {
IQ iq = provider.parse(parser);
assertTrue(iq instanceof HttpOverXmppReq);
HttpOverXmppReq body = (HttpOverXmppReq) iq;
HttpOverXmppReq body = ((HttpOverXmppReq) iq);
checkHeaders(body.getHeaders(), expectedHeaders);
}

View file

@ -79,7 +79,7 @@ public class ServiceAdministrationManager extends Manager {
answerForm.setAnswer("password-verify", password);
command.execute(answerForm);
assert command.isCompleted();
assert (command.isCompleted());
}
public RemoteCommand deleteUser() {
@ -106,6 +106,6 @@ public class ServiceAdministrationManager extends Manager {
answerForm.setAnswer("accountjids", jidsToDelete);
command.execute(answerForm);
assert command.isCompleted();
assert (command.isCompleted());
}
}

View file

@ -82,7 +82,7 @@ public class BoBData {
private void setContentBinaryIfRequired() {
if (contentBinary == null) {
assert StringUtils.isNotEmpty(contentString);
assert (StringUtils.isNotEmpty(contentString));
contentBinary = Base64.decode(contentString);
}
}

View file

@ -757,7 +757,7 @@ public class InBandBytestreamSession implements BytestreamSession {
bufferPointer = 0;
// increment sequence, considering sequence overflow
this.seq = this.seq + 1 == 65535 ? 0 : this.seq + 1;
this.seq = (this.seq + 1 == 65535 ? 0 : this.seq + 1);
}

View file

@ -33,7 +33,7 @@ public abstract class AbstractDelayInformationProvider extends ExtensionElementP
public final DelayInformation parse(XmlPullParser parser,
int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException,
IOException, SmackTextParseException {
String stampString = parser.getAttributeValue("", "stamp");
String stampString = (parser.getAttributeValue("", "stamp"));
String from = parser.getAttributeValue("", "from");
final String reason;
XmlPullParser.Event event = parser.next();

View file

@ -79,7 +79,7 @@ public class DiscoverInfoProvider extends IQProvider<DiscoverInfo> {
if (parser.getName().equals("feature")) {
// Create a new feature and add it to the discovered info.
boolean notADuplicateFeature = discoverInfo.addFeature(variable);
assert notADuplicateFeature;
assert (notADuplicateFeature);
}
if (parser.getName().equals("query")) {
done = true;

View file

@ -73,7 +73,7 @@ public final class FileTransferNegotiator extends Manager {
* set this variable to true for testing purposes as IBB is the backup file transfer method
* and shouldn't be used as the only transfer method in production systems.
*/
public static boolean IBB_ONLY = System.getProperty("ibb") != null;//true;
public static boolean IBB_ONLY = (System.getProperty("ibb") != null);//true;
/**
* Returns the file transfer negotiator related to a particular connection.

View file

@ -214,7 +214,7 @@ public final class LastActivityManager extends Manager {
private long getIdleTime() {
long lms = lastMessageSent;
long now = System.currentTimeMillis();
return (now - lms) / 1000;
return ((now - lms) / 1000);
}
/**

View file

@ -19,4 +19,5 @@ package org.jivesoftware.smackx.jingle;
public enum Role {
initiator,
responder,
;
}

View file

@ -90,7 +90,7 @@ public class MediaElement implements FormFieldChildElement {
xml.append(uris, xmlEnvironment);
xml.closeElement(this);
return xml;
return null;
}
public MediaElement from(FormField formField) {

View file

@ -208,7 +208,7 @@ public class RoomInfo {
FormField subjectmodField = form.getField("muc#roominfo_subjectmod");
if (subjectmodField != null && !subjectmodField.getValues().isEmpty()) {
String firstValue = subjectmodField.getFirstValue();
subjectmod = "true".equals(firstValue) || "1".equals(firstValue);
subjectmod = ("true".equals(firstValue) || "1".equals(firstValue));
}
FormField urlField = form.getField("muc#roominfo_logs");

View file

@ -104,9 +104,9 @@ public final class PepManager extends Manager {
public void processStanza(Stanza stanza) {
final Message message = (Message) stanza;
final EventElement event = EventElement.from(stanza);
assert event != null;
assert (event != null);
final EntityBareJid from = message.getFrom().asEntityBareJidIfPossible();
assert from != null;
assert (from != null);
asyncButOrdered.performAsyncButOrdered(from, new Runnable() {
@Override
public void run() {

View file

@ -37,5 +37,5 @@ public enum AccessModel {
roster,
/** Only those on a whitelist may subscribe and retrieve items. */
whitelist,
whitelist;
}

View file

@ -167,7 +167,7 @@ public class Affiliation implements ExtensionElement {
*/
public boolean isAffiliationModification() {
if (jid != null && affiliation != null) {
assert node == null && namespace == AffiliationNamespace.owner;
assert (node == null && namespace == AffiliationNamespace.owner);
return true;
}
return false;

View file

@ -30,5 +30,5 @@ public enum ChildrenAssociationPolicy {
owners,
/** Only those on a whitelist may associate leaf nodes with the collection. */
whitelist,
whitelist;
}

View file

@ -50,6 +50,6 @@ public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketE
if (getConfiguration() == null)
return Collections.emptyList();
else
return Arrays.asList((ExtensionElement) getConfiguration().getDataFormToSend());
return Arrays.asList(((ExtensionElement) getConfiguration().getDataFormToSend()));
}
}

View file

@ -19,7 +19,6 @@ package org.jivesoftware.smackx.pubsub;
import java.util.ArrayList;
import java.util.List;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
@ -247,7 +246,7 @@ public class ConfigureForm extends Form {
* @return true if it does, false otherwise
*/
public boolean isDeliverPayloads() {
return ParserUtils.parseXmlBoolean(getFieldValue(ConfigureNodeFields.deliver_payloads));
return parseBoolean(getFieldValue(ConfigureNodeFields.deliver_payloads));
}
/**
@ -354,7 +353,7 @@ public class ConfigureForm extends Form {
* @return true if they should be notified, false otherwise
*/
public boolean isNotifyConfig() {
return ParserUtils.parseXmlBoolean(getFieldValue(ConfigureNodeFields.notify_config));
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_config));
}
/**
@ -373,7 +372,7 @@ public class ConfigureForm extends Form {
* @return true if subscribers should be notified, false otherwise
*/
public boolean isNotifyDelete() {
return ParserUtils.parseXmlBoolean(getFieldValue(ConfigureNodeFields.notify_delete));
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_delete));
}
/**
@ -393,7 +392,7 @@ public class ConfigureForm extends Form {
* @return true if subscribers should be notified, false otherwise
*/
public boolean isNotifyRetract() {
return ParserUtils.parseXmlBoolean(getFieldValue(ConfigureNodeFields.notify_retract));
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_retract));
}
/**
@ -437,7 +436,7 @@ public class ConfigureForm extends Form {
* @return true if items are persisted
*/
public boolean isPersistItems() {
return ParserUtils.parseXmlBoolean(getFieldValue(ConfigureNodeFields.persist_items));
return parseBoolean(getFieldValue(ConfigureNodeFields.persist_items));
}
/**
@ -456,7 +455,7 @@ public class ConfigureForm extends Form {
* @return true if users must be available
*/
public boolean isPresenceBasedDelivery() {
return ParserUtils.parseXmlBoolean(getFieldValue(ConfigureNodeFields.presence_based_delivery));
return parseBoolean(getFieldValue(ConfigureNodeFields.presence_based_delivery));
}
/**
@ -567,7 +566,7 @@ public class ConfigureForm extends Form {
* @return true if subscriptions are allowed, false otherwise
*/
public boolean isSubscribe() {
return ParserUtils.parseXmlBoolean(getFieldValue(ConfigureNodeFields.subscribe));
return parseBoolean(getFieldValue(ConfigureNodeFields.subscribe));
}
/**
@ -646,6 +645,10 @@ public class ConfigureForm extends Form {
return result.toString();
}
private static boolean parseBoolean(String fieldValue) {
return ("1".equals(fieldValue) || "true".equals(fieldValue));
}
private String getFieldValue(ConfigureNodeFields field) {
FormField formField = getField(field.getFieldName());

View file

@ -96,7 +96,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent {
* @return true if the items are delayed, false otherwise.
*/
public boolean isDelayed() {
return originalDate != null;
return (originalDate != null);
}
/**

View file

@ -305,7 +305,7 @@ public class LeafNode extends Node {
@SuppressWarnings("unchecked")
public <T extends Item> void publish(T item) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Collection<T> items = new ArrayList<>(1);
items.add(item == null ? (T) new Item() : item);
items.add((item == null ? (T) new Item() : item));
publish(items);
}

View file

@ -70,7 +70,7 @@ public enum PubSubElementType {
public static PubSubElementType valueOfFromElemName(String elemName, String namespace) {
int index = namespace.lastIndexOf('#');
String fragment = index == -1 ? null : namespace.substring(index + 1);
String fragment = (index == -1 ? null : namespace.substring(index + 1));
if (fragment != null) {
return valueOf((elemName + '_' + fragment).toUpperCase(Locale.US));

View file

@ -23,7 +23,6 @@ import java.util.Date;
import java.util.List;
import java.util.UnknownFormatConversionException;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
@ -59,7 +58,7 @@ public class SubscribeForm extends Form {
* @return true if want to receive, false otherwise
*/
public boolean isDeliverOn() {
return ParserUtils.parseXmlBoolean(getFieldValue(SubscribeOptionFields.deliver));
return parseBoolean(getFieldValue(SubscribeOptionFields.deliver));
}
/**
@ -78,7 +77,7 @@ public class SubscribeForm extends Form {
* @return true to aggregate, false otherwise
*/
public boolean isDigestOn() {
return ParserUtils.parseXmlBoolean(getFieldValue(SubscribeOptionFields.digest));
return parseBoolean(getFieldValue(SubscribeOptionFields.digest));
}
/**
@ -144,7 +143,7 @@ public class SubscribeForm extends Form {
* @return true to receive the message body, false otherwise
*/
public boolean isIncludeBody() {
return ParserUtils.parseXmlBoolean(getFieldValue(SubscribeOptionFields.include_body));
return parseBoolean(getFieldValue(SubscribeOptionFields.include_body));
}
/**
@ -189,6 +188,11 @@ public class SubscribeForm extends Form {
setAnswer(SubscribeOptionFields.show_values.getFieldName(), values);
}
private static boolean parseBoolean(String fieldValue) {
return ("1".equals(fieldValue) || "true".equals(fieldValue));
}
private String getFieldValue(SubscribeOptionFields field) {
FormField formField = getField(field.getFieldName());

View file

@ -55,7 +55,7 @@ public class SubscriptionProvider extends ExtensionElementProvider<Subscription>
while (tag != XmlPullParser.Event.END_ELEMENT && !parser.getName().equals("subscribe-options")) tag = parser.next();
}
while (parser.getEventType() != XmlPullParser.Event.END_ELEMENT) parser.next();
return new Subscription(jid, nodeId, subId, state == null ? null : Subscription.State.valueOf(state), isRequired);
return new Subscription(jid, nodeId, subId, (state == null ? null : Subscription.State.valueOf(state)), isRequired);
}
}

View file

@ -309,7 +309,7 @@ public final class DeliveryReceiptManager extends Manager {
* @return true if a delivery receipt was requested
*/
public static boolean hasDeliveryReceiptRequest(Message message) {
return DeliveryReceiptRequest.from(message) != null;
return (DeliveryReceiptRequest.from(message) != null);
}
/**

View file

@ -26,7 +26,7 @@ public class MucMemoryLeakTest extends SmackTestSuite {
@Test
public void mucMemoryLeakTest() throws XmppStringprepException, IllegalArgumentException, InterruptedException {
MemoryLeakTestUtil.noResourceLeakTest(c -> MultiUserChatManager.getInstanceFor(c));
MemoryLeakTestUtil.noResourceLeakTest((c) -> MultiUserChatManager.getInstanceFor(c));
}
}

View file

@ -103,7 +103,7 @@ public final class ChatManager extends Manager{
* Will attempt to match on the JID in the from field, and then attempt the base JID if no match was found.
* This is the most lenient matching.
*/
BARE_JID,
BARE_JID;
}
private final StanzaFilter packetFilter = new OrFilter(MessageTypeFilter.CHAT, new FlexibleStanzaTypeFilter<Message>() {

View file

@ -1570,7 +1570,7 @@ public final class Roster extends Manager {
else {
fullFrom = from.asFullJidIfPossible();
// We know that this must be a full JID in this case.
assert fullFrom != null;
assert (fullFrom != null);
}
}
Map<Resourcepart, Presence> userPresences;

View file

@ -123,7 +123,7 @@ public final class RosterEntry extends Manager {
* @param item new item
*/
void updateItem(RosterPacket.Item item) {
assert item != null;
assert (item != null);
this.item = item;
}

View file

@ -113,7 +113,7 @@ public class RosterPacketProvider extends IQProvider<RosterPacket> {
}
}
ParserUtils.assertAtEndTag(parser);
assert item != null;
assert (item != null);
return item;
}
}

View file

@ -149,7 +149,7 @@ public final class Configuration {
this.disabledTests = disabledTests;
this.testPackages = testPackages;
this.configurationApplier = builder -> {
this.configurationApplier = (builder) -> {
if (tlsContext != null) {
builder.setCustomSSLContext(tlsContext);
}

View file

@ -592,7 +592,7 @@ public class SmackIntegrationTestFramework<DC extends AbstractXMPPConnection> {
}
final String className = clz.getName();
final String unqualifiedClassName = clz.getSimpleName();
return classes.contains(className) || classes.contains(unqualifiedClassName);
return (classes.contains(className) || classes.contains(unqualifiedClassName));
}
public static final class TestRunResult {
@ -709,7 +709,7 @@ public class SmackIntegrationTestFramework<DC extends AbstractXMPPConnection> {
this.testMethod = testMethod;
smackIntegrationTestAnnotation = testMethod.getAnnotation(SmackIntegrationTest.class);
assert smackIntegrationTestAnnotation != null;
assert (smackIntegrationTestAnnotation != null);
parameterListOfConnections = testMethodParametersIsListOfConnections(testMethod);
}

View file

@ -28,7 +28,7 @@ public abstract class TestResult {
public TestResult(SmackIntegrationTestFramework.ConcreteTest concreteTest, long startTime, long endTime, List<String> logMessages) {
this.concreteTest = concreteTest;
assert endTime >= startTime;
assert (endTime >= startTime);
this.startTime = startTime;
this.endTime = endTime;
this.duration = endTime - startTime;

View file

@ -283,7 +283,7 @@ public class XmppConnectionManager<DC extends AbstractXMPPConnection> {
registerAccount(finalAccountUsername, finalAccountPassword);
}
DC mainConnection = defaultConnectionDescriptor.construct(sinttestConfiguration, builder -> {
DC mainConnection = defaultConnectionDescriptor.construct(sinttestConfiguration, (builder) -> {
try {
builder.setUsernameAndPassword(finalAccountUsername, finalAccountPassword)
.setResource(middlefix + '-' + testRunId);
@ -398,7 +398,7 @@ public class XmppConnectionManager<DC extends AbstractXMPPConnection> {
throw new IllegalArgumentException(e);
}
ConnectionConfigurationBuilderApplier usernameAndPasswordApplier = configurationBuilder -> {
ConnectionConfigurationBuilderApplier usernameAndPasswordApplier = (configurationBuilder) -> {
configurationBuilder.setUsernameAndPassword(username, password);
};

View file

@ -354,7 +354,7 @@ public class MediaNegotiator extends JingleNegotiator {
* @return true if the content is fully negotiated.
*/
public boolean isFullyEstablished() {
return isEstablished() && ((getNegotiatorState() == JingleNegotiatorState.SUCCEEDED) || (getNegotiatorState() == JingleNegotiatorState.FAILED));
return (isEstablished() && ((getNegotiatorState() == JingleNegotiatorState.SUCCEEDED) || (getNegotiatorState() == JingleNegotiatorState.FAILED)));
}
// Payload types

View file

@ -164,7 +164,7 @@ public class ImageTransmitter implements Runnable {
}
}
trace = System.currentTimeMillis() - trace;
trace = (System.currentTimeMillis() - trace);
LOGGER.fine("Loop Time:" + trace);
if (trace < 500) {

View file

@ -648,7 +648,7 @@ public abstract class TransportCandidate {
this.id = session.getSid();
this.candidate = candidate;
int keySplitIndex = (int) Math.ceil(((float) id.length()) / 2);
int keySplitIndex = ((int) Math.ceil(((float) id.length()) / 2));
String local = id.substring(0, keySplitIndex) + ";" + localUser;
String remote = id.substring(keySplitIndex) + ";" + remoteUser;

View file

@ -281,7 +281,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
* @return true if the transport is fully established.
*/
public final boolean isFullyEstablished() {
return isEstablished() && ((getNegotiatorState() == JingleNegotiatorState.SUCCEEDED) || (getNegotiatorState() == JingleNegotiatorState.FAILED));
return (isEstablished() && ((getNegotiatorState() == JingleNegotiatorState.SUCCEEDED) || (getNegotiatorState() == JingleNegotiatorState.FAILED)));
}
/**
@ -303,7 +303,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
// Sleep for some time, waiting for the candidates checks
int totalTime = CANDIDATES_ACCEPT_PERIOD + TransportResolver.CHECK_TIMEOUT;
int totalTime = (CANDIDATES_ACCEPT_PERIOD + TransportResolver.CHECK_TIMEOUT);
int tries = (int) Math.ceil(totalTime / 1000);
for (int i = 0; i < tries - 1; i++) {

View file

@ -78,7 +78,7 @@ public class OfflineSettings extends SimpleIQ {
}
public boolean redirects() {
return StringUtils.isNotEmpty(getRedirectURL());
return (StringUtils.isNotEmpty(getRedirectURL()));
}
public boolean isConfigured() {

View file

@ -149,8 +149,8 @@ public class SignalOmemoRatchet
}
// TODO: Figure out, if this is enough...
int type = ciphertextMessage.getType() == CiphertextMessage.PREKEY_TYPE ?
OmemoElement.TYPE_OMEMO_PREKEY_MESSAGE : OmemoElement.TYPE_OMEMO_MESSAGE;
int type = (ciphertextMessage.getType() == CiphertextMessage.PREKEY_TYPE ?
OmemoElement.TYPE_OMEMO_PREKEY_MESSAGE : OmemoElement.TYPE_OMEMO_MESSAGE);
return new CiphertextTuple(ciphertextMessage.serialize(), type);
}

View file

@ -135,7 +135,7 @@ public class SignalOmemoStoreConnector
@Override
public boolean containsPreKey(int i) {
try {
return loadPreKey(i) != null;
return (loadPreKey(i) != null);
} catch (InvalidKeyIdException e) {
return false;
}

View file

@ -113,7 +113,7 @@ public abstract class FileBasedOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigP
SortedSet<Integer> deviceIds = new TreeSet<>();
File userDir = hierarchy.getUserDirectory(localUser);
File[] list = userDir.listFiles();
for (File d : list != null ? list : new File[] {}) {
for (File d : (list != null ? list : new File[] {})) {
if (d.isDirectory()) {
try {
deviceIds.add(Integer.parseInt(d.getName()));

View file

@ -17,9 +17,6 @@
package org.jivesoftware.smackx.omemo;
import org.jivesoftware.smack.initializer.UrlInitializer;
import org.jivesoftware.smack.util.SecurityUtil;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
/**
* Initializer class that registers omemo providers.
@ -29,12 +26,6 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
@SuppressWarnings("unused")
public class OmemoInitializer extends UrlInitializer {
static {
// Remove any BC providers and add a fresh one.
// This is done, since older Android versions ship with a crippled BC provider.
SecurityUtil.ensureProviderAtFirstPosition(BouncyCastleProvider.class);
}
@Override
protected String getProvidersUri() {
return "classpath:org.jivesoftware.smackx.omemo/omemo.providers";

View file

@ -22,6 +22,7 @@ import static org.jivesoftware.smackx.omemo.util.OmemoConstants.Crypto.KEYTYPE;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.Security;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -44,6 +45,7 @@ import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smackx.carbons.packet.CarbonExtension;
import org.jivesoftware.smackx.mam.MamManager;
import org.jivesoftware.smackx.muc.MultiUserChat;
@ -78,6 +80,7 @@ import org.jivesoftware.smackx.pubsub.PayloadItem;
import org.jivesoftware.smackx.pubsub.PubSubException;
import org.jivesoftware.smackx.pubsub.PubSubManager;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.jxmpp.jid.BareJid;
import org.jxmpp.jid.EntityBareJid;
import org.jxmpp.jid.Jid;
@ -99,6 +102,10 @@ import org.jxmpp.jid.Jid;
public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>
implements OmemoCarbonCopyStanzaReceivedListener, OmemoMessageStanzaReceivedListener {
static {
Security.addProvider(new BouncyCastleProvider());
}
protected static final Logger LOGGER = Logger.getLogger(OmemoService.class.getName());
private static final long MILLIS_PER_HOUR = 1000L * 60 * 60;

View file

@ -25,20 +25,21 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import java.security.NoSuchAlgorithmException;
import java.security.Security;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smackx.omemo.element.OmemoElement;
import org.jivesoftware.smackx.omemo.exceptions.CryptoFailedException;
import org.jivesoftware.smackx.omemo.internal.CipherAndAuthTag;
import org.jivesoftware.smackx.omemo.internal.CiphertextTuple;
import org.jivesoftware.smackx.omemo.util.OmemoMessageBuilder;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.Test;
/**
* Test the identityKeyWrapper.
*/
public class WrapperObjectsTest extends SmackTestSuite {
public class WrapperObjectsTest {
@Test
public void ciphertextTupleTest() {
@ -55,6 +56,7 @@ public class WrapperObjectsTest extends SmackTestSuite {
@Test
public void cipherAndAuthTagTest() throws NoSuchAlgorithmException, CryptoFailedException {
Security.addProvider(new BouncyCastleProvider());
byte[] key = OmemoMessageBuilder.generateKey(KEYTYPE, KEYLENGTH);
byte[] iv = OmemoMessageBuilder.generateIv();
byte[] authTag = OmemoMessageBuilder.generateIv();

View file

@ -12,7 +12,7 @@ dependencies {
compile project(':smack-extensions')
compile project(':smack-experimental')
compile 'org.pgpainless:pgpainless-core:0.0.1-alpha7'
compile 'org.pgpainless:pgpainless-core:0.0.1-alpha4'
testCompile project(path: ":smack-core", configuration: "testRuntime")
testCompile project(path: ":smack-core", configuration: "archives")

View file

@ -60,6 +60,7 @@ public class OpenPgpMessage {
* Represents a {@link CryptElement}.
*/
crypt,
;
}
private final String element;

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.ox.crypto;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.Security;
import java.util.ArrayList;
import java.util.Collection;
import java.util.logging.Level;
@ -37,6 +38,7 @@ import org.jivesoftware.smackx.ox.element.SignElement;
import org.jivesoftware.smackx.ox.element.SigncryptElement;
import org.jivesoftware.smackx.ox.store.definition.OpenPgpStore;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
@ -51,6 +53,13 @@ public class PainlessOpenPgpProvider implements OpenPgpProvider {
private static final Logger LOGGER = Logger.getLogger(PainlessOpenPgpProvider.class.getName());
static {
// Remove any BC providers and add a fresh one.
// This is done, since older Android versions ship with a crippled BC provider.
Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME);
Security.addProvider(new BouncyCastleProvider());
}
private final XMPPConnection connection;
private final OpenPgpStore store;

View file

@ -160,7 +160,7 @@ public abstract class OpenPgpContentElement implements ExtensionElement {
}
protected void addCommonXml(XmlStringBuilder xml) {
for (Jid toJid : to != null ? to : Collections.<Jid>emptySet()) {
for (Jid toJid : (to != null ? to : Collections.<Jid>emptySet())) {
xml.halfOpenElement(ELEM_TO).attribute(ATTR_JID, toJid).closeEmptyElement();
}

View file

@ -17,21 +17,12 @@
package org.jivesoftware.smackx.ox.util;
import org.jivesoftware.smack.initializer.UrlInitializer;
import org.jivesoftware.smack.util.SecurityUtil;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
/**
* Initializer class which registers ExtensionElementProviders on startup.
*/
public class OpenPgpInitializer extends UrlInitializer {
static {
// Remove any BC providers and add a fresh one.
// This is done, since older Android versions ship with a crippled BC provider.
SecurityUtil.ensureProviderAtFirstPosition(BouncyCastleProvider.class);
}
@Override
protected String getProvidersUri() {
return "classpath:org.jivesoftware.smackx.ox/openpgp.providers";

View file

@ -28,6 +28,7 @@ import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Security;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@ -44,6 +45,7 @@ import org.jivesoftware.smackx.ox.store.definition.OpenPgpStore;
import org.jivesoftware.smackx.ox.store.definition.OpenPgpTrustStore;
import org.jivesoftware.smackx.ox.store.filebased.FileBasedOpenPgpStore;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
@ -79,6 +81,7 @@ public class OpenPgpStoreTest extends SmackTestSuite {
static {
storagePath = FileTestUtil.getTempDir("storeTest");
Security.addProvider(new BouncyCastleProvider());
}
@Parameterized.Parameters

View file

@ -173,7 +173,7 @@ public class SASLDigestMD5Mechanism extends SASLMechanism {
String serverResponse = null;
for (String part : challengeParts) {
String[] keyValue = part.split("=");
assert keyValue.length == 2;
assert (keyValue.length == 2);
String key = keyValue[0];
String value = keyValue[1];
if ("rspauth".equals(key)) {

View file

@ -569,7 +569,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
int port = hostAddress.getPort();
if (proxyInfo == null) {
inetAddresses = hostAddress.getInetAddresses().iterator();
assert inetAddresses.hasNext();
assert (inetAddresses.hasNext());
innerloop: while (inetAddresses.hasNext()) {
// Create a *new* Socket before every connection attempt, i.e. connect() call, since Sockets are not

View file

@ -229,7 +229,7 @@ public class XmppNioTcpConnection extends AbstractXmppNioConnection {
notifyConnectionError(ise);
return;
}
assert config.getXMPPServiceDomain().equals(reportedServerDomain);
assert (config.getXMPPServiceDomain().equals(reportedServerDomain));
break;
case "xmlns":
streamOpen.append(" xmlns='").append(attributeValue).append('\'');
@ -513,7 +513,7 @@ public class XmppNioTcpConnection extends AbstractXmppNioConnection {
} else {
outgoingCharSequenceIterator = Collections.singletonList(nextCharSequence).iterator();
}
assert outgoingCharSequenceIterator != null;
assert (outgoingCharSequenceIterator != null);
} else {
// There is nothing more to write.
break;
@ -1067,6 +1067,7 @@ public class XmppNioTcpConnection extends AbstractXmppNioConnection {
initiated,
successful,
failed,
;
}
private static final Level SSL_ENGINE_DEBUG_LOG_LEVEL = Level.FINEST;
@ -1281,7 +1282,7 @@ public class XmppNioTcpConnection extends AbstractXmppNioConnection {
return null;
case BUFFER_OVERFLOW:
int applicationBufferSize = engine.getSession().getApplicationBufferSize();
assert peerAppData.remaining() < applicationBufferSize;
assert (peerAppData.remaining() < applicationBufferSize);
peerAppData = ByteBuffer.allocate(applicationBufferSize);
continue;
}

View file

@ -10,7 +10,7 @@ allprojects {
// - https://issues.igniterealtime.org/browse/SMACK-858
jxmppVersion = '0.7.0-alpha5'
miniDnsVersion = '0.4.0-alpha3'
bouncyCastleVersion = '1.62'
bouncyCastleVersion = '1.61'
smackMinAndroidSdk = 19
}
}