public final class DefaultSecureRandomService extends Object implements SecureRandomService
SecureRandomService which delegates to a single, shared instance
of SecureRandom.
Potential improvements include:
SecureRandoms block on calls to produce random data, we may improve throughput
by pooling a collection of SecureRandoms. Contention is not yet been proved to be a problem,
so it has not been implemented.
The current implementation is guaranteed to be thread-safe as it delegates calls to the
underlying SecureRandom instance.
| Modifier and Type | Method and Description |
|---|---|
static SecureRandomService |
getInstance() |
boolean |
nextBoolean()
Returns the next pseudorandom
boolean. |
void |
nextBytes(byte[] bytes)
Generates a user-specified number of random bytes.
|
double |
nextDouble()
Returns the next pseudorandom
double. |
float |
nextFloat()
Returns the next pseudorandom
float. |
int |
nextInt()
Returns the next pseudorandom
int. |
int |
nextInt(int n)
Returns a pseudorandom,
int value between 0 (inclusive) and
the specified value (exclusive). |
long |
nextLong()
Returns the next pseudorandom
long. |
public static SecureRandomService getInstance()
DefaultSecureRandomService instance which delegates to a single, shared instance
of SecureRandom.public void nextBytes(byte[] bytes)
SecureRandomServicenextBytes in interface SecureRandomServicebytes - the array to be filled in with random bytes.SecureRandom.nextBytes(byte[])public int nextInt()
SecureRandomServiceint.nextInt in interface SecureRandomServiceint.Random.nextInt()public int nextInt(int n)
SecureRandomServiceint value between 0 (inclusive) and
the specified value (exclusive).nextInt in interface SecureRandomServicen - the bound on the random number to be returned. Must be
positive.int
value between 0 (inclusive) and n (exclusive).Random.nextInt(int)public long nextLong()
SecureRandomServicelong.nextLong in interface SecureRandomServicelong.Random.nextLong()public boolean nextBoolean()
SecureRandomServiceboolean.nextBoolean in interface SecureRandomServiceboolean.Random.nextBoolean()public float nextFloat()
SecureRandomServicefloat.nextFloat in interface SecureRandomServicefloat.Random.nextFloat()public double nextDouble()
SecureRandomServicedouble.nextDouble in interface SecureRandomServicedouble.Random.nextDouble()Copyright © 2017 Atlassian. All rights reserved.