blob: 1934561785da0cf48995670c3821bf69a658c262 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2005 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24/**
25 * @test
26 * @bug 6220064
27 * @summary make sure everything works ok in the Turkish local (dotted/dotless i problem)
28 * @author Andreas Sterbenz
29 */
30
31import java.util.*;
32
33import java.security.*;
34import java.security.Provider.Service;
35import javax.crypto.*;
36
37public 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
43 Locale.setDefault(new Locale("tr", "TR"));
44
45 Provider p2 = new TProvider("T2");
46 System.out.println(p2.getServices()); // trigger service parsing
47
48 System.out.println(Signature.getInstance("MD5withRSA"));
49 System.out.println(Signature.getInstance("md5withrsa"));
50 System.out.println(Signature.getInstance("MD5WITHRSA"));
51 Service s1, s2;
52 s1 = p1.getService("Signature", "MD5withRSA");
53 check(s1, null);
54 check(s1, p1.getService("Signature", "md5withrsa"));
55 check(s1, p1.getService("Signature", "MD5WITHRSA"));
56 check(s1, p1.getService("Signature", "MD5RSA"));
57 check(s1, p1.getService("Signature", "md5rsa"));
58 check(s1, p1.getService("Signature", "MD5rsa"));
59
60 s1 = p1.getService("Signature", "SHAwithRSA");
61 check(s1, null);
62 check(s1, p1.getService("Signature", "shawithrsa"));
63 check(s1, p1.getService("Signature", "SHAWITHRSA"));
64 check(s1, p1.getService("Signature", "SHARSA"));
65 check(s1, p1.getService("Signature", "sharsa"));
66 check(s1, p1.getService("Signature", "SHArsa"));
67 check(s1, p1.getService("Signature", "SHA1RSA"));
68 check(s1, p1.getService("Signature", "sha1rsa"));
69 check(s1, p1.getService("Signature", "SHA1rsa"));
70
71 s1 = p2.getService("Signature", "MD5withRSA");
72 check(s1, null);
73 check(s1, p2.getService("Signature", "md5withrsa"));
74 check(s1, p2.getService("Signature", "MD5WITHRSA"));
75 check(s1, p2.getService("Signature", "MD5RSA"));
76 check(s1, p2.getService("Signature", "md5rsa"));
77 check(s1, p2.getService("Signature", "MD5rsa"));
78
79 s1 = p2.getService("Signature", "SHAwithRSA");
80 check(s1, null);
81 check(s1, p2.getService("Signature", "shawithrsa"));
82 check(s1, p2.getService("Signature", "SHAWITHRSA"));
83 check(s1, p2.getService("Signature", "SHARSA"));
84 check(s1, p2.getService("Signature", "sharsa"));
85 check(s1, p2.getService("Signature", "SHArsa"));
86 check(s1, p2.getService("Signature", "SHA1RSA"));
87 check(s1, p2.getService("Signature", "sha1rsa"));
88 check(s1, p2.getService("Signature", "SHA1rsa"));
89
90 System.out.println("OK");
91 }
92
93 private static void check(Service s1, Service s2) throws Exception {
94 System.out.println(s1);
95 if (s1 == null) {
96 throw new Exception("service is null");
97 }
98 if ((s2 != null) && (s1 != s2)) {
99 throw new Exception("service does not match");
100 }
101 }
102
103 private static class TProvider extends Provider {
104 TProvider(String name) {
105 super(name, 1.0d, null);
106 put("Signature.MD5withRSA", "com.foo.Sig");
107 put("Alg.Alias.Signature.MD5RSA", "MD5withRSA");
108 put("sIGNATURE.shaWITHrsa", "com.foo.Sig");
109 put("aLG.aLIAS.sIGNATURE.sharsa", "shaWITHrsa");
110 put("aLG.aLIAS.sIGNATURE.sha1rsa", "shawithrsa");
111 }
112 }
113
114}