ClientJSSEServerJSSE.java revision 4479:cb83fe13af98
1/*
2 * Copyright (c) 2002, 2011, 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 * @test
26 * @bug 6313675 6323647
27 * @summary Verify that all ciphersuites work in FIPS mode
28 * @library ..
29 * @run main/othervm ClientJSSEServerJSSE
30 * @ignore JSSE supported cipher suites are changed with CR 6916074,
31 *     need to update this test case in JDK 7 soon
32 * @author Andreas Sterbenz
33 */
34
35import java.security.*;
36
37// This test belongs more in JSSE than here, but the JSSE workspace does not
38// have the NSS test infrastructure. It will live here for the time being.
39
40public class ClientJSSEServerJSSE extends SecmodTest {
41
42    public static void main(String[] args) throws Exception {
43        if (initSecmod() == false) {
44            return;
45        }
46
47        if ("sparc".equals(System.getProperty("os.arch")) == false) {
48            // we have not updated other platforms with the proper NSS libraries yet
49            System.out.println("Test currently works only on solaris-sparc, skipping");
50            return;
51        }
52
53        String configName = BASE + SEP + "fips.cfg";
54        Provider p = getSunPKCS11(configName);
55
56        System.out.println(p);
57        Security.addProvider(p);
58
59        Security.removeProvider("SunJSSE");
60        Provider jsse = new com.sun.net.ssl.internal.ssl.Provider(p);
61        Security.addProvider(jsse);
62        System.out.println(jsse.getInfo());
63
64        KeyStore ks = KeyStore.getInstance("PKCS11", p);
65        ks.load(null, "test12".toCharArray());
66
67        CipherTest.main(new JSSEFactory(), ks, args);
68    }
69
70    private static class JSSEFactory extends CipherTest.PeerFactory {
71
72        String getName() {
73            return "Client JSSE - Server JSSE";
74        }
75
76        CipherTest.Client newClient(CipherTest cipherTest) throws Exception {
77            return new JSSEClient(cipherTest);
78        }
79
80        CipherTest.Server newServer(CipherTest cipherTest) throws Exception {
81            return new JSSEServer(cipherTest);
82        }
83    }
84}
85