Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/x509/AlgorithmId/ExtensibleAlgorithmId.java
38853 views
/*1* Copyright (c) 1998, 2011, 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 416286826* @run main/othervm ExtensibleAlgorithmId27* @summary Algorithm Name-to-OID mapping needs to be made extensible.28*/2930// Run in othervm, coz AlgorithmId.oidTable is only initialized once3132import java.security.*;33import sun.security.x509.AlgorithmId;3435public class ExtensibleAlgorithmId {3637public static void main(String[] args) throws Exception {38TestProvider p = new TestProvider();39Security.addProvider(p);40AlgorithmId algid = AlgorithmId.getAlgorithmId("XYZ");41String alias = "Alg.Alias.Signature.OID." + algid.toString();42String stdAlgName = p.getProperty(alias);43if (stdAlgName == null || !stdAlgName.equalsIgnoreCase("XYZ")) {44throw new Exception("Wrong OID");45}46}47}4849class TestProvider extends Provider {5051public TestProvider() {52super("Dummy", 1.0, "XYZ algorithm");5354AccessController.doPrivileged(new PrivilegedAction() {55public Object run() {5657put("Signature.XYZ", "test.xyz");58// preferred OID59put("Alg.Alias.Signature.OID.1.2.3.4.5.6.7.8.9.0",60"XYZ");61put("Alg.Alias.Signature.9.8.7.6.5.4.3.2.1.0",62"XYZ");63return null;64}65});66}67}686970