Examples of TorParsingException


Examples of com.subgraph.orchid.TorParsingException

  }
 
  private void processKeyword(DocumentKeyword keyword) {
    switch(keyword) {
    case NETWORK_STATUS_VERSION:
      throw new TorParsingException("Network status version may only appear on the first line of status document");
    case VOTE_STATUS:
      final String voteStatus = fieldParser.parseString();
      if(!voteStatus.equals("consensus"))
        throw new TorParsingException("Unexpected vote-status type: "+ voteStatus);
      break;
    case CONSENSUS_METHOD:
      document.setConsensusMethod(fieldParser.parseInteger());
      break;
     
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

   
  }
 
  private void parseFirstLine(DocumentKeyword keyword) {
    if(keyword != DocumentKeyword.NETWORK_STATUS_VERSION)    
      throw new TorParsingException("network-status-version not found at beginning of consensus document as expected.");
     
    final int documentVersion = fieldParser.parseInteger();
   
    if(documentVersion != CURRENT_DOCUMENT_VERSION)
      throw new TorParsingException("Unexpected consensus document version number: " + documentVersion);
   
    if(fieldParser.argumentsRemaining() > 0) {
      parseConsensusFlavor();
    }
    isFirstLine = false;
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

    }
  }

  private void assertCurrentEntry() {
    if(currentEntry == null)
      throw new TorParsingException("Router status entry must begin with an 'r' line");
  }
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

    currentEntry = null;
  }
 
  private void parseFirstLine() {
    if(currentEntry != null)
      throw new TorParsingException("Unterminated router status entry.");
    currentEntry = new RouterStatusImpl();
    currentEntry.setNickname(fieldParser.parseNickname());
    currentEntry.setIdentity(parseBase64Digest());
    if(document.getFlavor() != ConsensusFlavor.MICRODESC) {
      currentEntry.setDigest(parseBase64Digest());
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

      currentEntry.setMeasuredBandwidth(value);
  }
 
  private void parsePortList() {
    if(document.getFlavor() == ConsensusFlavor.MICRODESC) {
      throw new TorParsingException("'p' line does not appear in consensus flavor 'microdesc'");
    }
    final String arg = fieldParser.parseString();
    if(arg.equals("accept")) {
      currentEntry.setAcceptedPorts(fieldParser.parseString());
    } else if(arg.equals("reject")) {
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

    addCurrentEntry();
  }
 
  private void parseMicrodescriptorHash() {
    if(document.getFlavor() != ConsensusFlavor.MICRODESC) {
      throw new TorParsingException("'m' line is invalid unless consensus flavor is microdesc");
    }
    final byte[] hashBytes = fieldParser.parseBase64Data();
    if(hashBytes.length != TorMessageDigest.TOR_DIGEST256_SIZE) {
      throw new TorParsingException("'m' line has incorrect digest size "+ hashBytes.length +" != "+ TorMessageDigest.TOR_DIGEST256_SIZE);
    }
    currentEntry.setMicrodescriptorDigest(HexDigest.createFromDigestBytes(hashBytes));
  }
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

  }
 
  private void processCertificateVersion() {
    final int version = fieldParser.parseInteger();
    if(version != CURRENT_CERTIFICATE_VERSION)
      throw new TorParsingException("Unexpected certificate version: " + version);
  }
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

 
  private void processDirectoryAddress() {
    final String addrport = fieldParser.parseString();
    final String[] args = addrport.split(":");
    if(args.length != 2)
      throw new TorParsingException("Address/Port string incorrectly formed: " + addrport);
    currentCertificate.setDirectoryAddress(IPv4Address.createFromString(args[0]));
    currentCertificate.setDirectoryPort(fieldParser.parsePort(args[1]));
  }
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

 
  private void verifyCrossSignature(TorSignature crossSignature) {
    TorPublicKey identityKey = currentCertificate.getAuthorityIdentityKey();
    TorPublicKey signingKey = currentCertificate.getAuthoritySigningKey();
    if(!signingKey.verifySignature(crossSignature, identityKey.getFingerprint()))
      throw new TorParsingException("Cross signature on certificate failed.");
  }
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

    return currentItems.size() - currentItemsPosition;
  }

  private String getItem() {
    if(currentItemsPosition >= currentItems.size())
      throw new TorParsingException("Overrun while reading arguments");
    return currentItems.get(currentItemsPosition++);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.