本文整理汇总了Java中org.apache.sshd.common.Factory类的典型用法代码示例。如果您正苦于以下问题:Java Factory类的具体用法?Java Factory怎么用?Java Factory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Factory类属于org.apache.sshd.common包,在下文中一共展示了Factory类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.apache.sshd.common.Factory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
sshServer = setupTestServer();
final byte[] msg = Files.readAllBytes(
Paths.get(getClass().getResource("/big-msg.txt").toURI()));
sshServer.setShellFactory(new Factory<Command>() {
@Override
public Command create() {
return new FloodingAsyncCommand(msg, BIG_MSG_SEND_COUNT, END_FILE);
}
});
sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider());
sshServer.start();
port = sshServer.getPort();
}
示例2: wrap
import org.apache.sshd.common.Factory; //导入依赖的package包/类
public static Factory<Command> wrap(CommandRunner runner) {
return () -> new CommandWrapper() {
@Override
public int run(InputStream in, OutputStream out, OutputStream err) throws IOException {
return runner.run(in, out, err, session);
}
};
}
示例3: getShellFactory
import org.apache.sshd.common.Factory; //导入依赖的package包/类
@Override
public Factory<Command> getShellFactory() {
EnumSet<TtyOptions> ttyOptions;
if (OsUtils.isUNIX()) {
/**
* org.apache.sshd.server.shell.ProcessShellFactory does this: ttyOptions = EnumSet.of(TtyOptions.ONlCr);
*
* However, it doesn't seem to work for me. So in our copy of
* org.apache.sshd.server.shell.TtyFilterOutputStream.TtyFilterOutputStream(EnumSet<TtyOptions>,
* OutputStream, TtyFilterInputStream), we have a special hack that if TtyOptions.INlCr and TtyOptions.ICrNl
* are both set, send cr nl instead. no idea if the windows even works.
*/
// ttyOptions = EnumSet.of(TtyOptions.ONlCr);
ttyOptions = EnumSet.of(TtyOptions.OCrNl, TtyOptions.INlCr, TtyOptions.ICrNl);
} else {
ttyOptions = EnumSet.of(TtyOptions.Echo, TtyOptions.OCrNl, TtyOptions.INlCr, TtyOptions.ICrNl);
}
switch (shellMode) {
case FORWARDING_ECHO_SHELL:
return new ForwardingShellFactory(ttyOptions);
case GROOVY_SHELL:
return new GroovyShellFactory(ttyOptions);
case MESSAGE:
default:
// TODO when separating out settings, we'll provide a different success
// message, or a file path for it.
return new MessageShellFactory(SshProxyMessage.MESSAGE_STRING);
}
}
示例4: getRandomizerInstance
import org.apache.sshd.common.Factory; //导入依赖的package包/类
public static Random getRandomizerInstance() {
Factory<Random> factory = SecurityUtils.getRandomFactory();
return factory.create();
}
示例5: createCipherFactoryList
import org.apache.sshd.common.Factory; //导入依赖的package包/类
/**
* create a list of factories from a list of cipher names
*/
@SuppressWarnings("unchecked")
public static List<NamedFactory<Cipher>> createCipherFactoryList(List<String> cipherNames) {
final NamedFactory<Cipher>[] cipherArray = new NamedFactory[] { //
//
new AES128CTR.Factory(), //
new AES256CTR.Factory(), //
new ARCFOUR128.Factory(), //
new ARCFOUR256.Factory(), //
new AES128CBC.Factory(), //
new TripleDESCBC.Factory(), //
new BlowfishCBC.Factory(), //
new AES192CBC.Factory(), //
new AES256CBC.Factory(), //
};
// first get all of the ciphers we know about in a set
final Map<String, NamedFactory<Cipher>> nameMap = new HashMap<>();
final boolean useDefaults;
if (cipherNames.size() <= 0) {
useDefaults = true;
cipherNames = new ArrayList<>(cipherArray.length);
} else {
useDefaults = false;
}
for (NamedFactory<Cipher> cipherFactory : cipherArray) {
nameMap.put(cipherFactory.getName(), cipherFactory);
if (useDefaults) {
cipherNames.add(cipherFactory.getName());
}
}
final List<NamedFactory<Cipher>> available = new ArrayList<>(cipherArray.length);
for (String cipherName : cipherNames) {
final NamedFactory<Cipher> factory = nameMap.get(cipherName);
if (null == factory) {
continue;
}
try {
final Cipher c = factory.create();
final byte[] key = new byte[c.getBlockSize()];
final byte[] iv = new byte[c.getIVSize()];
c.init(Cipher.Mode.Encrypt, key, iv);
available.add(factory);
} catch (Exception e) {
LOGGER.info("Failed to load cipher " + cipherName
+ " ensure you have the unlimited strength JCE installed");
}
}
return available;
}
示例6: getShellFactory
import org.apache.sshd.common.Factory; //导入依赖的package包/类
/**
* Default shell just returns a message.
*
* @return an implementation of the Factory that implements a shell
*/
Factory<Command> getShellFactory();