public interface DocumentFieldParser
| Modifier and Type | Method and Description |
|---|---|
int |
argumentsRemaining()
Returns the number of unprocessed argument items on the current keyword line.
|
void |
endSignedEntity()
Set the current keyword line as the last line included in the current signature hash.
|
String |
getCurrentKeyword()
Return the keyword of the current keyword line.
|
String |
getRawDocument()
Return all lines from the current document as a single String.
|
TorMessageDigest |
getSignatureMessageDigest()
Return the internal message digest which is being used to calculate the
signature over the current document.
|
TorMessageDigest |
getSignatureMessageDigest256() |
void |
logDebug(String message)
Log the specified message at the debug logging level.
|
void |
logError(String message)
Log the specified message at the error logging level.
|
void |
logWarn(String message)
Log the specified message at the warn logging level.
|
IPv4Address |
parseAddress()
Extract the next argument and interpret it as an IPv4 network address in dotted quad notation.
|
HexDigest |
parseBase32Digest()
Extract the next argument and interpret it as a base 32 encoded digest string.
|
byte[] |
parseBase64Data()
Extract the next argument and interpret it as Base64 encoded binary data.
|
boolean |
parseBoolean()
Extract the next argument and interpret it as an integer boolean value.
|
String |
parseConcatenatedString()
Take all remaining arguments on the current keyword line and return them as a single space
delimited String.
|
HexDigest |
parseFingerprint()
Extract all remaining arguments and interpret the concatenated string as a
hex encoded fingerprint string.
|
HexDigest |
parseHexDigest()
Extract the next argument and interpret it as a hex encoded digest string.
|
int |
parseInteger()
Extract the next argument and interpret it as an integer.
|
int |
parseInteger(String item)
Parse the
item argument as an integer. |
int[] |
parseIntegerList()
Extract the next argument and interpret it as a comma separated list of integers.
|
String |
parseNickname()
Extract the next argument item and return it as a
String if it conforms to
a legally formed router nickname (dir-spec.txt section 2.3). |
byte[] |
parseNtorPublicKey() |
DocumentObject |
parseObject()
Extract a document object following the current keyword line and don't attempt to interpret
it further.
|
NameIntegerParameter |
parseParameter() |
int |
parsePort()
Extract the next argument and interpret it as a network port value.
|
int |
parsePort(String item)
Parse the
item arguement as a network port value. |
TorPublicKey |
parsePublicKey()
Extract a document object following the current keyword line and interpret it as a PEM
encoded public key.
|
TorSignature |
parseSignature()
Extract a document object following the current keyword line and interpret it as a
Base64 encoded PKCS1 signature object.
|
String |
parseString()
Extract the next argument item and return it as a String
|
Timestamp |
parseTimestamp()
Extract the next two arguments and parse as a timestamp field.
|
void |
processDocument()
Run the document parser.
|
void |
resetRawDocument()
Empty the internal buffer which is capturing the raw data from
the document which is being parsed.
|
void |
resetRawDocument(String initialContent)
Empty the internal buffer which is capturing raw data from document being parsed and set buffer contents to initalContent.
|
void |
setDelimiter(String delimeter)
The default delimiter between keyword line tokens is any whitespace.
|
void |
setHandler(DocumentParsingHandler handler)
Set the callback handler which is used to process the document.
|
void |
setRecognizeOpt()
Set a flag so that 'opt' tokens will be recognized at the start of keyword lines.
|
void |
setSignatureIgnoreToken(String token)
Tells the parser to not include lines that begin with
token in the current
signature calculation. |
void |
startSignedEntity()
Reset the document signing state.
|
void |
verifyExpectedArgumentCount(String keyword,
int argumentCount)
Test that the current keyword line has the correct number of arguments.
|
boolean |
verifySignedEntity(TorPublicKey publicKey,
TorSignature signature)
Verify that current signature hash matches the specified
signature signed
with the public key publicKey |
void processDocument()
setHandler(DocumentParsingHandler) method must be
called before calling this method to set a DocumentParsingHandler for processing
this document.TorParsingException - If a parsing error occurs while processing the document.int argumentsRemaining()
String parseString()
TorParsingException - If no arguments are remaining on the current keyword line.String parseConcatenatedString()
boolean parseBoolean()
TorParsingException - If no arguments are remaining or if the current argument cannot be
parsed as a boolean integer value.String parseNickname()
String if it conforms to
a legally formed router nickname (dir-spec.txt section 2.3).
A router nickname must be between 1 and 19 alphanumeric characters ([A-Za-z0-9]) to
be considered valid.String if it is a validly formatted nickname.TorParsingException - If no arguments are remaining or if the current argument is not
a valid router nickname.int parseInteger()
TorParsingException - If no arguments are remaining or if the current argument cannot
be parsed as an integer value.int parseInteger(String item)
item argument as an integer.item - A string to parse as an integer.item argument.TorParsingException - If the item argument cannot be parsed as an
integer value.int[] parseIntegerList()
TorParsingException - If no arguments are remaining or if the current argument cannot
be parsed as a list of integers.int parsePort()
TorParsingException - If no arguments are remaining or if the current argument cannot
be parsed as a legal port value.int parsePort(String item)
item arguement as a network port value. A valid port value
is an integer between 0 and 65535 inclusive.item - A string to parse as an integer port value.item argumentTorParsingException - If the item argument cannot be parsed as a
legal port value.byte[] parseBase64Data()
TorParsingException - If no arguments are remaining or if the current argument cannot
be parsed as Base64 encoded data.Timestamp parseTimestamp()
Timestamp value.TorParsingException - If there are not sufficient arguments remaining or if the current
arguments could not be parsed as a timestamp field.HexDigest parseHexDigest()
HexDigest value.TorParsingException - If no arguments are remaining or if the current argument cannot
be parsed as a hex encoded digest string.HexDigest parseBase32Digest()
HexDigest value.TorParsingException - If no arguments are remaining or if the current argument cannot
be parsed as a base 32 encoded digest string.HexDigest parseFingerprint()
HexDigest value extracted from the concatenated string.TorParsingException - If the concatenation of the remaining arguments could not be parsed
as a hex encoded fingerprint string.IPv4Address parseAddress()
IPv4Address value.TorParsingException - If no arguments are remaining or if the current argument cannot
be parsed as an IPv4 network address.TorPublicKey parsePublicKey()
TorPublicKey value.TorParsingException - If no document object is found following the current keyword line,
or if the document object cannot be parsed as a PEM encoded public key.byte[] parseNtorPublicKey()
TorSignature parseSignature()
TorSignature value.TorParsingException - If no document object is found following the current keyword line,
or if the document object cannot be parsed as a signature.DocumentObject parseObject()
DocumentObject.TorParsingException - If no document object is found following the current keyword line.NameIntegerParameter parseParameter()
String getCurrentKeyword()
String getRawDocument()
void resetRawDocument()
void resetRawDocument(String initialContent)
initialContent - Initial raw document content.void startSignedEntity()
void endSignedEntity()
void setSignatureIgnoreToken(String token)
token in the current
signature calculation.token - The parser will not include lines that begin with token in the
current signature.TorMessageDigest getSignatureMessageDigest()
TorMessageDigest instance or null if
a signature is not being actively calculated.TorMessageDigest getSignatureMessageDigest256()
boolean verifySignedEntity(TorPublicKey publicKey, TorSignature signature)
signature signed
with the public key publicKeypublicKey - The public key used to verify the signature.signature - The signature to verify against the current signature hash.trueIf the signature argument matches the hash currently
calculated document hash.void verifyExpectedArgumentCount(String keyword, int argumentCount)
keyword - The name of the current keyword. (used for errors)argumentCount - The expected number of arguments.TorParsingException - If the number of remaining arguments does not match
argumentCount.void setRecognizeOpt()
void setDelimiter(String delimeter)
delimeter - A regular expression which matches the desired delimiter.void setHandler(DocumentParsingHandler handler)
processDocument().handler - The callback handler.void logDebug(String message)
message - The message to log.void logWarn(String message)
message - The message to log.void logError(String message)
message - The message to log.Copyright © 2015. All rights reserved.