Package org.apache.ftpserver.ssl

Examples of org.apache.ftpserver.ssl.DefaultSslConfiguration


   
    private SslConfiguration parseSsl(final Element parent) {
        Element sslElm = SpringUtil.getChildElement(parent, FtpServerNamespaceHandler.FTPSERVER_NS, "ssl");
       
        if(sslElm != null) {
            DefaultSslConfiguration ssl = new DefaultSslConfiguration();
       
            Element keyStoreElm = SpringUtil.getChildElement(sslElm, FtpServerNamespaceHandler.FTPSERVER_NS, "keystore");
            if(keyStoreElm != null) {
                ssl.setKeystoreFile(SpringUtil.parseFile(keyStoreElm, "file"));
                ssl.setKeystorePassword(SpringUtil.parseString(keyStoreElm, "password"));
               
                String type = SpringUtil.parseString(keyStoreElm, "type");
                if(type != null) {
                    ssl.setKeystoreType(type);
                }

                String keyAlias = SpringUtil.parseString(keyStoreElm, "key-alias");
                if(keyAlias != null) {
                    ssl.setKeyAlias(keyAlias);
                }
               
                String keyPassword = SpringUtil.parseString(keyStoreElm, "key-password");
                if(keyPassword != null) {
                    ssl.setKeyPassword(keyPassword);
                }
               
                String algorithm = SpringUtil.parseString(keyStoreElm, "algorithm");
                if(algorithm != null) {
                    ssl.setKeystoreAlgorithm(algorithm);
                }
            }
           
            Element trustStoreElm = SpringUtil.getChildElement(sslElm, FtpServerNamespaceHandler.FTPSERVER_NS, "truststore");
            if(trustStoreElm != null) {
                ssl.setTruststoreFile(SpringUtil.parseFile(trustStoreElm, "file"));
                ssl.setTruststorePassword(SpringUtil.parseString(trustStoreElm, "password"));
               
                String type = SpringUtil.parseString(trustStoreElm, "type");
                if(type != null) {
                    ssl.setTruststoreType(type);
                }
               
                String algorithm = SpringUtil.parseString(trustStoreElm, "algorithm");
                if(algorithm != null) {
                    ssl.setTruststoreAlgorithm(algorithm);
                }
            }
           
            String clientAuthStr = SpringUtil.parseString(sslElm, "client-authentication");
            if(clientAuthStr != null) {
                ssl.setClientAuthentication(clientAuthStr);
            }
           
            String enabledCiphersuites = SpringUtil.parseString(sslElm, "enabled-ciphersuites");
            if(enabledCiphersuites != null) {
                ssl.setEnabledCipherSuites(enabledCiphersuites.split(" "));
           

            String protocol = SpringUtil.parseString(sslElm, "protocol");
            if(protocol != null) {
                ssl.setSslProtocol(protocol);
           

           
            return ssl;
        } else {
View Full Code Here


        assertEquals(3, subnets.size());
        assertEquals(new Subnet(InetAddress.getByName("1.2.3.0"), 16), subnets.get(0));
        assertEquals(new Subnet(InetAddress.getByName("1.2.4.0"), 16), subnets.get(1));
        assertEquals(new Subnet(InetAddress.getByName("1.2.3.4"), 32), subnets.get(2));
       
        DefaultSslConfiguration ssl = (DefaultSslConfiguration) listener.getSslConfiguration();
        assertEquals(new File("/tmp/tmp.jks"), ssl.getKeystoreFile());
        assertEquals("password", ssl.getKeystorePassword());

        // make sure the data connection got the same config
        ssl = (DefaultSslConfiguration) listener.getDataConnectionConfiguration().getSslConfiguration();
        assertEquals(new File("/tmp/tmp.jks"), ssl.getKeystoreFile());
        assertEquals("password", ssl.getKeystorePassword());

       
        listener = listeners.get("listener1");
        assertNotNull(listener);
        assertTrue(listener instanceof NioListener);
View Full Code Here

        FtpServer server = new FtpServer();
        // set the port of the default listener
        server.getListener("default").setPort(2221);

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

        // set the SSL configuration for the listener
        server.getListener("default").setSslConfiguration(ssl);
        server.getListener("default").setImplicitSsl(true);
View Full Code Here

    private SslConfiguration parseSsl(final Element parent) {
        Element sslElm = SpringUtil.getChildElement(parent,
                FtpServerNamespaceHandler.FTPSERVER_NS, "ssl");

        if (sslElm != null) {
            DefaultSslConfiguration ssl = new DefaultSslConfiguration();

            Element keyStoreElm = SpringUtil.getChildElement(sslElm,
                    FtpServerNamespaceHandler.FTPSERVER_NS, "keystore");
            if (keyStoreElm != null) {
                ssl.setKeystoreFile(SpringUtil.parseFile(keyStoreElm, "file"));
                ssl.setKeystorePassword(SpringUtil.parseString(keyStoreElm,
                        "password"));

                String type = SpringUtil.parseString(keyStoreElm, "type");
                if (type != null) {
                    ssl.setKeystoreType(type);
                }

                String keyAlias = SpringUtil.parseString(keyStoreElm,
                        "key-alias");
                if (keyAlias != null) {
                    ssl.setKeyAlias(keyAlias);
                }

                String keyPassword = SpringUtil.parseString(keyStoreElm,
                        "key-password");
                if (keyPassword != null) {
                    ssl.setKeyPassword(keyPassword);
                }

                String algorithm = SpringUtil.parseString(keyStoreElm,
                        "algorithm");
                if (algorithm != null) {
                    ssl.setKeystoreAlgorithm(algorithm);
                }
            }

            Element trustStoreElm = SpringUtil.getChildElement(sslElm,
                    FtpServerNamespaceHandler.FTPSERVER_NS, "truststore");
            if (trustStoreElm != null) {
                ssl.setTruststoreFile(SpringUtil.parseFile(trustStoreElm,
                        "file"));
                ssl.setTruststorePassword(SpringUtil.parseString(trustStoreElm,
                        "password"));

                String type = SpringUtil.parseString(trustStoreElm, "type");
                if (type != null) {
                    ssl.setTruststoreType(type);
                }

                String algorithm = SpringUtil.parseString(trustStoreElm,
                        "algorithm");
                if (algorithm != null) {
                    ssl.setTruststoreAlgorithm(algorithm);
                }
            }

            String clientAuthStr = SpringUtil.parseString(sslElm,
                    "client-authentication");
            if (clientAuthStr != null) {
                ssl.setClientAuthentication(clientAuthStr);
            }

            String enabledCiphersuites = SpringUtil.parseString(sslElm,
                    "enabled-ciphersuites");
            if (enabledCiphersuites != null) {
                ssl.setEnabledCipherSuites(enabledCiphersuites.split(" "));
            }

            String protocol = SpringUtil.parseString(sslElm, "protocol");
            if (protocol != null) {
                ssl.setSslProtocol(protocol);
            }

            return ssl;
        } else {
            return null;
View Full Code Here

        assertEquals(new Subnet(InetAddress.getByName("1.2.4.0"), 16), subnets
                .get(1));
        assertEquals(new Subnet(InetAddress.getByName("1.2.3.4"), 32), subnets
                .get(2));

        DefaultSslConfiguration ssl = (DefaultSslConfiguration) listener
                .getSslConfiguration();
        assertEquals(new File("/tmp/tmp.jks"), ssl.getKeystoreFile());
        assertEquals("password", ssl.getKeystorePassword());

        // make sure the data connection got the same config
        ssl = (DefaultSslConfiguration) listener
                .getDataConnectionConfiguration().getSslConfiguration();
        assertEquals(new File("/tmp/tmp.jks"), ssl.getKeystoreFile());
        assertEquals("password", ssl.getKeystorePassword());

        listener = listeners.get("listener1");
        assertNotNull(listener);
        assertTrue(listener instanceof NioListener);
        assertEquals(2223, ((NioListener) listener).getPort());
View Full Code Here

TOP

Related Classes of org.apache.ftpserver.ssl.DefaultSslConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.