|
| 1 | +/* |
| 2 | + * Copyright (c) 2022, Red Hat, Inc. |
| 3 | + * |
| 4 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 5 | + * |
| 6 | + * This code is free software; you can redistribute it and/or modify it |
| 7 | + * under the terms of the GNU General Public License version 2 only, as |
| 8 | + * published by the Free Software Foundation. |
| 9 | + * |
| 10 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 11 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 13 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 14 | + * accompanied this code). |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU General Public License version |
| 17 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 18 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | + * |
| 20 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 21 | + * or visit www.oracle.com if you need additional information or have any |
| 22 | + * questions. |
| 23 | + */ |
| 24 | + |
| 25 | +import java.security.Provider; |
| 26 | +import java.security.Security; |
| 27 | + |
| 28 | +/* |
| 29 | + * @test |
| 30 | + * @bug 9999999 |
| 31 | + * @requires (jdk.version.major >= 8) |
| 32 | + * @run main/othervm/timeout=30 Main |
| 33 | + * @author Martin Balao (mbalao@redhat.com) |
| 34 | + */ |
| 35 | + |
| 36 | +public final class VerifyMissingAttributes { |
| 37 | + |
| 38 | + private static final String[] svcAlgImplementedIn = { |
| 39 | + "AlgorithmParameterGenerator.DSA", |
| 40 | + "AlgorithmParameters.DSA", |
| 41 | + "CertificateFactory.X.509", |
| 42 | + "KeyStore.JKS", |
| 43 | + "KeyStore.CaseExactJKS", |
| 44 | + "KeyStore.DKS", |
| 45 | + "CertStore.Collection", |
| 46 | + "CertStore.com.sun.security.IndexedCollection" |
| 47 | + }; |
| 48 | + |
| 49 | + public static void main(String[] args) throws Throwable { |
| 50 | + Provider sunProvider = Security.getProvider("SUN"); |
| 51 | + for (String svcAlg : svcAlgImplementedIn) { |
| 52 | + String filter = svcAlg + " ImplementedIn:Software"; |
| 53 | + doQuery(sunProvider, filter); |
| 54 | + } |
| 55 | + if (Double.parseDouble( |
| 56 | + System.getProperty("java.specification.version")) >= 17) { |
| 57 | + String filter = "KeyFactory.RSASSA-PSS SupportedKeyClasses:" + |
| 58 | + "java.security.interfaces.RSAPublicKey" + |
| 59 | + "|java.security.interfaces.RSAPrivateKey"; |
| 60 | + doQuery(Security.getProvider("SunRsaSign"), filter); |
| 61 | + } |
| 62 | + System.out.println("TEST PASS - OK"); |
| 63 | + } |
| 64 | + |
| 65 | + private static void doQuery(Provider expectedProvider, String filter) |
| 66 | + throws Exception { |
| 67 | + if (expectedProvider == null) { |
| 68 | + throw new Exception("Provider not found."); |
| 69 | + } |
| 70 | + Provider[] providers = Security.getProviders(filter); |
| 71 | + if (providers == null || providers.length != 1 || |
| 72 | + providers[0] != expectedProvider) { |
| 73 | + throw new Exception("Failure retrieving the provider with this" + |
| 74 | + " query: " + filter); |
| 75 | + } |
| 76 | + } |
| 77 | +} |
0 commit comments