java.security.AccessControlContext.checkPermission()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(42)

本文整理了Java中java.security.AccessControlContext.checkPermission()方法的一些代码示例,展示了AccessControlContext.checkPermission()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AccessControlContext.checkPermission()方法的具体详情如下:
包路径:java.security.AccessControlContext
类名称:AccessControlContext
方法名:checkPermission

AccessControlContext.checkPermission介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

C:\ReflectionTest>java -Djava.security.manager CallFoo
Exception in thread "main" java.security.AccessControlException: access denied (java.lang.reflect.ReflectPermission suppressAccessChecks)
  at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
  at java.security.AccessController.checkPermission(AccessController.java:427)
  at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
  at java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:107)
  at CallFoo.main(CallFoo.java:8)

代码示例来源:origin: spring-projects/spring-framework

AccessControlContext acc = provider.getAccessControlContext();
try {
  acc.checkPermission(new PropertyPermission("*", "read"));
  fail("Acc should not have any permissions");

代码示例来源:origin: stackoverflow.com

if (System.getSecurityManager()!=null){
  acc.checkPermission(new RuntimePermission("setContextClassLoader"));

代码示例来源:origin: de.mirkosertic.bytecoder/java.base

public void checkPermission(Permission perm, Object context) {
  if (context instanceof AccessControlContext) {
    ((AccessControlContext)context).checkPermission(perm);
  } else {
    throw new SecurityException();
  }
}

代码示例来源:origin: mirkosertic/Bytecoder

public void checkPermission(Permission perm, Object context) {
  if (context instanceof AccessControlContext) {
    ((AccessControlContext)context).checkPermission(perm);
  } else {
    throw new SecurityException();
  }
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent

PrivilegedThreadFactory() {
  super();
  this.ccl = Thread.currentThread().getContextClassLoader();
  this.acc = AccessController.getContext();
  acc.checkPermission(new RuntimePermission("setContextClassLoader"));
}

代码示例来源:origin: org.scala-lang/scala-actors

PrivilegedCallableUsingCurrentClassLoader(Callable task) {
  this.task = task;
  this.ccl = Thread.currentThread().getContextClassLoader();
  this.acc = AccessController.getContext();
  acc.checkPermission(new RuntimePermission("getContextClassLoader"));
  acc.checkPermission(new RuntimePermission("setContextClassLoader"));
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent

PrivilegedCallableUsingCurrentClassLoader(Callable task) {
  this.task = task;
  this.ccl = Thread.currentThread().getContextClassLoader();
  this.acc = AccessController.getContext();
  acc.checkPermission(new RuntimePermission("getContextClassLoader"));
  acc.checkPermission(new RuntimePermission("setContextClassLoader"));
}

代码示例来源:origin: edu.emory.mathcs.backport/com.springsource.edu.emory.mathcs.backport

PrivilegedThreadFactory() {
  super();
  this.ccl = Thread.currentThread().getContextClassLoader();
  this.acc = AccessController.getContext();
  acc.checkPermission(new RuntimePermission("setContextClassLoader"));
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent-java12

PrivilegedCallableUsingCurrentClassLoader(Callable task) {
  this.task = task;
  this.ccl = Thread.currentThread().getContextClassLoader();
  this.acc = AccessController.getContext();
  acc.checkPermission(new RuntimePermission("getContextClassLoader"));
  acc.checkPermission(new RuntimePermission("setContextClassLoader"));
}

代码示例来源:origin: org.scala-lang.virtualized/scala-actors

PrivilegedCallableUsingCurrentClassLoader(Callable task) {
  this.task = task;
  this.ccl = Thread.currentThread().getContextClassLoader();
  this.acc = AccessController.getContext();
  acc.checkPermission(new RuntimePermission("getContextClassLoader"));
  acc.checkPermission(new RuntimePermission("setContextClassLoader"));
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat6

public boolean isAuthMandatory(Request request, Object constraints) {
  try {
    defaultACC.checkPermission(new WebResourcePermission(request));
    return false;
  } catch (AccessControlException e) {
    return true;
  }
}

代码示例来源:origin: org.knopflerfish/framework

/**
 *
 */
public T run() {
 acc.checkPermission(perm);
 checkPostponements();
 return null;
}

代码示例来源:origin: org.scala-lang/scala-actors

PrivilegedThreadFactory() {
  super();
  this.ccl = Thread.currentThread().getContextClassLoader();
  this.acc = AccessController.getContext();
  acc.checkPermission(new RuntimePermission("setContextClassLoader"));
}

代码示例来源:origin: edu.emory.mathcs.backport/com.springsource.edu.emory.mathcs.backport

PrivilegedCallableUsingCurrentClassLoader(Callable task) {
  this.task = task;
  this.ccl = Thread.currentThread().getContextClassLoader();
  this.acc = AccessController.getContext();
  acc.checkPermission(new RuntimePermission("getContextClassLoader"));
  acc.checkPermission(new RuntimePermission("setContextClassLoader"));
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat6

public boolean hasUserDataPermissions(Request request, Object constraints) {
  try {
    defaultACC.checkPermission(new WebUserDataPermission(request));
    return true;
  } catch (AccessControlException e) {
    return false;
  }
}

代码示例来源:origin: backport-util-concurrent/backport-util-concurrent-java12

PrivilegedThreadFactory() {
  super();
  this.ccl = Thread.currentThread().getContextClassLoader();
  this.acc = AccessController.getContext();
  acc.checkPermission(new RuntimePermission("setContextClassLoader"));
}

代码示例来源:origin: org.scala-lang.virtualized/scala-actors

PrivilegedThreadFactory() {
  super();
  this.ccl = Thread.currentThread().getContextClassLoader();
  this.acc = AccessController.getContext();
  acc.checkPermission(new RuntimePermission("setContextClassLoader"));
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat6

public boolean hasResourcePermissions(Request request, AuthResult authResult, Object constraints, UserIdentity userIdentity) {
    if (!(userIdentity instanceof JACCUserIdentity)) {
      return false;
    }

    AccessControlContext acc = ((JACCUserIdentity)userIdentity).getAccessControlContext();
    try {
      acc.checkPermission(new WebResourcePermission(request));
      return true;
    } catch (AccessControlException e) {
      return false;
    }
  }
}

代码示例来源:origin: org.apache.geronimo.ext.openejb/openejb-core

public boolean isCallerInRole(String role) {
  if (role == null) throw new IllegalArgumentException("Role must not be null");
  ThreadContext threadContext = ThreadContext.getThreadContext();
  SecurityContext securityContext = threadContext.get(SecurityContext.class);
  try {
    DeploymentInfo deployment = threadContext.getDeploymentInfo();
    securityContext.acc.checkPermission(new EJBRoleRefPermission(deployment.getEjbName(), role));
  } catch (AccessControlException e) {
    return false;
  }
  return true;
}

相关文章