Class RandomDotOrgAnonymousClient
- java.lang.Object
- 
- io.github.pr0methean.betterrandom.seed.WebSeedClient
- 
- io.github.pr0methean.betterrandom.seed.RandomDotOrgAnonymousClient
 
 
- 
- All Implemented Interfaces:
- SeedGenerator,- Serializable
 
 public class RandomDotOrgAnonymousClient extends WebSeedClient Connects to random.org's old API (via HTTPS) and downloads a set of random bits to use as seed data. It is generally better to use the DevRandomSeedGeneratorwhere possible, as it should be much quicker. This seed generator is most useful on Microsoft Windows without Cygwin, and other platforms that do not provide /dev/random (or where that device is very slow).Random.org collects randomness from atmospheric noise using 9 radios, located at undisclosed addresses in Dublin and Copenhagen and tuned to undisclosed AM/FM frequencies. (The secrecy is intended to help prevent tampering with the output using a well-placed radio transmitter, and the use of AM/FM helps ensure that any such tampering would cause illegal interference with broadcasts and quickly attract regulatory attention.) Random.org has two APIs: an old API and a newer JSON-RPC API. Since the new one requires a key provided to each user by random.org, a client for the old one is still useful for anonymous access. However, if you have a key, you can instead use RandomDotOrgApi2Client.Note that when using the old API, random.org limits the supply of free random numbers to any one IP address; if you operate from a fixed address (at least if you use IPv4), you can check your quota and buy more. On the new API, the quota is per key rather than per IP, and commercial-use pricing follows a different scheme. - Author:
- Daniel Dyer (original version), Chris Hennick (refactoring)
- See Also:
- Serialized Form
 
- 
- 
Field Summary- 
Fields inherited from class io.github.pr0methean.betterrandom.seed.WebSeedClientCLOCK, earliestNextAttempt, JSON_PARSER, lock, userAgent
 - 
Fields inherited from interface io.github.pr0methean.betterrandom.seed.SeedGeneratorEMPTY_SEED
 
- 
 - 
Constructor SummaryConstructors Constructor Description RandomDotOrgAnonymousClient()RandomDotOrgAnonymousClient(WebSeedClientConfiguration configuration)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddownloadBytes(HttpURLConnection connection, byte[] seed, int offset, int length)Performs a single request for random bytes.protected URLgetConnectionUrl(int numBytes)protected intgetMaxRequestSize()Returns the maximum number of bytes that can be obtained with one request to the service.- 
Methods inherited from class io.github.pr0methean.betterrandom.seed.WebSeedClientcheckedGetObject, divideRoundingUp, equals, generateSeed, getProxy, getResponseReader, getRetryDelayMs, getSocketFactory, hashCode, isWorthTrying, modRange1ToM, openConnection, parseJsonResponse
 - 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface io.github.pr0methean.betterrandom.seed.SeedGeneratorgenerateSeed
 
- 
 
- 
- 
- 
Constructor Detail- 
RandomDotOrgAnonymousClientpublic RandomDotOrgAnonymousClient(WebSeedClientConfiguration configuration) 
 - 
RandomDotOrgAnonymousClientpublic RandomDotOrgAnonymousClient() 
 
- 
 - 
Method Detail- 
getMaxRequestSizeprotected int getMaxRequestSize() Description copied from class:WebSeedClientReturns the maximum number of bytes that can be obtained with one request to the service. When a seed larger than this is needed, it is obtained using multiple requests.- Specified by:
- getMaxRequestSizein class- WebSeedClient
- Returns:
- the maximum number of bytes per request
 
 - 
getConnectionUrlprotected URL getConnectionUrl(int numBytes) - Specified by:
- getConnectionUrlin class- WebSeedClient
 
 - 
downloadBytesprotected void downloadBytes(HttpURLConnection connection, byte[] seed, int offset, int length) throws IOException Description copied from class:WebSeedClientPerforms a single request for random bytes.- Specified by:
- downloadBytesin 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
 
 
- 
 
-