Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e02ff3a

Browse files
committedMar 24, 2018
MimeTypeUtils uses SecureRandom
The prevailing current wisdom is to use the default constructor for secure and let it pick the best algorithm for the OS. On Java 8 (Oracle), Linux this results in "NativePRNG" which uses /dev/random (potentially blocking) for the initial seed, and /dev/urandom (non-blocking) for subsequent calls to nextInt. Issue: SPR-16635
1 parent ff377a3 commit e02ff3a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818

1919
import java.nio.charset.Charset;
2020
import java.nio.charset.UnsupportedCharsetException;
21+
import java.security.SecureRandom;
2122
import java.util.ArrayList;
2223
import java.util.Collection;
2324
import java.util.Collections;
@@ -46,7 +47,7 @@ public abstract class MimeTypeUtils {
4647
'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
4748
'V', 'W', 'X', 'Y', 'Z'};
4849

49-
private static final Random RND = new Random();
50+
private static final Random RND = new SecureRandom();
5051

5152
private static Charset US_ASCII = Charset.forName("US-ASCII");
5253

0 commit comments

Comments
 (0)
Please sign in to comment.