當前位置: 首頁>>代碼示例>>Java>>正文


Java ListenerFactory.setSslConfiguration方法代碼示例

本文整理匯總了Java中org.apache.ftpserver.listener.ListenerFactory.setSslConfiguration方法的典型用法代碼示例。如果您正苦於以下問題:Java ListenerFactory.setSslConfiguration方法的具體用法?Java ListenerFactory.setSslConfiguration怎麽用?Java ListenerFactory.setSslConfiguration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.ftpserver.listener.ListenerFactory的用法示例。


在下文中一共展示了ListenerFactory.setSslConfiguration方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configureSSL

import org.apache.ftpserver.listener.ListenerFactory; //導入方法依賴的package包/類
private ListenerFactory configureSSL() {
    ListenerFactory listener = new ListenerFactory();
    listener.setServerAddress("127.0.0.1");
    listener.setPort(PORT);

    SslConfigurationFactory ssl = new SslConfigurationFactory();
    ssl.setKeystoreFile(SERVER_SSL_KEY_TRUST_STORE);
    ssl.setKeyPassword(SERVER_SSL_KEY_PASSWD);
    ssl.setKeystorePassword(SERVER_SSL_STORE_PASSWD);
    ssl.setTruststoreFile(SERVER_SSL_KEY_TRUST_STORE);
    ssl.setTruststorePassword(SERVER_SSL_STORE_PASSWD);
    ssl.setClientAuthentication("NEED");

    SslConfiguration sslConfig = ssl.createSslConfiguration();

    listener.setSslConfiguration(sslConfig);
    listener.setImplicitSsl(true);
    DataConnectionConfigurationFactory dataConfigFactory = new DataConnectionConfigurationFactory();
    dataConfigFactory.setImplicitSsl(true);

    listener.setDataConnectionConfiguration(dataConfigFactory.createDataConnectionConfiguration());

    return listener;
}
 
開發者ID:jboss-integration,項目名稱:fuse-bxms-integ,代碼行數:25,代碼來源:CamelFtpsTest.java

示例2: Config2

import org.apache.ftpserver.listener.ListenerFactory; //導入方法依賴的package包/類
void Config2() {
//		Now, let's make it possible for a client to use FTPS (FTP over SSL) for the default listener.


        FtpServerFactory serverFactory = new FtpServerFactory();

        ListenerFactory factory = new ListenerFactory();

        // set the port of the listener
        factory.setPort(2221);

        // define SSL configuration
        SslConfigurationFactory ssl = new SslConfigurationFactory();
        ssl.setKeystoreFile(new File(ftpConfigDir + "ftpserver.jks"));
        ssl.setKeystorePassword("password");

        // set the SSL configuration for the listener
        factory.setSslConfiguration(ssl.createSslConfiguration());
        factory.setImplicitSsl(true);

        // replace the default listener
        serverFactory.addListener("default", factory.createListener());

        PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
        userManagerFactory.setFile(new File(ftpConfigDir + "users.properties"));

        serverFactory.setUserManager(userManagerFactory.createUserManager());

        // start the server
        FtpServer server = serverFactory.createServer();
        this.mFtpServer = server;
        try {
            server.start();
        } catch (FtpException e) {
            e.printStackTrace();
        }
    }
 
開發者ID:lucky-code,項目名稱:Practice,代碼行數:38,代碼來源:FtpActivity.java

示例3: createServer

