Class Cache.EncryptedDiskCacheBuilder

    • Method Detail

      • key

        public Cache.EncryptedDiskCacheBuilder key​(javax.crypto.SecretKey key)
        The secret key to encrypt/decrypt all files that this cache maintains.
        Parameters:
        key - The encryption key. Never null.
        Returns:
        builder itself.
      • publicKey

        public Cache.EncryptedDiskCacheBuilder publicKey​(java.security.PublicKey key)
        Sets the public key to use.
        Parameters:
        key - The encryption key. Never null.
        Returns:
        builder itself.
      • privateKey

        public Cache.EncryptedDiskCacheBuilder privateKey​(java.security.PrivateKey key)
        Sets the private key to use.
        Parameters:
        key - The encryption key. Never null.
        Returns:
        builder itself.
      • cipherAlgorithm

        public Cache.EncryptedDiskCacheBuilder cipherAlgorithm​(java.lang.String algorithm)
                                                        throws javax.crypto.NoSuchPaddingException,
                                                               java.security.NoSuchAlgorithmException
        The cipher algorithm to use. Typically, has form of "algorithm/mode/padding" or "algorithm". Note that "NoPadding" padding scheme is not supported.
        Parameters:
        algorithm - The algorithm name.
        Returns:
        builder itself.
        Throws:
        java.lang.IllegalArgumentException - if algorithm is null, or contains "NoPadding" padding scheme.
        java.security.NoSuchAlgorithmException - if algorithm empty, is in an invalid format, or if no Provider supports a CipherSpi implementation for the specified algorithm.
        javax.crypto.NoSuchPaddingException - if algorithm contains a padding scheme that is not available.
        See Also:
        Cipher.getInstance(String)
      • provider

        public Cache.EncryptedDiskCacheBuilder provider​(java.lang.String provider)
        The Provider name to use.
        Parameters:
        provider - The provider name.
        Returns:
        builder itself.
        See Also:
        Cipher.getInstance(String, String)
      • maxItems

        public B maxItems​(int maxItems)
        The maximum number of cache entries. After reaching the limit the eldest entries will be evicted. Default is 8192.
        Parameters:
        maxItems - The maximum number of cache entries. Should be positive.
        Returns:
        builder itself.
      • size

        public B size​(long size)
        The amount of bytes allowed to be stored. Negative value means no memory restriction is made. Note that only response body bytes are counted.
        Parameters:
        size - The maximum size in bytes. Negative for no size restriction.
        Returns:
        builder itself.
      • requestFilter

        public B requestFilter​(java.util.function.Predicate<java.net.http.HttpRequest> filter)
        Adds given predicate to predicated chain. The calls with requests that did not pass given predicate will not be subjected to caching facility. Semantically request filter is equivalent to Cache-Control: no-store header in request.
        Parameters:
        filter - The request filter.
        Returns:
        builder itself.
      • responseFilter

        public B responseFilter​(java.util.function.Predicate<java.net.http.HttpResponse.ResponseInfo> filter)
        Adds given predicate to predicated chain. The calls resulting with response that did not pass given predicate will not be subjected to caching facility. Semantically response filter is equivalent to Cache-Control: no-store header in response.
        Parameters:
        filter - The request filter.
        Returns:
        builder itself.