List of usage examples for org.apache.commons.net.util KeyManagerUtils createClientKeyManager
public static KeyManager createClientKeyManager(File storePath, String storePass, String keyAlias) throws IOException, GeneralSecurityException
From source file:com.streamsets.pipeline.lib.remote.FTPRemoteConnector.java
private void setFtpsUserKeyManagerOrTrustManager(String file, String fileConfigName, CredentialValue password, String passwordConfigName, KeyStoreType keyStoreType, boolean isKeystore, // or truststore List<Stage.ConfigIssue> issues, ConfigIssueContext context, Label group) { if (file != null && !file.isEmpty()) { File keystoreFile = new File(file); String keystorePassword = resolveCredential(password, passwordConfigName, issues, context, group); try {/*w ww . j a v a 2 s . co m*/ KeyStore keystore = loadKeystore(keystoreFile, keyStoreType.getJavaValue(), keystorePassword); 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)); } } catch (IOException | GeneralSecurityException e) { issues.add(context.createConfigIssue(group.getLabel(), fileConfigName, Errors.REMOTE_14, isKeystore ? "key" : "trust", keystoreFile.getAbsolutePath(), e.getMessage(), e)); } } else { if (isKeystore) { issues.add(context.createConfigIssue(group.getLabel(), fileConfigName, Errors.REMOTE_12)); } else { issues.add(context.createConfigIssue(group.getLabel(), fileConfigName, Errors.REMOTE_13)); } } }