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
 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.
 

Method Detail

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:
SecureRandom.nextBytes(byte[])

nextInt

int nextInt()
Returns the next pseudorandom int.

Returns:
the next pseudorandom int.
See Also:
Random.nextInt()

nextInt

int nextInt(int n)
Returns a pseudorandom, int value 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, int value between 0 (inclusive) and n (exclusive).
Throws:
IllegalArgumentException - if n is not positive
See Also:
Random.nextInt(int)

nextLong

long nextLong()
Returns the next pseudorandom long.

Returns:
the next pseudorandom long.
See Also:
Random.nextLong()

nextBoolean

boolean nextBoolean()
Returns the next pseudorandom boolean.

Returns:
the next pseudorandom boolean.
See Also:
Random.nextBoolean()

nextFloat

float nextFloat()
Returns the next pseudorandom float.

Returns:
the next pseudorandom float.
See Also:
Random.nextFloat()

nextDouble

double nextDouble()
Returns the next pseudorandom double.

Returns:
the next pseudorandom double.
See Also:
Random.nextDouble()


Copyright © 2013 Atlassian. All rights reserved.