Search in sources :

Example 1 with FossologyHostKeyRepository

use of org.eclipse.sw360.fossology.ssh.keyrepo.FossologyHostKeyRepository in project sw360portal by sw360.

the class RealSshConnectionUtils method getTrustingJSchSessionFactory.

static JSchSessionProvider getTrustingJSchSessionFactory() {
    FossologyFingerPrintRepository keyConnector = mock(FossologyFingerPrintRepository.class);
    FossologyHostKeyRepository hostKeyRepository = spy(new FossologyHostKeyRepository(keyConnector));
    doReturn(HostKeyRepository.OK).when(hostKeyRepository).check(anyString(), any(byte[].class));
    return new JSchSessionProvider(new FossologySettings(), hostKeyRepository);
}
Also used : FossologyFingerPrintRepository(org.eclipse.sw360.fossology.db.FossologyFingerPrintRepository) FossologyHostKeyRepository(org.eclipse.sw360.fossology.ssh.keyrepo.FossologyHostKeyRepository) FossologySettings(org.eclipse.sw360.fossology.config.FossologySettings)

Example 2 with FossologyHostKeyRepository

use of org.eclipse.sw360.fossology.ssh.keyrepo.FossologyHostKeyRepository in project sw360portal by sw360.

the class JSchSessionProvider method doGetSession.

private Session doGetSession(int connectionTimeout) throws SW360Exception {
    synchronized (J_SCH) {
        try {
            Session session = J_SCH.getSession(userName, hostName, hostPort);
            session.setHostKeyRepository(fossologyHostKeyRepository);
            session.connect(connectionTimeout);
            return session;
        } catch (JSchException e) {
            String serverString = getServerString();
            log.error("cannot connect to fossology server: " + serverString, e);
            throw new SW360Exception("cannot connect to Fossology Server");
        }
    }
}
Also used : JSchException(com.jcraft.jsch.JSchException) SW360Exception(org.eclipse.sw360.datahandler.thrift.SW360Exception) Session(com.jcraft.jsch.Session)

Aggregations

JSchException (com.jcraft.jsch.JSchException)1 Session (com.jcraft.jsch.Session)1 SW360Exception (org.eclipse.sw360.datahandler.thrift.SW360Exception)1 FossologySettings (org.eclipse.sw360.fossology.config.FossologySettings)1 FossologyFingerPrintRepository (org.eclipse.sw360.fossology.db.FossologyFingerPrintRepository)1 FossologyHostKeyRepository (org.eclipse.sw360.fossology.ssh.keyrepo.FossologyHostKeyRepository)1