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;
}
Aggregations