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