private void broadcast() { if (interrupted) { term.close(); return;
/** * Close the connection to terminal. */ public void close() { delegate.close(); }
/** * Close the connection to terminal. */ public void close() { delegate.close(); }
public void close() { if (term != null) { term.close(); } else { jobController.close(ar -> closedFuture.complete()); } } }
private void handleTerm(Term term) { synchronized (this) { // That might happen with multiple ser if (closed) { term.close(); return; } } ShellImpl session = createShell(term); session.setWelcome(welcomeMessage); session.closedFuture.setHandler(ar -> { boolean completeSessionClosed; synchronized (ShellServerImpl.this) { sessions.remove(session.id); completeSessionClosed = sessions.isEmpty() && closed; } if (completeSessionClosed) { sessionsClosed.complete(); } }); session.init(); if (shellHandler != null) { shellHandler.handle(session); } sessions.put(session.id, session); // Put after init so the close handler on the connection is set session.readline(); // Now readline }
@Test public void testClose(TestContext context) throws Exception { testClose(context, term -> { vertx.setTimer(10, id -> { term.close(); }); }); }
@Test public void testClose(TestContext context) throws Exception { testClose(context, term -> { vertx.setTimer(10, id -> { term.close(); }); }); }
@Test public void testDifferentCharset(TestContext context) throws Exception { CompletableFuture<Void> closeLatch = new CompletableFuture<Void>(); startTelnet(context, new TelnetTermOptions().setCharset("ISO_8859_1"), term -> { term.write("\u20AC"); closeLatch.thenAccept(v -> { term.close(); }); }); client.connect("localhost", server.actualPort()); InputStream in = client.getInputStream(); int b = in.read(); context.assertEquals(63, b); closeLatch.complete(null); }
@Test public void testKeymapFromFilesystem(TestContext context) throws Exception { URL url = TermServer.class.getResource(SSHTermOptions.DEFAULT_INPUTRC); File f = new File(url.toURI()); Async async = context.async(); server = createServer(context, new HttpTermOptions().setPort(8080).setIntputrc(f.getAbsolutePath())); server.termHandler(term -> { term.close(); async.complete(); }); server.listen(context.asyncAssertSuccess(server -> { HttpClient client = vertx.createHttpClient(); client.websocket(8080, "localhost", basePath + "/shell/websocket", new CaseInsensitiveHeaders().add("Authorization", "Basic " + Base64.getEncoder().encodeToString("paulo:anothersecret".getBytes())), ws -> { ws.handler(buf -> { }); }, context::fail); })); } }
@Test public void testDifferentCharset(TestContext context) throws Exception { termHandler = term -> { term.write("\u20AC"); term.close(); }; startShell(new SSHTermOptions().setDefaultCharset("ISO_8859_1").setPort(5000).setHost("localhost").setKeyPairOptions( new JksOptions().setPath("src/test/resources/server-keystore.jks").setPassword("wibble")). setAuthOptions(new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig( new JsonObject().put("properties_path", "classpath:test-auth.properties")))); Session session = createSession("paulo", "secret", false); session.connect(); Channel channel = session.openChannel("shell"); channel.connect(); InputStream in = channel.getInputStream(); int b = in.read(); context.assertEquals(63, b); }
@Test public void testDifferentCharset(TestContext context) throws Exception { Async async = context.async(); server = createServer(context, new HttpTermOptions().setPort(8080).setCharset("ISO_8859_1")); server.termHandler(term -> { term.write("\u20AC"); term.close(); }); server.listen(context.asyncAssertSuccess(server -> { HttpClient client = vertx.createHttpClient(); client.websocket(8080, "localhost", basePath + "/shell/websocket", new CaseInsensitiveHeaders().add("Authorization", "Basic " + Base64.getEncoder().encodeToString("paulo:anothersecret".getBytes())), ws -> { ws.handler(buf -> { context.assertTrue(Arrays.equals(new byte[]{63}, buf.getBytes())); async.complete(); }); }, context::fail); })); }