本文整理了Java中org.wildfly.security.manager.WildFlySecurityManager.getCallerClass()
方法的一些代码示例,展示了WildFlySecurityManager.getCallerClass()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WildFlySecurityManager.getCallerClass()
方法的具体详情如下:
包路径:org.wildfly.security.manager.WildFlySecurityManager
类名称:WildFlySecurityManager
方法名:getCallerClass
暂无
代码示例来源:origin: wildfly/wildfly
/**
* Get the caller class. The {@code skipFrames} argument specifies how many spots to go back
* on the call stack; 0 indicates the immediate caller.
*
* @param skipFrames the number of frames to skip over before the immediate caller
* @return the caller class
*/
public Class<?> getCallerClass(int skipFrames) {
return WildFlySecurityManager.getCallerClass(max(0, skipFrames) + 2);
}
代码示例来源:origin: wildfly/wildfly
/**
* Execute a parametric privileged action with the given parameter in a privileged context.
*
* @param parameter the parameter to send in to the action
* @param action the action to execute
* @param <T> the action result type
* @param <P> the parameter type
* @return the action result
*/
@SuppressWarnings("unchecked")
public static <T, P> T doPrivilegedWithParameter(P parameter, ParametricPrivilegedExceptionAction<T, P> action) throws PrivilegedActionException {
final Context ctx = CTX.get();
ctx.action2 = (ParametricPrivilegedExceptionAction<Object, Object>) action;
ctx.parameter = parameter;
return (T) doPrivileged(PA_TRAMPOLINE2, ACC_CACHE.get(getCallerClass(2)));
}
代码示例来源:origin: wildfly/wildfly
/**
* Execute a parametric privileged action with the given parameter in a privileged context.
*
* @param parameter the parameter to send in to the action
* @param action the action to execute
* @param <T> the action result type
* @param <P> the parameter type
* @return the action result
*/
@SuppressWarnings("unchecked")
public static <T, P> T doPrivilegedWithParameter(P parameter, ParametricPrivilegedAction<T, P> action) {
final Context ctx = CTX.get();
ctx.action1 = (ParametricPrivilegedAction<Object, Object>) action;
ctx.parameter = parameter;
return (T) doPrivileged(PA_TRAMPOLINE1, ACC_CACHE.get(getCallerClass(2)));
}
代码示例来源:origin: wildfly/wildfly
/**
* Perform an action with permission checking disabled. If permission checking is already disabled, the action is
* simply run. The immediate caller must have the {@code doUnchecked} runtime permission.
*
* @param action the action to perform
* @param context the access control context to use
* @param <T> the action return type
* @return the return value of the action
*/
public static <T> T doUnchecked(PrivilegedAction<T> action, AccessControlContext context) {
final Context ctx = CTX.get();
if (! ctx.checking) {
return AccessController.doPrivileged(action, context);
}
ctx.checking = false;
try {
final SecurityManager sm = getSecurityManager();
if (sm != null) {
checkPDPermission(getCallerClass(2), doUncheckedPermission);
}
return AccessController.doPrivileged(action, context);
} finally {
ctx.checking = true;
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Perform an action with permission checking disabled. If permission checking is already disabled, the action is
* simply run. The caller must have the {@code doUnchecked} runtime permission.
*
* @param action the action to perform
* @param context the access control context to use
* @param <T> the action return type
* @return the return value of the action
* @throws PrivilegedActionException if the action threw an exception
*/
public static <T> T doUnchecked(PrivilegedExceptionAction<T> action, AccessControlContext context) throws PrivilegedActionException {
final Context ctx = CTX.get();
if (! ctx.checking) {
return AccessController.doPrivileged(action, context);
}
ctx.checking = false;
try {
final SecurityManager sm = getSecurityManager();
if (sm != null) {
checkPDPermission(getCallerClass(2), doUncheckedPermission);
}
return AccessController.doPrivileged(action, context);
} finally {
ctx.checking = true;
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Get the current thread's context class loader, doing a faster permission check that skips having to execute a
* privileged action frame.
*
* @return the context class loader
*/
public static ClassLoader getCurrentContextClassLoaderPrivileged() {
final SecurityManager sm = System.getSecurityManager();
if (sm == null) {
return currentThread().getContextClassLoader();
}
if (sm instanceof WildFlySecurityManager) {
final Context ctx = CTX.get();
if (! ctx.checking) {
return currentThread().getContextClassLoader();
}
ctx.checking = false;
try {
checkPDPermission(getCallerClass(2), GET_CLASS_LOADER_PERMISSION);
return currentThread().getContextClassLoader();
} finally {
ctx.checking = true;
}
} else {
checkPDPermission(getCallerClass(2), GET_CLASS_LOADER_PERMISSION);
return doPrivileged(GetContextClassLoaderAction.getInstance());
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Get the system environment map, doing a faster permission check that skips having to execute a privileged action
* frame.
*
* @return the system environment map
*/
public static Map<String, String> getSystemEnvironmentPrivileged() {
final SecurityManager sm = System.getSecurityManager();
if (sm == null) {
return getenv();
}
if (sm instanceof WildFlySecurityManager) {
final Context ctx = CTX.get();
if (! ctx.checking) {
return getenv();
}
ctx.checking = false;
try {
checkPDPermission(getCallerClass(2), ENVIRONMENT_PERMISSION);
return getenv();
} finally {
ctx.checking = true;
}
} else {
checkPDPermission(getCallerClass(2), ENVIRONMENT_PERMISSION);
return doPrivileged(GetEnvironmentAction.getInstance());
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Get the system properties map, doing a faster permission check that skips having to execute a privileged action
* frame.
*
* @return the system property map
*/
public static Properties getSystemPropertiesPrivileged() {
final SecurityManager sm = System.getSecurityManager();
if (sm == null) {
return getProperties();
}
if (sm instanceof WildFlySecurityManager) {
final Context ctx = CTX.get();
if (! ctx.checking) {
return getProperties();
}
ctx.checking = false;
try {
checkPDPermission(getCallerClass(2), PROPERTIES_PERMISSION);
return getProperties();
} finally {
ctx.checking = true;
}
} else {
checkPDPermission(getCallerClass(2), PROPERTIES_PERMISSION);
return doPrivileged(GetSystemPropertiesAction.getInstance());
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Get the class loader for a class, doing a faster permission check that skips having to execute a privileged action
* frame.
*
* @param clazz the class to check
* @return the class loader
*/
public static ClassLoader getClassLoaderPrivileged(Class<?> clazz) {
final SecurityManager sm = System.getSecurityManager();
if (sm == null) {
return clazz.getClassLoader();
}
if (sm instanceof WildFlySecurityManager) {
final Context ctx = CTX.get();
if (! ctx.checking) {
return clazz.getClassLoader();
}
ctx.checking = false;
try {
checkPDPermission(getCallerClass(2), GET_CLASS_LOADER_PERMISSION);
return clazz.getClassLoader();
} finally {
ctx.checking = true;
}
} else {
checkPDPermission(getCallerClass(2), GET_CLASS_LOADER_PERMISSION);
return doPrivileged(new GetClassLoaderAction(clazz));
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Set a property, doing a faster permission check that skips having to execute a privileged action frame.
*
* @param name the property name
* @param value the value ot set
* @return the previous property value, or {@code null} if there was none
*/
public static String setPropertyPrivileged(String name, String value) {
final SecurityManager sm = getSecurityManager();
if (sm == null) {
return setProperty(name, value);
}
if (sm instanceof WildFlySecurityManager) {
final Context ctx = CTX.get();
if (! ctx.checking) {
return setProperty(name, value);
}
ctx.checking = false;
try {
checkPropertyWritePermission(getCallerClass(2), name);
return setProperty(name, value);
} finally {
ctx.checking = true;
}
} else {
checkPropertyWritePermission(getCallerClass(2), name);
return doPrivileged(new WritePropertyAction(name, value));
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Get a property, doing a faster permission check that skips having to execute a privileged action frame.
*
* @param name the property name
* @param def the default value if the property is not found
* @return the property value, or the default value
*/
public static String getPropertyPrivileged(String name, String def) {
final SecurityManager sm = getSecurityManager();
if (sm == null) {
return getProperty(name, def);
}
if (sm instanceof WildFlySecurityManager) {
final Context ctx = CTX.get();
if (! ctx.checking) {
return getProperty(name, def);
}
ctx.checking = false;
try {
checkPropertyReadPermission(getCallerClass(2), name);
return getProperty(name, def);
} finally {
ctx.checking = true;
}
} else {
checkPropertyReadPermission(getCallerClass(2), name);
return doPrivileged(new ReadPropertyAction(name, def));
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Clear a property, doing a faster permission check that skips having to execute a privileged action frame.
*
* @param name the property name
* @return the previous property value, or {@code null} if there was none
*/
public static String clearPropertyPrivileged(String name) {
final SecurityManager sm = getSecurityManager();
if (sm == null) {
return clearProperty(name);
}
if (sm instanceof WildFlySecurityManager) {
final Context ctx = CTX.get();
if (! ctx.checking) {
return clearProperty(name);
}
ctx.checking = false;
try {
checkPropertyWritePermission(getCallerClass(2), name);
return clearProperty(name);
} finally {
ctx.checking = true;
}
} else {
checkPropertyWritePermission(getCallerClass(2), name);
return doPrivileged(new ClearPropertyAction(name));
}
}
代码示例来源:origin: wildfly/wildfly
ProtectionDomain[] protectionDomainStack = getProtectionDomainStack(accessControlContext);
if (protectionDomainStack == null || protectionDomainStack.length == 0) {
combined = ACC_CACHE.get(getCallerClass(2));
} else {
final ProtectionDomain[] finalDomains = Arrays.copyOf(protectionDomainStack, protectionDomainStack.length + 1);
finalDomains[protectionDomainStack.length] = getCallerClass(2).getProtectionDomain();
combined = new AccessControlContext(finalDomains);
代码示例来源:origin: wildfly/wildfly
ProtectionDomain[] protectionDomainStack = getProtectionDomainStack(accessControlContext);
if (protectionDomainStack == null || protectionDomainStack.length == 0) {
combined = ACC_CACHE.get(getCallerClass(2));
} else {
final ProtectionDomain[] finalDomains = Arrays.copyOf(protectionDomainStack, protectionDomainStack.length + 1);
finalDomains[protectionDomainStack.length] = getCallerClass(2).getProtectionDomain();
combined = new AccessControlContext(finalDomains);
代码示例来源:origin: wildfly/wildfly
/**
* Get an environmental property, doing a faster permission check that skips having to execute a privileged action frame.
*
* @param name the property name
* @param def the default value if the property is not found
* @return the property value, or the default value
*/
public static String getEnvPropertyPrivileged(String name, String def) {
final SecurityManager sm = getSecurityManager();
if (sm == null) {
return getenv(name);
}
if (sm instanceof WildFlySecurityManager) {
final Context ctx = CTX.get();
if (! ctx.checking) {
return def(getenv(name), def);
}
ctx.checking = false;
try {
checkEnvPropertyReadPermission(getCallerClass(2), name);
return def(getenv(name), def);
} finally {
ctx.checking = true;
}
} else {
checkEnvPropertyReadPermission(getCallerClass(2), name);
return doPrivileged(new ReadEnvironmentPropertyAction(name, def));
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Perform an action with permission checking disabled. If permission checking is already disabled, the action is
* simply run. The immediate caller must have the {@code doUnchecked} runtime permission.
*
* @param action the action to perform
* @param <T> the action return type
* @return the return value of the action
*/
public static <T> T doUnchecked(PrivilegedAction<T> action) {
final Context ctx = CTX.get();
if (! ctx.checking) {
return action.run();
}
ctx.checking = false;
try {
final SecurityManager sm = getSecurityManager();
if (sm != null) {
checkPDPermission(getCallerClass(2), doUncheckedPermission);
}
return action.run();
} finally {
ctx.checking = true;
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Perform an action with permission checking disabled. If permission checking is already disabled, the action is
* simply run. The immediate caller must have the {@code doUnchecked} runtime permission.
*
* @param parameter the parameter to pass to the action
* @param action the action to perform
* @param <T> the action return type
* @param <P> the action parameter type
* @return the return value of the action
*/
public static <T, P> T doUnchecked(P parameter, ParametricPrivilegedAction<T, P> action) {
final Context ctx = CTX.get();
if (! ctx.checking) {
return action.run(parameter);
}
ctx.checking = false;
try {
final SecurityManager sm = getSecurityManager();
if (sm != null) {
checkPDPermission(getCallerClass(2), doUncheckedPermission);
}
return action.run(parameter);
} finally {
ctx.checking = true;
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Perform an action with permission checking disabled. If permission checking is already disabled, the action is
* simply run. The immediate caller must have the {@code doUnchecked} runtime permission.
*
* @param parameter the parameter to pass to the action
* @param action the action to perform
* @param context the access control context to use
* @param <T> the action return type
* @param <P> the action parameter type
* @return the return value of the action
*/
public static <T, P> T doUnchecked(P parameter, ParametricPrivilegedAction<T, P> action, AccessControlContext context) {
final Context ctx = CTX.get();
if (! ctx.checking) {
return doPrivilegedWithParameter(parameter, action, context);
}
ctx.checking = false;
try {
final SecurityManager sm = getSecurityManager();
if (sm != null) {
checkPDPermission(getCallerClass(2), doUncheckedPermission);
}
return doPrivilegedWithParameter(parameter, action, context);
} finally {
ctx.checking = true;
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Perform an action with permission checking disabled. If permission checking is already disabled, the action is
* simply run. The caller must have the {@code doUnchecked} runtime permission.
*
* @param parameter the parameter to pass to the action
* @param action the action to perform
* @param context the access control context to use
* @param <T> the action return type
* @param <P> the action parameter type
* @return the return value of the action
* @throws PrivilegedActionException if the action threw an exception
*/
public static <T, P> T doUnchecked(P parameter, ParametricPrivilegedExceptionAction<T, P> action, AccessControlContext context) throws PrivilegedActionException {
final Context ctx = CTX.get();
if (! ctx.checking) {
return doPrivilegedWithParameter(parameter, action, context);
}
ctx.checking = false;
try {
final SecurityManager sm = getSecurityManager();
if (sm != null) {
checkPDPermission(getCallerClass(2), doUncheckedPermission);
}
return doPrivilegedWithParameter(parameter, action, context);
} finally {
ctx.checking = true;
}
}
代码示例来源:origin: wildfly/wildfly
final SecurityManager sm = getSecurityManager();
if (sm != null) {
checkPDPermission(getCallerClass(2), doUncheckedPermission);
内容来源于网络,如有侵权,请联系作者删除!