当前位置: 首页>>代码示例>>Java>>正文


Java TransportException类代码示例

本文整理汇总了Java中net.schmizz.sshj.transport.TransportException的典型用法代码示例。如果您正苦于以下问题:Java TransportException类的具体用法?Java TransportException怎么用?Java TransportException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TransportException类属于net.schmizz.sshj.transport包,在下文中一共展示了TransportException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: map

import net.schmizz.sshj.transport.TransportException; //导入依赖的package包/类
public BackgroundException map(final IOException e, final StringBuilder buffer, final DisconnectReason reason) {
    final String failure = buffer.toString();
    if(DisconnectReason.HOST_KEY_NOT_VERIFIABLE.equals(reason)) {
        log.warn(String.format("Failure verifying host key. %s", failure));
        // Host key dismissed by user
        return new ConnectionCanceledException(e);
    }
    if(DisconnectReason.PROTOCOL_ERROR.equals(reason)) {
        // Too many authentication failures
        return new InteroperabilityException(failure, e);
    }
    if(DisconnectReason.ILLEGAL_USER_NAME.equals(reason)) {
        return new LoginFailureException(failure, e);
    }
    if(DisconnectReason.NO_MORE_AUTH_METHODS_AVAILABLE.equals(reason)) {
        return new LoginFailureException(failure, e);
    }
    if(DisconnectReason.PROTOCOL_VERSION_NOT_SUPPORTED.equals(reason)) {
        return new InteroperabilityException(failure, e);
    }
    if(e instanceof TransportException) {
        return new ConnectionRefusedException(buffer.toString(), e);
    }
    return this.wrap(e, buffer);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:26,代码来源:SFTPExceptionMappingService.java

示例2: executeCommand

import net.schmizz.sshj.transport.TransportException; //导入依赖的package包/类
private Command executeCommand(String command) throws TransportException, ConnectionException {
	Session sshSession = null;
	Command cmd = null;
	
	try {
		sshSession = sshClient.startSession();
		
		cmd = sshSession.exec(command);
		
		cmd.join(SSH_EXEC_TIMEOUT_IN_SEC, TimeUnit.SECONDS);
		
	} catch (ConnectionException e) {
		if (e.getCause() instanceof TimeoutException) {
			return null;
		}
		throw e;
	} finally {
		if (sshSession != null) {
			sshSession.close();
		}
	}
	
	return cmd;
}
 
开发者ID:openaire,项目名称:iis,代码行数:25,代码来源:SshSimpleConnection.java

示例3: sshAuth

import net.schmizz.sshj.transport.TransportException; //导入依赖的package包/类
private void sshAuth() throws IOException, UserAuthException, TransportException, CryptographyException {
	if (server != null) {
		ssh.connect(server.getHost(), server.getPort());
		switch (server.getAuthentication().getAuthenticationTypeEnum()) {
		case NO_AUTHENTICATION:
			NoAuthentication noAuthentication = (NoAuthentication) server.getAuthentication();
			ssh.auth(noAuthentication.getLogin());
			break;
		case SSH_AUTHENTICATION_PASSWORD:
			SSHAuthenticationPassword sshAuthenticationPassword = (SSHAuthenticationPassword) server.getAuthentication();
			String password = sshAuthenticationPassword.getDecryptPassword(myAuthentication.getKey());
			PasswordFinder createOneOff = PasswordUtils.createOneOff(password.toCharArray());
			ssh.auth(sshAuthenticationPassword.getLogin(), new AuthPassword(createOneOff));
			break;
		default:
			throw new RuntimeException("authentication type is not supported");
		}
	} else {
		throw new IllegalStateException("server is required");
	}
}
 
开发者ID:joakim-ribier,项目名称:JOneTouch,代码行数:22,代码来源:CommandExecutor.java

示例4: resolveStateFromThrowable

import net.schmizz.sshj.transport.TransportException; //导入依赖的package包/类
protected ApplicationState resolveStateFromThrowable(final Throwable throwable) {

        final ApplicationState state;
        if (throwable == null) {
            state = ApplicationState.UNKNOWN;
        }
        else if (throwable instanceof UnknownHostException) {
            state = ApplicationState.INVALID;
        }
        else if (throwable instanceof UserAuthException) {
            state = ApplicationState.NO_AUTH;
        }
        else if (throwable instanceof TransportException) {
            state = ApplicationState.UNREACHABLE;
        }
        else if (throwable instanceof TimeoutException) {
            state = ApplicationState.UNREACHABLE;
        }
        else if (throwable instanceof InterruptedException) {
            state = ApplicationState.UNKNOWN;
        }
        else {
            final Throwable cause = throwable.getCause();
            state = cause == null ? ApplicationState.UNREACHABLE : resolveStateFromThrowable(cause);
        }
        return state;
    }
 
开发者ID:stacs-srg,项目名称:shabdiz,代码行数:28,代码来源:AbstractApplicationManager.java

示例5: executeCommandWithRetries

import net.schmizz.sshj.transport.TransportException; //导入依赖的package包/类
private Command executeCommandWithRetries(String command) throws TransportException, ConnectionException {
	int currentRetryCount = 0;
	Command cmd = null;
	
	while(true) {
		
		cmd = executeCommand(command);
		
		if (cmd == null) {
			if (currentRetryCount >= SSH_MAX_RETRY_COUNT) {
				throw new RuntimeException("Retry limit exceeded when trying to execute ssh command.");
			}
			
			++currentRetryCount;
			log.debug("Timeout when trying to execute ssh command. Will try again in " + SSH_RETRY_COOLDOWN_IN_SEC + " seconds");
			
			try {
				Thread.sleep(1000 * SSH_RETRY_COOLDOWN_IN_SEC);
			} catch (InterruptedException e1) {
				throw new RuntimeException(e1);
			}
			
			continue;
		}
		
		break;
	}
	
	return cmd;
}
 
开发者ID:openaire,项目名称:iis,代码行数:31,代码来源:SshSimpleConnection.java

示例6: onPostExecute

import net.schmizz.sshj.transport.TransportException; //导入依赖的package包/类
@Override
protected void onPostExecute(AsyncTaskResult<SSHClient> result) {

    if(result.exception != null) {
        if(SocketException.class.isAssignableFrom(result.exception.getClass())
                || SocketTimeoutException.class.isAssignableFrom(result.exception.getClass())) {
            Toast.makeText(AppConfig.getInstance(),
                    String.format(AppConfig.getInstance().getResources().getString(R.string.ssh_connect_failed),
                            mHostname, mPort, result.exception.getLocalizedMessage()),
                    Toast.LENGTH_LONG).show();
            return;
        }
        else if(TransportException.class.isAssignableFrom(result.exception.getClass()))
        {
            DisconnectReason disconnectReason = TransportException.class.cast(result.exception).getDisconnectReason();
            if(DisconnectReason.HOST_KEY_NOT_VERIFIABLE.equals(disconnectReason)) {
                new AlertDialog.Builder(AppConfig.getInstance().getActivityContext())
                        .setTitle(R.string.ssh_connect_failed_host_key_changed_title)
                        .setMessage(R.string.ssh_connect_failed_host_key_changed_message)
                        .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        }).show();
            }
            return;
        }
        else if(mPassword != null) {
            Toast.makeText(AppConfig.getInstance(), R.string.ssh_authentication_failure_password, Toast.LENGTH_LONG).show();
            return;
        }
        else if(mPrivateKey != null) {
            Toast.makeText(AppConfig.getInstance(), R.string.ssh_authentication_failure_key, Toast.LENGTH_LONG).show();
            return;
        }
    }
}
 
