예제 #1
0
  public static void updateTesterIntroducer(
      long testerIntroducerID, D_TesterIntroducer testerIntroducer) {
    String params[] = new String[net.ddp2p.common.table.tester_introducer.F_FIELDS];

    params[net.ddp2p.common.table.tester_introducer.F_TESTER_LID] =
        Util.getStringID(testerIntroducer.testerLID);
    params[net.ddp2p.common.table.tester_introducer.F_INTRODUCER_PEER_LID] =
        Util.getStringID(testerIntroducer.introducerPeerLID);
    params[net.ddp2p.common.table.tester_introducer.F_SIGNATURE] =
        Util.stringSignatureFromByte(testerIntroducer.signature);
    params[net.ddp2p.common.table.tester_introducer.F_WEIGH] = testerIntroducer.weight;
    params[net.ddp2p.common.table.tester_introducer.F_CREATION_DATE] =
        Encoder.getGeneralizedTime(testerIntroducer.creation_date);
    params[net.ddp2p.common.table.tester_introducer.F_TESTER_REJECTING_DATE] =
        Encoder.getGeneralizedTime(testerIntroducer.testerRejectingDate);
    params[net.ddp2p.common.table.tester_introducer.F_ATTACK_BY_INTRODUCER] =
        Util.getString(testerIntroducer.attackByIntroducer);
    // ID:
    params[net.ddp2p.common.table.tester_introducer.F_ID] = Util.getStringID(testerIntroducerID);

    try {
      Application.db.update(
          net.ddp2p.common.table.tester_introducer.TNAME,
          net.ddp2p.common.table.tester_introducer._fields_tester_introducer_no_ID,
          new String[] {net.ddp2p.common.table.tester_introducer.testerIntroducerID},
          params,
          DEBUG);
    } catch (P2PDDSQLException e) {
      e.printStackTrace();
    }
  }
예제 #2
0
파일: DD_SK.java 프로젝트: Rfinley93/DDP2P
 @Override
 public Encoder getEncoder() {
   Encoder enc = getSignEncoder();
   if (sender != null) enc.addToSequence(sender.getEncoder().setASN1Type(DD.TAG_AP1));
   if (signature != null) enc.addToSequence(new Encoder(signature).setASN1Type(DD.TAG_AP2));
   enc.setASN1Type(Encoder.CLASS_APPLICATION, Encoder.PC_CONSTRUCTED, getASN1Tag());
   return enc;
 }
예제 #3
0
 public Encoder getSignatureEncoder() {
   Encoder enc = new Encoder().initSequence();
   // enc.addToSequence(new Encoder(introducerPeerGID));
   enc.addToSequence(new Encoder(testerGID));
   enc.addToSequence(new Encoder(weight));
   enc.addToSequence(new Encoder(creation_date));
   // enc.addToSequence(new Encoder(signature));
   enc.setASN1Type(getASNType());
   return enc;
 }
예제 #4
0
  public static void insertTesterIntroducerInfo(D_TesterIntroducer testerIntroducer) {
    String params[] = new String[net.ddp2p.common.table.tester_introducer.F_FIELDS_NOID];

    params[net.ddp2p.common.table.tester_introducer.F_TESTER_LID] =
        Util.getStringID(testerIntroducer.testerLID);
    params[net.ddp2p.common.table.tester_introducer.F_INTRODUCER_PEER_LID] =
        Util.getStringID(testerIntroducer.introducerPeerLID);
    params[net.ddp2p.common.table.tester_introducer.F_SIGNATURE] =
        Util.stringSignatureFromByte(testerIntroducer.signature);
    params[net.ddp2p.common.table.tester_introducer.F_WEIGH] = testerIntroducer.weight;
    params[net.ddp2p.common.table.tester_introducer.F_CREATION_DATE] =
        Encoder.getGeneralizedTime(testerIntroducer.creation_date);
    // the following should be null!!
    params[net.ddp2p.common.table.tester_introducer.F_TESTER_REJECTING_DATE] =
        null; // Encoder.getGeneralizedTime(testerIntroducer.testerRejectingDate);
    params[net.ddp2p.common.table.tester_introducer.F_ATTACK_BY_INTRODUCER] =
        "0"; // Util.getString(testerIntroducer.attackByIntroducer);
    //			// ID:
    //			params[table.tester_introducer.F_ID] =
    // Util.getStringID(testerIntroducer.testerIntroducerID);

    try {
      Application.db.insert(
          net.ddp2p.common.table.tester_introducer.TNAME,
          net.ddp2p.common.table.tester_introducer._fields_tester_introducer_no_ID,
          params,
          DEBUG);
    } catch (P2PDDSQLException e) {
      e.printStackTrace();
    }
  }
 @Override
 public Encoder getEncoder() {
   return Encoder.getStringEncoder(getStrsArray(), Encoder.TAG_UTF8String)
       .setASN1Type(getASN1Tag());
 }
