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


Java NamedFactory类代码示例

本文整理汇总了Java中org.apache.sshd.common.NamedFactory的典型用法代码示例。如果您正苦于以下问题:Java NamedFactory类的具体用法?Java NamedFactory怎么用?Java NamedFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NamedFactory类属于org.apache.sshd.common包,在下文中一共展示了NamedFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startServer

import org.apache.sshd.common.NamedFactory; //导入依赖的package包/类
public void startServer() throws IOException {
    SshServer sshd = SshServer.setUpDefaultServer();
    port = getPort();
    sshd.setPort(port);
    sshd.setPublickeyAuthenticator(AcceptAllPublickeyAuthenticator.INSTANCE);
    SimpleGeneratorHostKeyProvider provider = new SimpleGeneratorHostKeyProvider();
    sshd.setKeyPairProvider(provider);
    SftpSubsystemFactory.Builder builder = new SftpSubsystemFactory.Builder();

    SftpSubsystemFactory sftpFactory = builder.build();
    sshd.setSubsystemFactories(new ArrayList<NamedFactory<Command>>() {
        {
            add(sftpFactory);
        }
    });
    sshd.setHost(LOCALHOST);
    String msg = String.format("Local SSH Server started on [%s] and listening on port [%d]", sshd.getHost(), sshd
        .getPort());
    LOGGER.info(msg);
    ScpCommandFactory factory = new ScpCommandFactory();
    factory.setDelegateCommandFactory(new FakeCommandFactory());
    sshd.setCommandFactory(factory);
    Runtime.getRuntime().addShutdownHook(new Thread(new Close(sshd)));
    sshd.start();
}
 
开发者ID:RationaleEmotions,项目名称:SimpleSSH,代码行数:26,代码来源:LocalServer.java

示例2: initCompression

import org.apache.sshd.common.NamedFactory; //导入依赖的package包/类
private void initCompression(boolean enableCompression) {
  List<NamedFactory<Compression>> compressionFactories = new ArrayList<>();

  // Always support no compression over SSHD.
  compressionFactories.add(BuiltinCompressions.none);

  // In the general case, we want to disable transparent compression, since
  // the majority of our data transfer is highly compressed Git pack files
  // and we cannot make them any smaller than they already are.
  //
  // However, if there are CPU in abundance and the server is reachable through
  // slow networks, gits with huge amount of refs can benefit from SSH-compression
  // since git does not compress the ref announcement during the handshake.
  //
  // Compression can be especially useful when Gerrit slaves are being used
  // for the larger clones and fetches and the master server mostly takes small
  // receive-packs.

  if (enableCompression) {
    compressionFactories.add(BuiltinCompressions.zlib);
  }

  setCompressionFactories(compressionFactories);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:SshDaemon.java

示例3: init

import org.apache.sshd.common.NamedFactory; //导入依赖的package包/类
public void init(Context context, Device device) {

        sshd.setKeyExchangeFactories(Arrays.asList(
                new DHG14.Factory(),
                new DHG1.Factory()));

        sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(context.getFilesDir() + "/sftpd.ser"));

        sshd.setFileSystemFactory(new AndroidFileSystemFactory(context));
        sshd.setCommandFactory(new ScpCommandFactory());
        sshd.setSubsystemFactories(Collections.singletonList((NamedFactory<Command>)new SftpSubsystem.Factory()));

        if (device.publicKey != null) {
            keyAuth.deviceKey = device.publicKey;
            sshd.setPublickeyAuthenticator(keyAuth);
        }
        sshd.setPasswordAuthenticator(passwordAuth);
    }
 
开发者ID:KDE,项目名称:kdeconnect-android,代码行数:19,代码来源:SimpleSftpServer.java

示例4: setupSftp

import org.apache.sshd.common.NamedFactory; //导入依赖的package包/类
protected void setupSftp(int port, final String username, final String password, File fileSystemFolder)
    throws IOException {
    sshd = SshServer.setUpDefaultServer();
    sshd.setPort(port);
    SftpSubsystem.Factory factory = new SftpSubsystem.Factory();

    @SuppressWarnings("unchecked")
    List<NamedFactory<Command>> factoryList = Arrays.<NamedFactory<Command>> asList(new NamedFactory[] {factory});
    this.sshd.setSubsystemFactories(factoryList);

    sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
        public boolean authenticate(String tryUsername, String tryPassword, ServerSession session) {
            return (username.equals(tryUsername)) && (password.equals(tryPassword));
        }

    });
    sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider());
    sshd.start();

    VirtualFileSystemFactory vfSysFactory = new VirtualFileSystemFactory();
    vfSysFactory.setDefaultHomeDir(fileSystemFolder.getCanonicalPath());
    sshd.setFileSystemFactory(vfSysFactory);
    LOGGER.info("Embedded SFTP started on port {}", Integer.valueOf(sshd.getPort()));
}
 
