Class RandomDotOrgApi2Client

  • All Implemented Interfaces:
    SeedGenerator, Serializable

    public final class RandomDotOrgApi2Client
    extends WebSeedClient
    Uses the random.org JSON API documented at api.random.org. This allows some customers to get a larger volume of random numbers from random.org than they can with RandomDotOrgAnonymousClient, especially when there are many other clients using the old API on the same IP address. The source and quality of the random numbers is the same.
    See Also:
    Serialized Form
    • Constructor Detail

      • RandomDotOrgApi2Client

        public RandomDotOrgApi2Client​(UUID apiKey)
    • Method Detail

      • getMaxRequestSize

        protected int getMaxRequestSize()
        The maximum number of bytes the site will provide in response to one request. Seeds larger than this will be generated using multiple requests.
        Specified by:
        getMaxRequestSize in class WebSeedClient
        Returns:
        the maximum request size in bytes
      • downloadBytes

        protected void downloadBytes​(HttpURLConnection connection,
                                     byte[] seed,
                                     int offset,
                                     int length)
                              throws IOException
        Description copied from class: WebSeedClient
        Performs a single request for random bytes.
        Specified by:
        downloadBytes in class WebSeedClient
        Parameters:
        connection - the connection to download from
        seed - the array to save them to
        offset - the first index to save them to in the array
        length - the number of bytes to download
        Throws:
        IOException - if a connection error occurs