import org.apache.ftpserver.listener.ListenerFactory; //導入方法依賴的package包/類
private FtpServer createServer( int port, String username, String password, boolean implicitSsl ) throws Exception {
  ListenerFactory factory = new ListenerFactory();
  factory.setPort( port );

  if ( implicitSsl ) {
    SslConfigurationFactory ssl = new SslConfigurationFactory();
    ssl.setKeystoreFile( new File( SERVER_KEYSTORE ) );
    ssl.setKeystorePassword( PASSWORD );
    // set the SSL configuration for the listener
    factory.setSslConfiguration( ssl.createSslConfiguration() );
    factory.setImplicitSsl( true );
  }

  FtpServerFactory serverFactory = new FtpServerFactory();
  // replace the default listener
  serverFactory.addListener( "default", factory.createListener() );

  PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();

  userManagerFactory.setFile( new File( SERVER_USERS ) );
  UserManager userManager = userManagerFactory.createUserManager();
  if ( !userManager.doesExist( username ) ) {
    BaseUser user = new BaseUser();
    user.setName( username );
    user.setPassword( password );
    user.setEnabled( true );
    user.setHomeDirectory( USER_HOME_DIR );
    user.setAuthorities( Collections.<Authority>singletonList( new WritePermission() ) );
    userManager.save( user );
  }

  serverFactory.setUserManager( userManager );
  return serverFactory.createServer();
}
 
開發者ID:pentaho,項目名稱:pentaho-kettle,代碼行數:35,代碼來源:FtpsServer.java

示例4: main

import org.apache.ftpserver.listener.ListenerFactory; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    FtpServerFactory serverFactory = new FtpServerFactory();
    
    ListenerFactory factory = new ListenerFactory();
    
    // set the port of the listener
    factory.setPort(2221);

    // define SSL configuration
    SslConfigurationFactory ssl = new SslConfigurationFactory();
    ssl.setKeystoreFile(new File("src/test/resources/ftpserver.jks"));
    ssl.setKeystorePassword("password");

    // set the SSL configuration for the listener
    factory.setSslConfiguration(ssl.createSslConfiguration());
    factory.setImplicitSsl(true);

    // replace the default listener
    serverFactory.addListener("default", factory.createListener());
    
    PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
    userManagerFactory.setFile(new File("myusers.properties"));
    
    serverFactory.setUserManager(userManagerFactory.createUserManager());
    
    // start the server
    FtpServer server = serverFactory.createServer(); 
    
    server.start();
}
 
開發者ID:saaconsltd,項目名稱:mina-ftpserver,代碼行數:31,代碼來源:EmbeddingFtpServer.java

示例5: before

import org.apache.ftpserver.listener.ListenerFactory; //導入方法依賴的package包/類
@BeforeClass
public static void before() throws Exception {

    sshd = SshServer.setUpDefaultServer();
    sshd.setPort(2220);
    sshd.setKeyPairProvider(createTestKeyPairProvider("target/test-classes/quickstarts/camel-ftp-binding/hostkey.pem"));
    sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));
    sshd.setCommandFactory(new ScpCommandFactory());
    sshd.setPasswordAuthenticator(new BogusPasswordAuthenticator());
    //sshd.setFileSystemFactory(new org.apache.sshd.common.file.nativefs.NativeFileSystemFactory());

    sshd.start();

    FtpServerFactory serverFactory = new FtpServerFactory();
    ListenerFactory listenerFactory = new ListenerFactory();
    listenerFactory.setPort(2222);
    serverFactory.addListener("default", listenerFactory.createListener());

    ListenerFactory sslListenerFactory = new ListenerFactory();
    sslListenerFactory.setPort(2221);
    SslConfigurationFactory ssl = new SslConfigurationFactory();
    ssl.setKeystoreFile(getFile("target/test-classes/quickstarts/camel-ftp-binding/ftpserver.jks"));
    ssl.setKeystorePassword("password");
    sslListenerFactory.setSslConfiguration(ssl.createSslConfiguration());
    sslListenerFactory.setImplicitSsl(false); // Setting it to true will not read the file
    serverFactory.addListener("ssl", sslListenerFactory.createListener());

    PropertiesUserManagerFactory managerFactory = new PropertiesUserManagerFactory();
    managerFactory.setPasswordEncryptor(new ClearTextPasswordEncryptor());
    managerFactory.setFile(getFile("target/test-classes/quickstarts/camel-ftp-binding/ftp-users.properties"));
    UserManager createUserManager = managerFactory.createUserManager();
    serverFactory.setUserManager(createUserManager);

    // This doesn't work due to class method signature mismatch
    //NativeFileSystemFactory fileSystemFactory = new NativeFileSystemFactory();
    //fileSystemFactory.setCreateHome(true);
    //serverFactory.setFileSystem(fileSystemFactory);

    File file = new File("target/ftp/ftps");
    file.mkdirs();
    file = new File("target/ftp/sftp");
    file.mkdirs();

    JSch sch = new JSch();
    Session session = sch.getSession("camel", "localhost", 2220);
    session.setUserInfo(new SimpleUserInfo("isMyFriend"));
    session.connect();
    ChannelSftp c = (ChannelSftp) session.openChannel("sftp");
    c.connect();
    System.out.println("Home: " + c.getHome());
    c.chmod(777, ".");
    c.chmod(777, "target");
    c.chmod(777, "target/ftp");
    c.chmod(777, "target/ftp/sftp");
    c.disconnect();
    session.disconnect();

    ftpServer = serverFactory.createServer();
    ftpServer.start();
    startTestContainer(featureName, bundleName);
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:62,代碼來源:CamelFTPBindingQuickstartTest.java

