当前位置: 首页>>代码示例>>Java>>正文


Java PTP类代码示例

本文整理汇总了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));
}
 
开发者ID:kit-tm,项目名称:PTP,代码行数:27,代码来源:PublicKeyAuthenticatorTest.java

示例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; 
}
 
开发者ID:kit-tm,项目名称:bitnym,代码行数:13,代码来源:Mixer.java

示例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;
}
 
开发者ID:kit-tm,项目名称:bitnym,代码行数:8,代码来源:ChallengeResponseVerifier.java

示例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());
}
 
开发者ID:kit-tm,项目名称:PTP,代码行数:37,代码来源:ConnectionManagerTest.java

示例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);
}
 
开发者ID:kit-tm,项目名称:PTP,代码行数:13,代码来源:ChannelManagerTest.java

示例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();
}
 
开发者ID:kit-tm,项目名称:PTP,代码行数:48,代码来源:CryptHelperTest.java


注:本文中的edu.kit.tm.ptp.PTP类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。