com.jcraft.jsch.IdentityRepository Java Examples
The following examples show how to use
com.jcraft.jsch.IdentityRepository.
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: SftpClient.java From netbeans with Apache License 2.0 | 6 votes |
private boolean setAgent(JSch jsch, String identityFile, boolean preferAgent) throws JSchException { boolean agentUsed = false; if (preferAgent) { Connector con = ConnectorFactory.getInstance().createConnector(ConnectorFactory.ConnectorKind.ANY); if (con != null) { IdentityRepository irepo = new IdentityRepositoryImpl(con); if (irepo.getStatus() == IdentityRepository.RUNNING) { jsch.setIdentityRepository(irepo); agentUsed = true; } } } if (!agentUsed) { jsch.setIdentityRepository(null); // remove all identity files jsch.removeAllIdentity(); // and add the one specified by CredentialsProvider if (StringUtils.hasText(identityFile)) { jsch.addIdentity(identityFile); } } return agentUsed; }
Example #2
Source File: JGitSshSessionFactory.java From netbeans with Apache License 2.0 | 6 votes |
private boolean setupJSchIdentityRepository (JSch jsch, String identityFile, boolean preferAgent) throws JSchException { boolean agentUsed = false; if (preferAgent) { Connector con = ConnectorFactory.getInstance().createConnector(ConnectorFactory.ConnectorKind.ANY); if (con != null) { IdentityRepository irepo = new IdentityRepositoryImpl(con); if (irepo.getStatus() == IdentityRepository.RUNNING) { jsch.setIdentityRepository(irepo); agentUsed = true; } } } if (!agentUsed) { jsch.setIdentityRepository(null); // remove all identity files jsch.removeAllIdentity(); // and add the one specified by CredentialsProvider jsch.addIdentity(identityFile); } return agentUsed; }
Example #3
Source File: SFTPEnvironmentTest.java From sftp-fs with Apache License 2.0 | 5 votes |
@Test public void testInitializeJSchFull() throws IOException, JSchException { SFTPEnvironment env = new SFTPEnvironment(); initializeFully(env); JSch jsch = mock(JSch.class); env.initialize(jsch); verify(jsch).setIdentityRepository((IdentityRepository) env.get("identityRepository")); IdentityTest.assertIdentityFromFilesAdded(jsch); verify(jsch).setHostKeyRepository((HostKeyRepository) env.get("hostKeyRepository")); verify(jsch).setKnownHosts(((File) env.get("knownHosts")).getAbsolutePath()); verifyNoMoreInteractions(jsch); }
Example #4
Source File: SftpClient.java From netbeans with Apache License 2.0 | 4 votes |
@Override public int getStatus() { return connector.isAvailable() && proxy.isRunning() ? IdentityRepository.RUNNING : IdentityRepository.UNAVAILABLE; }
Example #5
Source File: JGitSshSessionFactory.java From netbeans with Apache License 2.0 | 4 votes |
@Override public int getStatus () { return connector.isAvailable() && proxy.isRunning() ? IdentityRepository.RUNNING : IdentityRepository.UNAVAILABLE; }
Example #6
Source File: AgentProxyAwareJschConfigSessionFactory.java From gitflow-incremental-builder with MIT License | 4 votes |
@Override public int getStatus() { return IdentityRepository.RUNNING; }
Example #7
Source File: SFTPEnvironment.java From sftp-fs with Apache License 2.0 | 2 votes |
/** * Stores the identity repository to use. * * @param repository The identity repository to use. * @return This object. */ public SFTPEnvironment withIdentityRepository(IdentityRepository repository) { put(IDENTITY_REPOSITORY, repository); return this; }
Example #8
Source File: DefaultSessionFactory.java From jsch-extension with MIT License | 2 votes |
/** * Sets the {@link IdentityRepository} for this factory. This will replace * any current IdentityRepository, so you should be sure to call this before * any of the <code>setIdentit(y|ies)Xxx</code> if you plan on using both. * * @param identityRepository * The identity repository * * @see JSch#setIdentityRepository(IdentityRepository) */ public void setIdentityRepository( IdentityRepository identityRepository ) { jsch.setIdentityRepository( identityRepository ); }
Example #9
Source File: IdentityRepositoryFactory.java From commons-vfs with Apache License 2.0 | 2 votes |
/** * Creates an Identity repository for a given JSch instance. * * @param jsch JSch context * @return a new IdentityRepository */ IdentityRepository create(JSch jsch);