Path: blob/master/test/jdk/java/security/Provider/Turkish.java
41149 views
/*1* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 6220064 7054918 813018126* @summary make sure everything works ok in the Turkish local (dotted/dotless i problem)27* @author Andreas Sterbenz28*/2930import java.util.*;3132import java.security.*;33import java.security.Provider.Service;34import javax.crypto.*;3536public class Turkish {3738public static void main(String[] args) throws Exception {39Provider p1 = new TProvider("T1");40System.out.println(p1.getServices()); // trigger service parsing4142Locale loc = Locale.getDefault();43try {44Locale.setDefault(new Locale("tr", "TR"));4546Provider p2 = new TProvider("T2");47System.out.println(p2.getServices()); // trigger service parsing4849System.out.println(Signature.getInstance("MD5withRSA"));50System.out.println(Signature.getInstance("md5withrsa"));51System.out.println(Signature.getInstance("MD5WITHRSA"));52Service s1, s2;53s1 = p1.getService("Signature", "MD5withRSA");54check(s1, null);55check(s1, p1.getService("Signature", "md5withrsa"));56check(s1, p1.getService("Signature", "MD5WITHRSA"));57check(s1, p1.getService("Signature", "MD5RSA"));58check(s1, p1.getService("Signature", "md5rsa"));59check(s1, p1.getService("Signature", "MD5rsa"));6061s1 = p1.getService("Signature", "SHAwithRSA");62check(s1, null);63check(s1, p1.getService("Signature", "shawithrsa"));64check(s1, p1.getService("Signature", "SHAWITHRSA"));65check(s1, p1.getService("Signature", "SHARSA"));66check(s1, p1.getService("Signature", "sharsa"));67check(s1, p1.getService("Signature", "SHArsa"));68check(s1, p1.getService("Signature", "SHA1RSA"));69check(s1, p1.getService("Signature", "sha1rsa"));70check(s1, p1.getService("Signature", "SHA1rsa"));7172s1 = p2.getService("Signature", "MD5withRSA");73check(s1, null);74check(s1, p2.getService("Signature", "md5withrsa"));75check(s1, p2.getService("Signature", "MD5WITHRSA"));76check(s1, p2.getService("Signature", "MD5RSA"));77check(s1, p2.getService("Signature", "md5rsa"));78check(s1, p2.getService("Signature", "MD5rsa"));7980s1 = p2.getService("Signature", "SHAwithRSA");81check(s1, null);82check(s1, p2.getService("Signature", "shawithrsa"));83check(s1, p2.getService("Signature", "SHAWITHRSA"));84check(s1, p2.getService("Signature", "SHARSA"));85check(s1, p2.getService("Signature", "sharsa"));86check(s1, p2.getService("Signature", "SHArsa"));87check(s1, p2.getService("Signature", "SHA1RSA"));88check(s1, p2.getService("Signature", "sha1rsa"));89check(s1, p2.getService("Signature", "SHA1rsa"));9091System.out.println("OK");92} finally {93Locale.setDefault(loc);94}95}9697private static void check(Service s1, Service s2) throws Exception {98System.out.println(s1);99if (s1 == null) {100throw new Exception("service is null");101}102if ((s2 != null) && (s1 != s2)) {103throw new Exception("service does not match");104}105}106107private static class TProvider extends Provider {108TProvider(String name) {109super(name, "1.0", null);110put("Signature.MD5withRSA", "com.foo.Sig");111put("Alg.Alias.Signature.MD5RSA", "MD5withRSA");112put("sIGNATURE.shaWITHrsa", "com.foo.Sig");113put("aLG.aLIAS.sIGNATURE.sharsa", "shaWITHrsa");114put("aLG.aLIAS.sIGNATURE.sha1rsa", "shawithrsa");115}116}117118}119120121