public String getPrivateKey() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); keyPair.writePrivateKey(baos); return baos.toString(); }
/** * Writes the plain private key to the file. * @param name file name * @see #writePrivateKey(String name, byte[] passphrase) */ public void writePrivateKey(String name) throws java.io.FileNotFoundException, java.io.IOException{ this.writePrivateKey(name, null); }
/** * Writes the plain private key to the given output stream. * * @param out output stream * @see #writePrivateKey(java.io.OutputStream out, byte[] passphrase) */ public void writePrivateKey(java.io.OutputStream out) { this.writePrivateKey(out, null); }
/** * Writes the plain private key to the given output stream. * @param out output stream * @see #writePrivateKey(java.io.OutputStream out, byte[] passphrase) */ public void writePrivateKey(java.io.OutputStream out){ this.writePrivateKey(out, null); }
/** * Writes the plain private key to the file. * @param name file name * @see #writePrivateKey(String name, byte[] passphrase) */ public void writePrivateKey(String name) throws java.io.FileNotFoundException, java.io.IOException{ this.writePrivateKey(name, null); }
/** * Writes the plain private key to the given output stream. * @param out output stream * @see #writePrivateKey(java.io.OutputStream out, byte[] passphrase) */ public void writePrivateKey(java.io.OutputStream out){ this.writePrivateKey(out, null); }
/** * Writes the plain private key to the file. * * @param name file name * @see #writePrivateKey(String name, byte[] passphrase) */ public void writePrivateKey(String name) throws java.io.FileNotFoundException, java.io.IOException { this.writePrivateKey(name, null); }
/** * Writes the plain private key to the given output stream. * @param out output stream * @see #writePrivateKey(java.io.OutputStream out, byte[] passphrase) */ public void writePrivateKey(java.io.OutputStream out){ this.writePrivateKey(out, null); }
/** * Writes the plain private key to the file. * @param name file name * @see #writePrivateKey(String name, byte[] passphrase) */ public void writePrivateKey(String name) throws java.io.FileNotFoundException, java.io.IOException{ this.writePrivateKey(name, null); }
public byte[] getFormattedKey() throws SshException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); kpair.writePrivateKey(baos); return baos.toByteArray(); }
/** * Writes the cyphered private key to the file. * @param name file name * @param passphrase a passphrase to encrypt the private key * @see #writePrivateKey(java.io.OutputStream out, byte[] passphrase) */ public void writePrivateKey(String name, byte[] passphrase) throws java.io.FileNotFoundException, java.io.IOException{ FileOutputStream fos=new FileOutputStream(name); writePrivateKey(fos, passphrase); fos.close(); }
/** * Writes the cyphered private key to the file. * * @param name file name * @param passphrase a passphrase to encrypt the private key * @see #writePrivateKey(java.io.OutputStream out, byte[] passphrase) */ public void writePrivateKey(String name, byte[] passphrase) throws java.io.FileNotFoundException, java.io.IOException { FileOutputStream fos = new FileOutputStream(name); writePrivateKey(fos, passphrase); fos.close(); }
/** * Writes the cyphered private key to the file. * @param name file name * @param passphrase a passphrase to encrypt the private key * @see #writePrivateKey(java.io.OutputStream out, byte[] passphrase) */ public void writePrivateKey(String name, byte[] passphrase) throws java.io.FileNotFoundException, java.io.IOException{ FileOutputStream fos=new FileOutputStream(name); writePrivateKey(fos, passphrase); fos.close(); }
public void writePrivateKey(String name) throws java.io.FileNotFoundException, java.io.IOException{ FileOutputStream fos=new FileOutputStream(name); writePrivateKey(fos); fos.close(); }
public String getPrivateKey() { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); keyPair.writePrivateKey(baos); return baos.toString(); } }
/** * Writes the cyphered private key to the file. * @param name file name * @param passphrase a passphrase to encrypt the private key * @see #writePrivateKey(java.io.OutputStream out, byte[] passphrase) */ public void writePrivateKey(String name, byte[] passphrase) throws java.io.FileNotFoundException, java.io.IOException{ FileOutputStream fos=new FileOutputStream(name); writePrivateKey(fos, passphrase); fos.close(); }
protected String getPrivateKey(com.jcraft.jsch.KeyPair keyPair) { ByteArrayOutputStream out = new ByteArrayOutputStream(); keyPair.writePrivateKey(out); return getUTF8String(out.toByteArray()); }
public static String generateKeyPair(Context context) { JSch jsch = new JSch(); KeyPair kpair = null; try { kpair = KeyPair.genKeyPair(jsch, KeyPair.RSA); kpair.writePrivateKey(context.getFilesDir().getAbsoluteFile() + "/" + AuthData.PRIVATE_KEY); kpair.writePublicKey(context.getFilesDir().getAbsoluteFile() + "/" + AuthData.PUBLIC_KEY, "MobileOrgPubKey"); } catch (JSchException | IOException e){ Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show(); return ""; } return AuthData.getPublicKey(context); }
private void generatePrivateKey(File file) throws IOException, JSchException { KeyPair kpair = KeyPair.genKeyPair(jsch, KeyPair.RSA, PRIVATE_KEY_LENGTH); kpair.writePrivateKey(file.getAbsolutePath()); kpair.dispose(); }
private SSHConfig getSSHConfig() { return SSHConfig.builder(SSH_SERVER.getHost()) .setUser("cdap") .setPort(SSH_SERVER.getPort()) .setPrivateKeySupplier(() -> { ByteArrayOutputStream bos = new ByteArrayOutputStream(); keyPair.writePrivateKey(bos, null); return bos.toByteArray(); }) .build(); }