Class MemoryLimits


  • public class MemoryLimits
    extends java.lang.Object
    A 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.
    • Constructor Detail

      • MemoryLimits

        public MemoryLimits()
    • 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...)