本文整理匯總了Java中org.apache.sshd.common.cipher.Cipher類的典型用法代碼示例。如果您正苦於以下問題:Java Cipher類的具體用法?Java Cipher怎麽用?Java Cipher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Cipher類屬於org.apache.sshd.common.cipher包,在下文中一共展示了Cipher類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: runClient
import org.apache.sshd.common.cipher.Cipher; //導入依賴的package包/類
@SuppressWarnings("checkstyle:nestedtrydepth")
protected void runClient(String msg) throws Exception {
try (SshClient client = setupTestClient()) {
PropertyResolverUtils.updateProperty(client, FactoryManager.MAX_PACKET_SIZE, 1024 * 16);
PropertyResolverUtils.updateProperty(client, FactoryManager.WINDOW_SIZE, 1024 * 8);
client.setKeyExchangeFactories(Arrays.asList(
ClientBuilder.DH2KEX.transform(BuiltinDHFactories.dhg1)));
client.setCipherFactories(Arrays.<NamedFactory<Cipher>>asList(BuiltinCiphers.blowfishcbc));
client.start();
try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) {
session.addPasswordIdentity(getCurrentTestName());
session.auth().verify(5L, TimeUnit.SECONDS);
try (ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayOutputStream err = new ByteArrayOutputStream();
ClientChannel channel = session.createChannel(Channel.CHANNEL_SHELL)) {
channel.setOut(out);
channel.setErr(err);
try {
channel.open().verify(9L, TimeUnit.SECONDS);
try (OutputStream pipedIn = channel.getInvertedIn()) {
msg += "\nexit\n";
pipedIn.write(msg.getBytes(StandardCharsets.UTF_8));
pipedIn.flush();
}
Collection<ClientChannelEvent> result =
channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), TimeUnit.SECONDS.toMillis(15L));
assertFalse("Timeout while waiting for channel closure", result.contains(ClientChannelEvent.TIMEOUT));
} finally {
channel.close(false);
}
assertArrayEquals("Mismatched message data", msg.getBytes(StandardCharsets.UTF_8), out.toByteArray());
}
} finally {
client.stop();
}
}
}
示例2: getCipherFactories
import org.apache.sshd.common.cipher.Cipher; //導入依賴的package包/類
@Override
public List<NamedFactory<Cipher>> getCipherFactories() {
throw new RuntimeException("Not implemented");
}
示例3: setCipherFactories
import org.apache.sshd.common.cipher.Cipher; //導入依賴的package包/類
@Override
public void setCipherFactories(List<NamedFactory<Cipher>> cipherFactories) {
throw new RuntimeException("Not implemented");
}