当前位置: 首页>>代码示例>>Java>>正文


Java Factory类代码示例

本文整理汇总了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();
}
 
开发者ID:termd,项目名称:termd,代码行数:18,代码来源:WindowAdjustTest.java

示例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);
        }
    };
}
 
开发者ID:FauxFaux,项目名称:ssh-key-capture,代码行数:9,代码来源:CommandWrapper.java

示例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);
    }
}
 
开发者ID:yahoo,项目名称:artifactory_ssh_proxy,代码行数:34,代码来源:SshdProxySettings.java

示例4: getRandomizerInstance

import org.apache.sshd.common.Factory; //导入依赖的package包/类
public static Random getRandomizerInstance() {
    Factory<Random> factory = SecurityUtils.getRandomFactory();
    return factory.create();
}
 
开发者ID:termd,项目名称:termd,代码行数:5,代码来源:Utils.java

示例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;
}
 
开发者ID:yahoo,项目名称:artifactory_ssh_proxy,代码行数:62,代码来源:SshdProxySettings.java

示例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();
 
开发者ID:yahoo,项目名称:artifactory_ssh_proxy,代码行数:7,代码来源:SshdSettingsInterface.java


注:本文中的org.apache.sshd.common.Factory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。