Package org.ngengine.platform
Class MemoryLimits
- java.lang.Object
-
- org.ngengine.platform.MemoryLimits
-
public class MemoryLimits extends java.lang.ObjectA last resort hardening against memory overuse. This is used to stop the propagation of obviously abnormal data sizes that would indicate an obvious denial of service attack. This class can be reimplemented to be platform sensitive, eg. by checking the sizes against remaining free memory. The different checks are to differentiate for likely maximum memory usage patterns for the different use cases, but they should be kept reasonably high and they should not do any validation or check beyond simple size limits, those checks are to be done elsewhere.
-
-
Field Summary
Fields Modifier and Type Field Description protected longBprotected longBASE64_LIMITprotected longBIGDATA_LIMITprotected longDATA_LIMITprotected longIMAGE_LIMITprotected longJSON_LIMITprotected longKEYS_LIMITprotected longKIBprotected longMIBprotected longRANDOM_LIMITprotected longSTRING_LIMITprotected longTRANSPORT_LIMIT
-
Constructor Summary
Constructors Constructor Description MemoryLimits()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckForBase64(long byteLength)Check limit for base64 encoded databooleancheckForBigData(long byteLength)Check limit for big data blobs (eg.booleancheckForData(long byteLength)Check limit for generic data blobs (eg.booleancheckForImage(long byteLength)Check limit for image databooleancheckForJSON(long byteLength)Check limit for json encoded databooleancheckForKeys(long byteLength)Check limit for cryptographic keys and signaturesbooleancheckForRandomData(long n)Check limit for random generated databooleancheckForString(int length)Check limit for human readable strings (eg.booleancheckForTransport(long byteLength)Check limit for network packetsprotected booleancheckLimit(long size, long limit)longgetTransportLimit()
-
-
-
Field Detail
-
MIB
protected final long MIB
- See Also:
- Constant Field Values
-
KIB
protected final long KIB
- See Also:
- Constant Field Values
-
B
protected final long B
- See Also:
- Constant Field Values
-
JSON_LIMIT
protected final long JSON_LIMIT
- See Also:
- Constant Field Values
-
BASE64_LIMIT
protected final long BASE64_LIMIT
- See Also:
- Constant Field Values
-
TRANSPORT_LIMIT
protected final long TRANSPORT_LIMIT
- See Also:
- Constant Field Values
-
BIGDATA_LIMIT
protected final long BIGDATA_LIMIT
- See Also:
- Constant Field Values
-
DATA_LIMIT
protected final long DATA_LIMIT
- See Also:
- Constant Field Values
-
IMAGE_LIMIT
protected final long IMAGE_LIMIT
- See Also:
- Constant Field Values
-
KEYS_LIMIT
protected final long KEYS_LIMIT
- See Also:
- Constant Field Values
-
STRING_LIMIT
protected final long STRING_LIMIT
- See Also:
- Constant Field Values
-
RANDOM_LIMIT
protected final long RANDOM_LIMIT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getTransportLimit
public long getTransportLimit()
-
checkLimit
protected boolean checkLimit(long size, long limit)
-
checkForJSON
public boolean checkForJSON(long byteLength)
Check limit for json encoded data
-
checkForBase64
public boolean checkForBase64(long byteLength)
Check limit for base64 encoded data
-
checkForTransport
public boolean checkForTransport(long byteLength)
Check limit for network packets
-
checkForBigData
public boolean checkForBigData(long byteLength)
Check limit for big data blobs (eg. files, assets...)
-
checkForData
public boolean checkForData(long byteLength)
Check limit for generic data blobs (eg. events, messages...)
-
checkForImage
public boolean checkForImage(long byteLength)
Check limit for image data
-
checkForKeys
public boolean checkForKeys(long byteLength)
Check limit for cryptographic keys and signatures
-
checkForRandomData
public boolean checkForRandomData(long n)
Check limit for random generated data
-
checkForString
public boolean checkForString(int length)
Check limit for human readable strings (eg. keys in key-value pairs, names...)
-
-