Path: blob/master/test/jdk/java/security/Security/NoInstalledProviders.java
41149 views
/*1* Copyright (c) 1999, 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 4273454 7054918 705253726* @library ../testlibrary27* @summary Make sure getProviders(filter) doesn't throw NPE28* @run main/othervm NoInstalledProviders29*/3031import java.security.*;3233public class NoInstalledProviders {3435public static void main(String[] args) throws Exception {36ProvidersSnapshot snapshot = ProvidersSnapshot.create();37try {38main0(args);39} finally {40snapshot.restore();41}42}4344public static void main0(String[] args) throws Exception {4546Provider[] provs = Security.getProviders();47// make sure there are no providers in the system48for(int i = 0; i < provs.length; i++ ) {49Security.removeProvider( provs[i].getName());50}5152String filter = "Signature.SHA1withDSA";5354provs = Security.getProviders(filter);55}56}575859