示例6: startUp

import org.apache.ftpserver.listener.ListenerFactory; //導入方法依賴的package包/類
@BeforeClass
public static void startUp() throws Exception {
    FtpServerFactory serverFactory = new FtpServerFactory();
    ListenerFactory listenerFactory = new ListenerFactory();
    listenerFactory.setPort(2222);
    serverFactory.addListener("default", listenerFactory.createListener());

    ListenerFactory sslListenerFactory = new ListenerFactory();
    sslListenerFactory.setPort(2221);
    SslConfigurationFactory ssl = new SslConfigurationFactory();
    ssl.setKeystoreFile(new File("src/test/resources/ftpserver.jks"));
    ssl.setKeystorePassword("password");
    sslListenerFactory.setSslConfiguration(ssl.createSslConfiguration());
    sslListenerFactory.setImplicitSsl(false); // Setting it to true will not read the file
    serverFactory.addListener("ftps", sslListenerFactory.createListener());

    PropertiesUserManagerFactory managerFactory = new PropertiesUserManagerFactory();
    managerFactory.setPasswordEncryptor(new ClearTextPasswordEncryptor());
    managerFactory.setFile(new File("src/test/resources/users.properties"));
    UserManager createUserManager = managerFactory.createUserManager();
    serverFactory.setUserManager(createUserManager);

    NativeFileSystemFactory fileSystemFactory = new NativeFileSystemFactory();
    fileSystemFactory.setCreateHome(true);
    serverFactory.setFileSystem(fileSystemFactory);

    File file = new File("target/ftp/ftps");
    file.mkdirs();
    file = new File("target/ftp/sftp");
    file.mkdirs();

    ftpServer = serverFactory.createServer();
    ftpServer.start();

    SshServer sshd = SshServer.setUpDefaultServer();
    sshd.setPort(2220);
    sshd.setKeyPairProvider(createTestKeyPairProvider("src/test/resources/hostkey.pem"));
    sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));
    sshd.setCommandFactory(new ScpCommandFactory());
    sshd.setPasswordAuthenticator(new BogusPasswordAuthenticator());

    sshd.start();

    JSch sch = new JSch();
    Session session = sch.getSession("camel", "localhost", 2220);
    session.setUserInfo(new SimpleUserInfo("isMyFriend"));
    session.connect();
    ChannelSftp c = (ChannelSftp) session.openChannel("sftp");
    c.connect();
    System.out.println("Home: " + c.getHome());
    c.chmod(777, ".");
    c.chmod(777, "target");
    c.chmod(777, "target/ftp");
    c.chmod(777, "target/ftp/sftp");
    c.disconnect();
    session.disconnect();
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:58,代碼來源:CamelFtpBindingTest.java

