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


Java HostKeyRepository类代码示例

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


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

示例1: getHostKeyRepository

import com.jcraft.jsch.HostKeyRepository; //导入依赖的package包/类
/**
 * @param knownHostFile
 * @return
 * @throws JSchException
 */
private static HostKeyRepository getHostKeyRepository( String knownHostFile )
    throws JSchException
{
    JSch jsch = new JSch();
    jsch.setKnownHosts( knownHostFile );
    return jsch.getHostKeyRepository();
}
 
开发者ID:vmware,项目名称:OHMS,代码行数:13,代码来源:SshUtil.java

示例2: testKnownHostsFile

import com.jcraft.jsch.HostKeyRepository; //导入依赖的package包/类
@Test
public void testKnownHostsFile() throws Exception {

    final JschBuilder builder = new JschBuilder();
    builder.setKnownHostsFileName(knownHostsFile);
    builder.setPrivateKeyFileName(privateKeyFile);

    final JSch jsch = builder.build();
    final HostKeyRepository knownHosts = jsch.getHostKeyRepository();

    assertEquals(knownHostsFile,
                 knownHosts.getKnownHostsRepositoryID());
}
 
开发者ID:cerner,项目名称:jwala,代码行数:14,代码来源:JschBuilderTest.java

示例3: connect

import com.jcraft.jsch.HostKeyRepository; //导入依赖的package包/类
/**
 * Enforce server reconnection (closes the current connection if it is still alive)
 */
public synchronized void connect() throws SFTPConnectionException {
	//checkLocked();

	try {
		// Try to disconnect
		this.disconnect();

		// Open new connection			
		Logger.defaultLogger().info("Trying to connect to server : " + this.remoteServer + " ...");
		debug("connect : connect", remoteServer);

		JSch jsch = new JSch();
		if (checkHostKey) {
			HostKeyRepository hkr = jsch.getHostKeyRepository();
			byte[] keybytes = this.getHostKeyAsByteArray();
			if (keybytes == null) {
				throw new SFTPConnectionException("Incorrect hostkey : " + this.getHostKeyAsString());
			}
			HostKey key = new HostKey(remoteServer, keybytes);
			hkr.add(key, null);
			jsch.setHostKeyRepository(hkr);
		}

		if (useCertificateAuth) {
			if (certificateFileName == null || certificateFileName.trim().length() == 0 || ! FileSystemManager.exists(new File(certificateFileName))) {
				throw new SFTPConnectionException("Certificate file not set or not found : " + certificateFileName);
			} else {
				Logger.defaultLogger().info("Using private key file : " + certificateFileName);
				if (certificateFileName.toLowerCase().endsWith(".ppk")) {
					Logger.defaultLogger().warn("Your private key file seems to be in PuTTY's \"ppk\" file format. Please convert it to the standard OpenSSH format (this can be done by using the \"puttygen.exe\" utility - see \"Convertions\" menu.)");
				}
				jsch.addIdentity(certificateFileName);
			}
		}
		session = jsch.getSession(login, remoteServer, remotePort);
		UserInfo ui = new DefaultUserInfo(this.password, certPassPhrase, certificateFileName);
		session.setUserInfo(ui);

		session.setDaemonThread(true);
		session.setConfig("StrictHostKeyChecking", checkHostKey ? "yes":"no");
		
		String preferredAuth;
		String configuredPAuth = FrameworkConfiguration.getInstance().getSftpPreferredAuthOverride();
		if (configuredPAuth != null && configuredPAuth.trim().length() != 0) {
			preferredAuth = configuredPAuth;
		} else {
			preferredAuth = useCertificateAuth ? "publickey,password" : "password,publickey";
		}
		Logger.defaultLogger().fine("Authentication methods: " + preferredAuth);

		session.setConfig("PreferredAuthentications", preferredAuth);
		session.setTimeout(FrameworkConfiguration.getInstance().getSFTPTimeout());

		Logger.defaultLogger().info("Trying to log in with user : " + this.login + " (" + (useCertificateAuth ? "certificate":"password") + ") ...");
		debug("connect : login", login);
		session.connect();

		client = (ChannelSftp)session.openChannel("sftp");
		client.connect();

		this.connectionId = Util.getRndLong();
		this.updateOpTime();

		Logger.defaultLogger().info("Connected to server : " + this.remoteServer);
	} catch (JSchException e) {
		resetClient(e);
		throw new SFTPConnectionException("Unable to connect to server : " + this.remoteServer + " (" + e.getMessage() + ")");
	} finally {
		clearCache();
	}
}
 
