Example usage for org.apache.commons.net.ftp FTPSClient setAuthValue

List of usage examples for org.apache.commons.net.ftp FTPSClient setAuthValue

Introduction

In this page you can find the example usage for org.apache.commons.net.ftp FTPSClient setAuthValue.

Prototype

public void setAuthValue(String auth) 

Source Link

Document

Set AUTH command use value.

Usage

From source file:org.apache.ftpserver.ssl.SSLTestTemplate.java

protected FTPSClient createFTPClient() throws Exception {
    FTPSClient ftpsClient = new FTPSClient(useImplicit());

    FileInputStream fin = new FileInputStream(FTPCLIENT_KEYSTORE);
    KeyStore store = KeyStore.getInstance("jks");
    store.load(fin, KEYSTORE_PASSWORD.toCharArray());
    fin.close();//from w w w. j  ava 2 s .  co m

    // initialize key manager factory
    KeyManagerFactory keyManagerFactory = KeyManagerFactory
            .getInstance(KeyManagerFactory.getDefaultAlgorithm());
    keyManagerFactory.init(store, KEYSTORE_PASSWORD.toCharArray());

    // initialize trust manager factory
    TrustManagerFactory trustManagerFactory = TrustManagerFactory
            .getInstance(TrustManagerFactory.getDefaultAlgorithm());

    trustManagerFactory.init(store);

    clientKeyManager = keyManagerFactory.getKeyManagers()[0];
    clientTrustManager = trustManagerFactory.getTrustManagers()[0];

    ftpsClient.setKeyManager(clientKeyManager);
    ftpsClient.setTrustManager(clientTrustManager);

    String auth = getAuthValue();
    if (auth != null) {
        ftpsClient.setAuthValue(auth);

        if (auth.equals("SSL")) {
            ftpsClient.setEnabledProtocols(new String[] { "SSLv3" });
        }
    }
    return ftpsClient;
}

From source file:org.springframework.integration.ftp.session.DefaultFtpsSessionFactory.java

@Override
protected void postProcessClientBeforeConnect(FTPSClient ftpsClient) throws IOException {
    if (StringUtils.hasText(this.authValue)) {
        ftpsClient.setAuthValue(authValue);
    }/*from   w w w.j  a v a2  s.  c o m*/
    if (this.trustManager != null) {
        ftpsClient.setTrustManager(this.trustManager);
    }
    if (this.cipherSuites != null) {
        ftpsClient.setEnabledCipherSuites(this.cipherSuites);
    }
    if (this.protocols != null) {
        ftpsClient.setEnabledProtocols(this.protocols);
    }
    if (this.sessionCreation != null) {
        ftpsClient.setEnabledSessionCreation(this.sessionCreation);
    }
    if (this.useClientMode != null) {
        ftpsClient.setUseClientMode(this.useClientMode);
    }
    if (this.sessionCreation != null) {
        ftpsClient.setEnabledSessionCreation(this.sessionCreation);
    }
    if (this.keyManager != null) {
        ftpsClient.setKeyManager(keyManager);
    }
    if (this.needClientAuth != null) {
        ftpsClient.setNeedClientAuth(this.needClientAuth);
    }
    if (this.wantsClientAuth != null) {
        ftpsClient.setWantClientAuth(this.wantsClientAuth);
    }
}

From source file:org.teiid.resource.adapter.ftp.FtpManagedConnectionFactory.java

private void afterConnectProcessing(FTPClient client) throws IOException {

    if (this.parentDirectory == null) {
        throw new IOException(UTIL.getString("parentdirectory_not_set")); //$NON-NLS-1$
    }/*  w w  w . j a va 2 s . c  o m*/

    if (!client.changeWorkingDirectory(this.getParentDirectory())) {
        throw new IOException(UTIL.getString("ftp_dir_not_exist", this.getParentDirectory())); //$NON-NLS-1$
    }

    updateClientMode(client);

    client.setFileType(this.fileType);
    client.setBufferSize(this.bufferSize);

    if (this.isFtps) {
        FTPSClient ftpsClient = (FTPSClient) client;
        if (this.getAuthValue() != null) {
            ftpsClient.setAuthValue(this.authValue);
        }
        if (this.trustManager != null) {
            ftpsClient.setTrustManager(this.trustManager);
        }
        if (this.cipherSuites != null) {
            ftpsClient.setEnabledCipherSuites(this.cipherSuites);
        }
        if (this.protocols != null) {
            ftpsClient.setEnabledProtocols(this.protocols);
        }
        if (this.sessionCreation != null) {
            ftpsClient.setEnabledSessionCreation(this.sessionCreation);
        }
        if (this.useClientMode != null) {
            ftpsClient.setUseClientMode(this.useClientMode);
        }
        if (this.sessionCreation != null) {
            ftpsClient.setEnabledSessionCreation(this.sessionCreation);
        }
        if (this.keyManager != null) {
            ftpsClient.setKeyManager(this.keyManager);
        }
        if (this.needClientAuth != null) {
            ftpsClient.setNeedClientAuth(this.needClientAuth);
        }
        if (this.wantsClientAuth != null) {
            ftpsClient.setWantClientAuth(this.wantsClientAuth);
        }
    }
}

From source file:org.teiid.test.teiid4441.FTPClientFactory.java

private void afterConnectProcessing(FTPClient client) throws IOException {

    if (this.parentDirectory == null) {
        throw new IOException("parentdirectory_not_set");
    }/* www. jav  a  2 s.  c  om*/

    if (!client.changeWorkingDirectory(this.getParentDirectory())) {
        throw new IOException("ftp_dir_not_exist");
    }

    updateClientMode(client);

    client.setFileType(this.fileType);
    client.setBufferSize(this.bufferSize);

    if (this.isFtps) {
        FTPSClient ftpsClient = (FTPSClient) client;
        if (this.getAuthValue() != null) {
            ftpsClient.setAuthValue(this.authValue);
        }
        if (this.trustManager != null) {
            ftpsClient.setTrustManager(this.trustManager);
        }
        if (this.cipherSuites != null) {
            ftpsClient.setEnabledCipherSuites(this.cipherSuites);
        }
        if (this.protocols != null) {
            ftpsClient.setEnabledProtocols(this.protocols);
        }
        if (this.sessionCreation != null) {
            ftpsClient.setEnabledSessionCreation(this.sessionCreation);
        }
        if (this.useClientMode != null) {
            ftpsClient.setUseClientMode(this.useClientMode);
        }
        if (this.sessionCreation != null) {
            ftpsClient.setEnabledSessionCreation(this.sessionCreation);
        }
        if (this.keyManager != null) {
            ftpsClient.setKeyManager(this.keyManager);
        }
        if (this.needClientAuth != null) {
            ftpsClient.setNeedClientAuth(this.needClientAuth);
        }
        if (this.wantsClientAuth != null) {
            ftpsClient.setWantClientAuth(this.wantsClientAuth);
        }
    }
}