@Override public void checkIfSuccessfulOrThrow() throws SmackException { if (verifyServerResponse && state != State.VALID_SERVER_RESPONSE) { throw new SmackException(NAME + " no valid server response"); } }
@Override public void run() { StreamHost streamHost = new StreamHost(proxyJID, serverAddress, serverPort); Socks5Client socks5Client = new Socks5Client(streamHost, digest); try { socks5Client.getSocket(10000); fail("exception should be thrown"); } catch (SmackException e) { assertTrue(e.getMessage().contains( "SOCKS5 negotiation failed")); } catch (Exception e) { fail(e.getMessage()); } }
e.printStackTrace(); System.exit(1);
@Override public void run() { StreamHost streamHost = new StreamHost(proxyJID, serverAddress, serverPort); Socks5Client socks5Client = new Socks5Client(streamHost, digest); try { socks5Client.getSocket(10000); fail("exception should be thrown"); } catch (SmackException e) { assertTrue(e.getMessage().contains( "SOCKS5 negotiation failed")); } catch (Exception e) { fail(e.getMessage()); } }
e.printStackTrace(); System.exit(1);
@Override public void checkIfSuccessfulOrThrow() throws SmackException { if (state != State.VALID_SERVER_RESPONSE) { throw new SmackException("SCRAM-SHA1 is missing valid server response"); } }
@Override public void run() { StreamHost streamHost = new StreamHost(proxyJID, serverAddress, serverPort); Socks5Client socks5Client = new Socks5Client(streamHost, digest); try { socks5Client.getSocket(10000); fail("exception should be thrown"); } catch (SmackException e) { assertTrue(e.getMessage().contains( "Unsupported SOCKS5 address type")); } catch (Exception e) { fail(e.getMessage()); } }
@Override protected byte[] getChannelBindingData() throws SmackException { byte[] cbData; try { cbData = TLSUtils.getChannelBindingTlsServerEndPoint(sslSession); } catch (SSLPeerUnverifiedException | CertificateEncodingException | NoSuchAlgorithmException e) { throw new SmackException(e); } return cbData; } }
assertTrue(e.getMessage().contains("no SOCKS5 proxies available"));
@Override public OutputStream createOutgoingStream(String streamID, Jid initiator, Jid target) throws SmackException, XMPPException { try { return this.manager.establishSession(target, streamID).getOutputStream(); } catch (IOException e) { throw new SmackException("error establishing SOCKS5 Bytestream", e); } catch (InterruptedException e) { throw new SmackException("error establishing SOCKS5 Bytestream", e); } }
assertTrue(e.getMessage().contains("no SOCKS5 proxies available")); assertTrue(e.getMessage().contains("no SOCKS5 proxies available"));
public static int getIntegerAttributeOrThrow(XmlPullParser parser, String name, String throwMessage) throws SmackException { Integer res = getIntegerAttribute(parser, name); if (res == null) { throw new SmackException(throwMessage); } return res; }
/** * If the target is not connected to the local SOCKS5 proxy an exception should be thrown. * * @throws Exception should not happen */ @Test public void shouldFailIfTargetIsNotConnectedToLocalSocks5Proxy() throws Exception { // start a local SOCKS5 proxy Socks5Proxy.setLocalSocks5ProxyPort(proxyPort); Socks5Proxy socks5Proxy = Socks5Proxy.getSocks5Proxy(); socks5Proxy.start(); // build stream host information for local SOCKS5 proxy StreamHost streamHost = new StreamHost(connection.getUser(), loopbackAddress, socks5Proxy.getPort()); // create digest to get the socket opened by target String digest = Socks5Utils.createDigest(sessionID, initiatorJID, targetJID); Socks5ClientForInitiator socks5Client = new Socks5ClientForInitiator(streamHost, digest, connection, sessionID, targetJID); try { socks5Client.getSocket(GET_SOCKET_TIMEOUT); fail("exception should be thrown"); } catch (SmackException e) { assertTrue(e.getMessage().contains("target is not connected to SOCKS5 proxy")); protocol.verifyAll(); // assert no XMPP messages were sent } socks5Proxy.stop(); }
@SuppressWarnings("unchecked") @Override public PE parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { try { return (PE) parseWithIntrospection(elementClass, parser, initialDepth); } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | ClassNotFoundException e) { throw new SmackException(e); } } }
assertTrue(e.getMessage().contains("no SOCKS5 proxies available"));
private static Map<Character, String> parseAttributes(String string) throws SmackException { if (string.length() == 0) { return Collections.emptyMap(); } String[] keyValuePairs = string.split(","); Map<Character, String> res = new HashMap<Character, String>(keyValuePairs.length, 1); for (String keyValuePair : keyValuePairs) { if (keyValuePair.length() < 3) { throw new SmackException("Invalid Key-Value pair: " + keyValuePair); } char key = keyValuePair.charAt(0); if (keyValuePair.charAt(1) != '=') { throw new SmackException("Invalid Key-Value pair: " + keyValuePair); } String value = keyValuePair.substring(2); res.put(key, value); } return res; }
assertTrue(e.getMessage().contains("Remote user responded with unknown host"));
@SuppressWarnings("unchecked") @Override public I parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { try { return (I) parseWithIntrospection(elementClass, parser, initialDepth); } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | ClassNotFoundException e) { throw new SmackException(e); } } }
try { connection.connect(); } catch (SmackException e) { Log.i("SmackException ", "ConnectionException: " + e.getMessage()); List<HostAddress> hostAddresses = ((SmackException.ConnectionException) e).getFailedAddresses(); if (!hostAddresses.isEmpty()) { Log.i("SmackException: HostAddress: ", hostAddresses.get(0).toString()); Log.i("SmackException: HostAddress: ", hostAddresses.get(0).getException().toString()); }
@Override public ExtensionElement parse(XmlPullParser parser, int initialDepth) throws SmackException { throw new SmackException("Test Exception"); }