提交 e8c2e932 编写于 作者: A akosarev

8154009: Some methods of java.security.Security require more permissions, than necessary

Reviewed-by: mullan
上级 03581157
/*
* Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -255,6 +255,15 @@ final class ProviderConfig {
disableLoad();
}
return null;
} catch (ExceptionInInitializerError err) {
// unexpected exception thrown from static initialization block in provider
// (ex: insufficient permission to initialize provider class)
if (debug != null) {
debug.println("Error loading provider " + ProviderConfig.this);
err.printStackTrace();
}
disableLoad();
return null;
}
}
});
......
......@@ -237,10 +237,6 @@ sun/security/tools/keytool/standard.sh solaris-all
# 8026393
sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java generic-all
# 8154009
javax/security/auth/PrivateCredentialPermission/MoreThenOnePrincipals.java solaris-all
java/security/Policy/ExtensiblePolicy/ExtensiblePolicyTest.java solaris-all
############################################################################
# jdk_sound
......
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -23,7 +23,7 @@
/*
* @test
* @bug 8001319
* @bug 8001319 8154009
* @summary check that SecurityPermission insertProvider permission is enforced
* correctly
* @run main/othervm/policy=AddProvider.policy.1 AddProvider 1
......
grant codeBase "file:${{java.ext.dirs}}/*" {
permission java.security.AllPermission;
};
grant {
permission java.security.SecurityPermission "insertProvider";
};
grant codeBase "file:${{java.ext.dirs}}/*" {
permission java.security.AllPermission;
};
grant {
permission java.security.SecurityPermission "insertProvider.Test1";
permission java.security.SecurityPermission "insertProvider.Test2";
......
grant codeBase "file:${{java.ext.dirs}}/*" {
permission java.security.AllPermission;
};
grant {
permission java.security.SecurityPermission "insertProvider.*";
};
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8154009
* @summary make sure getProviders() doesn't require additional permissions
* @run main/othervm/policy=EmptyPolicy.policy GetProviders
*/
import java.security.Provider;
import java.security.Security;
import java.util.HashMap;
import java.util.Map;
public class GetProviders {
private static final String serviceAlgFilter = "Signature.SHA1withRSA";
private static final String emptyServAlgFilter = "wrongSig.wrongAlg";
public static void main(String[] args) throws Exception {
try {
Provider[] providers1 = Security.getProviders();
System.out.println("Amount of providers1: " + providers1.length);
Provider[] providers2 = Security.getProviders(serviceAlgFilter);
System.out.println("Amount of providers2: " + providers2.length);
Map<String, String> filter = new HashMap<String, String>();
filter.put(serviceAlgFilter, "");
Provider[] providers3 = Security.getProviders(filter);
System.out.println("Amount of providers3: " + providers3.length);
Provider[] emptyProv1 = Security.getProviders(emptyServAlgFilter);
if (emptyProv1 != null) {
throw new RuntimeException("Empty Filter returned: " +
emptyProv1.length + " providers");
}
System.out.println("emptyProv1 is empty as expected");
Map<String, String> emptyFilter = new HashMap<String, String>();
emptyFilter.put(emptyServAlgFilter, "");
Provider[] emptyProv2 = Security.getProviders(emptyFilter);
if (emptyProv2 != null) {
throw new RuntimeException("Empty Filter returned: " +
emptyProv2.length + " providers");
}
System.out.println("emptyProv2 is empty as expected");
} catch(ExceptionInInitializerError e) {
e.printStackTrace(System.out);
throw new RuntimeException("Provider initialization error due to "
+ e.getCause());
}
System.out.println("Test passed");
}
}
/*
* Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -23,7 +23,7 @@
/*
* @test
* @bug 4420687
* @bug 4420687 8154009
* @summary Make sure that a removed provider won't be acceessable.
* @run main/othervm/policy=RemoveStaticProvider.policy RemoveStaticProvider
*/
......
......@@ -3,8 +3,3 @@ grant {
permission java.security.SecurityPermission "insertProvider.SunJCE";
};
// Standard extensions get all permissions
grant codeBase "file:${java.home}/lib/ext/*" {
permission java.security.AllPermission;
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册