1 /*
2 * Copyright (c) 2005, 2007, 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 IsSunMSCAPIAvailable.sh
26 */
27
28 import java.security.Provider;
29 import java.security.*;
30 import javax.crypto.Cipher;
31
32 public class IsSunMSCAPIAvailable {
33
34 public static void main(String[] args) throws Exception {
35
36 // Check if the provider is available
37 try {
38 Class.forName("sun.security.mscapi.SunMSCAPI");
39
40 } catch (Exception e) {
41 System.out.println(
42 "The SunMSCAPI provider is not available on this platform");
43 return;
44 }
45
46 // Dynamically register the SunMSCAPI provider
47 Security.addProvider(new sun.security.mscapi.SunMSCAPI());
48
49
50 Provider p = Security.getProvider("SunMSCAPI");
51
52 System.out.println("SunMSCAPI provider classname is " +
53 p.getClass().getName());
54 System.out.println("SunMSCAPI provider name is " + p.getName());
55 System.out.println("SunMSCAPI provider version # is " + p.getVersion());
56 System.out.println("SunMSCAPI provider info is " + p.getInfo());
57
58 /*
59 * Secure Random
60 */
61
62 SecureRandom random = SecureRandom.getInstance("Windows-PRNG", p);
63 System.out.println(" Windows-PRNG is implemented by: " +
64 random.getClass().getName());
65
66 /*
67 * Key Store
68 */
69 KeyStore keystore = KeyStore.getInstance("Windows-MY", p);
70 System.out.println(" Windows-MY is implemented by: " +
71 keystore.getClass().getName());
72
73 keystore = KeyStore.getInstance("Windows-ROOT", p);
74 System.out.println(" Windows-ROOT is implemented by: " +
75 keystore.getClass().getName());
76
77 /*
78 * Signature
79 */
80 Signature signature = Signature.getInstance("SHA1withRSA", p);
81 System.out.println(" SHA1withRSA is implemented by: " +
|
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 IsSunMSCAPIAvailable.sh
26 */
27
28 import java.security.Provider;
29 import java.security.*;
30 import javax.crypto.Cipher;
31
32 public class IsSunMSCAPIAvailable {
33
34 public static void main(String[] args) throws Exception {
35
36 // Dynamically register the SunMSCAPI provider
37 Security.addProvider(new sun.security.mscapi.SunMSCAPI());
38
39
40 Provider p = Security.getProvider("SunMSCAPI");
41
42 System.out.println("SunMSCAPI provider classname is " +
43 p.getClass().getName());
44 System.out.println("SunMSCAPI provider name is " + p.getName());
45 System.out.println("SunMSCAPI provider version # is " + p.getVersion());
46 System.out.println("SunMSCAPI provider info is " + p.getInfo());
47
48 /*
49 * Secure Random
50 */
51 SecureRandom random = SecureRandom.getInstance("Windows-PRNG", p);
52 System.out.println(" Windows-PRNG is implemented by: " +
53 random.getClass().getName());
54
55 /*
56 * Key Store
57 */
58 KeyStore keystore = KeyStore.getInstance("Windows-MY", p);
59 System.out.println(" Windows-MY is implemented by: " +
60 keystore.getClass().getName());
61
62 keystore = KeyStore.getInstance("Windows-ROOT", p);
63 System.out.println(" Windows-ROOT is implemented by: " +
64 keystore.getClass().getName());
65
66 /*
67 * Signature
68 */
69 Signature signature = Signature.getInstance("SHA1withRSA", p);
70 System.out.println(" SHA1withRSA is implemented by: " +
|