예제 #1
0
파일: DD_SK.java 프로젝트: Rfinley93/DDP2P
 @Override
 public DD_SK decode(Decoder dec) throws ASN1DecoderFail {
   String default_orgGID = null;
   String default_orgGIDH = null;
   Decoder d = dec.getContent();
   if (d.getTypeByte() == DD.TAG_AP0)
     version = d.getFirstObject(true).getInteger(DD.TAG_AP0).intValue();
   if (d.getTypeByte() == DD.TAG_AC0)
     sk = d.getFirstObject(true).getSequenceOfAL(DD_SK_Entry.getASN1Tag(), new DD_SK_Entry());
   if (d.getTypeByte() == DD.TAG_AC1)
     peer = d.getFirstObject(true).getSequenceOfAL(D_Peer.getASN1Type(), D_Peer.getEmpty());
   if (d.getTypeByte() == DD.TAG_AC2) {
     org =
         d.getFirstObject(true)
             .getSequenceOfAL(D_Organization.getASN1Type(), D_Organization.getEmpty());
     if (org.size() == 1) {
       default_orgGID = org.get(0).getGID();
       default_orgGIDH = org.get(0).getGIDH();
       if (DEBUG)
         System.out.println(
             "DD_SK: has a GID for orgs: " + default_orgGID + " H=" + default_orgGIDH);
     }
   }
   if (d.getTypeByte() == DD.TAG_AC3)
     neigh =
         d.getFirstObject(true)
             .getSequenceOfAL(D_Neighborhood.getASN1Type(), D_Neighborhood.getEmpty());
   if (d.getTypeByte() == DD.TAG_AC4)
     constit =
         d.getFirstObject(true)
             .getSequenceOfAL(D_Constituent.getASN1Type(), D_Constituent.getEmpty());
   if (d.getTypeByte() == DD.TAG_AC5)
     witn = d.getFirstObject(true).getSequenceOfAL(D_Witness.getASN1Type(), D_Witness.getEmpty());
   if (d.getTypeByte() == DD.TAG_AC6) {
     moti = d.getFirstObject(true).getSequenceOfAL(D_Motion.getASN1Type(), D_Motion.getEmpty());
     for (D_Motion m : moti) {
       if (m.getOrganizationGIDH() == null) {
         if (_DEBUG) System.out.println("DD_SK: put a GIDH for " + m);
         m.setOrganizationGID(default_orgGIDH);
         if (_DEBUG) System.out.println("DD_SK: did put a GIDH for " + m);
       } else if (DEBUG) System.out.println("DD_SK: had a GIDH for " + m);
     }
   }
   if (d.getTypeByte() == DD.TAG_AC7)
     just =
         d.getFirstObject(true)
             .getSequenceOfAL(D_Justification.getASN1Type(), D_Justification.getEmpty());
   if (d.getTypeByte() == DD.TAG_AC8)
     vote = d.getFirstObject(true).getSequenceOfAL(D_Vote.getASN1Type(), D_Vote.getEmpty());
   if (d.getTypeByte() == DD.TAG_AC10)
     tran =
         d.getFirstObject(true)
             .getSequenceOfAL(D_Translations.getASN1Type(), D_Translations.getEmpty());
   if (d.getTypeByte() == DD.TAG_AP1) sender = D_Peer.getEmpty().decode(d.getFirstObject(true));
   if (d.getTypeByte() == DD.TAG_AP2) signature = d.getFirstObject(true).getBytes(DD.TAG_AP2);
   return this;
 }
예제 #2
0
파일: DD_SK.java 프로젝트: Rfinley93/DDP2P
  /**
   * This does not add a vote
   *
   * @param d_SK
   * @param crt_justification
   */
  public static void addJustificationToDSSK(DD_SK d_SK, D_Justification crt_justification) {
    if (crt_justification != null) {
      // skip if no GID
      String jGID = crt_justification.getGID();
      if (jGID == null) return;
      // skip if already in
      for (D_Justification old_j : d_SK.just) {
        if (Util.equalStrings_and_not_null(old_j.getGID(), jGID)) return;
      }

      d_SK.just.add(crt_justification);
      addConstituentToDSSK(d_SK, crt_justification.getConstituentForce());
      addMotionToDSSK(d_SK, crt_justification.getMotionForce());
    }
  }
예제 #3
0
파일: DD_SK.java 프로젝트: Rfinley93/DDP2P
 @Override
 public String getNiceDescription() {
   String result = "";
   for (DD_SK_Entry _sk : sk)
     result += "SK[: sk=" + _sk.name + "]"; // Util.concat(sk, ";;;", "NULL");
   for (D_Peer _peer : peer) result += " Safe=[" + _peer.getName() + "]";
   for (D_Organization _org : org) result += " Org=[" + _org.getName() + "]";
   for (D_Constituent _constit : constit) result += " Cons=[" + _constit.getNameFull() + "]";
   for (D_Witness _witn : witn) result += " Witn=[" + _witn.witnessed_global_constituentID + "]";
   for (D_Motion _moti : moti) result += " Moti=[" + _moti.getTitleStrOrMy() + "]";
   for (D_Justification _just : just) result += " Just=[" + _just.getTitleStrOrMy() + "]";
   for (D_News _news : news) result += " News=[" + _news.getTitleStrOrMy() + "]";
   for (D_Vote _vote : vote)
     result += " Vote=[" + _vote.getChoice() + " " + _vote.getMotionGID() + "]";
   // to implement
   if (tran.size() > 0) result += " tran=" + Util.concat(tran, ",,,", "NULL");
   result += "]";
   return result;
 }
예제 #4
0
파일: DD_SK.java 프로젝트: Rfinley93/DDP2P
 /**
  * @param d_SK
  * @param crt_justification
  * @param voting_constituent
  * @param alreadySupported
  */
 public static void addJustificationWithAnySupportToDSSK(
     DD_SK d_SK,
     D_Justification crt_justification,
     D_Constituent voting_constituent,
     boolean alreadySupported) {
   addJustificationToDSSK(d_SK, crt_justification);
   if (alreadySupported) return;
   D_Motion crt_motion = crt_justification.getMotionForce();
   D_Vote my_vote =
       D_Vote.getOneBroadcastedSupportForJustification(
           crt_motion, crt_justification, voting_constituent, crt_motion.getSupportChoice());
   if (my_vote != null) {
     addVoteIfNew(d_SK, my_vote);
     addConstituentToDSSK(d_SK, my_vote.getConstituent_force());
   }
 }