示例7: testUploadLoginSSLImplicite

import org.apache.ftpserver.listener.ListenerFactory; //導入方法依賴的package包/類
/**
 * Test method for {@link ch.sdi.core.impl.ftp.FtpExecutor#executeUpload(java.io.InputStream, java.lang.String)}.
 */
@Test
public void testUploadLoginSSLImplicite() throws Throwable
{
    myLog.debug( "Testing SSL login (implicite)" );

    String targetDir = myTargetDirLocal;
    cleanTargetDir( targetDir );
    Map<String, InputStream> filesToUpload = createFileUploadMap( targetDir );

    List<String> args = new ArrayList<String>();
    args.add( "-p" );
    args.add( "false" );  // activate implicite SSL
    args.add( "localhost" );
    args.add( "heri" ); // user
    args.add( "heri" ); // pw

    ListenerFactory listenerFactory = new ListenerFactory();

    // define SSL configuration
    SslConfigurationFactory ssl = new SslConfigurationFactory();
    ssl.setKeystoreFile(new File("keystore.jks"));  // this is in core/test/resources and contains one
                                                    // selfsigned certificate
    ssl.setKeystorePassword("password");
    listenerFactory.setSslConfiguration(ssl.createSslConfiguration());
    listenerFactory.setImplicitSsl(false);

    // replace the default listener
    Listener listenerOrg = myServerFactory.getListener( "default" );
    try
    {
        myServerFactory.addListener("default", listenerFactory.createListener());

        registerFtpUser( "heri", "heri" );

        FtpServer server = startFtpServer();
        try
        {
            myClassUnderTest.init( args.toArray( new String[args.size()] ) );
            myClassUnderTest.connectAndLogin();
            myClassUnderTest.uploadFiles( filesToUpload );
            myClassUnderTest.logoutAndDisconnect();
            assertFilesUploaded( createFileUploadMap( targetDir ) );
        }
        finally
        {
            if ( server != null )
            {
                myLog.debug( "stopping the embedded FTP server" );
                server.stop();
            } // if myServer != null
        }
    }
    finally
    {
        myServerFactory.addListener("default", listenerOrg );
    }
}
 
開發者ID:heribender,項目名稱:SocialDataImporter,代碼行數:61,代碼來源:FtpExecutorTest.java

示例8: doCreateFtpServerFactory

import org.apache.ftpserver.listener.ListenerFactory; //導入方法依賴的package包/類
protected FtpServerFactory doCreateFtpServerFactory() throws Exception {
    assertTrue(FTPSERVER_KEYSTORE.exists());
    
    FtpServerFactory serverFactory = super.createFtpServerFactory();
    
    ListenerFactory listenerFactory = new ListenerFactory(serverFactory.getListener(DEFAULT_LISTENER));
    listenerFactory.setImplicitSsl(useImplicit());
    listenerFactory.setSslConfiguration(createSslConfiguration().createSslConfiguration());
    
    serverFactory.addListener(DEFAULT_LISTENER, listenerFactory.createListener());

    return serverFactory;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:14,代碼來源:FtpsServerTestSupport.java

示例9: createServer

import org.apache.ftpserver.listener.ListenerFactory; //導入方法依賴的package包/類
@Override
protected FtpServerFactory createServer() throws Exception {
    assertTrue(FTPSERVER_KEYSTORE.exists());

    FtpServerFactory server = super.createServer();
    ListenerFactory factory = new ListenerFactory(server.getListener("default"));
    
    factory.setImplicitSsl(useImplicit());

    factory.setSslConfiguration(createSslConfiguration().createSslConfiguration());
    
    server.addListener("default", factory.createListener());
    
    return server;
}
 
開發者ID:saaconsltd,項目名稱:mina-ftpserver,代碼行數:16,代碼來源:SSLTestTemplate.java


注:本文中的org.apache.ftpserver.listener.ListenerFactory.setSslConfiguration方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。