mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 20:42:06 +01:00
Cleanup code
This commit is contained in:
parent
e53165a96c
commit
e1655aa344
30 changed files with 92 additions and 109 deletions
|
@ -35,9 +35,9 @@ public abstract class AesGcmNoPadding {
|
|||
|
||||
private final int length;
|
||||
protected final Cipher cipher;
|
||||
protected final byte[] key, iv, keyAndIv;
|
||||
private final byte[] key, iv, keyAndIv;
|
||||
|
||||
protected AesGcmNoPadding(int bits, int MODE) throws NoSuchAlgorithmException, NoSuchProviderException,
|
||||
AesGcmNoPadding(int bits, int MODE) throws NoSuchAlgorithmException, NoSuchProviderException,
|
||||
NoSuchPaddingException, InvalidAlgorithmParameterException, InvalidKeyException {
|
||||
this.length = bits;
|
||||
int bytes = bits / 8;
|
||||
|
@ -136,7 +136,7 @@ public abstract class AesGcmNoPadding {
|
|||
|
||||
public abstract String getNamespace();
|
||||
|
||||
public static byte[] copyOfRange(byte[] source, int start, int end) {
|
||||
static byte[] copyOfRange(byte[] source, int start, int end) {
|
||||
byte[] copy = new byte[end - start];
|
||||
System.arraycopy(source, start, copy, 0, end - start);
|
||||
return copy;
|
||||
|
|
|
@ -52,19 +52,19 @@ public class JetSecurity extends JingleSecurity<JetSecurityElement> {
|
|||
private final String methodNamespace;
|
||||
|
||||
private AesGcmNoPadding aesKey;
|
||||
private ExtensionElement child;
|
||||
private String cipherName;
|
||||
private String name;
|
||||
private final ExtensionElement child;
|
||||
private final String cipherName;
|
||||
private final String contentName;
|
||||
|
||||
public JetSecurity(JetSecurityElement element) {
|
||||
super();
|
||||
this.child = element.getChild();
|
||||
this.methodNamespace = element.getMethodNamespace();
|
||||
this.name = element.getName();
|
||||
this.contentName = element.getContentName();
|
||||
this.cipherName = element.getCipherName();
|
||||
}
|
||||
|
||||
public JetSecurity(JingleEncryptionMethod method, FullJid recipient, String name, String cipherName)
|
||||
public JetSecurity(JingleEncryptionMethod method, FullJid recipient, String contentName, String cipherName)
|
||||
throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException,
|
||||
InvalidAlgorithmParameterException, InvalidKeyException, InterruptedException,
|
||||
JingleEncryptionMethod.JingleEncryptionException, SmackException.NotConnectedException,
|
||||
|
@ -73,11 +73,11 @@ public class JetSecurity extends JingleSecurity<JetSecurityElement> {
|
|||
this.methodNamespace = method.getNamespace();
|
||||
this.aesKey = AesGcmNoPadding.createEncryptionKey(cipherName);
|
||||
this.child = method.encryptJingleTransfer(recipient, aesKey.getKeyAndIv());
|
||||
this.name = name;
|
||||
this.contentName = contentName;
|
||||
this.cipherName = cipherName;
|
||||
}
|
||||
|
||||
public void decryptEncryptionKey(JingleEncryptionMethod method, FullJid sender)
|
||||
private void decryptEncryptionKey(JingleEncryptionMethod method, FullJid sender)
|
||||
throws InterruptedException, JingleEncryptionMethod.JingleEncryptionException, XMPPException.XMPPErrorException,
|
||||
SmackException.NotConnectedException, SmackException.NoResponseException, NoSuchAlgorithmException,
|
||||
InvalidAlgorithmParameterException, NoSuchProviderException, InvalidKeyException, NoSuchPaddingException {
|
||||
|
@ -87,7 +87,7 @@ public class JetSecurity extends JingleSecurity<JetSecurityElement> {
|
|||
|
||||
@Override
|
||||
public JetSecurityElement getElement() {
|
||||
return new JetSecurityElement(name, cipherName, child);
|
||||
return new JetSecurityElement(contentName, cipherName, child);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -71,7 +71,7 @@ public class JetSecurityElement extends JingleContentSecurityElement {
|
|||
return child;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
public String getContentName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ import org.jxmpp.jid.FullJid;
|
|||
* Created by vanitas on 22.07.17.
|
||||
*/
|
||||
public final class JingleFileTransferManager extends Manager implements JingleDescriptionManager {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(JingleFileTransferManager.class.getName());
|
||||
|
||||
private static final WeakHashMap<XMPPConnection, JingleFileTransferManager> INSTANCES = new WeakHashMap<>();
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.jivesoftware.smackx.jingle_filetransfer.component;
|
|||
*/
|
||||
public abstract class AbstractJingleFileOffer<D extends JingleFileTransferFile> extends JingleFileTransfer {
|
||||
|
||||
public AbstractJingleFileOffer(D fileTransferFile) {
|
||||
AbstractJingleFileOffer(D fileTransferFile) {
|
||||
super(fileTransferFile);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.jivesoftware.smackx.jingle_filetransfer.component;
|
|||
*/
|
||||
public abstract class AbstractJingleFileRequest<D extends JingleFileTransferFile> extends JingleFileTransfer {
|
||||
|
||||
public AbstractJingleFileRequest(D fileTransferFile) {
|
||||
AbstractJingleFileRequest(D fileTransferFile) {
|
||||
super(fileTransferFile);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ public abstract class JingleFileTransfer extends JingleDescription<JingleFileTra
|
|||
protected State state;
|
||||
protected JingleFileTransferFile file;
|
||||
|
||||
protected final List<ProgressListener> progressListeners = Collections.synchronizedList(new ArrayList<ProgressListener>());
|
||||
private final List<ProgressListener> progressListeners = Collections.synchronizedList(new ArrayList<ProgressListener>());
|
||||
|
||||
public JingleFileTransfer(JingleFileTransferFile file) {
|
||||
JingleFileTransfer(JingleFileTransferFile file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,11 @@ public abstract class JingleFileTransfer extends JingleDescription<JingleFileTra
|
|||
progressListeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
//TODO
|
||||
}
|
||||
|
||||
public void notifyProgressListeners(float progress) {
|
||||
for (ProgressListener p : progressListeners) {
|
||||
p.progress(progress);
|
||||
|
|
|
@ -58,7 +58,7 @@ public abstract class JingleFileTransferFile {
|
|||
|
||||
public static class LocalFile extends JingleFileTransferFile {
|
||||
|
||||
private File file;
|
||||
private final File file;
|
||||
private String name;
|
||||
private String description;
|
||||
private String mediaType;
|
||||
|
@ -137,7 +137,7 @@ public abstract class JingleFileTransferFile {
|
|||
|
||||
public static class RemoteFile extends JingleFileTransferFile {
|
||||
|
||||
private JingleFileTransferChildElement file;
|
||||
private final JingleFileTransferChildElement file;
|
||||
|
||||
public RemoteFile(JingleFileTransferChildElement file) {
|
||||
super();
|
||||
|
|
|
@ -28,6 +28,8 @@ import org.jivesoftware.smack.XMPPException;
|
|||
* User interface for an incoming Jingle file offer.
|
||||
*/
|
||||
public interface IncomingFileOfferController extends JingleFileTransferController {
|
||||
|
||||
void accept(XMPPConnection connection, File target) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException, IOException;
|
||||
|
||||
void accept(XMPPConnection connection, OutputStream outputStream) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException, IOException;
|
||||
}
|
||||
|
|
|
@ -20,5 +20,5 @@ package org.jivesoftware.smackx.jingle_filetransfer.controller;
|
|||
* Created by vanitas on 27.07.17.
|
||||
*/
|
||||
public interface IncomingFileRequestController extends JingleFileTransferController {
|
||||
|
||||
//TODO: Declare methods.
|
||||
}
|
||||
|
|
|
@ -30,4 +30,6 @@ public interface JingleFileTransferController extends JingleDescriptionControlle
|
|||
void removeProgressListener(ProgressListener listener);
|
||||
|
||||
JingleFileTransferFile getFile();
|
||||
|
||||
void cancel();
|
||||
}
|
||||
|
|
|
@ -20,5 +20,5 @@ package org.jivesoftware.smackx.jingle_filetransfer.controller;
|
|||
* Created by vanitas on 27.07.17.
|
||||
*/
|
||||
public interface OutgoingFileOfferController extends JingleFileTransferController {
|
||||
|
||||
//TODO: Declare methods.
|
||||
}
|
||||
|
|
|
@ -20,4 +20,5 @@ package org.jivesoftware.smackx.jingle_filetransfer.controller;
|
|||
* Created by vanitas on 27.07.17.
|
||||
*/
|
||||
public interface OutgoingFileRequestController extends JingleFileTransferController {
|
||||
//TODO: Declare methods.
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.jivesoftware.smackx.jingle_filetransfer.component.JingleFileTransfer;
|
|||
* Checksum element.
|
||||
*/
|
||||
public class ChecksumElement implements ExtensionElement {
|
||||
|
||||
public static final String ELEMENT = "checksum";
|
||||
public static final String ATTR_CREATOR = "creator";
|
||||
public static final String ATTR_NAME = "name";
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildEleme
|
|||
* Content of type File.
|
||||
*/
|
||||
public class JingleFileTransferChildElement extends JingleContentDescriptionChildElement {
|
||||
|
||||
public static final String ELEMENT = "file";
|
||||
public static final String ELEM_DATE = "date";
|
||||
public static final String ELEM_DESC = "desc";
|
||||
|
@ -139,8 +140,8 @@ public class JingleFileTransferChildElement extends JingleContentDescriptionChil
|
|||
* This is a MIME type from this list:
|
||||
* https://www.iana.org/assignments/media-types/media-types.xhtml
|
||||
* Default should be application/octet-stream.
|
||||
* @param mediaType
|
||||
* @return
|
||||
* @param mediaType new media type.
|
||||
* @return builder.
|
||||
*/
|
||||
public Builder setMediaType(String mediaType) {
|
||||
this.mediaType = mediaType;
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
* Provider for the Checksum element.
|
||||
*/
|
||||
public class ChecksumProvider extends ExtensionElementProvider<ChecksumElement> {
|
||||
|
||||
@Override
|
||||
public ChecksumElement parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||
JingleContentElement.Creator creator = null;
|
||||
|
|
|
@ -45,7 +45,7 @@ public class JetElementTest extends SmackTestSuite {
|
|||
assertEquals(SecurityStub.NAMESPACE, security.getMethodNamespace());
|
||||
assertEquals(Aes128GcmNoPadding.NAMESPACE, element.getCipherName());
|
||||
assertEquals(SecurityStub.NAMESPACE, element.getMethodNamespace());
|
||||
assertEquals("content1", element.getName());
|
||||
assertEquals("content1", element.getContentName());
|
||||
|
||||
String xml = "<security xmlns='" + JetSecurity.NAMESPACE + "' " +
|
||||
"name='content1' " +
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017 Paul Schaub
|
||||
*
|
||||
* 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.smackx.jingle.callbacks;
|
||||
|
||||
import org.jivesoftware.smackx.jingle.JingleDescriptionController;
|
||||
|
||||
/**
|
||||
* Created by vanitas on 27.07.17.
|
||||
*/
|
||||
public interface JingleCallback<P extends JingleCallback.Parameters> {
|
||||
|
||||
JingleDescriptionController accept(P parameters);
|
||||
|
||||
void decline();
|
||||
|
||||
class Parameters {
|
||||
|
||||
}
|
||||
}
|
|
@ -56,8 +56,8 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
|||
|
||||
private JingleSession parent;
|
||||
private JingleContentElement.Creator creator;
|
||||
private String name;
|
||||
private String disposition;
|
||||
private final String name;
|
||||
private final String disposition;
|
||||
private JingleContentElement.Senders senders;
|
||||
private JingleDescription<?> description;
|
||||
private JingleTransport<?> transport;
|
||||
|
@ -120,6 +120,10 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
|||
return new JingleContent(description, transport, security, content.getName(), content.getDisposition(), content.getCreator(), content.getSenders());
|
||||
}
|
||||
|
||||
public void setSenders(JingleContentElement.Senders senders) {
|
||||
this.senders = senders;
|
||||
}
|
||||
|
||||
/* HANDLE_XYZ */
|
||||
|
||||
public IQ handleJingleRequest(JingleElement request, XMPPConnection connection) {
|
||||
|
@ -145,12 +149,12 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
|||
}
|
||||
}
|
||||
|
||||
public void handleContentAccept(JingleElement request, XMPPConnection connection) {
|
||||
void handleContentAccept(JingleElement request, XMPPConnection connection) {
|
||||
start(connection);
|
||||
}
|
||||
|
||||
|
||||
public IQ handleSessionAccept(JingleElement request, XMPPConnection connection) {
|
||||
IQ handleSessionAccept(JingleElement request, XMPPConnection connection) {
|
||||
LOGGER.log(Level.INFO, "RECEIVED SESSION ACCEPT!");
|
||||
JingleContentElement contentElement = null;
|
||||
for (JingleContentElement c : request.getContents()) {
|
||||
|
@ -169,26 +173,26 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
|||
return IQ.createResultIQ(request);
|
||||
}
|
||||
|
||||
public IQ handleContentModify(JingleElement request, XMPPConnection connection) {
|
||||
private IQ handleContentModify(JingleElement request, XMPPConnection connection) {
|
||||
return IQ.createErrorResponse(request, XMPPError.Condition.feature_not_implemented);
|
||||
}
|
||||
|
||||
public IQ handleDescriptionInfo(JingleElement request, XMPPConnection connection) {
|
||||
private IQ handleDescriptionInfo(JingleElement request, XMPPConnection connection) {
|
||||
return IQ.createErrorResponse(request, XMPPError.Condition.feature_not_implemented);
|
||||
}
|
||||
|
||||
public void handleContentRemove(JingleSession session, XMPPConnection connection) {
|
||||
}
|
||||
|
||||
public IQ handleSecurityInfo(JingleElement request, XMPPConnection connection) {
|
||||
private IQ handleSecurityInfo(JingleElement request, XMPPConnection connection) {
|
||||
return IQ.createErrorResponse(request, XMPPError.Condition.feature_not_implemented);
|
||||
}
|
||||
|
||||
public IQ handleSessionInfo(JingleElement request, XMPPConnection connection) {
|
||||
private IQ handleSessionInfo(JingleElement request, XMPPConnection connection) {
|
||||
return IQ.createResultIQ(request);
|
||||
}
|
||||
|
||||
public IQ handleTransportAccept(JingleElement request, XMPPConnection connection) {
|
||||
private IQ handleTransportAccept(JingleElement request, XMPPConnection connection) {
|
||||
|
||||
if (pendingReplacingTransport == null) {
|
||||
LOGGER.log(Level.WARNING, "Received transport-accept, but apparently we did not try to replace the transport.");
|
||||
|
@ -203,14 +207,14 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
|||
return IQ.createResultIQ(request);
|
||||
}
|
||||
|
||||
public IQ handleTransportInfo(JingleElement request, XMPPConnection connection) {
|
||||
private IQ handleTransportInfo(JingleElement request, XMPPConnection connection) {
|
||||
assert request.getContents().size() == 1;
|
||||
JingleContentElement content = request.getContents().get(0);
|
||||
|
||||
return transport.handleTransportInfo(content.getTransport().getInfo(), request);
|
||||
}
|
||||
|
||||
public IQ handleTransportReject(JingleElement request, XMPPConnection connection) {
|
||||
private IQ handleTransportReject(JingleElement request, XMPPConnection connection) {
|
||||
if (pendingReplacingTransport == null) {
|
||||
throw new AssertionError("We didn't try to replace the transport.");
|
||||
}
|
||||
|
@ -224,7 +228,7 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
|||
return IQ.createResultIQ(request);
|
||||
}
|
||||
|
||||
public IQ handleTransportReplace(final JingleElement request, final XMPPConnection connection) {
|
||||
private IQ handleTransportReplace(final JingleElement request, final XMPPConnection connection) {
|
||||
//Tie Break?
|
||||
if (pendingReplacingTransport != null) {
|
||||
Async.go(new Runnable() {
|
||||
|
@ -490,7 +494,7 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
|||
connection.createStanzaCollectorAndSend(transportReplace).nextResultOrThrow();
|
||||
}
|
||||
|
||||
public static String randomName() {
|
||||
private static String randomName() {
|
||||
return "cont-" + StringUtils.randomString(16);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -370,7 +370,7 @@ public class JingleSession {
|
|||
return content;
|
||||
}
|
||||
|
||||
private JingleContent getSoleProposedContentOrThrow(JingleElement request) {
|
||||
private static JingleContent getSoleProposedContentOrThrow(JingleElement request) {
|
||||
if (request.getContents().size() != 1) {
|
||||
throw new AssertionError("More/less than 1 content in request!");
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public enum JingleAction {
|
|||
transport_replace,
|
||||
;
|
||||
|
||||
private static final Map<String, JingleAction> map = new HashMap<String, JingleAction>(
|
||||
private static final Map<String, JingleAction> map = new HashMap<>(
|
||||
JingleAction.values().length);
|
||||
static {
|
||||
for (JingleAction jingleAction : JingleAction.values()) {
|
||||
|
@ -54,7 +54,7 @@ public enum JingleAction {
|
|||
|
||||
private final String asString;
|
||||
|
||||
private JingleAction() {
|
||||
JingleAction() {
|
||||
asString = this.name().replace('_', '-');
|
||||
}
|
||||
|
||||
|
|
|
@ -26,13 +26,13 @@ public final class JingleErrorElement implements ExtensionElement {
|
|||
|
||||
public static String NAMESPACE = "urn:xmpp:jingle:errors:1";
|
||||
|
||||
public static final JingleErrorElement OUT_OF_ORDER = new JingleErrorElement("out-of-order");
|
||||
static final JingleErrorElement OUT_OF_ORDER = new JingleErrorElement("out-of-order");
|
||||
|
||||
public static final JingleErrorElement TIE_BREAK = new JingleErrorElement("tie-break");
|
||||
static final JingleErrorElement TIE_BREAK = new JingleErrorElement("tie-break");
|
||||
|
||||
public static final JingleErrorElement UNKNOWN_SESSION = new JingleErrorElement("unknown-session");
|
||||
static final JingleErrorElement UNKNOWN_SESSION = new JingleErrorElement("unknown-session");
|
||||
|
||||
public static final JingleErrorElement UNSUPPORTED_INFO = new JingleErrorElement("unsupported-info");
|
||||
static final JingleErrorElement UNSUPPORTED_INFO = new JingleErrorElement("unsupported-info");
|
||||
|
||||
private final String errorName;
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ public class JingleReasonElement implements NamedElement {
|
|||
|
||||
public static class AlternativeSession extends JingleReasonElement {
|
||||
|
||||
public static final String SID = "sid";
|
||||
public static final String ATTR_SID = "sid";
|
||||
private final String sessionId;
|
||||
|
||||
public AlternativeSession(String sessionId) {
|
||||
|
@ -148,9 +148,9 @@ public class JingleReasonElement implements NamedElement {
|
|||
xml.rightAngleBracket();
|
||||
|
||||
xml.openElement(reason.asString);
|
||||
xml.openElement(SID);
|
||||
xml.openElement(ATTR_SID);
|
||||
xml.append(sessionId);
|
||||
xml.closeElement(SID);
|
||||
xml.closeElement(ATTR_SID);
|
||||
xml.closeElement(reason.asString);
|
||||
|
||||
xml.closeElement(this);
|
||||
|
|
|
@ -99,7 +99,7 @@ public class JingleProvider extends IQProvider<JingleElement> {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
public static JingleContentElement parseJingleContent(XmlPullParser parser, final int initialDepth)
|
||||
private static JingleContentElement parseJingleContent(XmlPullParser parser, final int initialDepth)
|
||||
throws Exception {
|
||||
JingleContentElement.Builder builder = JingleContentElement.getBuilder();
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.jivesoftware.smackx.jingle.transport.jingle_s5b;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.logging.Level;
|
||||
|
@ -234,7 +233,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
|||
}
|
||||
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
void establishBytestreamSession(XMPPConnection connection)
|
||||
private void establishBytestreamSession(XMPPConnection connection)
|
||||
throws SmackException.NotConnectedException, InterruptedException {
|
||||
Socks5Proxy.getSocks5Proxy().addTransfer(ourDstAddr);
|
||||
JingleS5BTransportManager transportManager = JingleS5BTransportManager.getInstanceFor(connection);
|
||||
|
@ -254,7 +253,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
|||
}
|
||||
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public JingleS5BTransportCandidate connectToCandidates(int timeout) {
|
||||
private JingleS5BTransportCandidate connectToCandidates(int timeout) {
|
||||
|
||||
if (getTheirCandidates().size() == 0) {
|
||||
LOGGER.log(Level.INFO, "They provided 0 candidates.");
|
||||
|
@ -281,7 +280,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
|||
}
|
||||
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
void connectIfReady() {
|
||||
private void connectIfReady() {
|
||||
final JingleS5BTransportManager jingleS5BTransportManager = JingleS5BTransportManager.getInstanceFor(getParent().getParent().getJingleManager().getConnection());
|
||||
final JingleSession session = getParent().getParent();
|
||||
|
||||
|
@ -427,9 +426,8 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
|||
return;
|
||||
}
|
||||
|
||||
Iterator<JingleTransportCandidate<?>> ourCandidates = getOurCandidates().iterator();
|
||||
while (ourCandidates.hasNext()) {
|
||||
JingleS5BTransportCandidate candidate = (JingleS5BTransportCandidate) ourCandidates.next();
|
||||
for (JingleTransportCandidate<?> jingleTransportCandidate : getOurCandidates()) {
|
||||
JingleS5BTransportCandidate candidate = (JingleS5BTransportCandidate) jingleTransportCandidate;
|
||||
if (candidate.getCandidateId().equals(candidateId)) {
|
||||
theirSelectedCandidate = candidate;
|
||||
}
|
||||
|
|
|
@ -45,11 +45,11 @@ public class JingleS5BTransportCandidate extends JingleTransportCandidate<Jingle
|
|||
|
||||
private Socket socket;
|
||||
|
||||
public JingleS5BTransportCandidate(JingleS5BTransportCandidateElement element) {
|
||||
JingleS5BTransportCandidate(JingleS5BTransportCandidateElement element) {
|
||||
this(element.getCandidateId(), new Bytestream.StreamHost(element.getJid(), element.getHost(), element.getPort()), element.getPriority(), element.getType());
|
||||
}
|
||||
|
||||
public JingleS5BTransportCandidate(String candidateId,
|
||||
JingleS5BTransportCandidate(String candidateId,
|
||||
Bytestream.StreamHost streamHost,
|
||||
int priority,
|
||||
JingleS5BTransportCandidateElement.Type type) {
|
||||
|
@ -60,18 +60,18 @@ public class JingleS5BTransportCandidate extends JingleTransportCandidate<Jingle
|
|||
setPriority(priority);
|
||||
}
|
||||
|
||||
public JingleS5BTransportCandidate(JingleS5BTransportCandidate other) {
|
||||
JingleS5BTransportCandidate(JingleS5BTransportCandidate other) {
|
||||
this(other.candidateId,
|
||||
other.getStreamHost(),
|
||||
other.getPriority(),
|
||||
other.type);
|
||||
}
|
||||
|
||||
public static JingleS5BTransportCandidate fromElement(JingleS5BTransportCandidateElement element) {
|
||||
static JingleS5BTransportCandidate fromElement(JingleS5BTransportCandidateElement element) {
|
||||
return new JingleS5BTransportCandidate(element.getCandidateId(), element.getStreamHost(), element.getPriority(), element.getType());
|
||||
}
|
||||
|
||||
public String getCandidateId() {
|
||||
String getCandidateId() {
|
||||
return candidateId;
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ public final class JingleS5BTransportManager extends Manager implements JingleTr
|
|||
return 10000; // SOCKS5 has a high priority
|
||||
}
|
||||
|
||||
public List<JingleTransportCandidate<?>> collectCandidates() {
|
||||
List<JingleTransportCandidate<?>> collectCandidates() {
|
||||
List<JingleTransportCandidate<?>> candidates = new ArrayList<>();
|
||||
|
||||
//Local host
|
||||
|
@ -156,21 +156,21 @@ public final class JingleS5BTransportManager extends Manager implements JingleTr
|
|||
return socks5BytestreamManager.getLocalStreamHost();
|
||||
}
|
||||
|
||||
public List<Bytestream.StreamHost> getServersStreamHosts() throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException {
|
||||
private List<Bytestream.StreamHost> getServersStreamHosts() throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException {
|
||||
if (availableStreamHosts == null) {
|
||||
availableStreamHosts = queryServersStreamHosts();
|
||||
}
|
||||
return availableStreamHosts;
|
||||
}
|
||||
|
||||
public List<Bytestream.StreamHost> getLocalStreamHosts() {
|
||||
private List<Bytestream.StreamHost> getLocalStreamHosts() {
|
||||
if (localStreamHosts == null) {
|
||||
localStreamHosts = queryLocalStreamHosts();
|
||||
}
|
||||
return localStreamHosts;
|
||||
}
|
||||
|
||||
public List<Bytestream.StreamHost> determineStreamHostInfo(List<Jid> proxies) {
|
||||
private List<Bytestream.StreamHost> determineStreamHostInfo(List<Jid> proxies) {
|
||||
List<Bytestream.StreamHost> streamHosts = new ArrayList<>();
|
||||
|
||||
Iterator<Jid> iterator = proxies.iterator();
|
||||
|
@ -192,7 +192,7 @@ public final class JingleS5BTransportManager extends Manager implements JingleTr
|
|||
return streamHosts;
|
||||
}
|
||||
|
||||
private JingleElement createTransportInfo(JingleS5BTransport transport, JingleS5BTransportInfoElement info) {
|
||||
private static JingleElement createTransportInfo(JingleS5BTransport transport, JingleS5BTransportInfoElement info) {
|
||||
JingleContent content = transport.getParent();
|
||||
JingleSession session = content.getParent();
|
||||
|
||||
|
@ -222,19 +222,19 @@ public final class JingleS5BTransportManager extends Manager implements JingleTr
|
|||
return jingle;
|
||||
}
|
||||
|
||||
JingleElement createCandidateUsed(JingleS5BTransport transport, JingleS5BTransportCandidate candidate) {
|
||||
static JingleElement createCandidateUsed(JingleS5BTransport transport, JingleS5BTransportCandidate candidate) {
|
||||
return createTransportInfo(transport, new JingleS5BTransportInfoElement.CandidateUsed(candidate.getCandidateId()));
|
||||
}
|
||||
|
||||
JingleElement createCandidateError(JingleS5BTransport transport) {
|
||||
static JingleElement createCandidateError(JingleS5BTransport transport) {
|
||||
return createTransportInfo(transport, JingleS5BTransportInfoElement.CandidateError.INSTANCE);
|
||||
}
|
||||
|
||||
JingleElement createProxyError(JingleS5BTransport transport) {
|
||||
static JingleElement createProxyError(JingleS5BTransport transport) {
|
||||
return createTransportInfo(transport, JingleS5BTransportInfoElement.ProxyError.INSTANCE);
|
||||
}
|
||||
|
||||
JingleElement createCandidateActivated(JingleS5BTransport transport, JingleS5BTransportCandidate candidate) {
|
||||
static JingleElement createCandidateActivated(JingleS5BTransport transport, JingleS5BTransportCandidate candidate) {
|
||||
return createTransportInfo(transport, new JingleS5BTransportInfoElement.CandidateActivated(candidate.getCandidateId()));
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ public final class JingleS5BTransportManager extends Manager implements JingleTr
|
|||
return getPriority() > other.getPriority() ? 1 : -1;
|
||||
}
|
||||
|
||||
private ConnectionListener connectionListener = new ConnectionListener() {
|
||||
private final ConnectionListener connectionListener = new ConnectionListener() {
|
||||
|
||||
@Override
|
||||
public void connected(XMPPConnection connection) {
|
||||
|
|
|
@ -32,7 +32,7 @@ public class S5BTransportException extends FailedTransportException {
|
|||
public static class CandidateError extends S5BTransportException {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
|
||||
public CandidateError(Throwable throwable) {
|
||||
CandidateError(Throwable throwable) {
|
||||
super(throwable);
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class S5BTransportException extends FailedTransportException {
|
|||
public static class ProxyError extends S5BTransportException {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
|
||||
public ProxyError(Throwable throwable) {
|
||||
ProxyError(Throwable throwable) {
|
||||
super(throwable);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public abstract class JingleS5BTransportInfoElement extends JingleContentTranspo
|
|||
|
||||
private final String candidateId;
|
||||
|
||||
protected JingleS5BCandidateTransportInfoElement(String candidateId) {
|
||||
JingleS5BCandidateTransportInfoElement(String candidateId) {
|
||||
this.candidateId = candidateId;
|
||||
}
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ public class JingleFileTransferIntegrationTest extends AbstractSmackIntegrationT
|
|||
}
|
||||
|
||||
@AfterClass
|
||||
public void cleanup() {
|
||||
public static void cleanup() {
|
||||
Socks5Proxy.getSocks5Proxy().stop();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue