本文整理了Java中java.lang.SecurityManager
类的一些代码示例,展示了SecurityManager
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SecurityManager
类的具体详情如下:
包路径:java.lang.SecurityManager
类名称:SecurityManager
[英]Legacy security code; do not use.
Security managers do not provide a secure environment for executing untrusted code. Untrusted code cannot be safely isolated within the Dalvik VM.
[中]遗留安全代码;不要使用。
安全管理器不提供执行不受信任代码的安全环境。不受信任的代码无法在Dalvik VM中安全隔离。
代码示例来源:origin: org.apache.logging.log4j/log4j-api
private static void checkPermission(final Permission permission) {
if (SECURITY_MANAGER != null) {
SECURITY_MANAGER.checkPermission(permission);
}
}
代码示例来源:origin: apache/incubator-dubbo
public NamedThreadFactory(String prefix, boolean daemon) {
mPrefix = prefix + "-thread-";
mDaemon = daemon;
SecurityManager s = System.getSecurityManager();
mGroup = (s == null) ? Thread.currentThread().getThreadGroup() : s.getThreadGroup();
}
代码示例来源:origin: javax.xml.bind/jaxb-api
static void checkPackageAccess(String className) {
// make sure that the current thread has an access to the package of the given name.
SecurityManager s = System.getSecurityManager();
if (s != null) {
int i = className.lastIndexOf('.');
if (i != -1) {
s.checkPackageAccess(className.substring(0, i));
}
}
}
代码示例来源:origin: redisson/redisson
protected Class<?>[] getClassContext() {
return super.getClassContext();
}
}
代码示例来源:origin: spring-projects/spring-framework
public CallbacksSecurityTests() {
// setup security
if (System.getSecurityManager() == null) {
Policy policy = Policy.getPolicy();
URL policyURL = getClass()
.getResource(
"/org/springframework/beans/factory/support/security/policy.all");
System.setProperty("java.security.policy", policyURL.toString());
System.setProperty("policy.allowSystemProperty", "true");
policy.refresh();
System.setSecurityManager(new SecurityManager());
}
}
代码示例来源:origin: bytedeco/javacpp
@Override public Class[] getClassContext() {
return super.getClassContext();
}
}.getClassContext();
代码示例来源:origin: groovy/groovy-core
protected void setUp() {
if (checkSecurity()) {
securityManager = System.getSecurityManager();
if (securityManager == null) {
System.setSecurityManager(new SecurityManager());
}
}
currentClassLoader = Thread.currentThread().getContextClassLoader();
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
Thread.currentThread().setContextClassLoader(loader);
return null;
}
});
}
代码示例来源:origin: prestodb/presto
/**
* Get a factory for creating "unsafe" slices that can reference
* arbitrary memory addresses. If there is a security manager, its
* {@code checkPermission} method is called with a
* {@code ReflectPermission("suppressAccessChecks")} permission.
*
* @return an unsafe slice factory
*/
public static UnsafeSliceFactory getInstance()
{
// see setAccessible() in AccessibleObject
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(ACCESS_PERMISSION);
}
return INSTANCE;
}
代码示例来源:origin: apache/incubator-dubbo
public NamedThreadFactory(String prefix, boolean daemon) {
mPrefix = prefix + "-thread-";
mDaemon = daemon;
SecurityManager s = System.getSecurityManager();
mGroup = (s == null) ? Thread.currentThread().getThreadGroup() : s.getThreadGroup();
}
代码示例来源:origin: org.springframework.boot/spring-boot
private void checkPackageAccess(String name) throws ClassNotFoundException {
if (this.securityManager != null && name.lastIndexOf('.') >= 0) {
try {
this.securityManager
.checkPackageAccess(name.substring(0, name.lastIndexOf('.')));
}
catch (SecurityException ex) {
throw new ClassNotFoundException("Security Violation, attempt to use "
+ "Restricted Class: " + name, ex);
}
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-api
@Override
protected Class<?>[] getClassContext() {
return super.getClassContext();
}
代码示例来源:origin: ben-manes/caffeine
/**
* Runs all JSR166 unit tests using junit.textui.TestRunner.
* Optional command line arg provides the number of iterations to
* repeat running the tests.
*/
public static void main(String[] args) {
if (useSecurityManager) {
System.err.println("Setting a permissive security manager");
Policy.setPolicy(permissivePolicy());
System.setSecurityManager(new SecurityManager());
}
int iters = (args.length == 0) ? 1 : Integer.parseInt(args[0]);
Test s = suite();
for (int i = 0; i < iters; ++i) {
junit.textui.TestRunner.run(s);
System.gc();
System.runFinalization();
}
System.exit(0);
}
代码示例来源:origin: MovingBlocks/Terasology
/**
* @return A PrivateIndentityCertificate belonging to the player, if possible (exists and is allowed)
*/
public PrivateIdentityCertificate getPlayerPrivateCertificate() {
if (System.getSecurityManager() != null) {
System.getSecurityManager().checkPermission(SecurityConfig.PRIVATE_CERTIFICATE_ACCESS_PERMISSION);
}
return playerPrivateCertificate;
}
代码示例来源:origin: netty/netty
public DefaultThreadFactory(String poolName, boolean daemon, int priority) {
this(poolName, daemon, priority, System.getSecurityManager() == null ?
Thread.currentThread().getThreadGroup() : System.getSecurityManager().getThreadGroup());
}
代码示例来源:origin: wildfly/wildfly
public void checkPackageAccess(final String pkg) {
if (doCheck()) {
super.checkPackageAccess(pkg);
}
}
代码示例来源:origin: wildfly/wildfly
protected Class<?>[] getClassContext() {
return super.getClassContext();
}
}
代码示例来源:origin: google/guava
public void testUnloadableInStaticFieldIfClosed() throws Exception {
if (isJdk9OrHigher()) {
return;
}
Policy oldPolicy = Policy.getPolicy();
SecurityManager oldSecurityManager = System.getSecurityManager();
try {
Policy.setPolicy(new PermissivePolicy());
System.setSecurityManager(new SecurityManager());
WeakReference<ClassLoader> loaderRef = doTestUnloadableInStaticFieldIfClosed();
GcFinalization.awaitClear(loaderRef);
} finally {
System.setSecurityManager(oldSecurityManager);
Policy.setPolicy(oldPolicy);
}
}
代码示例来源:origin: MovingBlocks/Terasology
private void checkPermission(Permission permission) {
if (System.getSecurityManager() != null) {
System.getSecurityManager().checkPermission(permission);
}
}
代码示例来源:origin: alibaba/canal
public NamedThreadFactory(String name, boolean daemon){
this.name = name;
this.daemon = daemon;
SecurityManager s = System.getSecurityManager();
group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
}
代码示例来源:origin: frohoff/ysoserial
@Override
public void checkPackageAccess(String pkg) {
getSecurityManager().checkPackageAccess(pkg);
}
内容来源于网络,如有侵权,请联系作者删除!