0N/A/*
5359N/A * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/**
0N/A * @test
5359N/A * @bug 6220064 7054918
0N/A * @summary make sure everything works ok in the Turkish local (dotted/dotless i problem)
0N/A * @author Andreas Sterbenz
0N/A */
0N/A
0N/Aimport java.util.*;
0N/A
0N/Aimport java.security.*;
0N/Aimport java.security.Provider.Service;
0N/Aimport javax.crypto.*;
0N/A
0N/Apublic class Turkish {
0N/A
0N/A public static void main(String[] args) throws Exception {
0N/A Provider p1 = new TProvider("T1");
0N/A System.out.println(p1.getServices()); // trigger service parsing
0N/A
5359N/A Locale loc = Locale.getDefault();
5359N/A try {
5359N/A Locale.setDefault(new Locale("tr", "TR"));
0N/A
5359N/A Provider p2 = new TProvider("T2");
5359N/A System.out.println(p2.getServices()); // trigger service parsing
0N/A
5359N/A System.out.println(Signature.getInstance("MD5withRSA"));
5359N/A System.out.println(Signature.getInstance("md5withrsa"));
5359N/A System.out.println(Signature.getInstance("MD5WITHRSA"));
5359N/A Service s1, s2;
5359N/A s1 = p1.getService("Signature", "MD5withRSA");
5359N/A check(s1, null);
5359N/A check(s1, p1.getService("Signature", "md5withrsa"));
5359N/A check(s1, p1.getService("Signature", "MD5WITHRSA"));
5359N/A check(s1, p1.getService("Signature", "MD5RSA"));
5359N/A check(s1, p1.getService("Signature", "md5rsa"));
5359N/A check(s1, p1.getService("Signature", "MD5rsa"));
0N/A
5359N/A s1 = p1.getService("Signature", "SHAwithRSA");
5359N/A check(s1, null);
5359N/A check(s1, p1.getService("Signature", "shawithrsa"));
5359N/A check(s1, p1.getService("Signature", "SHAWITHRSA"));
5359N/A check(s1, p1.getService("Signature", "SHARSA"));
5359N/A check(s1, p1.getService("Signature", "sharsa"));
5359N/A check(s1, p1.getService("Signature", "SHArsa"));
5359N/A check(s1, p1.getService("Signature", "SHA1RSA"));
5359N/A check(s1, p1.getService("Signature", "sha1rsa"));
5359N/A check(s1, p1.getService("Signature", "SHA1rsa"));
0N/A
5359N/A s1 = p2.getService("Signature", "MD5withRSA");
5359N/A check(s1, null);
5359N/A check(s1, p2.getService("Signature", "md5withrsa"));
5359N/A check(s1, p2.getService("Signature", "MD5WITHRSA"));
5359N/A check(s1, p2.getService("Signature", "MD5RSA"));
5359N/A check(s1, p2.getService("Signature", "md5rsa"));
5359N/A check(s1, p2.getService("Signature", "MD5rsa"));
0N/A
5359N/A s1 = p2.getService("Signature", "SHAwithRSA");
5359N/A check(s1, null);
5359N/A check(s1, p2.getService("Signature", "shawithrsa"));
5359N/A check(s1, p2.getService("Signature", "SHAWITHRSA"));
5359N/A check(s1, p2.getService("Signature", "SHARSA"));
5359N/A check(s1, p2.getService("Signature", "sharsa"));
5359N/A check(s1, p2.getService("Signature", "SHArsa"));
5359N/A check(s1, p2.getService("Signature", "SHA1RSA"));
5359N/A check(s1, p2.getService("Signature", "sha1rsa"));
5359N/A check(s1, p2.getService("Signature", "SHA1rsa"));
0N/A
5359N/A System.out.println("OK");
5359N/A } finally {
5359N/A Locale.setDefault(loc);
5359N/A }
0N/A }
0N/A
0N/A private static void check(Service s1, Service s2) throws Exception {
0N/A System.out.println(s1);
0N/A if (s1 == null) {
0N/A throw new Exception("service is null");
0N/A }
0N/A if ((s2 != null) && (s1 != s2)) {
0N/A throw new Exception("service does not match");
0N/A }
0N/A }
0N/A
0N/A private static class TProvider extends Provider {
0N/A TProvider(String name) {
0N/A super(name, 1.0d, null);
0N/A put("Signature.MD5withRSA", "com.foo.Sig");
0N/A put("Alg.Alias.Signature.MD5RSA", "MD5withRSA");
0N/A put("sIGNATURE.shaWITHrsa", "com.foo.Sig");
0N/A put("aLG.aLIAS.sIGNATURE.sharsa", "shaWITHrsa");
0N/A put("aLG.aLIAS.sIGNATURE.sha1rsa", "shawithrsa");
0N/A }
0N/A }
0N/A
0N/A}