|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.random.rjgodoy.trng.MH_HttpClient
public class MH_HttpClient
Mini HTTP-Client for accessing www.random.org.
This class accesses the following services:
MH_SecureRandom
).
Note: this class has package-private scope because crypto-related helper classes in a provider package should have package-private scope.
Besides, instances of this class are NOT thread safe (there is only one instance of this class, and it use is controlled by a lock in MH_SecureRandomSpi
).
TODO: It should be possible to configure which cipher-suite will be used.
Field Summary | |
---|---|
static String |
JVM
|
static String |
VERSION
|
Constructor Summary | |
---|---|
MH_HttpClient()
Initializes an instance of MH_HttpClient . |
Method Summary | |
---|---|
(package private) long |
checkQuota()
Query and returns the available quota. |
(package private) void |
closeSocket()
Closes the socket used by this instance. |
(package private) long |
estimateQuota()
Returns an estimated quota (avoids requesting the actual quota if it is already known to be positive). |
protected void |
finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |
(package private) int |
nextBytes(byte[] bytes,
int offset,
int length)
Fetches a block of bytes from www.random.org web-service. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String JVM
public static final String VERSION
Constructor Detail |
---|
MH_HttpClient()
MH_HttpClient
.
The initialization process uses several system properties for configuration (see MH_SecureRandom
).
Method Detail |
---|
long estimateQuota()
actual quota
is requested.
As a consequence, it is guarranteed that:
Long.MIN_VALUE
if an error occurs.long checkQuota()
If this method fails (because a server or protocol error) returns Long.MIN_VALUE.
If this method was successful, the estimated quota
is updated and accumulated bit consumtion is reset.
Long.MIN_VALUE
if an error occurs.int nextBytes(byte[] bytes, int offset, int length)
If this method is successful, it should return length
.
If this method fails because of a service error (e.g.: the service is unavailable,
the service has changed its interface, etc) it returns 0 (i.e. no bytes were read).
If this method fails because an error when parsing the results (e.g.: no trailng TAB character) it returns the amount of bytes actually written to bytes
buffer.
bytes
- destination bufferoffset
- offset at which to start storing byteslength
- maximum number of bytes to read.
ArrayIndexOutOfBoundsException
- if any offset
or length
is negative,
if offset
is greater than bytes.length
or if length+offset
is greater than bytes.length
.
NullPointerException
- if bytes
is null
.void closeSocket()
checkQuota()
and nextBytes(byte[], int, int)
will open a new socket.
protected void finalize() throws Throwable
finalize
in class Object
Throwable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or request a feature | Copyright © (2008-2011) Roberto Javier Godoy |
Project Web Hosted by | SouceForge.net is registered trademark of SourceForge, Inc., in the United States and other countries. |