1 /*
2 * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
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 * @see KeyStoreCompatibilityMode.sh
26 */
27
28 import java.io.*;
29 import java.security.Provider;
30 import java.security.*;
31
32 public class KeyStoreCompatibilityMode {
33
34 private static final String KEYSTORE_COMPATIBILITY_MODE_PROP =
35 "sun.security.mscapi.keyStoreCompatibilityMode";
36
37 private static boolean mode;
38
39 public static void main(String[] args) throws Exception {
40
41 // Check if the provider is available
42 try {
43 Class.forName("sun.security.mscapi.SunMSCAPI");
44
45 } catch (Exception e) {
46 System.out.println(
47 "The SunMSCAPI provider is not available on this platform: " +
48 e);
49 return;
50 }
51
52 if (args.length > 0 && "-disable".equals(args[0])) {
53 mode = false;
54 } else {
55 mode = true;
56 }
57
58 Provider p = Security.getProvider("SunMSCAPI");
59
60 System.out.println("SunMSCAPI provider classname is " +
61 p.getClass().getName());
62 System.out.println(KEYSTORE_COMPATIBILITY_MODE_PROP + " = " +
63 System.getProperty(KEYSTORE_COMPATIBILITY_MODE_PROP));
64
65 KeyStore myKeyStore = KeyStore.getInstance("Windows-MY", p);
66 KeyStore myKeyStore2 = KeyStore.getInstance("Windows-MY", p);
67 KeyStore rootKeyStore = KeyStore.getInstance("Windows-ROOT", p);
68 KeyStore rootKeyStore2 = KeyStore.getInstance("Windows-ROOT", p);
69
70 InputStream inStream = new ByteArrayInputStream(new byte[1]);
|
1 /*
2 * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
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 * @see KeyStoreCompatibilityMode.sh
26 */
27
28 import java.io.*;
29 import java.security.Provider;
30 import java.security.*;
31
32 public class KeyStoreCompatibilityMode {
33
34 private static final String KEYSTORE_COMPATIBILITY_MODE_PROP =
35 "sun.security.mscapi.keyStoreCompatibilityMode";
36
37 private static boolean mode;
38
39 public static void main(String[] args) throws Exception {
40
41 if (args.length > 0 && "-disable".equals(args[0])) {
42 mode = false;
43 } else {
44 mode = true;
45 }
46
47 Provider p = Security.getProvider("SunMSCAPI");
48
49 System.out.println("SunMSCAPI provider classname is " +
50 p.getClass().getName());
51 System.out.println(KEYSTORE_COMPATIBILITY_MODE_PROP + " = " +
52 System.getProperty(KEYSTORE_COMPATIBILITY_MODE_PROP));
53
54 KeyStore myKeyStore = KeyStore.getInstance("Windows-MY", p);
55 KeyStore myKeyStore2 = KeyStore.getInstance("Windows-MY", p);
56 KeyStore rootKeyStore = KeyStore.getInstance("Windows-ROOT", p);
57 KeyStore rootKeyStore2 = KeyStore.getInstance("Windows-ROOT", p);
58
59 InputStream inStream = new ByteArrayInputStream(new byte[1]);
|