开发者ID:TeamAmaze,项目名称:AmazeFileManager,代码行数:39,代码来源:SshAuthenticationTask.java

示例7: vcgencmd_in_path

import net.schmizz.sshj.transport.TransportException; //导入依赖的package包/类
@Test
public void vcgencmd_in_path() throws RaspiQueryException,
        ConnectionException, TransportException {
    String vcgencmdPath = "vcgencmd";
    sessionMocker.withCommand(vcgencmdPath, new CommandMocker()
            .withResponse("vcgencmd version 1.2.3.4").mock());
    sessionMocker.withCommand(vcgencmdPath + " measure_clock arm",
            new CommandMocker().withResponse("frequency(45)=840090000")
                    .mock());
    sessionMocker.withCommand(vcgencmdPath + " measure_clock core",
            new CommandMocker().withResponse("frequency(1)=320000000")
                    .mock());
    sessionMocker.withCommand(vcgencmdPath + " measure_volts core",
            new CommandMocker().withResponse("volt=1.200V").mock());
    sessionMocker.withCommand(vcgencmdPath + " measure_temp",
            new CommandMocker().withResponse("temp=41.2'C").mock());
    sessionMocker
            .withCommand(
                    vcgencmdPath + " version",
                    new CommandMocker()
                            .withResponse(
                                    "Dec 29 2014 14:23:10\nCopyright (c) 2012 Broadcom\nversion d3c15a3b57203798ff811c40ea65174834267d48 (clean) (release)")
                            .mock());
    VcgencmdBean vcgencmd = raspiQuery.queryVcgencmd();
    assertNotNull(vcgencmd);
    assertThat(vcgencmd.getArmFrequency(), CoreMatchers.is(840090000L));
    assertThat(vcgencmd.getCoreFrequency(), CoreMatchers.is(320000000L));
    assertEquals(1.200, vcgencmd.getCoreVolts(), 0.00001);
    assertEquals(41.2, vcgencmd.getCpuTemperature(), 0.00001);
}
 
开发者ID:eidottermihi,项目名称:rpicheck,代码行数:31,代码来源:VcgencmdTest.java

示例8: connect_auth_failure

import net.schmizz.sshj.transport.TransportException; //导入依赖的package包/类
@Test(expected = RaspiQueryException.class)
public void connect_auth_failure() throws RaspiQueryException,
        UserAuthException, TransportException {
    Mockito.doThrow(UserAuthException.class).when(sshClient)
            .authPassword(Mockito.anyString(), Mockito.anyString());
    raspiQuery.connect("wrong_pw");
}
 
开发者ID:eidottermihi,项目名称:rpicheck,代码行数:8,代码来源:ConnectAndAuthTest.java

示例9: testWrapped

import net.schmizz.sshj.transport.TransportException; //导入依赖的package包/类
@Test
public void testWrapped() throws Exception {
    assertEquals(InteroperabilityException.class,
            new SFTPExceptionMappingService().map(new TransportException(DisconnectReason.UNKNOWN, new SSHException(DisconnectReason.PROTOCOL_ERROR))).getClass());
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:6,代码来源:SFTPExceptionMappingServiceTest.java

示例10: loginAs

import net.schmizz.sshj.transport.TransportException; //导入依赖的package包/类
public SftpClientBuilder loginAs(String user, String password) throws UserAuthException, TransportException {
    this.user = user;
    this.password = password;
    return this;
}
 
开发者ID:signed,项目名称:in-memory-infrastructure,代码行数:6,代码来源:SftpClientBuilder.java


注:本文中的net.schmizz.sshj.transport.TransportException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。