Class JsonProtectionInterceptor
java.lang.Object
com.predic8.membrane.core.interceptor.AbstractInterceptor
com.predic8.membrane.core.interceptor.json.JsonProtectionInterceptor
- All Implemented Interfaces:
Interceptor
Enforces JSON restrictions in requests
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.predic8.membrane.core.interceptor.Interceptor
Interceptor.Flow -
Field Summary
Fields inherited from class com.predic8.membrane.core.interceptor.AbstractInterceptor
name, router -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintintintintintintinthandleRequest(Exchange exc) voidinit()Called after parsing is complete and this has been added to the object tree (whose root is Router).voidsetMaxArraySize(int maxArraySize) voidsetMaxDepth(int maxDepth) voidsetMaxKeyLength(int maxKeyLength) voidsetMaxObjectSize(int maxObjectSize) voidsetMaxSize(int maxSize) voidsetMaxStringLength(int maxStringLength) voidsetMaxTokens(int maxTokens) voidsetReportError(boolean reportError) Methods inherited from class com.predic8.membrane.core.interceptor.AbstractInterceptor
getDisplayName, getFlow, getHelpId, getMessage, getRouter, getRule, handleAbort, handleResponse, init, setDisplayName, setFlow
-
Constructor Details
-
JsonProtectionInterceptor
public JsonProtectionInterceptor()
-
-
Method Details
-
init
Description copied from class:AbstractInterceptorCalled after parsing is complete and this has been added to the object tree (whose root is Router).- Overrides:
initin classAbstractInterceptor- Throws:
Exception
-
handleRequest
- Specified by:
handleRequestin interfaceInterceptor- Overrides:
handleRequestin classAbstractInterceptor- Throws:
Exception
-
getMaxTokens
public int getMaxTokens() -
setReportError
public void setReportError(boolean reportError) - Parameters:
reportError-- Default
- null
- Description
- Overwrites default error reporting behaviour. If set to true, errors will provide ProblemDetails body, if set to false, errors will throw standard exceptions.
-
getReportError
-
setMaxTokens
public void setMaxTokens(int maxTokens) - Parameters:
maxTokens-- Default
- 10000
- Description
- Maximum number of tokens a JSON document may consist of. For example,
{"a":"b"}counts as 3.
-
getMaxSize
public int getMaxSize() -
setMaxSize
public void setMaxSize(int maxSize) - Parameters:
maxSize-- Default
- 52428800
- Description
- Maximum total size of the JSON document in bytes.
-
getMaxDepth
public int getMaxDepth() -
setMaxDepth
public void setMaxDepth(int maxDepth) - Parameters:
maxDepth-- Default
- 50
- Description
- Maximum depth of nested JSON structures. For example,
{"a":{"b":{"c":"d"}}}has a depth of 3.
-
getMaxStringLength
public int getMaxStringLength() -
setMaxStringLength
public void setMaxStringLength(int maxStringLength) - Parameters:
maxStringLength-- Default
- 262144
- Description
- Maximum string length. For example,
{"abcd": "efgh", "ijkl": [ "mnop" ], "qrst": { "uvwx": 1}}has a maximum string length of 4. (In this example, all 6 strings effectively have length 4.)The maximum string length also affects keys ("abcd", "ijkl", "qrst" and "uvwx" in the example). The keys can be also limited by the separate property maxKeyLength. The stricter limit applies.
-
getMaxKeyLength
public int getMaxKeyLength() -
setMaxKeyLength
public void setMaxKeyLength(int maxKeyLength) - Parameters:
maxKeyLength-- Default
- 256
- Description
- Maximum key length. For example,
{"abcd": "efgh123", "ijkl": [ "mnop123" ], "qrst": { "uvwx": 1}}has a maximum key length of 4. (In this example, all 4 strings used as keys effectively have length 4.)The maximum key length also affects strings ("abcd", "ijkl", "qrst" and "uvwx" in the example). The strings can be also limited by the separate property maxStringLength. The stricter limit applies.
-
getMaxObjectSize
public int getMaxObjectSize() -
setMaxObjectSize
public void setMaxObjectSize(int maxObjectSize) - Parameters:
maxObjectSize-- Default
- 1000
- Description
- Maximum size of JSON objects. For example,
{"a": {"b":"c", "d": "e"}, "f": "g"}has a maximum object size of 2. (In this example, both objects effectively have a size of 2.)
-
getMaxArraySize
public int getMaxArraySize() -
setMaxArraySize
public void setMaxArraySize(int maxArraySize) - Parameters:
maxArraySize-- Default
- 1000
- Description
- Maximum size of JSON objects. For example,
{"a": {"b":"c", "d": "e"}, "f": "g"}has a maximum object size of 2. (In this example, both objects effectively have a size of 2.)
-
getShortDescription
- Specified by:
getShortDescriptionin interfaceInterceptor- Overrides:
getShortDescriptionin classAbstractInterceptor
-
getLongDescription
- Specified by:
getLongDescriptionin interfaceInterceptor- Overrides:
getLongDescriptionin classAbstractInterceptor
-