I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 760c3164 authored by dev's avatar dev
Browse files

merge of '883c453307272eee439471d4e9da1e120804dac1'

     and 'c60598471c5f08b7d7e12e38d39f7a1d4c8ccf63'
parents 9b8772a4 5d9d8287
No related branches found
No related tags found
No related merge requests found
package net.i2p.data;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import net.i2p.I2PException;
import net.i2p.client.I2PClient;
import net.i2p.client.I2PSession;
import net.i2p.client.I2PSessionException;
public class PrivateKeyFile {
public PrivateKeyFile(File file, I2PClient client) {
this.file = file;
this.client = client;
this.dest = null;
}
public void createIfAbsent() throws I2PException, IOException {
if(!this.file.exists()) {
FileOutputStream out = new FileOutputStream(this.file);
this.dest = this.client.createDestination(out);
out.close();
}
}
public Destination getDestination() {
// TODO: how to load destination if this is an old key?
return dest;
}
public I2PSession open() throws I2PSessionException, IOException {
return this.open(new Properties());
}
public I2PSession open(Properties opts) throws I2PSessionException, IOException {
// open input file
FileInputStream in = new FileInputStream(this.file);
// create sesssion
I2PSession s = this.client.createSession(in, opts);
// close file
in.close();
return s;
}
private File file;
private I2PClient client;
private Destination dest;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment