public class DocumentFieldParserImpl extends Object implements DocumentFieldParser
| Constructor and Description |
|---|
DocumentFieldParserImpl(ByteBuffer buffer) |
| 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.
|
DocumentObject |
parseTypedObject(String type) |
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 delimiter)
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 |
public DocumentFieldParserImpl(ByteBuffer buffer)
public String parseNickname()
DocumentFieldParserString 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.parseNickname in interface DocumentFieldParserString if it is a validly formatted nickname.public String parseString()
DocumentFieldParserparseString in interface DocumentFieldParserpublic void setRecognizeOpt()
DocumentFieldParsersetRecognizeOpt in interface DocumentFieldParserpublic void setHandler(DocumentParsingHandler handler)
DocumentFieldParserDocumentFieldParser.processDocument().setHandler in interface DocumentFieldParserhandler - The callback handler.public void setDelimiter(String delimiter)
DocumentFieldParsersetDelimiter in interface DocumentFieldParserdelimiter - A regular expression which matches the desired delimiter.public int argumentsRemaining()
DocumentFieldParserargumentsRemaining in interface DocumentFieldParserpublic String parseConcatenatedString()
DocumentFieldParserparseConcatenatedString in interface DocumentFieldParserpublic boolean parseBoolean()
DocumentFieldParserparseBoolean in interface DocumentFieldParserpublic int parseInteger()
DocumentFieldParserparseInteger in interface DocumentFieldParserpublic int parseInteger(String item)
DocumentFieldParseritem argument as an integer.parseInteger in interface DocumentFieldParseritem - A string to parse as an integer.item argument.public int[] parseIntegerList()
DocumentFieldParserparseIntegerList in interface DocumentFieldParserpublic int parsePort()
DocumentFieldParserparsePort in interface DocumentFieldParserpublic int parsePort(String item)
DocumentFieldParseritem arguement as a network port value. A valid port value
is an integer between 0 and 65535 inclusive.parsePort in interface DocumentFieldParseritem - A string to parse as an integer port value.item argumentpublic Timestamp parseTimestamp()
DocumentFieldParserparseTimestamp in interface DocumentFieldParserTimestamp value.public HexDigest parseHexDigest()
DocumentFieldParserparseHexDigest in interface DocumentFieldParserHexDigest value.public HexDigest parseBase32Digest()
DocumentFieldParserparseBase32Digest in interface DocumentFieldParserHexDigest value.public HexDigest parseFingerprint()
DocumentFieldParserparseFingerprint in interface DocumentFieldParserHexDigest value extracted from the concatenated string.public void verifyExpectedArgumentCount(String keyword, int argumentCount)
DocumentFieldParserverifyExpectedArgumentCount in interface DocumentFieldParserkeyword - The name of the current keyword. (used for errors)argumentCount - The expected number of arguments.public byte[] parseBase64Data()
DocumentFieldParserparseBase64Data in interface DocumentFieldParserpublic IPv4Address parseAddress()
DocumentFieldParserparseAddress in interface DocumentFieldParserIPv4Address value.public TorPublicKey parsePublicKey()
DocumentFieldParserparsePublicKey in interface DocumentFieldParserTorPublicKey value.public byte[] parseNtorPublicKey()
parseNtorPublicKey in interface DocumentFieldParserpublic TorSignature parseSignature()
DocumentFieldParserparseSignature in interface DocumentFieldParserTorSignature value.public NameIntegerParameter parseParameter()
parseParameter in interface DocumentFieldParserpublic DocumentObject parseTypedObject(String type)
public DocumentObject parseObject()
DocumentFieldParserparseObject in interface DocumentFieldParserDocumentObject.public String getCurrentKeyword()
DocumentFieldParsergetCurrentKeyword in interface DocumentFieldParserpublic void processDocument()
DocumentFieldParserDocumentFieldParser.setHandler(DocumentParsingHandler) method must be
called before calling this method to set a DocumentParsingHandler for processing
this document.processDocument in interface DocumentFieldParserpublic void startSignedEntity()
DocumentFieldParserstartSignedEntity in interface DocumentFieldParserpublic void endSignedEntity()
DocumentFieldParserendSignedEntity in interface DocumentFieldParserpublic void setSignatureIgnoreToken(String token)
DocumentFieldParsertoken in the current
signature calculation.setSignatureIgnoreToken in interface DocumentFieldParsertoken - The parser will not include lines that begin with token in the
current signature.public TorMessageDigest getSignatureMessageDigest()
DocumentFieldParsergetSignatureMessageDigest in interface DocumentFieldParserTorMessageDigest instance or null if
a signature is not being actively calculated.public TorMessageDigest getSignatureMessageDigest256()
getSignatureMessageDigest256 in interface DocumentFieldParserpublic String getRawDocument()
DocumentFieldParsergetRawDocument in interface DocumentFieldParserpublic void resetRawDocument()
DocumentFieldParserresetRawDocument in interface DocumentFieldParserpublic void resetRawDocument(String initialContent)
DocumentFieldParserresetRawDocument in interface DocumentFieldParserinitialContent - Initial raw document content.public boolean verifySignedEntity(TorPublicKey publicKey, TorSignature signature)
DocumentFieldParsersignature signed
with the public key publicKeyverifySignedEntity in interface DocumentFieldParserpublicKey - 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.public void logDebug(String message)
DocumentFieldParserlogDebug in interface DocumentFieldParsermessage - The message to log.public void logError(String message)
DocumentFieldParserlogError in interface DocumentFieldParsermessage - The message to log.public void logWarn(String message)
DocumentFieldParserlogWarn in interface DocumentFieldParsermessage - The message to log.Copyright © 2015. All rights reserved.