Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/security/Provider/DefaultPKCS11.java
38812 views
/*1* Copyright (c) 2005, 2012, 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 626088826* @summary check SunPKCS11-Solaris is available on S10+ systems27* @author Andreas Sterbenz28*/2930import java.util.*;3132import java.security.*;3334public class DefaultPKCS11 {3536public static void main(String[] args) throws Exception {37String osName = System.getProperty("os.name", "(null)");38String osVersion = System.getProperty("os.version", "(null)");39System.out.println("Running on " + osName + " " + osVersion);40Provider[] ps = Security.getProviders();41System.out.println("Providers: " + Arrays.asList(ps));42System.out.println();4344if (osName.equals("SunOS") == false) {45System.out.println("Test only applies to Solaris, skipping");46return;47}48String[] v = osVersion.split("\\.");49if (v.length < 2) {50throw new Exception("Failed to parse Solaris version: " + Arrays.asList(v));51}52if (Integer.parseInt(v[0]) != 5) {53throw new Exception("Unknown Solaris major version: " + v[0]);54}55if (Integer.parseInt(v[1]) < 10) {56System.out.println("Test only applies to Solaris 10 and later, skipping");57return;58}59// SunPKCS11-Solaris provider should be either the first one or60// the second one61if (ps[0].getName().equals("SunPKCS11-Solaris") == false &&62ps[1].getName().equals("SunPKCS11-Solaris") == false) {63throw new Exception("SunPKCS11-Solaris provider not installed");64}65System.out.println("OK");66}6768}697071