1 package org.eclipse.jetty.websocket;
2
3 import java.util.Random;
4
5
6 public class RandomMaskGen implements MaskGen
7 {
8 private final Random _random;
9
10 public RandomMaskGen()
11 {
12 this(new Random());
13 }
14
15 public RandomMaskGen(Random random)
16 {
17 _random=random;
18 }
19
20 public void genMask(byte[] mask)
21 {
22 // The assumption is that this code is always called
23 // with an external lock held to prevent concurrent access
24 // Otherwise we need to synchronize on the _random.
25 _random.nextBytes(mask);
26 }
27 }