org.apache.sshd.common.kex.KeyExchange Java Examples
The following examples show how to use
org.apache.sshd.common.kex.KeyExchange.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KeyReExchangeTest.java From termd with Apache License 2.0 | 4 votes |
@Test // see SSHD-558 public void testKexFutureExceptionPropagation() throws Exception { setUp(0L, 0L, 0L); sshd.getCipherFactories().add(BuiltinCiphers.none); try (SshClient client = setupTestClient()) { client.getCipherFactories().add(BuiltinCiphers.none); // replace the original KEX factories with wrapped ones that we can fail intentionally List<NamedFactory<KeyExchange>> kexFactories = new ArrayList<>(); final AtomicBoolean successfulInit = new AtomicBoolean(true); final AtomicBoolean successfulNext = new AtomicBoolean(true); final ClassLoader loader = getClass().getClassLoader(); final Class<?>[] interfaces = {KeyExchange.class}; for (final NamedFactory<KeyExchange> factory : client.getKeyExchangeFactories()) { kexFactories.add(new NamedFactory<KeyExchange>() { @Override public String getName() { return factory.getName(); } @Override public KeyExchange create() { final KeyExchange proxiedInstance = factory.create(); return (KeyExchange) Proxy.newProxyInstance(loader, interfaces, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if ("init".equals(name) && (!successfulInit.get())) { throw new UnsupportedOperationException("Intentionally failing 'init'"); } else if ("next".equals(name) && (!successfulNext.get())) { throw new UnsupportedOperationException("Intentionally failing 'next'"); } else { return method.invoke(proxiedInstance, args); } } }); } }); } client.setKeyExchangeFactories(kexFactories); client.start(); try { try { testKexFutureExceptionPropagation("init", successfulInit, client); } finally { successfulInit.set(true); } try { testKexFutureExceptionPropagation("next", successfulNext, client); } finally { successfulNext.set(true); } } finally { client.stop(); } } }
Example #2
Source File: KeyReExchangeTest.java From termd with Apache License 2.0 | 4 votes |
@Test // see SSHD-558 public void testKexFutureExceptionPropagation() throws Exception { setUp(0L, 0L, 0L); sshd.getCipherFactories().add(BuiltinCiphers.none); try (SshClient client = setupTestClient()) { client.getCipherFactories().add(BuiltinCiphers.none); // replace the original KEX factories with wrapped ones that we can fail intentionally List<NamedFactory<KeyExchange>> kexFactories = new ArrayList<>(); final AtomicBoolean successfulInit = new AtomicBoolean(true); final AtomicBoolean successfulNext = new AtomicBoolean(true); final ClassLoader loader = getClass().getClassLoader(); final Class<?>[] interfaces = {KeyExchange.class}; for (final NamedFactory<KeyExchange> factory : client.getKeyExchangeFactories()) { kexFactories.add(new NamedFactory<KeyExchange>() { @Override public String getName() { return factory.getName(); } @Override public KeyExchange create() { final KeyExchange proxiedInstance = factory.create(); return (KeyExchange) Proxy.newProxyInstance(loader, interfaces, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if ("init".equals(name) && (!successfulInit.get())) { throw new UnsupportedOperationException("Intentionally failing 'init'"); } else if ("next".equals(name) && (!successfulNext.get())) { throw new UnsupportedOperationException("Intentionally failing 'next'"); } else { return method.invoke(proxiedInstance, args); } } }); } }); } client.setKeyExchangeFactories(kexFactories); client.start(); try { try { testKexFutureExceptionPropagation("init", successfulInit, client); } finally { successfulInit.set(true); } try { testKexFutureExceptionPropagation("next", successfulNext, client); } finally { successfulNext.set(true); } } finally { client.stop(); } } }
Example #3
Source File: MockClientSession.java From xenon with Apache License 2.0 | 4 votes |
@Override public KeyExchange getKex() { throw new RuntimeException("Not implemented"); }