开发者ID:northlander,项目名称:activemft,代码行数:25,代码来源:EmbeddedSftp.java

示例5: setupSftpServer

import org.apache.sshd.common.NamedFactory; //导入依赖的package包/类
public void setupSftpServer() throws IOException {
    sshd = SshServer.setUpDefaultServer();
    sshd.setHost("127.0.0.1");
    sshd.setPort(4922);
    sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("target/hostkey.ser"));
    sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
        @Override
        public boolean authenticate(String username, String password, ServerSession session) {
            return "ftpuser".equals(username) && "topsecret".equals(password);
        }
    });

    List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>();
    userAuthFactories.add(new UserAuthPassword.Factory());
    sshd.setUserAuthFactories(userAuthFactories);

    sshd.setCommandFactory(new ScpCommandFactory());

    List<NamedFactory<Command>> namedFactoryList = new ArrayList<NamedFactory<Command>>();
    namedFactoryList.add(new SftpSubsystem.Factory());
    sshd.setSubsystemFactories(namedFactoryList);

    // prepare directory for test files
    VirtualFileSystemFactory fileSystemFactory = new VirtualFileSystemFactory(ROOT.getAbsolutePath());
    sshd.setFileSystemFactory(fileSystemFactory);

    sshd.start();
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:29,代码来源:SftpFileServiceTest.java

示例6: start

import org.apache.sshd.common.NamedFactory; //导入依赖的package包/类
public void start() {
    sshd = SshServer.setUpDefaultServer();
    sshd.setPort(configuration.port());
    sshd.setKeyPairProvider(keyPairProvider);
    setupUserHomeDirectories();

    List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>();
    userAuthFactories.add(new UserAuthPassword.Factory());
    sshd.setPasswordAuthenticator(new SftpUserBackedPasswordAuthenticator(loginToUserDictionary()));
    userAuthFactories.add(new UserAuthPublicKey.Factory());
    sshd.setPublickeyAuthenticator(new SftpUserBackedPublicKeyAuthenticator(loginToUserDictionary()));
    sshd.setUserAuthFactories(userAuthFactories);
    sshd.setCommandFactory(new ScpCommandFactory());

    List<NamedFactory<Command>> namedFactoryList = new ArrayList<NamedFactory<Command>>();
    namedFactoryList.add(new SftpSubsystem.Factory());
    sshd.setSubsystemFactories(namedFactoryList);

    try {
        sshd.start();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:signed,项目名称:in-memory-infrastructure,代码行数:25,代码来源:SftpServer.java

示例7: testDefaultFactories

import org.apache.sshd.common.NamedFactory; //导入依赖的package包/类
@Test
public void testDefaultFactories() throws SshdConfigurationException {
    // IF THIS TEST IS FAILING. Install the unlimited strength jce policy
    // files.
    // arcfour's aren't working on 7u45

    SshdSettingsInterface settings =
                    new SshdSettingsBuilder().setSshdPort(2222).setConfiguration(Utils.getConfigMock())
                                    .setArtifactoryUsername("a").setArtifactoryPassword("password")
                                    .setArtifactoryUrl("http://your:4080/artifactory")
                                    .setCommandFactories(Collections.<DelegatingCommandFactory>emptyList()).build();

    List<NamedFactory<Cipher>> ciphers = settings.getCiphers();

    Assert.assertTrue(ciphers.size() >= 4);

}
 
开发者ID:yahoo,项目名称:artifactory_ssh_proxy,代码行数:18,代码来源:TestCipherFactories.java

示例8: initializeServer

import org.apache.sshd.common.NamedFactory; //导入依赖的package包/类
private void initializeServer(String host, int listeningPort) {
	log.info("Configuring server...");
	sshd = SshServer.setUpDefaultServer();
	sshd.setHost(host);
	sshd.setPort(listeningPort);

	log.info("Host: '" + host + "', listenig port: " + listeningPort);

	sshd.setPasswordAuthenticator(new AlwaysTruePasswordAuthenticator());
	sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(""));

	List<NamedFactory<Command>> subsystemFactories = new ArrayList<NamedFactory<Command>>();
	subsystemFactories.add(NetconfSubsystem.Factory.createFactory(this, this));
	sshd.setSubsystemFactories(subsystemFactories);

	log.info("Server configured.");
}
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:18,代码来源:Server.java

示例9: startSshdServer

import org.apache.sshd.common.NamedFactory; //导入依赖的package包/类
private static void startSshdServer() throws IOException {
  sshd = SshServer.setUpDefaultServer();
  // ask OS to assign a port
  sshd.setPort(0);
  sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider());

  List<NamedFactory<UserAuth>> userAuthFactories =
      new ArrayList<NamedFactory<UserAuth>>();
  userAuthFactories.add(new UserAuthPassword.Factory());

  sshd.setUserAuthFactories(userAuthFactories);

  sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
    @Override
    public boolean authenticate(String username, String password,
        ServerSession session) {
      if (username.equals("user") && password.equals("password")) {
        return true;
      }
      return false;
    }
  });

  sshd.setSubsystemFactories(
      Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));

  sshd.start();
  port = sshd.getPort();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:30,代码来源:TestSFTPFileSystem.java

