Package net.tomp2p.connection

Examples of net.tomp2p.connection.DSASignatureFactory


  @Test
  public void testPutSignedAndContentProtectedData() throws IOException, ClassNotFoundException,
      NoSuchAlgorithmException, InvalidKeyException, SignatureException {
    KeyPairGenerator gen = KeyPairGenerator.getInstance("DSA");

    SignatureFactory factory = new DSASignatureFactory();

    KeyPair keyPairPeer1 = gen.generateKeyPair();
    Peer p1 = new PeerMaker(Number160.createHash(1)).ports(4838).keyPair(keyPairPeer1)
        .setEnableIndirectReplication(true).makeAndListen();
    KeyPair keyPairPeer2 = gen.generateKeyPair();
View Full Code Here


  @Test
  public void testPutOverwriteWithWrongContentProtectionKeys() throws IOException, ClassNotFoundException,
      NoSuchAlgorithmException, InvalidKeyException, SignatureException {
    KeyPairGenerator gen = KeyPairGenerator.getInstance("DSA");

    SignatureFactory factory = new DSASignatureFactory();

    KeyPair keyPairPeer1 = gen.generateKeyPair();
    Peer p1 = new PeerMaker(Number160.createHash(1)).ports(4838).keyPair(keyPairPeer1)
        .setEnableIndirectReplication(true).makeAndListen();
    KeyPair keyPairPeer2 = gen.generateKeyPair();
View Full Code Here

  final private static Number160 locationKey = new Number160(10);
  private static File DIR;

  public Storage createStorage() throws IOException {
    DB db = DBMaker.newFileDB(new File(DIR, "tomp2p")).transactionDisable().closeOnJvmShutdown().cacheDisable().make();
    return new StorageDisk(db, locationKey, DIR, new DSASignatureFactory(), 60 * 1000);
  }
 
View Full Code Here

       
        //for the decoding we need a flat bytebuf
        ByteBuf transfer2 = Unpooled.buffer();
        transfer2.writeBytes(transfer);

        Data newData = Data.decodeHeader(transfer2, new DSASignatureFactory());
        newData.decodeBuffer(transfer2);
        newData.decodeDone(transfer2, null, factory);

        Assert.assertEquals(data, newData);
        Object test = newData.object();
View Full Code Here

        boolean done1 = data.decodeBuffer(pa1);
        Assert.assertEquals(true, done1);
        transfer.writeBytes(data.buffer());
        data.encodeDone(transfer, factory);

        Data newData = Data.decodeHeader(transfer, new DSASignatureFactory());
        newData.decodeBuffer(transfer);
        newData.decodeDone(transfer, null, factory);

        Assert.assertEquals(data, newData);
        ByteBuf test = newData.buffer();
View Full Code Here

        data.resetAlreadyTransferred();
       
        data.encodeBuffer(transfer);
        data.encodeDone(transfer, factory);

        Data newData = Data.decodeHeader(transfer, new DSASignatureFactory());
        newData.decodeBuffer(transfer);
        newData.decodeDone(transfer, null, factory);

        Assert.assertEquals(data, newData);
        ByteBuf test = newData.buffer();
View Full Code Here

        data.encodeHeader(transfer, factory);
        ByteBuf pa = Unpooled.wrappedBuffer(new byte[50000]);
        boolean done = data.decodeBuffer(pa);
        Assert.assertEquals(false, done);
       
        Data newData = Data.decodeHeader(transfer, new DSASignatureFactory());
       
        ByteBuf pa1 = Unpooled.wrappedBuffer(new byte[50000]);
        boolean done1 = data.decodeBuffer(pa1);
        Assert.assertEquals(true, done1);
        transfer.writeBytes(data.buffer());
View Full Code Here

    AlternativeCompositeByteBuf transfer = AlternativeCompositeByteBuf.compBuffer();
        data.encodeHeader(transfer, factory);
        data.encodeBuffer(transfer);
        data.encodeDone(transfer, factory);
        //
        Data newData = Data.decodeHeader(transfer, new DSASignatureFactory());
        newData.decodeBuffer(transfer);
        newData.decodeDone(transfer, null, factory);
        return newData;
    }
View Full Code Here

   */
  private Message encodeDecode(final Message m1) throws Exception {
    AtomicReference<Message> m2 = new AtomicReference<Message>();
    final AlternativeCompositeByteBuf buf = AlternativeCompositeByteBuf.compBuffer();
    TomP2POutbound encoder = new TomP2POutbound(true,
        new DSASignatureFactory(), new CompByteBufAllocator() {
          @Override
          public AlternativeCompositeByteBuf compBuffer() {
            return buf;
          }
          @Override
          public AlternativeCompositeByteBuf compDirectBuffer() {
            return buf;
          }
        });
   
    buf.retain();
    ChannelHandlerContext ctx = mockChannelHandlerContext(buf, m2);
    encoder.write(ctx, m1, null);
    Decoder decoder = new Decoder(new DSASignatureFactory());
    decoder.decode(ctx, buf, m1.recipient().createSocketTCP(), m1
        .sender().createSocketTCP());
    return decoder.message();
  }
View Full Code Here

    //these two values may be overwritten in the peer builder
    channelServerConfiguration.ports(new Ports(Ports.DEFAULT_PORT, Ports.DEFAULT_PORT));
    channelServerConfiguration.portsForwarding(new Ports(Ports.DEFAULT_PORT, Ports.DEFAULT_PORT));
    channelServerConfiguration.behindFirewall(false);
    channelServerConfiguration.pipelineFilter(new DefaultPipelineFilter());
    channelServerConfiguration.signatureFactory(new DSASignatureFactory());
    return channelServerConfiguration;
  }
View Full Code Here

TOP

Related Classes of net.tomp2p.connection.DSASignatureFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.