本文整理了Java中java.security.AccessControlContext.<init>()
方法的一些代码示例,展示了AccessControlContext.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AccessControlContext.<init>()
方法的具体详情如下:
包路径:java.security.AccessControlContext
类名称:AccessControlContext
方法名:<init>
暂无
代码示例来源:origin: robovm/robovm
public AccessControlContext run() {
return new AccessControlContext(context, combiner);
}
};
代码示例来源:origin: robovm/robovm
public Object run() {
return new AccessControlContext(context, combiner);
}
};
代码示例来源:origin: robovm/robovm
public static AccessControlContext getContext() { return new AccessControlContext(null); }
}
代码示例来源:origin: wildfly/wildfly
protected AccessControlContext computeValue(final Class<?> type) {
final Context ctx = CTX.get();
assert ! ctx.entered;
ctx.entered = true;
try {
return new AccessControlContext(new ProtectionDomain[] { type.getProtectionDomain() });
} finally {
ctx.entered = false;
}
}
};
代码示例来源:origin: robovm/robovm
/**
* Run the code defined by {@code action} using the permissions granted to
* the {@code Subject} and to the code itself, additionally providing a more
* specific context.
*
* @param subject
* the distinguished {@code Subject}.
* @param action
* the code to be run.
* @param context
* the specific context in which the {@code action} is invoked.
* if {@code null} a new {@link AccessControlContext} is
* instantiated.
* @return the {@code Object} returned when running the {@code action}.
*/
@SuppressWarnings("unchecked")
public static <T> T doAsPrivileged(Subject subject, PrivilegedAction<T> action,
AccessControlContext context) {
if (context == null) {
return doAs_PrivilegedAction(subject, action, new AccessControlContext(
new ProtectionDomain[0]));
}
return doAs_PrivilegedAction(subject, action, context);
}
代码示例来源:origin: robovm/robovm
/**
* Runs the code defined by {@code action} using the permissions granted to
* the subject and to the code itself, additionally providing a more
* specific context.
*
* @param subject
* the distinguished {@code Subject}.
* @param action
* the code to be run.
* @param context
* the specific context in which the {@code action} is invoked.
* if {@code null} a new {@link AccessControlContext} is
* instantiated.
* @return the {@code Object} returned when running the {@code action}.
* @throws PrivilegedActionException
* if running the {@code action} throws an exception.
*/
@SuppressWarnings("unchecked")
public static <T> T doAsPrivileged(Subject subject,
PrivilegedExceptionAction<T> action, AccessControlContext context)
throws PrivilegedActionException {
if (context == null) {
return doAs_PrivilegedExceptionAction(subject, action,
new AccessControlContext(new ProtectionDomain[0]));
}
return doAs_PrivilegedExceptionAction(subject, action, context);
}
代码示例来源:origin: wildfly/wildfly
final ProtectionDomain[] finalDomains = Arrays.copyOf(protectionDomainStack, protectionDomainStack.length + 1);
finalDomains[protectionDomainStack.length] = getCallerClass(2).getProtectionDomain();
combined = new AccessControlContext(finalDomains);
代码示例来源:origin: wildfly/wildfly
final ProtectionDomain[] finalDomains = Arrays.copyOf(protectionDomainStack, protectionDomainStack.length + 1);
finalDomains[protectionDomainStack.length] = getCallerClass(2).getProtectionDomain();
combined = new AccessControlContext(finalDomains);
代码示例来源:origin: alibaba/jvm-sandbox
/**
* 清理来自URLClassLoader.acc.ProtectionDomain[]中,来自上一个ModuleClassLoader的ProtectionDomain
* 这样写好蛋疼,而且还有不兼容的风险,从JDK6+都必须要这样清理,但我找不出更好的办法。
* 在重置沙箱时,遇到MgrModule模块无法正确卸载类的情况,主要的原因是在于URLClassLoader.acc.ProtectionDomain[]中包含了上一个ModuleClassLoader的引用
* 所以必须要在这里清理掉,否则随着重置次数的增加,类会越累积越多
*/
private void cleanProtectionDomainWhichCameFromModuleClassLoader() {
// got ProtectionDomain[] from URLClassLoader's acc
final AccessControlContext acc = unCaughtGetClassDeclaredJavaFieldValue(URLClassLoader.class, "acc", this);
final ProtectionDomain[] protectionDomainArray = unCaughtInvokeMethod(
unCaughtGetClassDeclaredJavaMethod(AccessControlContext.class, "getContext"),
acc
);
// remove ProtectionDomain which loader is ModuleClassLoader
final Set<ProtectionDomain> cleanProtectionDomainSet = new LinkedHashSet<ProtectionDomain>();
if (ArrayUtils.isNotEmpty(protectionDomainArray)) {
for (final ProtectionDomain protectionDomain : protectionDomainArray) {
if (protectionDomain.getClassLoader() == null
|| !StringUtils.equals(ModuleClassLoader.class.getName(), protectionDomain.getClassLoader().getClass().getName())) {
cleanProtectionDomainSet.add(protectionDomain);
}
}
}
// rewrite acc
final AccessControlContext newAcc = new AccessControlContext(cleanProtectionDomainSet.toArray(new ProtectionDomain[]{}));
unCaughtSetClassDeclaredJavaFieldValue(URLClassLoader.class, "acc", this, newAcc);
}
代码示例来源:origin: spring-projects/spring-framework
@Before
public void setUp() throws Exception {
final ProtectionDomain empty = new ProtectionDomain(null,
new Permissions());
provider = new SecurityContextProvider() {
private final AccessControlContext acc = new AccessControlContext(
new ProtectionDomain[] { empty });
@Override
public AccessControlContext getAccessControlContext() {
return acc;
}
};
DefaultResourceLoader drl = new DefaultResourceLoader();
Resource config = drl
.getResource("/org/springframework/beans/factory/support/security/callbacks.xml");
beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(config);
beanFactory.setSecurityContextProvider(provider);
}
代码示例来源:origin: spring-projects/spring-framework
ProtectionDomain pd = new ProtectionDomain(null, perms);
new AccessControlContext(new ProtectionDomain[] { pd });
代码示例来源:origin: MobiVM/robovm
public Object run() {
return new AccessControlContext(context, combiner);
}
};
代码示例来源:origin: org.ogema.ref-impl/security
public AccessControlContext run() {
if (cls != null) {
ProtectionDomain[] pda = new ProtectionDomain[1];
pda[0] = cls.getProtectionDomain();
return new AccessControlContext(new AccessControlContext(pda), domainCombiner);
}
else {
return null;
}
}
});
代码示例来源:origin: au.net.zeus.jgdms/jgdms-platform
private static AccessControlContext combine(final AccessControlContext acc, final Subject subject){
return AccessController.doPrivileged(new PrivilegedAction<AccessControlContext>(){
@Override
public AccessControlContext run() {
AccessControlContext context = acc != null ? acc : new AccessControlContext(new ProtectionDomain[0]);
if (subject == null) return context;
return new AccessControlContext(context, new DistributedSubjectCombiner(subject));
}
});
}
代码示例来源:origin: org.ogema.ref-impl/security
private boolean setProtectionDomain(ProtectionDomain pda[]) {
final AccessControlContext acc = new AccessControlContext(new AccessControlContext(pda), domainCombiner);
permMan.setAccessContext(acc);
return true;
}
代码示例来源:origin: org.wildfly.security/wildfly-elytron
protected AccessControlContext computeValue(final Class<?> type) {
final Context ctx = CTX.get();
assert ! ctx.entered;
ctx.entered = true;
try {
return new AccessControlContext(new ProtectionDomain[] { type.getProtectionDomain() });
} finally {
ctx.entered = false;
}
}
};
代码示例来源:origin: org.glassfish.main.ejb/ejb-container
public Object run() throws Exception {
return new AccessControlContext
(new AccessControlContext(pdArray),
new SubjectDomainCombiner(s));
}
});
代码示例来源:origin: de.unkrig.commons/commons-lang
/**
* All future actions that are executed through the named class will be checked against the given {@code
* protectionDomain}.
*
* @throws SecurityException Permissions are already confined for the <var>className</var>
*/
public static void
confine(String className, ProtectionDomain protectionDomain) {
Sandbox.confine(className, new AccessControlContext(new ProtectionDomain[] { protectionDomain }));
}
代码示例来源:origin: net.sourceforge.streamsupport/android-retrostreams
static AccessControlContext contextWithPermissions(Permission ... perms) {
Permissions permissions = new Permissions();
for (Permission perm : perms)
permissions.add(perm);
return new AccessControlContext(
new ProtectionDomain[] { new ProtectionDomain(null, permissions) });
}
代码示例来源:origin: stackoverflow.com
private static final AccessControlContext allowedPermissionsAcc;
static { // initialization of the allowed permissions
PermissionCollection allowedPermissions = new Permissions();
allowedPermissions.add(new RuntimePermission("accessDeclaredMembers"));
// ... <many more permissions here> ...
allowedPermissionsAcc = new AccessControlContext(new ProtectionDomain[] {
new ProtectionDomain(null, allowedPermissions)});
}
内容来源于网络,如有侵权,请联系作者删除!