Package com.atlassian.security.random
Interface SecureRandomService
- All Known Implementing Classes:
DefaultSecureRandomService
public interface SecureRandomService
A generator for random data which is cryptographically secure, based
on the same interface as
SecureRandom.
Using this interface instead of using SecureRandom directly will
allow implementations to provide security or performance improvements (such as dynamic
re-seeding) without any changes to client code.
Implementations are required to be thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the next pseudorandomboolean.voidnextBytes(byte[] bytes) Generates a user-specified number of random bytes.doubleReturns the next pseudorandomdouble.floatReturns the next pseudorandomfloat.intnextInt()Returns the next pseudorandomint.intnextInt(int n) Returns a pseudorandom,intvalue between 0 (inclusive) and the specified value (exclusive).longnextLong()Returns the next pseudorandomlong.
-
Method Details
-
nextBytes
void nextBytes(byte[] bytes) Generates a user-specified number of random bytes.- Parameters:
bytes- the array to be filled in with random bytes.- See Also:
-
nextInt
int nextInt()Returns the next pseudorandomint.- Returns:
- the next pseudorandom
int. - See Also:
-
nextInt
int nextInt(int n) Returns a pseudorandom,intvalue between 0 (inclusive) and the specified value (exclusive).- Parameters:
n- the bound on the random number to be returned. Must be positive.- Returns:
- the next pseudorandom,
intvalue between0(inclusive) andn(exclusive). - Throws:
IllegalArgumentException- if n is not positive- See Also:
-
nextLong
long nextLong()Returns the next pseudorandomlong.- Returns:
- the next pseudorandom
long. - See Also:
-
nextBoolean
boolean nextBoolean()Returns the next pseudorandomboolean.- Returns:
- the next pseudorandom
boolean. - See Also:
-
nextFloat
float nextFloat()Returns the next pseudorandomfloat.- Returns:
- the next pseudorandom
float. - See Also:
-
nextDouble
double nextDouble()Returns the next pseudorandomdouble.- Returns:
- the next pseudorandom
double. - See Also:
-