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


Java SSHException类代码示例

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


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

示例1: executeCommand

import net.schmizz.sshj.common.SSHException; //导入依赖的package包/类
@Override
public InputStream executeCommand(String logAccessConfigId, String shellCommand) throws LogAccessException {
	
	// Get the LogAccessConfig
	LogAccessConfig logAccessConfig = configService.getLogAccessConfig(logAccessConfigId);

	// Create ssh client and authenticate
	SSHClient sshClient = sshClientThreadLocal.get();
	boolean closeSshClient = false;
	if (sshClient == null) {
		sshClient = connectAndAuthenticate(logAccessConfig);
		closeSshClient = true;
	}
	
	// Define the precommand (if any)
	String precommand = "";
	if (StringUtils.hasText(logAccessConfig.getPreCommand())) {
		precommand = logAccessConfig.getPreCommand() + " && ";
	}

	// Execute the shell command
	Session session = null;
	Command resultCommand;
	try {
		session = sshClient.startSession();
		resultCommand = session.exec("cd \"" + logAccessConfig.getDirectory() + "\" && " + precommand + shellCommand);
	}
	catch (SSHException e) {
		IOUtils.closeQuietly(session, sshClient);
		throw new LogAccessException("Error when executing command " + shellCommand + " to " + logAccessConfig, e);
	}
	
	// Get and return the result stream
	InputStream sequenceStream = new SequenceInputStream(resultCommand.getInputStream(), resultCommand.getErrorStream());
	InputStream resultStream = new SshCloseFilterInputStream(sequenceStream, resultCommand, session, (closeSshClient ? sshClient : null));
	return resultStream;
}
 
开发者ID:fbaligand,项目名称:lognavigator,代码行数:38,代码来源:SshLogAccessService.java

示例2: notifyDisconnect

import net.schmizz.sshj.common.SSHException; //导入依赖的package包/类
@Override
public void notifyDisconnect(final DisconnectReason reason, final String message) {
    log.warn(String.format("Disconnected %s", reason));
    failure = new SSHException(reason, message);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:6,代码来源:SFTPSession.java

示例3: getFailure

import net.schmizz.sshj.common.SSHException; //导入依赖的package包/类
/**
 * @return Last disconnect reason
 */
public SSHException getFailure() {
    return failure;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:7,代码来源:SFTPSession.java

示例4: testWrapped

import net.schmizz.sshj.common.SSHException; //导入依赖的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


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