public int start()

in wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/SshServerEmbedded.java [84:159]


    public int start() throws IOException {
        sshd.setPort(0);

        sshd.setUserAuthFactories(Arrays.asList(new UserAuthPublicKey.Factory(), new UserAuthPassword.Factory()));

        sshd.setPublickeyAuthenticator(this.publickeyAuthenticator);

        sshd.setPasswordAuthenticator(this.passwordAuthenticator);

        sshd.setUserAuthFactories(Arrays.asList(new UserAuthPublicKey.Factory(), new UserAuthPassword.Factory()));

        // ResourceKeyPairProvider resourceKeyPairProvider =
        //    new ResourceKeyPairProvider( sshKeysResources.toArray( new String[sshKeysResources.size()] ) );

        File path = new File("target/keys");
        path.mkdirs();
        path = new File(path, "simple.key");
        path.delete();

        PEMGeneratorHostKeyProvider provider = new PEMGeneratorHostKeyProvider();
        provider.setAlgorithm("RSA");
        provider.setKeySize(1024);
        provider.setPath(path.getPath());

        sshd.setKeyPairProvider(provider);
        SessionFactory sessionFactory = new SessionFactory() {
            @Override
            protected AbstractSession doCreateSession(IoSession ioSession) throws Exception {
                return super.doCreateSession(ioSession);
            }
        };
        sshd.setSessionFactory(sessionFactory);

        // sshd.setFileSystemFactory(  );

        final ProcessShellFactory processShellFactory = new ProcessShellFactory(new String[] {"/bin/sh", "-i", "-l"});
        sshd.setShellFactory(processShellFactory);

        CommandFactory delegateCommandFactory = new CommandFactory() {
            public Command createCommand(String command) {
                return new ShellCommand(command);
            }
        };

        ScpCommandFactory commandFactory = new ScpCommandFactory(delegateCommandFactory);
        sshd.setCommandFactory(commandFactory);

        FileSystemFactory fileSystemFactory = new FileSystemFactory() {
            public FileSystemView createFileSystemView(Session session) throws IOException {
                return new FileSystemView() {
                    public SshFile getFile(String file) {
                        file = file.replace("\\", "");
                        file = file.replace("\"", "");
                        File f = new File(FileUtils.normalize(file));

                        return new SshServerEmbedded.TestSshFile(
                                f.getAbsolutePath(), f, System.getProperty("user.name"));
                    }

                    public SshFile getFile(SshFile baseDir, String file) {
                        file = file.replace("\\", "");
                        file = file.replace("\"", "");
                        File f = new File(FileUtils.normalize(file));
                        return new SshServerEmbedded.TestSshFile(
                                f.getAbsolutePath(), f, System.getProperty("user.name"));
                    }
                };
            }
        };
        sshd.setNioWorkers(0);
        // sshd.setScheduledExecutorService(  );
        sshd.setFileSystemFactory(fileSystemFactory);
        sshd.start();
        this.port = sshd.getPort();
        return this.port;
    }