Search in sources :

Example 1 with DataStructure

use of net.i2p.data.DataStructure in project i2p.i2p by i2p.

the class RouterInfoTest method createDataStructure.

@SuppressWarnings("deprecation")
public DataStructure createDataStructure() throws DataFormatException {
    RouterInfo info = new RouterInfo();
    HashSet<RouterAddress> addresses = new HashSet<RouterAddress>();
    DataStructure structure = (new RouterAddressTest()).createDataStructure();
    addresses.add((RouterAddress) structure);
    info.setAddresses(addresses);
    PublicKey pubKey = null;
    SigningPublicKey signingPubKey = null;
    PrivateKey privKey = null;
    SigningPrivateKey signingPrivKey = null;
    Object[] obj = KeyGenerator.getInstance().generatePKIKeypair();
    pubKey = (PublicKey) obj[0];
    privKey = (PrivateKey) obj[1];
    obj = KeyGenerator.getInstance().generateSigningKeypair();
    signingPubKey = (SigningPublicKey) obj[0];
    signingPrivKey = (SigningPrivateKey) obj[1];
    _log.debug("SigningPublicKey: " + signingPubKey);
    _log.debug("SigningPrivateKey: " + signingPrivKey);
    RouterIdentity ident = new RouterIdentity();
    ident.setCertificate(new Certificate(Certificate.CERTIFICATE_TYPE_NULL, null));
    ident.setPublicKey(pubKey);
    ident.setSigningPublicKey(signingPubKey);
    info.setIdentity(ident);
    Properties options = new Properties();
    for (int i = 0; i < 16; i++) {
        options.setProperty("option." + i, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890$:." + i);
    }
    options.setProperty("netConnectionSpeed", "OC12");
    info.setOptions(options);
    HashSet<Hash> peers = new HashSet<Hash>();
    structure = (new HashTest()).createDataStructure();
    peers.add((Hash) structure);
    info.setPeers(peers);
    info.setPublished(System.currentTimeMillis());
    // info.setVersion(69);
    info.sign(signingPrivKey);
    return info;
}
Also used : SigningPublicKey(net.i2p.data.SigningPublicKey) PrivateKey(net.i2p.data.PrivateKey) SigningPrivateKey(net.i2p.data.SigningPrivateKey) SigningPublicKey(net.i2p.data.SigningPublicKey) PublicKey(net.i2p.data.PublicKey) DataStructure(net.i2p.data.DataStructure) Properties(java.util.Properties) Hash(net.i2p.data.Hash) HashTest(net.i2p.data.HashTest) SigningPrivateKey(net.i2p.data.SigningPrivateKey) HashSet(java.util.HashSet) Certificate(net.i2p.data.Certificate)

Aggregations

HashSet (java.util.HashSet)1 Properties (java.util.Properties)1 Certificate (net.i2p.data.Certificate)1 DataStructure (net.i2p.data.DataStructure)1 Hash (net.i2p.data.Hash)1 HashTest (net.i2p.data.HashTest)1 PrivateKey (net.i2p.data.PrivateKey)1 PublicKey (net.i2p.data.PublicKey)1 SigningPrivateKey (net.i2p.data.SigningPrivateKey)1 SigningPublicKey (net.i2p.data.SigningPublicKey)1