org.apache.commons.vfs2.provider.ftps.FtpsFileSystemConfigBuilder Java Examples

The following examples show how to use org.apache.commons.vfs2.provider.ftps.FtpsFileSystemConfigBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FTPRemoteConnector.java    From datacollector with Apache License 2.0 5 votes vote down vote up
private void setFtpsUserKeyManagerOrTrustManager(
    KeyStore keystore,
    String fileConfigName,
    String keyStorePassword,
    boolean isKeyStore, // or truststore
    List<Stage.ConfigIssue> issues,
    ConfigIssueContext context,
    Label group
) {
  try {
    if (isKeyStore) {
      FtpsFileSystemConfigBuilder.getInstance().setKeyManager(
          options,
          KeyManagerUtils.createClientKeyManager(keystore, null, keyStorePassword)
      );
    } else {
      FtpsFileSystemConfigBuilder.getInstance().setTrustManager(
          options,
          TrustManagerUtils.getDefaultTrustManager(keystore)
      );
    }
  } catch (GeneralSecurityException e) {
    issues.add(context.createConfigIssue(group.getLabel(),
        fileConfigName,
        Errors.REMOTE_15,
        isKeyStore ? "key" : "trust",
        e.getMessage(),
        e
    ));
  }
}
 
Example #2
Source File: StorageObject.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
private FileSystemOptions getOptions(StorageMapping mapping) throws Exception {
	FileSystemOptions opts = new FileSystemOptions();
	if (null == mapping.getProtocol()) {
		throw new Exception("storage protocol is null.");
	}
	switch (mapping.getProtocol()) {
	// bzip2,file, ftp, ftps, gzip, hdfs, http, https, jar, ram, res, sftp,
	// tar, temp, webdav, zip, cifs, mime;
	case ftp:
		FtpFileSystemConfigBuilder ftpBuilder = FtpFileSystemConfigBuilder.getInstance();
		/*
		 * 如果使用被动模式在阿里云centos7下会经常性出现无法连接 Caused by: java.net.ConnectException:
		 * Connection timed out (Connection timed out) at
		 * java.net.PlainSocketImpl.socketConnect(Native Method) at
		 * java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
		 * at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.
		 * java:206) at
		 * java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at
		 * java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at
		 * java.net.Socket.connect(Socket.java:589)
		 */
		ftpBuilder.setPassiveMode(opts, Config.vfs().getFtp().getPassive());
		// builder.setPassiveMode(opts, false);
		// builder.setPassiveMode(opts, true);
		/** 强制不校验IP */
		ftpBuilder.setRemoteVerification(opts, false);
		// FtpFileType.BINARY is the default
		ftpBuilder.setFileType(opts, FtpFileType.BINARY);
		ftpBuilder.setConnectTimeout(opts, 10000);
		ftpBuilder.setSoTimeout(opts, 10000);
		ftpBuilder.setControlEncoding(opts, DefaultCharset.name);
		break;
	case ftps:
		FtpsFileSystemConfigBuilder ftpsBuilder = FtpsFileSystemConfigBuilder.getInstance();
		ftpsBuilder.setPassiveMode(opts, Config.vfs().getFtp().getPassive());
		/** 强制不校验IP */
		ftpsBuilder.setRemoteVerification(opts, false);
		// FtpFileType.BINARY is the default
		ftpsBuilder.setFileType(opts, FtpFileType.BINARY);
		ftpsBuilder.setConnectTimeout(opts, 10000);
		ftpsBuilder.setSoTimeout(opts, 10000);
		ftpsBuilder.setControlEncoding(opts, DefaultCharset.name);
		break;
	case cifs:
		break;
	case webdav:
		WebdavFileSystemConfigBuilder webdavBuilder = (WebdavFileSystemConfigBuilder) WebdavFileSystemConfigBuilder
				.getInstance();
		webdavBuilder.setConnectionTimeout(opts, 10000);
		webdavBuilder.setSoTimeout(opts, 10000);
		webdavBuilder.setUrlCharset(opts, DefaultCharset.name);
		// webdavBuilder.setVersioning(opts, true);
		break;
	case file:
		break;
	default:
		break;
	}
	return opts;
}
 
Example #3
Source File: FtpsProviderExplicitTestCase.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
protected void setupOptions(final FtpsFileSystemConfigBuilder builder) {
    super.setupOptions(builder);
    builder.setDataChannelProtectionLevel(fileSystemOptions, FtpsDataChannelProtectionLevel.P);
    builder.setFtpsMode(fileSystemOptions, FtpsMode.EXPLICIT);
}
 
Example #4
Source File: AbstractFtpsProviderTestCase.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
protected void setupOptions(final FtpsFileSystemConfigBuilder builder) {
    builder.setConnectTimeout(fileSystemOptions, Integer.valueOf(1000));
    builder.setDataTimeout(fileSystemOptions, Integer.valueOf(2000));
}
 
Example #5
Source File: FtpsProviderImplicitTestCase.java    From commons-vfs with Apache License 2.0 4 votes vote down vote up
@Override
protected void setupOptions(final FtpsFileSystemConfigBuilder builder) {
    super.setupOptions(builder);
    builder.setFtpsMode(fileSystemOptions, FtpsMode.IMPLICIT);
}