当前位置: 首页>>代码示例>>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;未经允许,请勿转载。