示例10: create

import org.apache.sshd.common.NamedFactory; //导入依赖的package包/类
public static SshServer create() {

        SshServer sshd = SshServer.setUpDefaultServer();
        sshd.setPort(SpashConfig.getInstance().spashListenPort());

        AbstractGeneratorHostKeyProvider keyProvider = new SimpleGeneratorHostKeyProvider(new File(SpashConfig.getInstance().spashKeyFileName()));
        keyProvider.setAlgorithm(SpashConfig.getInstance().spashKeyAlgorithm());
        keyProvider.setKeySize(SpashConfig.getInstance().spashKeyLength());

        sshd.setKeyPairProvider(keyProvider);

        List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>();
        userAuthFactories.add(new UserAuthPasswordFactory());
        sshd.setUserAuthFactories(userAuthFactories);

        sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
            @Override
            public boolean authenticate(String username, String password, ServerSession serverSession) throws PasswordChangeRequiredException {
                return username!=null && username.length()>0 && username.equals(password);
            }
        });

        sshd.setShellFactory(new SpashShellFactory());

        List<NamedFactory<Command>> namedFactoryList = new ArrayList<>();
        namedFactoryList.add(new SftpSubsystemFactory());
        sshd.setSubsystemFactories(namedFactoryList);

        sshd.setCommandFactory(new ScpCommandFactory());

        sshd.setFileSystemFactory(new FileSystemFactory() {
            @Override
            public FileSystem createFileSystem(Session session) throws IOException {
                return SpashFileSystem.get().getFileSystem();
            }
        });

        return sshd;
    }
 
开发者ID:nerdammer,项目名称:spash,代码行数:40,代码来源:SshServerFactory.java

示例11: setupSftpServer

import org.apache.sshd.common.NamedFactory; //导入依赖的package包/类
/**
 * Starts a SFTP server on port 22
 */