开发者ID:chfoo,项目名称:areca-backup-release-mirror,代码行数:75,代码来源:SFTPProxy.java

示例4: configure

import com.jcraft.jsch.HostKeyRepository; //导入依赖的package包/类
@Override
protected void configure() {
    install(RepositoryScope.module());
    install(OperationScope.module());
    bind(UserInfo.class).to(GUIUserInfo.class);
    bind(ImageSession.class).toProvider(ImageSessionProvider.class).in(ContextSingleton.class);

    bind(Repository.class).toProvider(RepositoryProvider.class);
    bind(Ref.class).annotatedWith(named("branch")).toProvider(BranchRefProvider.class);
    bind(AndroidAuthAgent.class).toProvider(AndroidAuthAgentProvider.class);
    bind(GitAsyncTaskFactory.class).toProvider(newFactory(GitAsyncTaskFactory.class, GitAsyncTask.class));
    bind(ContextScopedViewInflatorFactory.class).toProvider(newFactory(ContextScopedViewInflatorFactory.class,
            ContextScopedViewInflator.class));

    bind(SyncCampaignFactory.class).toProvider(newFactory(SyncCampaignFactory.class, SyncCampaign.class));

    bind(TransportConfigCallback.class).to(AgitTransportConfig.class);
    bind(CredentialsProvider.class).to(GUICredentialsProvider.class);
    bind(SshSessionFactory.class).to(AndroidSshSessionFactory.class);
    bind(PromptUIRegistry.class);

    bind(HostKeyRepository.class).to(CuriousHostKeyRepository.class);
    bind(PromptUI.class).annotatedWith(named("status-bar")).to(StatusBarPromptUI.class);

    bind(RepoDomainType.class).annotatedWith(named("branch")).to(RDTBranch.class);
    bind(RepoDomainType.class).annotatedWith(named("remote")).to(RDTRemote.class);
    bind(RepoDomainType.class).annotatedWith(named("tag")).to(RDTTag.class);

    bind(CommitViewHolderFactory.class).toProvider(newFactory(CommitViewHolderFactory.class,
            CommitViewHolder.class));
    bind(BranchViewHolderFactory.class).toProvider(newFactory(BranchViewHolderFactory.class,
            BranchViewHolder.class));
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:34,代码来源:AgitModule.java

示例5: AndroidSshSessionFactory

import com.jcraft.jsch.HostKeyRepository; //导入依赖的package包/类
@Inject
public AndroidSshSessionFactory(Provider<AndroidAuthAgent> androidAuthAgentProvider, UserInfo userInfo,
                                HostKeyRepository hostKeyRepository) {
    this.androidAuthAgentProvider = androidAuthAgentProvider;
    this.userInfo = userInfo;
    this.hostKeyRepository = hostKeyRepository;
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:8,代码来源:AndroidSshSessionFactory.java

示例6: check

import com.jcraft.jsch.HostKeyRepository; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public int check(String host,
    byte[] key) {

    return HostKeyRepository.OK;
}
 
开发者ID:trajano,项目名称:wagon-git,代码行数:10,代码来源:AcceptAllHostKeyRepository.java

示例7: check

import com.jcraft.jsch.HostKeyRepository; //导入依赖的package包/类
@Override
public int check(final String host, final byte[] bkey) {
    return HostKeyRepository.OK;
}
 
开发者ID:jcabi,项目名称:jcabi-ssh,代码行数:5,代码来源:EasyRepo.java

示例8: check

import com.jcraft.jsch.HostKeyRepository; //导入依赖的package包/类
@Override
public int check(String host, byte[] key) {
    return HostKeyRepository.OK;
}
 
开发者ID:sonyxperiadev,项目名称:gerrit-events,代码行数:5,代码来源:SshConnectionImpl.java


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