author | valeriep |
Thu, 12 Jan 2012 16:04:03 -0800 | |
changeset 11523 | 85131f3172a1 |
permissions | -rw-r--r-- |
11523
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
1 |
/* |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
2 |
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
4 |
* |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
8 |
* |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
13 |
* accompanied this code). |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
14 |
* |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
18 |
* |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
21 |
* questions. |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
22 |
*/ |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
23 |
|
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
24 |
|
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
25 |
// common infrastructure for OracleUcrypto provider tests |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
26 |
|
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
27 |
import java.io.*; |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
28 |
import java.util.*; |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
29 |
import java.lang.reflect.*; |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
30 |
|
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
31 |
import java.security.*; |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
32 |
|
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
33 |
public abstract class UcryptoTest { |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
34 |
|
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
35 |
protected static final boolean hasUcrypto; |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
36 |
static { |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
37 |
hasUcrypto = (Security.getProvider("OracleUcrypto") != null); |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
38 |
} |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
39 |
|
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
40 |
private static Provider getCustomizedUcrypto(String config) throws Exception { |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
41 |
Class clazz = Class.forName("com.oracle.security.ucrypto.OracleUcrypto"); |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
42 |
Constructor cons = clazz.getConstructor(new Class[] {String.class}); |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
43 |
Object obj = cons.newInstance(new Object[] {config}); |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
44 |
return (Provider)obj; |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
45 |
} |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
46 |
|
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
47 |
public abstract void doTest(Provider p) throws Exception; |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
48 |
|
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
49 |
public static void main(UcryptoTest test, String config) throws Exception { |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
50 |
Provider prov = null; |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
51 |
if (hasUcrypto) { |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
52 |
if (config != null) { |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
53 |
prov = getCustomizedUcrypto(config); |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
54 |
} else { |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
55 |
prov = Security.getProvider("OracleUcrypto"); |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
56 |
} |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
57 |
} |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
58 |
if (prov == null) { |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
59 |
// un-available, skip testing... |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
60 |
System.out.println("No OracleUcrypto provider found, skipping test"); |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
61 |
return; |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
62 |
} |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
63 |
test.doTest(prov); |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
64 |
} |
85131f3172a1
7088989: Improve the performance for T4 by utilizing the newly provided crypto APIs
valeriep
parents:
diff
changeset
|
65 |
} |