org.apache.commons.net.util.TrustManagerUtils Java Examples
The following examples show how to use
org.apache.commons.net.util.TrustManagerUtils.
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 |
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: FtpsFileSystemConfigBuilder.java From commons-vfs with Apache License 2.0 | 3 votes |
/** * Gets the TrustManager that validates the FTPS server's certificate. * <p> * If the params do not contain the key for the trust manager, it will return a trust manger that simply checks this * certificate for validity. * </p> * * @param opts The FileSystemOptions. * @return the trust manager instance or {@code null} * @see org.apache.commons.net.ftp.FTPSClient#setTrustManager(TrustManager) * @since 2.1 */ public TrustManager getTrustManager(final FileSystemOptions opts) { final TrustManager trustManager; if (hasParam(opts, TRUST_MANAGER)) { trustManager = (TrustManager) getParam(opts, TRUST_MANAGER); } else { trustManager = TrustManagerUtils.getValidateServerCertificateTrustManager(); } return trustManager; }