0N/A/*
2362N/A * Copyright (c) 1998, 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
0N/A * @bug 4162868
5361N/A * @run main/othervm ExtensibleAlgorithmId
0N/A * @summary Algorithm Name-to-OID mapping needs to be made extensible.
0N/A */
0N/A
5361N/A// Run in othervm, coz AlgorithmId.oidTable is only initialized once
5361N/A
0N/Aimport java.security.*;
0N/Aimport sun.security.x509.AlgorithmId;
0N/A
0N/Apublic class ExtensibleAlgorithmId {
0N/A
0N/A public static void main(String[] args) throws Exception {
0N/A TestProvider p = new TestProvider();
0N/A Security.addProvider(p);
0N/A AlgorithmId algid = AlgorithmId.getAlgorithmId("XYZ");
0N/A String alias = "Alg.Alias.Signature.OID." + algid.toString();
0N/A String stdAlgName = p.getProperty(alias);
0N/A if (stdAlgName == null || !stdAlgName.equalsIgnoreCase("XYZ")) {
0N/A throw new Exception("Wrong OID");
0N/A }
0N/A }
0N/A}
0N/A
0N/Aclass TestProvider extends Provider {
0N/A
0N/A public TestProvider() {
0N/A super("Dummy", 1.0, "XYZ algorithm");
0N/A
0N/A AccessController.doPrivileged(new PrivilegedAction() {
0N/A public Object run() {
0N/A
0N/A put("Signature.XYZ", "test.xyz");
0N/A // preferred OID
0N/A put("Alg.Alias.Signature.OID.1.2.3.4.5.6.7.8.9.0",
0N/A "XYZ");
0N/A put("Alg.Alias.Signature.9.8.7.6.5.4.3.2.1.0",
0N/A "XYZ");
0N/A return null;
0N/A }
0N/A });
0N/A }
0N/A}