Examples of TorParsingException


Examples of com.subgraph.orchid.TorParsingException

    if(i == 1)
      return true;
    else if(i == 0)
      return false;
    else
      throw new TorParsingException("Illegal boolean value: "+ i);
  }
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

  public int parseInteger(String item) {
    try {
      return Integer.parseInt(item);
    } catch(NumberFormatException e) {
      throw new TorParsingException("Failed to parse expected integer value: " + item);
    }
  }
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

  }

  public int parsePort(String item) {
    final int port = parseInteger(item);
    if(port < 0 || port > 65535)
      throw new TorParsingException("Illegal port value: " + port);
    return port;
  }
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

  public Timestamp parseTimestamp() {
    String timeAndDate = getItem() + " " + getItem();
    try {
      return new Timestamp(dateFormat.parse(timeAndDate));
    } catch (ParseException e) {
      throw new TorParsingException("Could not parse timestamp value: "+ timeAndDate);
    }
  }
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

  }

  private  void verifyExpectedArgumentCount(String keyword, int expectedMin, int expectedMax) {
    final int argumentCount = argumentsRemaining();
    if(expectedMin != -1 && argumentCount < expectedMin)
      throw new TorParsingException("Not enough arguments for keyword '"+ keyword +"' expected "+ expectedMin +" and got "+ argumentCount);

    if(expectedMax != -1 && argumentCount > expectedMax)
      // Is this the correct thing to do, or should just be a warning?
      throw new TorParsingException("Too many arguments for keyword '"+ keyword +"' expected "+ expectedMax +" and got "+ argumentCount);
  }
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

 
  public byte[] parseNtorPublicKey() {
    final byte[] key = parseBase64Data();
    if(key.length != TorNTorKeyAgreement.CURVE25519_PUBKEY_LEN) {
      throw new TorParsingException("NTor public key was not expected length after base64 decoding.  Length is "+ key.length);
    }
    return key;
  }
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

  public NameIntegerParameter parseParameter() {
    final String item = getItem();
    final int eq = item.indexOf('=');
    if(eq == -1) {
      throw new TorParsingException("Parameter not in expected form name=value");
    }
    final String name = item.substring(0, eq);
    validateParameterName(name);
    final int value = parseInteger(item.substring(eq + 1));
    return new NameIntegerParameter(name, value);
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

    return new NameIntegerParameter(name, value);
  }
 
  private void validateParameterName(String name) {
    if(name.isEmpty()) {
      throw new TorParsingException("Parameter name cannot be empty");
    }
    for(char c: name.toCharArray()) {
      if(!(Character.isLetterOrDigit(c) || c == '_')) {
        throw new TorParsingException("Parameter name can only contain letters.  Rejecting: "+ name);
      }
    }
  }
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

  }

  public DocumentObject parseTypedObject(String type) {
    final DocumentObject object = parseObject();
    if(!type.equals(object.getKeyword()))
      throw new TorParsingException("Unexpected object type.  Expecting: "+ type +", but got: "+ object.getKeyword());
    return object;
  }
View Full Code Here

Examples of com.subgraph.orchid.TorParsingException

    return object;
  }

  private String parseObjectHeader(String headerLine) {
    if(!(headerLine.startsWith(BEGIN_TAG) && headerLine.endsWith(TAG_DELIMITER)))
      throw new TorParsingException("Did not find expected object start tag.");
    return headerLine.substring(BEGIN_TAG.length() + 1,
        headerLine.length() - TAG_DELIMITER.length());
  }
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.