當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyPairWrapper類代碼示例

本文整理匯總了Java中net.schmizz.sshj.userauth.keyprovider.KeyPairWrapper的典型用法代碼示例。如果您正苦於以下問題:Java KeyPairWrapper類的具體用法?Java KeyPairWrapper怎麽用?Java KeyPairWrapper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


KeyPairWrapper類屬於net.schmizz.sshj.userauth.keyprovider包,在下文中一共展示了KeyPairWrapper類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: uploadFile

import net.schmizz.sshj.userauth.keyprovider.KeyPairWrapper; //導入依賴的package包/類
@Test
public void uploadFile() throws IOException, NoSuchProviderException, NoSuchAlgorithmException {
  final SSHClient ssh = new SSHClient();
  ssh.addHostKeyVerifier(SecurityUtils.getFingerprint(subject.getHostsPublicKey()));

  ssh.connect("localhost", subject.getPort());
  try {
    ssh.authPublickey("this_is_ignored", new KeyPairWrapper(
        KeyPairGenerator.getInstance("DSA", "SUN").generateKeyPair()));

    final SFTPClient sftp = ssh.newSFTPClient();
    File testFile = local.newFile("fred.txt");
    try {
      sftp.put(new FileSystemFile(testFile), "/fred.txt");
    } finally {
      sftp.close();
    }
  } finally {
    ssh.disconnect();
  }

  assertThat(sftpHome.getRoot().list(), is(new String[]{"fred.txt"}));
}
 
開發者ID:mlk,項目名稱:AssortmentOfJUnitRules,代碼行數:24,代碼來源:TestSftpRule.java

示例2: downloadFile

import net.schmizz.sshj.userauth.keyprovider.KeyPairWrapper; //導入依賴的package包/類
@Test
public void downloadFile() throws IOException, NoSuchProviderException, NoSuchAlgorithmException {
  FileUtils.write(sftpHome.newFile("fred.txt"), "Electric boogaloo");

  final SSHClient ssh = new SSHClient();
  ssh.addHostKeyVerifier(SecurityUtils.getFingerprint(subject.getHostsPublicKey()));

  ssh.connect("localhost", subject.getPort());
  try {
    ssh.authPublickey("this_is_ignored", new KeyPairWrapper(
        KeyPairGenerator.getInstance("DSA", "SUN").generateKeyPair()));

    final SFTPClient sftp = ssh.newSFTPClient();

    try {
      sftp.get("fred.txt", new FileSystemFile(new File(local.getRoot(), "fred.txt")));
    } finally {
      sftp.close();
    }
  } finally {
    ssh.disconnect();
  }

  assertThat(FileUtils.readFileToString(new File(local.getRoot(), "fred.txt")),
      is("Electric boogaloo"));
}
 
開發者ID:mlk,項目名稱:AssortmentOfJUnitRules,代碼行數:27,代碼來源:TestSftpRule.java

示例3: prepareSshConnection

import net.schmizz.sshj.userauth.keyprovider.KeyPairWrapper; //導入依賴的package包/類
private void prepareSshConnection(SSHClient ssh, String ip, int port, HostKeyVerifier hostKeyVerifier, String user,
        String privateKeyString, Stack stack) throws CloudbreakException, IOException {
    ssh.addHostKeyVerifier(hostKeyVerifier);
    ssh.connect(ip, port);
    if (stack.getStackAuthentication().passwordAuthenticationRequired()) {
        ssh.authPassword(user, stack.getStackAuthentication().getLoginPassword());
    } else {
        try {
            KeyPair keyPair = KeyStoreUtil.createKeyPair(privateKeyString);
            KeyPairWrapper keyPairWrapper = new KeyPairWrapper(keyPair);
            ssh.authPublickey(user, keyPairWrapper);
        } catch (Exception e) {
            throw new CloudbreakException("Couldn't prepare SSH connection", e);
        }
    }
}
 
開發者ID:hortonworks,項目名稱:cloudbreak,代碼行數:17,代碼來源:TlsSetupService.java

示例4: listFiles

import net.schmizz.sshj.userauth.keyprovider.KeyPairWrapper; //導入依賴的package包/類
@Test
public void listFiles() throws IOException, NoSuchProviderException, NoSuchAlgorithmException {
  sftpHome.newFile("fred.txt");
  List<RemoteResourceInfo> files;

  final SSHClient ssh = new SSHClient();
  ssh.addHostKeyVerifier(SecurityUtils.getFingerprint(subject.getHostsPublicKey()));

  ssh.connect("localhost", subject.getPort());
  try {
    ssh.authPublickey("this_is_ignored", new KeyPairWrapper(
        KeyPairGenerator.getInstance("DSA", "SUN").generateKeyPair()));

    final SFTPClient sftp = ssh.newSFTPClient();

    try {
      files = sftp.ls("/");
    } finally {
      sftp.close();
    }
  } finally {
    ssh.disconnect();
  }

  assertThat(files.size(), is(1));
  assertThat(files.get(0).getName(), is("fred.txt"));
}
 
開發者ID:mlk,項目名稱:AssortmentOfJUnitRules,代碼行數:28,代碼來源:TestSftpRule.java

示例5: client

import net.schmizz.sshj.userauth.keyprovider.KeyPairWrapper; //導入依賴的package包/類
public SFTPClient client() throws IOException {
    final SSHClient ssh = new SSHClient();
    ssh.addHostKeyVerifier(new PublicKeyVerifier(hostKey.publicKey()));
    ssh.connect("localhost", port);

    createdClients.add(ssh);

    if (null == password) {
        ssh.authPublickey(user, new KeyPairWrapper(keyPair));
    } else {
        ssh.authPassword(user, password);
    }

    return ssh.newSFTPClient();
}
 
開發者ID:signed,項目名稱:in-memory-infrastructure,代碼行數:16,代碼來源:SftpClientBuilder.java


注:本文中的net.schmizz.sshj.userauth.keyprovider.KeyPairWrapper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。