Class J2DoPrivHelper
java.lang.Object
org.apache.openjpa.lib.util.J2DoPrivHelper
Helper class to obtain the Privilege(Exception)Action object to perform
Java 2 doPrivilege security sensitive function call in the following
methods:
- AccessibleObject.setAccessible
- Class.forName
- Class.getClassLoader
- Class.getDeclaredField
- Class.getDeclaredFields
- Class.getDeclaredMethod
- Class.getDeclaredMethods
- Class.getProtectionDomain
- Class.getResource
- Class.newInstance
- ClassLoader.getParent
- ClassLoader.getResource
- ClassLoader.getResources
- ClassLoader.getSystemClassLoader
- File.deleteOnExit
- File.delete
- File.exists
- File.getAbsoluteFile
- File.getAbsolutePath
- File.getCanonicalPath
- File.listFiles
- File.length
- File.isDirectory
- File.mkdirs
- File.renameTo
- File.toURL
- FileInputStream new
- FileOutputStream new
- System.getProperties
- InetAddress.getByName
- MultiClassLoader new
- ServerSocket new
- Socket new
- Socket.accept
- System.getProperty
- Thread.getContextClassLoader
- Thread.setContextClassLoader
- Thread new
- TemporaryClassLoader new
- URL.openStream
- URLConnection.getContent
- ZipFile new
- AnnotatedElement.getAnnotations
- AnnotatedElement.getDeclaredAnnotations
- AnnotatedElement.isAnnotationPresent
- jakarta.validation.Validator.validate
- jakarta.validation.Validation.buildDefaultValidatorFactory
1) No security risk method call. E.g.
private static final String SEP = J2DoPrivHelper.getLineSeparator();
2) Methods with no exception thrown. PrivilegedAction is returned from
J2DoPrivHelper.*Action(). E.g.
ClassLoader loader = AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(clazz));
ClassLoader loader = (ClassLoader) (System.getSecurityManager() == null)
? clazz.getClassLoader()
: AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(clazz));
3) Methods with exception thrown. PrivilegedExceptionAction is returned
from J2DoPrivHelper.*Action(). E.g.
try {
method = AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction(clazz, name, parameterType));
} catch (PrivilegedActionException pae) {
throw (NoSuchMethodException) pae.getException();
}
try {
method = (System.getSecurityManager() == null)
? clazz.getDeclaredMethod(name,parameterType)
: AccessController.doPrivileged(
J2DoPrivHelper.getDeclaredMethodAction(
clazz, name, parameterType));
} catch (PrivilegedActionException pae) {
throw (NoSuchMethodException) pae.getException()
}
- Author:
- Albert Lee
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringReturn the value of the "line.separator" system property.static StringReturn the value of the "path.separator" system property.static ThreadnewDeamonThread(Runnable target, String name) Returns a new daemon Thread.static <T> TnewInstance(Class<T> clazz) Return a new object for clazz.newInstance().
-
Constructor Details
-
J2DoPrivHelper
public J2DoPrivHelper()
-
-
Method Details
-
getLineSeparator
Return the value of the "line.separator" system property. Requires security policy: 'permission java.util.PropertyPermission "read";' -
getPathSeparator
Return the value of the "path.separator" system property. Requires security policy: 'permission java.util.PropertyPermission "read";' -
newInstance
public static <T> T newInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException Return a new object for clazz.newInstance().- Returns:
- A new instance of the provided class.
- Throws:
IllegalAccessExceptionInstantiationException
-
newDeamonThread
-