author | prr |
Fri, 25 May 2018 12:12:24 -0700 | |
changeset 50347 | b2f046ae8eb6 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
40416
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
10057
diff
changeset
|
2 |
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 22 |
*/ |
23 |
||
24 |
/** |
|
25 |
* @test |
|
40416
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
10057
diff
changeset
|
26 |
* @bug 6220064 7054918 8130181 |
2 | 27 |
* @summary make sure everything works ok in the Turkish local (dotted/dotless i problem) |
28 |
* @author Andreas Sterbenz |
|
29 |
*/ |
|
30 |
||
31 |
import java.util.*; |
|
32 |
||
33 |
import java.security.*; |
|
34 |
import java.security.Provider.Service; |
|
35 |
import javax.crypto.*; |
|
36 |
||
37 |
public class Turkish { |
|
38 |
||
39 |
public static void main(String[] args) throws Exception { |
|
40 |
Provider p1 = new TProvider("T1"); |
|
41 |
System.out.println(p1.getServices()); // trigger service parsing |
|
42 |
||
10057 | 43 |
Locale loc = Locale.getDefault(); |
44 |
try { |
|
45 |
Locale.setDefault(new Locale("tr", "TR")); |
|
2 | 46 |
|
10057 | 47 |
Provider p2 = new TProvider("T2"); |
48 |
System.out.println(p2.getServices()); // trigger service parsing |
|
2 | 49 |
|
10057 | 50 |
System.out.println(Signature.getInstance("MD5withRSA")); |
51 |
System.out.println(Signature.getInstance("md5withrsa")); |
|
52 |
System.out.println(Signature.getInstance("MD5WITHRSA")); |
|
53 |
Service s1, s2; |
|
54 |
s1 = p1.getService("Signature", "MD5withRSA"); |
|
55 |
check(s1, null); |
|
56 |
check(s1, p1.getService("Signature", "md5withrsa")); |
|
57 |
check(s1, p1.getService("Signature", "MD5WITHRSA")); |
|
58 |
check(s1, p1.getService("Signature", "MD5RSA")); |
|
59 |
check(s1, p1.getService("Signature", "md5rsa")); |
|
60 |
check(s1, p1.getService("Signature", "MD5rsa")); |
|
2 | 61 |
|
10057 | 62 |
s1 = p1.getService("Signature", "SHAwithRSA"); |
63 |
check(s1, null); |
|
64 |
check(s1, p1.getService("Signature", "shawithrsa")); |
|
65 |
check(s1, p1.getService("Signature", "SHAWITHRSA")); |
|
66 |
check(s1, p1.getService("Signature", "SHARSA")); |
|
67 |
check(s1, p1.getService("Signature", "sharsa")); |
|
68 |
check(s1, p1.getService("Signature", "SHArsa")); |
|
69 |
check(s1, p1.getService("Signature", "SHA1RSA")); |
|
70 |
check(s1, p1.getService("Signature", "sha1rsa")); |
|
71 |
check(s1, p1.getService("Signature", "SHA1rsa")); |
|
2 | 72 |
|
10057 | 73 |
s1 = p2.getService("Signature", "MD5withRSA"); |
74 |
check(s1, null); |
|
75 |
check(s1, p2.getService("Signature", "md5withrsa")); |
|
76 |
check(s1, p2.getService("Signature", "MD5WITHRSA")); |
|
77 |
check(s1, p2.getService("Signature", "MD5RSA")); |
|
78 |
check(s1, p2.getService("Signature", "md5rsa")); |
|
79 |
check(s1, p2.getService("Signature", "MD5rsa")); |
|
2 | 80 |
|
10057 | 81 |
s1 = p2.getService("Signature", "SHAwithRSA"); |
82 |
check(s1, null); |
|
83 |
check(s1, p2.getService("Signature", "shawithrsa")); |
|
84 |
check(s1, p2.getService("Signature", "SHAWITHRSA")); |
|
85 |
check(s1, p2.getService("Signature", "SHARSA")); |
|
86 |
check(s1, p2.getService("Signature", "sharsa")); |
|
87 |
check(s1, p2.getService("Signature", "SHArsa")); |
|
88 |
check(s1, p2.getService("Signature", "SHA1RSA")); |
|
89 |
check(s1, p2.getService("Signature", "sha1rsa")); |
|
90 |
check(s1, p2.getService("Signature", "SHA1rsa")); |
|
2 | 91 |
|
10057 | 92 |
System.out.println("OK"); |
93 |
} finally { |
|
94 |
Locale.setDefault(loc); |
|
95 |
} |
|
2 | 96 |
} |
97 |
||
98 |
private static void check(Service s1, Service s2) throws Exception { |
|
99 |
System.out.println(s1); |
|
100 |
if (s1 == null) { |
|
101 |
throw new Exception("service is null"); |
|
102 |
} |
|
103 |
if ((s2 != null) && (s1 != s2)) { |
|
104 |
throw new Exception("service does not match"); |
|
105 |
} |
|
106 |
} |
|
107 |
||
108 |
private static class TProvider extends Provider { |
|
109 |
TProvider(String name) { |
|
40416
5d91b2fd668c
8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents:
10057
diff
changeset
|
110 |
super(name, "1.0", null); |
2 | 111 |
put("Signature.MD5withRSA", "com.foo.Sig"); |
112 |
put("Alg.Alias.Signature.MD5RSA", "MD5withRSA"); |
|
113 |
put("sIGNATURE.shaWITHrsa", "com.foo.Sig"); |
|
114 |
put("aLG.aLIAS.sIGNATURE.sharsa", "shaWITHrsa"); |
|
115 |
put("aLG.aLIAS.sIGNATURE.sha1rsa", "shawithrsa"); |
|
116 |
} |
|
117 |
} |
|
118 |
||
119 |
} |