Class SafeTokenReader
java.lang.Object
java.io.Reader
graphql.parser.SafeTokenReader
- All Implemented Interfaces:
Closeable, AutoCloseable, Readable
This reader will only emit a maximum number of characters from it. This is used to protect us from evil input.
If a graphql system does not have some max HTTP input limit, then this will help protect the system. This is a limit of last resort. Ideally the http input should be limited, but if its not, we have this.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSafeTokenReader(Reader delegate, int maxCharacters, Consumer<Integer> whenMaxCharactersExceeded) -
Method Summary
Modifier and TypeMethodDescriptionprivate intcheckHowMany(int read, int howMany) voidclose()voidmark(int readAheadLimit) booleanintread()intread(char @NotNull [] buff) intread(char @NotNull [] buff, int off, int len) intread(@NotNull CharBuffer target) booleanready()voidreset()longskip(long n)
-
Field Details
-
delegate
-
maxCharacters
private final int maxCharacters -
whenMaxCharactersExceeded
-
count
private int count
-
-
Constructor Details
-
SafeTokenReader
-
-
Method Details
-
checkHowMany
private int checkHowMany(int read, int howMany) -
read
- Specified by:
readin classReader- Throws:
IOException
-
read
- Overrides:
readin classReader- Throws:
IOException
-
read
- Specified by:
readin interfaceReadable- Overrides:
readin classReader- Throws:
IOException
-
read
- Overrides:
readin classReader- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException
-
skip
- Overrides:
skipin classReader- Throws:
IOException
-
ready
- Overrides:
readyin classReader- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classReader
-
mark
- Overrides:
markin classReader- Throws:
IOException
-
reset
- Overrides:
resetin classReader- Throws:
IOException
-