Search in sources :

Example 16 with I2PClient

use of net.i2p.client.I2PClient in project i2p.i2p-bote by i2p.

the class ElGamal2048_DSA1024 method createI2PSession.

private I2PSession createI2PSession() throws KeyException {
    try {
        I2PClient i2pClient = I2PClientFactory.createClient();
        ByteArrayOutputStream arrayStream = new ByteArrayOutputStream();
        i2pClient.createDestination(arrayStream);
        byte[] destinationArray = arrayStream.toByteArray();
        I2PSession i2pSession = i2pClient.createSession(new ByteArrayInputStream(destinationArray), null);
        return i2pSession;
    } catch (Exception e) {
        throw new KeyException("Can't generate I2P destination.", e);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) I2PSession(net.i2p.client.I2PSession) I2PClient(net.i2p.client.I2PClient) ByteArrayOutputStream(java.io.ByteArrayOutputStream) KeyException(java.security.KeyException) DataFormatException(net.i2p.data.DataFormatException) GeneralSecurityException(java.security.GeneralSecurityException) KeyException(java.security.KeyException)

Aggregations

I2PClient (net.i2p.client.I2PClient)16 I2PSession (net.i2p.client.I2PSession)9 ByteArrayInputStream (java.io.ByteArrayInputStream)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 IOException (java.io.IOException)7 Destination (net.i2p.data.Destination)7 Properties (java.util.Properties)6 I2PException (net.i2p.I2PException)6 I2PSessionException (net.i2p.client.I2PSessionException)4 I2PSimpleClient (net.i2p.client.I2PSimpleClient)3 File (java.io.File)2 SigType (net.i2p.crypto.SigType)2 DataFormatException (net.i2p.data.DataFormatException)2 OrderedProperties (net.i2p.util.OrderedProperties)2 Getopt (gnu.getopt.Getopt)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 GeneralSecurityException (java.security.GeneralSecurityException)1 KeyException (java.security.KeyException)1