Class RandomDotOrgApi2Client
- java.lang.Object
-
- io.github.pr0methean.betterrandom.seed.WebSeedClient
-
- io.github.pr0methean.betterrandom.seed.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 withRandomDotOrgAnonymousClient
, 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
-
-
Field Summary
-
Fields inherited from class io.github.pr0methean.betterrandom.seed.WebSeedClient
CLOCK, earliestNextAttempt, JSON_PARSER, lock, userAgent
-
Fields inherited from interface io.github.pr0methean.betterrandom.seed.SeedGenerator
EMPTY_SEED
-
-
Constructor Summary
Constructors Constructor Description RandomDotOrgApi2Client(WebSeedClientConfiguration configuration, UUID apiKey)
RandomDotOrgApi2Client(UUID apiKey)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
downloadBytes(HttpURLConnection connection, byte[] seed, int offset, int length)
Performs a single request for random bytes.boolean
equals(Object o)
protected URL
getConnectionUrl(int numBytes)
protected int
getMaxRequestSize()
The maximum number of bytes the site will provide in response to one request.int
hashCode()
-
Methods inherited from class io.github.pr0methean.betterrandom.seed.WebSeedClient
checkedGetObject, divideRoundingUp, generateSeed, getProxy, getResponseReader, getRetryDelayMs, getSocketFactory, isWorthTrying, modRange1ToM, openConnection, parseJsonResponse
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.github.pr0methean.betterrandom.seed.SeedGenerator
generateSeed
-
-
-
-
Constructor Detail
-
RandomDotOrgApi2Client
public RandomDotOrgApi2Client(WebSeedClientConfiguration configuration, UUID apiKey)
-
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 classWebSeedClient
- Returns:
- the maximum request size in bytes
-
getConnectionUrl
protected URL getConnectionUrl(int numBytes)
- Specified by:
getConnectionUrl
in classWebSeedClient
-
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 classWebSeedClient
- Parameters:
connection
- the connection to download fromseed
- the array to save them tooffset
- the first index to save them to in the arraylength
- the number of bytes to download- Throws:
IOException
- if a connection error occurs
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classWebSeedClient
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classWebSeedClient
-
-