예제 #6
0
파일: DD_SK.java 프로젝트: Rfinley93/DDP2P
  public void __run() throws P2PDDSQLException {
    for (DD_SK_Entry d : ds.sk) {
      try {
        String params[] = new String[net.ddp2p.common.table.key.fields.length];
        PK pk = d.key.getPK();
        params[net.ddp2p.common.table.key.COL_SK] = Util.stringSignatureFromByte(d.key.encode());
        params[net.ddp2p.common.table.key.COL_NAME] = d.name;
        params[net.ddp2p.common.table.key.COL_TYPE] = d.type;
        params[net.ddp2p.common.table.key.COL_CREATION_DATE] =
            Encoder.getGeneralizedTime(d.creation);
        params[net.ddp2p.common.table.key.COL_PK] = Util.stringSignatureFromByte(pk.encode());
        params[net.ddp2p.common.table.key.COL_IDHASH] =
            Util.getGIDhash((String) params[net.ddp2p.common.table.key.COL_PK]);
        Application.db.insert(
            net.ddp2p.common.table.key.TNAME, net.ddp2p.common.table.key.fields, params, DEBUG);
      } catch (Exception e) {
        String localized = "";
        if (e.getLocalizedMessage() != null)
          localized = "\n" + __("Error:") + e.getLocalizedMessage();
        Application_GUI.warning(
            __("Error saving key:") + d + localized + "\nError:" + e, __("Error saving key"));
        e.printStackTrace();
      }
    }
    /*
     	for (D_Peer p : ds.peer) {
    if (DEBUG) System.out.println("WB_Messages: store: handle peer: "+p);
    if (! p.verifySignature()) {
    	if (DEBUG) System.out.println("WB_Messages: store: failed signature for: "+p);
    	continue;
    }
    p.fillLocals(null, null);
    if (DEBUG) System.out.println("WB_Messages: store: nou="+p);
    D_Peer old = D_Peer.getPeerByGID_or_GIDhash(p.getGID(), null, true, true, true, ds.sender);
    if (DEBUG) System.out.println("WB_Messages: store: old="+old);
    if (old.loadRemote(p, null, null)) {
    	if (old.dirty_any()) {
    		old.setArrivalDate();
    		old.storeRequest();

    		config.Application_GUI.inform_arrival(old, null);
    	}
    }
    old.releaseReference();
     	}
     	*/
    WB_Messages wm = new WB_Messages();
    wm.peers.addAll(ds.peer);
    if (ds.sender != null) wm.peers.add(0, ds.sender);
    wm.orgs.addAll(ds.org);
    wm.neig.addAll(ds.neigh);
    wm.cons.addAll(ds.constit);
    wm.witn.addAll(ds.witn);
    wm.moti.addAll(ds.moti);
    wm.just.addAll(ds.just);
    wm.sign.addAll(ds.vote);
    wm.news.addAll(ds.news);
    wm.tran.addAll(ds.tran);

    Hashtable<String, RequestData> missing_sr = new Hashtable<String, RequestData>();
    Hashtable<String, RequestData> obtained_sr = new Hashtable<String, RequestData>();
    HashSet<String> orgs = new HashSet<String>();
    String dbg_msg = __("Importing manually!");
    D_Peer myself = ds.sender; // data.HandlingMyself_Peer.get_myself_or_null();
    WB_Messages.store(null, myself, wm, missing_sr, obtained_sr, orgs, dbg_msg);
  }
예제 #7
0
파일: DD_SK.java 프로젝트: Rfinley93/DDP2P
 /**
  * sender has its own signature, so needs not be signed. Its PK has to match anyhow.
  *
  * @return
  */
 public Encoder getSignEncoder() {
   Encoder enc = new Encoder().initSequence();
   enc.addToSequence(new Encoder(version).setASN1Type(DD.TAG_AP0));
   if (sk.size() > 0) enc.addToSequence(Encoder.getEncoder(sk).setASN1Type(DD.TAG_AC0));
   if (peer.size() > 0) enc.addToSequence(Encoder.getEncoder(peer).setASN1Type(DD.TAG_AC1));
   if (org.size() > 0) enc.addToSequence(Encoder.getEncoder(org).setASN1Type(DD.TAG_AC2));
   if (neigh.size() > 0) enc.addToSequence(Encoder.getEncoder(neigh).setASN1Type(DD.TAG_AC3));
   if (constit.size() > 0) enc.addToSequence(Encoder.getEncoder(constit).setASN1Type(DD.TAG_AC4));
   if (witn.size() > 0) enc.addToSequence(Encoder.getEncoder(witn).setASN1Type(DD.TAG_AC5));
   if (moti.size() > 0) enc.addToSequence(Encoder.getEncoder(moti).setASN1Type(DD.TAG_AC6));
   if (just.size() > 0) enc.addToSequence(Encoder.getEncoder(just).setASN1Type(DD.TAG_AC7));
   if (vote.size() > 0) enc.addToSequence(Encoder.getEncoder(vote).setASN1Type(DD.TAG_AC8));
   if (news.size() > 0) enc.addToSequence(Encoder.getEncoder(news).setASN1Type(DD.TAG_AC9));
   if (tran.size() > 0) enc.addToSequence(Encoder.getEncoder(tran).setASN1Type(DD.TAG_AC10));
   return enc;
 }