本文整理汇总了Java中edu.kit.tm.ptp.PTP类的典型用法代码示例。如果您正苦于以下问题:Java PTP类的具体用法?Java PTP怎么用?Java PTP使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PTP类属于edu.kit.tm.ptp包,在下文中一共展示了PTP类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpClass
import edu.kit.tm.ptp.PTP; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws IOException, InvalidKeyException, InvalidKeySpecException,
NoSuchAlgorithmException, NoSuchProviderException {
ptp1 = new PTP(true);
ptp2 = new PTP(true);
ptp1.init();
ptp2.init();
ptp1.reuseHiddenService();
ptp2.reuseHiddenService();
String hsDir1 = ptp1.getHiddenServiceDirectory();
String hsDir2 = ptp2.getHiddenServiceDirectory();
pk1 = new File(hsDir1 + File.separator + Constants.prkey);
pk2 = new File(hsDir2 + File.separator + Constants.prkey);
cryptHelper = new CryptHelper();
cryptHelper.init();
cryptHelper.setKeyPair(CryptHelper.readKeyPairFromFile(pk1));
cryptHelper2 = new CryptHelper();
cryptHelper2.init();
cryptHelper2.setKeyPair(CryptHelper.readKeyPairFromFile(pk2));
}
示例2: Mixer
import edu.kit.tm.ptp.PTP; //导入依赖的package包/类
public Mixer(PTP ptp, BroadcastAnnouncement bca, ProofMessage pm, Wallet w, NetworkParameters params, PeerGroup pg, BlockChain bc) {
this.ptp = ptp;
this.bca = bca;
this.mixPartnerAdress = new Identifier(bca.getOnionAdress() + ".onion");
this.ownProof = pm;
this.w = w;
this.params = params;
this.pg = pg;
this.bc = bc;
this.mfListeners = new ArrayList<MixFinishedEventListener>();
this.lockTime = 0;
}
示例3: ChallengeResponseVerifier
import edu.kit.tm.ptp.PTP; //导入依赖的package包/类
public ChallengeResponseVerifier(PTP ptp, Wallet w, NetworkParameters params, PeerGroup pg, BlockChain bc) {
this.ptp = ptp;
this.w = w;
this.params = params;
this.pg = pg;
this.bc = bc;
}
示例4: testSend
import edu.kit.tm.ptp.PTP; //导入依赖的package包/类
@Test
public void testSend() throws IOException {
ptp = new PTP(true);
ptp.authFactory = new DummyAuthenticatorFactory();
// Avoid warning about dropped message
ptp.setReceiveListener(new ReceiveListenerAdapter());
ptp.init();
ptp.reuseHiddenService();
Configuration config = ptp.getConfiguration();
Serializer serializer = new Serializer();
serializer.registerClass(byte[].class);
serializer.registerClass(ByteArrayMessage.class);
SendReceiveListener listener = new SendReceiveListener();
ConnectionManager manager =
new ConnectionManager(config.getHiddenServicePort(), listener, listener, null,
new DummyAuthenticatorFactory());
manager.updateSOCKSProxy(Constants.localhost, config.getTorSOCKSProxyPort());
manager.setLocalIdentifier(new Identifier("aaaaaaaaaaaaaaaa.onion"));
manager.start();
byte[] data = new byte[] {0x0, 0x1, 0x2, 0x3};
ByteArrayMessage message = new ByteArrayMessage(data);
long id = manager.send(serializer.serialize(message), ptp.getIdentifier(),
TestConstants.hiddenServiceSetupTimeout);
TestHelper.wait(listener.sent, 1, TestConstants.hiddenServiceSetupTimeout);
assertEquals(1, listener.sent.get());
assertEquals(id, listener.getId());
assertEquals(SendListener.State.SUCCESS, listener.getState());
assertEquals(ptp.getIdentifier(), listener.getDestination());
}
示例5: setUp
import edu.kit.tm.ptp.PTP; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
server = ServerSocketChannel.open();
server.socket()
.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), Constants.anyport));
server.configureBlocking(false);
listener = new Listener();
channelManager = new ChannelManager(listener);
ptp = new PTP(true);
}
示例6: testCalculateHiddenServiceIdentifier
import edu.kit.tm.ptp.PTP; //导入依赖的package包/类
@Test
public void testCalculateHiddenServiceIdentifier()
throws IOException, InterruptedException, InvalidKeySpecException, InvalidKeyException,
NoSuchAlgorithmException, NoSuchProviderException {
PTP ptp = new PTP(true);
ptp.init();
ptp.reuseHiddenService();
File hiddenServices = new File(ptp.getConfiguration().getHiddenServicesDirectory());
int found = 0;
File privateKey = null;
BufferedReader reader = null;
File[] dirs = hiddenServices.listFiles();
assertNotNull(dirs);
for (File dir : dirs) {
if (dir.isDirectory()) {
File hostname = new File(dir.getAbsolutePath() + File.separator + "hostname");
reader = new BufferedReader(
new InputStreamReader(new FileInputStream(hostname), Constants.charset));
String onionName = reader.readLine();
if (onionName != null && onionName.equals(ptp.getIdentifier().toString())) {
found++;
privateKey = new File(dir.getAbsolutePath() + File.separator + "private_key");
}
reader.close();
}
}
assertEquals(1, found);
assertNotNull(privateKey);
CryptHelper helper = new CryptHelper();
helper.init();
KeyPair pair = CryptHelper.readKeyPairFromFile(privateKey);
Identifier ident = helper.calculateHiddenServiceIdentifier(pair.getPublic());
assertEquals(ptp.getIdentifier().toString(), ident.toString());
ptp.exit();
}