コード例 #1
0
  public SocialCircleSetUpResponse(
      boolean[] protocolVersion,
      boolean[] messageType,
      boolean isAcknowledgment,
      boolean isSentByPeer,
      boolean isRecursive,
      boolean[] responseCode,
      byte ttl,
      byte[] transactionID,
      byte[] sourceID,
      byte[] responseID,
      boolean isOverReliable,
      boolean isEncrypted,
      PeerInfo ownPeerInfo,
      List<PeerInfo> vset) {
    super(
        protocolVersion,
        messageType,
        isAcknowledgment,
        isSentByPeer,
        isRecursive,
        responseCode,
        SET_UP_MESSAGE_TYPE,
        ttl,
        transactionID,
        sourceID,
        responseID,
        isOverReliable,
        isEncrypted);
    this.originatorPeerInfo =
        new PeerInfo(
            ownPeerInfo.getPeerID(),
            ownPeerInfo.getUptime(),
            ownPeerInfo.getAddressInfos(),
            ownPeerInfo.getUnhashedID());

    if (vset != null) {
      // given array may contain nulls, so only non-null elements are added
      for (PeerInfo peerInfo : vset) {
        if (peerInfo != null) {
          this.vset.add(peerInfo);
        }
      }
    }
  }
コード例 #2
0
  public SocialCircleSetUpResponse(
      boolean[] protocolVersion,
      boolean[] messageType,
      boolean isAcknowledgment,
      boolean isSentByPeer,
      boolean isRecursive,
      boolean[] responseCode,
      byte ttl,
      byte[] transactionID,
      byte[] sourceID,
      byte[] responseID,
      boolean isOverReliable,
      boolean isEncrypted,
      PeerInfo ownPeerInfo,
      PeerInfo peerInfo) {
    super(
        protocolVersion,
        messageType,
        isAcknowledgment,
        isSentByPeer,
        isRecursive,
        responseCode,
        SET_UP_MESSAGE_TYPE,
        ttl,
        transactionID,
        sourceID,
        responseID,
        isOverReliable,
        isEncrypted);
    this.originatorPeerInfo =
        new PeerInfo(
            ownPeerInfo.getPeerID(),
            ownPeerInfo.getUptime(),
            ownPeerInfo.getAddressInfos(),
            ownPeerInfo.getUnhashedID());

    if (null != peerInfo) {
      this.vset.add(peerInfo);
    }
  }
コード例 #3
0
  @Override
  public boolean verify() {
    boolean result = true;

    if (this.originatorPeerInfo == null || this.vset == null) {
      result = false;
    } else {
      // must contain peerID
      PeerID peerID = this.originatorPeerInfo.getPeerID();
      if (peerID == null) {
        result = false;
      } else {
        if (peerID.getPeerIDBytes() == null) {
          result = false;
        }
      }
      // not checked if peerID isn't here
      if (result) {
        // must contain unshadedID
        UnhashedID unhashedID = this.originatorPeerInfo.getUnhashedID();
        if (unhashedID == null) {
          result = false;
        } else {
          if (unhashedID.getUnhashedIDValue() == null) {
            result = false;
          }
        }
      }
      // not checked if PeerID or UnhashedID isn't here
      if (result) {
        // has to contain at least one AddressInfo
        Vector<AddressInfo> addressInfos = this.originatorPeerInfo.getAddressInfos();
        if (addressInfos == null) {
          result = false;
        } else if (addressInfos.size() <= 0) {
          result = false;
        }
      }

      if (result) {
        if (ByteUtils.booleanArrayToInt(this.reservedOrResponseCode) == Response.RESPONSE_CODE_OK) {
          int vsetSize = this.vset.size();
          if (vsetSize == 0) {
            result = false;
          } else {
            for (int i = 0; i < vsetSize; i++) {
              PeerInfo currentPeerInfo = this.vset.get(i);
              PeerID currentPeerID = currentPeerInfo.getPeerID();
              if (currentPeerID == null) {
                result = false;
              } else {
                if (currentPeerID.getPeerIDBytes() == null) {
                  result = false;
                } else {
                  Vector<AddressInfo> addressInfos = currentPeerInfo.getAddressInfos();
                  if (addressInfos == null) {
                    result = false;
                  } else if (addressInfos.size() <= 0) {
                    result = false;
                  } else {
                    UnhashedID currentUnhashedID = currentPeerInfo.getUnhashedID();
                    if (currentUnhashedID == null) {
                      result = false;
                    } else {
                      if (currentUnhashedID.getUnhashedIDValue() == null) {
                        result = false;
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }

    return result;
  }