Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * $Id: ProcessingTime.java 23484 2011-12-14 01:26:29Z dfeist $
   * --------------------------------------------------------------------------------------
   * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
   *
   * The software in this package is published under the terms of the CPAL v1.0
   * license, a copy of which has been included with this distribution in the
   * LICENSE.txt file.
   */
 
 package org.mule.transport.sftp.util;
 
 
 import  org.bouncycastle.jce.provider.BouncyCastleProvider;
 
 public class SftpServer
 {
 
     protected static final String USERNAME = "muletest1";
     protected static final String PASSWORD = "muletest1";
     private SshServer sshdServer;
     private Integer port;
 
     public SftpServer(int port)
     {
         this. = port;
         configureSecurityProvider();
         SftpSubsystem.Factory factory = createFtpSubsystemFactory();
          = SshServer.setUpDefaultServer();
         configureSshdServer(factorypasswordAuthenticator());
     }
 
     private void configureSshdServer(SftpSubsystem.Factory factory,
                                      PasswordAuthenticator passwordAuthenticator)
     {
         .setPort();
         .setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser"));
         .setSubsystemFactories(Arrays.<NamedFactory<Command>> asList(factory));
         .setPasswordAuthenticator(passwordAuthenticator);
     }
 
     {
         SftpSubsystem.Factory factory = new SftpSubsystem.Factory();
         return factory;
     }
 
     private void configureSecurityProvider()
     {
         Security.addProvider(new BouncyCastleProvider());
     }
 
     private static PasswordAuthenticator passwordAuthenticator()
     {
         return new PasswordAuthenticator()
         {
 
             @Override
             public boolean authenticate(String arg0String arg1ServerSession arg2)
             {
                 return .equals(arg0) && .equals(arg1);
             }
         };
     }
 
     public void start()
     {
         try
         {
             .start();
         }
         catch (IOException e)
         {
             e.printStackTrace();
         }
     }
 
     public void stop()
     {
         try
         {
             .stop();
         }
         catch (InterruptedException e)
         {
            e.printStackTrace();
        }
         = null;
    }
New to GrepCode? Check out our FAQ X