File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed
wicket-core/src/main/java/org/apache/wicket Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 3232 */
3333public class DefaultSecureRandomSupplier implements ISecureRandomSupplier
3434{
35- private SecureRandom random ;
36-
37- public DefaultSecureRandomSupplier ()
35+ private static final class Holder
3836 {
39- try
40- {
41- random = SecureRandom .getInstance ("SHA1PRNG" );
42- }
43- catch (NoSuchAlgorithmException e )
37+ private static final SecureRandom INSTANCE ;
38+
39+ static
4440 {
45- throw new WicketRuntimeException (e );
41+ try
42+ {
43+ INSTANCE = SecureRandom .getInstance ("SHA1PRNG" );
44+ } catch (NoSuchAlgorithmException e ) {
45+ throw new WicketRuntimeException (e );
46+ }
4647 }
4748 }
4849
4950 @ Override
5051 public SecureRandom getRandom ()
5152 {
52- return random ;
53+ return Holder . INSTANCE ;
5354 }
5455}
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ public class SecuritySettings
5959 private ICryptFactory cryptFactory ;
6060
6161 /** supplier of random data and SecureRandom */
62- private ISecureRandomSupplier randomSupplier = new DefaultSecureRandomSupplier () ;
62+ private ISecureRandomSupplier randomSupplier ;
6363
6464 /**
6565 * Whether mounts should be enforced. If {@code true}, requests for a page will be
@@ -139,6 +139,10 @@ public synchronized ICryptFactory getCryptFactory()
139139 */
140140 public ISecureRandomSupplier getRandomSupplier ()
141141 {
142+ if (randomSupplier == null )
143+ {
144+ randomSupplier = new DefaultSecureRandomSupplier ();
145+ }
142146 return randomSupplier ;
143147 }
144148
You can’t perform that action at this time.
0 commit comments