7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8141039
27 * @library /lib/testlibrary
28 * @summary SecureRandom supports multiple getInstance method including
29 * getInstanceStrong() method. This test verifies a set of possible
30 * cases for getInstance with different SecureRandom mechanism
31 * supported in Java.
32 * @run main GetInstanceTest
33 */
34 import java.security.NoSuchAlgorithmException;
35 import java.security.NoSuchProviderException;
36 import java.security.SecureRandom;
37 import java.security.SecureRandomParameters;
38 import java.security.DrbgParameters;
39 import static java.security.DrbgParameters.Capability.*;
40 import java.security.Security;
41 import java.util.Arrays;
42 import jdk.testlibrary.Asserts;
43
44 public class GetInstanceTest {
45
46 private static final boolean PASS = true;
47 private static final String INVALID_ALGO = "INVALID";
48 private static final String SUN_PROVIDER = "SUN";
49 private static final String INVALID_PROVIDER = "INVALID";
50 private static final String STRONG_ALG_SEC_PROP
51 = "securerandom.strongAlgorithms";
52 private static final String DRBG_CONFIG = "securerandom.drbg.config";
53 private static final String DRBG_CONFIG_VALUE
54 = Security.getProperty(DRBG_CONFIG);
55
56 public static void main(String[] args) throws Exception {
57
58 boolean success = true;
59 // Only accepted failure is NoSuchAlgorithmException.
60 // For any other failure the test case will fail here.
61 SecureRandom sr = matchExc(() -> SecureRandom.getInstanceStrong(),
62 PASS, NoSuchAlgorithmException.class,
|
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8141039
27 * @library /test/lib
28 * @summary SecureRandom supports multiple getInstance method including
29 * getInstanceStrong() method. This test verifies a set of possible
30 * cases for getInstance with different SecureRandom mechanism
31 * supported in Java.
32 * @run main GetInstanceTest
33 */
34 import java.security.NoSuchAlgorithmException;
35 import java.security.NoSuchProviderException;
36 import java.security.SecureRandom;
37 import java.security.SecureRandomParameters;
38 import java.security.DrbgParameters;
39 import static java.security.DrbgParameters.Capability.*;
40 import java.security.Security;
41 import java.util.Arrays;
42 import jdk.test.lib.Asserts;
43
44 public class GetInstanceTest {
45
46 private static final boolean PASS = true;
47 private static final String INVALID_ALGO = "INVALID";
48 private static final String SUN_PROVIDER = "SUN";
49 private static final String INVALID_PROVIDER = "INVALID";
50 private static final String STRONG_ALG_SEC_PROP
51 = "securerandom.strongAlgorithms";
52 private static final String DRBG_CONFIG = "securerandom.drbg.config";
53 private static final String DRBG_CONFIG_VALUE
54 = Security.getProperty(DRBG_CONFIG);
55
56 public static void main(String[] args) throws Exception {
57
58 boolean success = true;
59 // Only accepted failure is NoSuchAlgorithmException.
60 // For any other failure the test case will fail here.
61 SecureRandom sr = matchExc(() -> SecureRandom.getInstanceStrong(),
62 PASS, NoSuchAlgorithmException.class,
|