private void setupSftpServer() {
    SshServer sshd = SshServer.setUpDefaultServer();
    sshd.setPort(9009);
    //sshd.setKeyPairProvider(new FileKeyPairProvider(new String[]{"/home/ravi/WORK/SUPPORT/JIRA/SKYTVNZDEV-26/SftpTest/dist/hostkey.ser"}));
    ClassLoader classLoader = getClass().getClassLoader();
    log.info("Using identity file: " + classLoader.getResource("sftp/id_rsa.pub").getFile());
    File file = new File(classLoader.getResource("sftp/id_rsa.pub").getFile());
    sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(file.getAbsolutePath()));
    System.out.println(file.getAbsolutePath());

    List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>();
    userAuthFactories.add(new UserAuthPublicKey.Factory());
    sshd.setUserAuthFactories(userAuthFactories);

    sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
        public boolean authenticate(String username, PublicKey key, ServerSession session) {
            if ("sftpuser".equals(username)) {
                return true;
            }

            return false;
        }
    });

    sshd.setCommandFactory(new ScpCommandFactory());

    List<NamedFactory<Command>> namedFactoryList = new ArrayList<NamedFactory<Command>>();
    namedFactoryList.add(new SftpSubsystem.Factory());
    sshd.setSubsystemFactories(namedFactoryList);

    try {
        sshd.start();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:40,代码来源:ESBJAVA3470.java

示例12: setUpServer

import org.apache.sshd.common.NamedFactory; //导入依赖的package包/类
protected void setUpServer() throws Exception {
    canTest = true;
    try {
        sshd = SshServer.setUpDefaultServer();
        sshd.setPort(getPort());
        sshd.setKeyPairProvider(new FileKeyPairProvider(new String[]{"src/test/resources/hostkey.pem"}));
        sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));
        sshd.setCommandFactory(new ScpCommandFactory());
        sshd.setPasswordAuthenticator(new MyPasswordAuthenticator());
        PublickeyAuthenticator publickeyAuthenticator = new PublickeyAuthenticator() {
            // consider all keys as authorized for all users
            @Override
            public boolean authenticate(String username, PublicKey key, ServerSession session) {
                return true;
            }
        };
        sshd.setPublickeyAuthenticator(publickeyAuthenticator);
        sshd.start();
    } catch (Exception e) {
        // ignore if algorithm is not on the OS
        NoSuchAlgorithmException nsae = ObjectHelper.getException(NoSuchAlgorithmException.class, e);
        if (nsae != null) {
            canTest = false;

            String name = System.getProperty("os.name");
            String message = nsae.getMessage();
            log.warn("SunX509 is not avail on this platform [{}] Testing is skipped! Real cause: {}", name, message);
        } else {
            // some other error then throw it so the test can fail
            throw e;
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:34,代码来源:SftpServerTestSupport.java

示例13: AsyncUserAuthService

import org.apache.sshd.common.NamedFactory; //导入依赖的package包/类
public AsyncUserAuthService(Session s) throws SshException {
    ValidateUtils.checkTrue(s instanceof ServerSession, "Server side service used on client side");
    if (s.isAuthenticated()) {
        throw new SshException("Session already authenticated");
    }

    this.session = (ServerSession) s;
    maxAuthRequests = session.getIntProperty(ServerFactoryManager.MAX_AUTH_REQUESTS, DEFAULT_MAX_AUTH_REQUESTS);

    ServerFactoryManager manager = getFactoryManager();
    userAuthFactories = new ArrayList<>(manager.getUserAuthFactories());
    // Get authentication methods
    authMethods = new ArrayList<>();

    String mths = FactoryManagerUtils.getString(manager, ServerFactoryManager.AUTH_METHODS);
    if (GenericUtils.isEmpty(mths)) {
        for (NamedFactory<UserAuth> uaf : manager.getUserAuthFactories()) {
            authMethods.add(new ArrayList<>(Collections.singletonList(uaf.getName())));
        }
    }
    else {
        for (String mthl : mths.split("\\s")) {
            authMethods.add(new ArrayList<>(Arrays.asList(mthl.split(","))));
        }
    }
    // Verify all required methods are supported
    for (List<String> l : authMethods) {
        for (String m : l) {
            NamedFactory<UserAuth> factory = NamedResource.Utils.findByName(m, String.CASE_INSENSITIVE_ORDER, userAuthFactories);
            if (factory == null) {
                throw new SshException("Configured method is not supported: " + m);
            }
        }
    }

    if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.fine("Authorized authentication methods: "+ NamedResource.Utils.getNames(userAuthFactories));
    }
}
 
开发者ID:aeshell,项目名称:aesh-readline,代码行数:40,代码来源:AsyncUserAuthService.java

示例14: initProviderBouncyCastle

import org.apache.sshd.common.NamedFactory; //导入依赖的package包/类
private void initProviderBouncyCastle(Config cfg) {
  NamedFactory<Random> factory;
  if (cfg.getBoolean("sshd", null, "testUseInsecureRandom", false)) {
    factory = new InsecureBouncyCastleRandom.Factory();
  } else {
    factory = SecurityUtils.getRandomFactory();
  }
  setRandomFactory(new SingletonRandomFactory(factory));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:10,代码来源:SshDaemon.java

示例15: find

import org.apache.sshd.common.NamedFactory; //导入依赖的package包/类
@SafeVarargs
private static <T> NamedFactory<T> find(String name, NamedFactory<T>... avail) {
  for (NamedFactory<T> n : avail) {
    if (n != null && name.equals(n.getName())) {
      return n;
    }
  }
  return null;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:10,代码来源:SshDaemon.java


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