@Override protected JSch createDefaultJSch(FS fs) throws JSchException { if (GitMonitoringService.this.isJschLoggerEnabled) { JSch.setLogger(new JschLogger()); } JSch defaultJSch = super.createDefaultJSch(fs); defaultJSch.getIdentityRepository().removeAll(); if (GitMonitoringService.this.privateKeyPath != null) { defaultJSch.addIdentity(GitMonitoringService.this.privateKeyPath, GitMonitoringService.this.passphrase); } else { defaultJSch.addIdentity("gaas-git", GitMonitoringService.this.privateKey, null, GitMonitoringService.this.passphrase.getBytes(Charset.forName("UTF-8"))); } if (!Strings.isNullOrEmpty(GitMonitoringService.this.knownHosts)) { defaultJSch.setKnownHosts(new ByteArrayInputStream(GitMonitoringService.this.knownHosts.getBytes(Charset.forName("UTF-8")))); } else if (!Strings.isNullOrEmpty(GitMonitoringService.this.knownHostsFile)) { defaultJSch.setKnownHosts(GitMonitoringService.this.knownHostsFile); } return defaultJSch; } };
@Override protected JSch createDefaultJSch(FS fs) throws JSchException { JSch jSch = super.createDefaultJSch(fs); // apply customized private key if (privateKeyPath != null) { jSch.removeAllIdentity(); jSch.addIdentity(privateKeyPath.toString()); } return jSch; } };
defaultJSch = createDefaultJSch(fs); if (defaultJSch.getConfigRepository() == null) { defaultJSch.setConfigRepository(
@Override protected JSch createDefaultJSch(FS fs) throws JSchException { if (privateKey != null) { JSch defaultJSch = super.createDefaultJSch(fs); defaultJSch.addIdentity(privateKey.toFile().getAbsolutePath()); return defaultJSch; } else { return super.createDefaultJSch(fs); } } };
@Override protected JSch createDefaultJSch(FS fs) throws JSchException { if (privateKey != null) { JSch defaultJSch = super.createDefaultJSch(fs); defaultJSch.addIdentity(privateKey.toFile().getAbsolutePath()); return defaultJSch; } else { return super.createDefaultJSch(fs); } } };
@Override protected JSch createDefaultJSch(FS fs) throws JSchException { if (privateKey != null) { JSch defaultJSch = super.createDefaultJSch(fs); defaultJSch.addIdentity(privateKey.toFile().getAbsolutePath()); return defaultJSch; } else { return super.createDefaultJSch(fs); } } };
@Override protected JSch createDefaultJSch(final FS fs) throws JSchException { JSch.setConfig("StrictHostKeyChecking", "no"); final JSch defaultJSch = super.createDefaultJSch(fs); if (credentialFile != null) { defaultJSch.addIdentity(credentialFile.toString()); } return defaultJSch; } };
@Override protected JSch createDefaultJSch(FS fs ) throws JSchException { JSch defaultJSch = super.createDefaultJSch( fs ); defaultJSch.setConfig("StrictHostKeyChecking", "no"); defaultJSch.addIdentity(configuration.getString("idRsaKeyPath")); return defaultJSch; } };
@Override protected JSch createDefaultJSch(FS fs ) throws JSchException { JSch defaultJSch = super.createDefaultJSch( fs ); defaultJSch.setConfig("StrictHostKeyChecking", "no"); defaultJSch.addIdentity(configuration.getString("idRsaKeyPath")); return defaultJSch; } };
@Override protected JSch createDefaultJSch(FS fs) throws JSchException { JSch defaultJSch = super.createDefaultJSch(fs); if (connection == ConnectionType.kSshPubKey) defaultJSch.addIdentity(AuthData.getPrivateKeyPath(context)); return defaultJSch; }
@Override protected JSch createDefaultJSch(FS fs) throws JSchException { if (GitMonitoringService.this.isJschLoggerEnabled) { JSch.setLogger(new JschLogger()); } JSch defaultJSch = super.createDefaultJSch(fs); defaultJSch.addIdentity(GitMonitoringService.this.privateKeyPath, GitMonitoringService.this.passphrase); return defaultJSch; } };
@Override protected JSch createDefaultJSch(FS fs) throws JSchException { JSch def = super.createDefaultJSch(fs); String keyName = ServerConfiguration.getInstance(). getFirstProperty(GitDeploymentSynchronizerConstants.SSH_PRIVATE_KEY_NAME); String keyPath = ServerConfiguration.getInstance(). getFirstProperty(GitDeploymentSynchronizerConstants.SSH_PRIVATE_KEY_PATH); if (keyName == null || keyName.isEmpty()) keyName = GitDeploymentSynchronizerConstants.SSH_KEY; if (keyPath == null || keyPath.isEmpty()) keyPath = System.getProperty("user.home") + "/" + GitDeploymentSynchronizerConstants.SSH_KEY_DIRECTORY; if (keyPath.endsWith("/")) def.addIdentity(keyPath + keyName); else def.addIdentity(keyPath + "/" + keyName); return def; } }
@Override protected JSch createDefaultJSch(FS fs) throws JSchException { Connector connector = null; try { if (SSHAgentConnector.isConnectorAvailable()) { USocketFactory usf = new JNAUSocketFactory(); connector = new SSHAgentConnector(usf); } log.info("Successfully connected to an agent"); } catch (AgentProxyException e) { log.error( "Exception occurred while trying to connect to agent. Will create" + "the default JSch connection", e); return super.createDefaultJSch(fs); } final JSch jsch = super.createDefaultJSch(fs); if (connector != null) { JSch.setConfig("PreferredAuthentications", "publickey,password"); IdentityRepository identityRepository = new RemoteIdentityRepository( connector); jsch.setIdentityRepository(identityRepository); } return jsch; } };
defaultJSch = createDefaultJSch(fs); for (Object name : defaultJSch.getIdentityNames()) byIdentityFile.put((String) name, defaultJSch);
final JSch jsch = super.createDefaultJSch(fs); if (con != null) { JSch.setConfig("PreferredAuthentications", "publickey");
defaultJSch = createDefaultJSch(fs); if (defaultJSch.getConfigRepository() == null) { defaultJSch.setConfigRepository(
@Override protected JSch createDefaultJSch(FS fs) throws JSchException { Connector con = null; try { if (SSHAgentConnector.isConnectorAvailable()) { USocketFactory usf = new JNAUSocketFactory(); con = new SSHAgentConnector(usf); } else { ConnectorFactory cf = ConnectorFactory.getDefault(); con = cf.createConnector(); } } catch (AgentProxyException e) { Log.log(e); } JSch jsch = super.createDefaultJSch(fs); if (con != null) { JSch.setConfig("PreferredAuthentications", "publickey"); IdentityRepository irepo = new RemoteIdentityRepository(con); jsch.setIdentityRepository(irepo); } return jsch; } };