Top Description Inners Fields Constructors Methods
org.eclipse.persistence.internal.security

public Class PrivilegedAccessHelper

extends Object
Class Inheritance
Imports
java.lang.reflect.Constructor, .Field, .InvocationTargetException, .Method, java.security.AccessController, .PrivilegedAction, .PrivilegedActionException, .PrivilegedExceptionAction, java.util.Arrays, .Collections, .HashMap, .HashSet, .Map, .Set, org.eclipse.persistence.config.PersistenceUnitProperties, .SystemProperties, org.eclipse.persistence.internal.helper.Helper, .JavaVersion, org.eclipse.persistence.internal.localization.ExceptionLocalization, org.eclipse.persistence.logging.AbstractSessionLog, .SessionLog, org.eclipse.persistence.platform.server.ServerPlatformBase, org.eclipse.persistence.platform.xml.XMLPlatformFactory

INTERNAL: Privileged Access Helper provides a utility so all calls that require privileged access can use the same code. Do privileged blocks can be used with a security manager to grant a code base (eclipselink.jar) access to certain Java operations such as reflection. Generally a security manager is not enabled in a JVM, so this is not an issue. If a security manager is enabled, then either the application can be configured to have access to operations such as reflection, or only EclipseLink can be given access. If only EclipseLink is desired to be given access then do privileged must be enabled through the System property "eclipselink.security.usedoprivileged"=true. Note the usage of do privileged has major impacts on performance, so should normally be avoided.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
PrivilegedAccessHelper.CallableExceptionSupplier<
specific Exception type
E extends Exception
>

INTERNAL Specific Exception supplier for PrivilegedExceptionCallable.

public static interface
PrivilegedAccessHelper.CallableThrowableSupplier<
specific Throwable type
T extends Throwable
>

INTERNAL Specific Throwable supplier for PrivilegedExceptionCallable.

public static interface
PrivilegedAccessHelper.PrivilegedCallable<
the result type of method call
T
>

INTERNAL A task that returns a result and shall not throw an exception.

public static interface
PrivilegedAccessHelper.PrivilegedExceptionCallable<
the result type of method call
T
>

INTERNAL A task that returns a result and may throw an exception.

public static interface
PrivilegedAccessHelper.PrivilegedExceptionConsumer

INTERNAL A task that does not return any result and may throw an exception.

Field Summary

Modifier and TypeField and Description
private static boolean
private static final String[]
private static final Set<String>
private static final String[]
private static final Set<String>
private static final Map<String, Class<?>>
private static boolean
private static boolean
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <
PrivilegedCallable return type
T
>
T
callDoPrivileged(final PrivilegedAccessHelper.PrivilegedCallable<T>
task to execute
task
)

INTERNAL Executes provided PrivilegedCallable task using AccessController#doPrivileged(PrivilegedAction) when privileged access is enabled.

public static <T> T
public static void
public static <T,
specific Exception type
E extends Exception
>
T
callDoPrivilegedWithException(final PrivilegedAccessHelper.PrivilegedExceptionCallable<T>
task to execute
task
,
final PrivilegedAccessHelper.CallableExceptionSupplier<E>
specific Exception supplier
exception
)

INTERNAL Executes provided PrivilegedExceptionCallable task using AccessController#doPrivileged(PrivilegedExceptionAction) when privileged access is enabled.

public static <
specific Exception type
E extends Exception
>
void
public static <T> T
public static <T,
specific Throwable type
E extends Throwable
>
T
callDoPrivilegedWithThrowable(final PrivilegedAccessHelper.PrivilegedExceptionCallable<T>
task to execute
task
,
final PrivilegedAccessHelper.CallableThrowableSupplier<E>
specific Throwable supplier
throwable
)

INTERNAL Executes provided PrivilegedExceptionCallable task using AccessController#doPrivileged(PrivilegedExceptionAction) when privileged access is enabled.

private static <T> Field
findDeclaredField(Class<T> javaClass, String fieldName)

Finding a field within a class potentially has to navigate through it's superclasses to eventually find the field.

private static <T> Method
findMethod(Class<T> javaClass, String methodName, Class<?>[] methodParameterTypes)

Finding a method within a class potentially has to navigate through it's superclasses to eventually find the method.

public static <T> Class<T>
getClassForName(final String className)

Execute a java Class.forName().

public static <T> Class<T>
getClassForName(final String className, final boolean initialize, final ClassLoader loader)

Execute a java Class.forName() wrap the call in a doPrivileged block if necessary.

public static ClassLoader
getClassLoaderForClass(final Class<?> clazz)

Gets the class loader for a given class.

public static <T> Constructor<T>
getConstructorFor(final Class<T>
The class to get the Constructor for
javaClass
,
final Class<?>[]
An array of classes representing the argument types of the constructor
args
,
final boolean
whether or not to call the setAccessible API
shouldSetAccessible
)

Get the public constructor for the given class and given arguments and wrap it in doPrivileged if necessary.

public static ClassLoader
getContextClassLoader(final Thread thread)

Get the context ClassLoader for a thread.

public static <T> Constructor<T>
getDeclaredConstructorFor(final Class<T>
The class to get the Constructor for
javaClass
,
final Class<?>[]
An array of classes representing the argument types of the constructor
args
,
final boolean
whether or not to call the setAccessible API
shouldSetAccessible
)

Get the constructor for the given class and given arguments (regardless of whether it is public or private))and wrap it in doPrivileged if necessary.

public static Field
getDeclaredField(final Class<?>
The class to get the field from
javaClass
,
final String
The name of the field
fieldName
,
final boolean
whether or not to call the setAccessible API
shouldSetAccessible
)

Get a field actually declared in a class and wrap the call in doPrivileged if necessary.

public static Field[]
getDeclaredFields(final Class<?>
the class to get the fields from.
clazz
)

Get the list of fields in a class.

public static Method
getDeclaredMethod(final Class<?>
the class to get the method from
clazz
,
final String
the name of the method to get
methodName
,
final Class<?>[]
a list of classes representing the classes of the parameters of the method.
methodParameterTypes
)

Return a method on a given class with the given method name and parameter types.

public static Method[]
getDeclaredMethods(final Class<?>
the class to get the methods from.
clazz
)

Get the list of methods in a class.

public static Field
getField(final Class<?>
The class to get the field from
javaClass
,
final String
The name of the field
fieldName
,
final boolean
whether or not to call the setAccessible API
shouldSetAccessible
)

Get a field in a class or its superclasses and wrap the call in doPrivileged if necessary.

public static Field[]
getFields(final Class<?>
the class to get the fields from.
clazz
)

Get the list of public fields in a class.

public static <T> Class<T>
getFieldType(final Field field)

Get the return type for a given method.

public static String

Returns:

The String containing the platform-appropriate characters for line separator.
getLineSeparator
()

INTERNAL: Get the line separator character.

public static Method
getMethod(final Class<?>
The class to get the method from
javaClass
,
final String
The name of the method to get
methodName
,
final Class<?>[]
A list of classes representing the classes of the parameters of the mthod
methodParameterTypes
,
final boolean
whether or not to call the setAccessible API
shouldSetAccessible
)

Get a method declared in the given class.

public static Class<?>[]
getMethodParameterTypes(final Method
The method to get the parameter types of
method
)

Get the list of parameter types for a given method.

public static <T> Class<T>
getMethodReturnType(final Method method)

Get the return type for a given method.

public static Method[]
getMethods(final Class<?>
the class to get the methods from.
clazz
)

Get the list of methods in a class.

public static Method
getPublicMethod(final Class<?>
The class to get the method from
javaClass
,
final String
The name of the method to get
methodName
,
final Class<?>[]
A list of classes representing the classes of the parameters of the method
methodParameterTypes
,
final boolean
whether or not to call the setAccessible API
shouldSetAccessible
)

Get a public method declared in the given class.

public static String

Returns:

The String value of the system property or null if property identified by key does not exist.
getSystemProperty
(final String
The name of the System property.
key
)

INTERNAL: Get the System property indicated by the specified key.

public static String

Returns:

The String value of the system property or def if property identified by key does not exist.
getSystemProperty
(final String
The name of the System property.
key
,
final String
The default value.
def
)

INTERNAL: Get the System property indicated by the specified key.

public static boolean

Returns:

true if the property value is "true" (case insensitive) or the property is not defined and def is true; false otherwise.
getSystemPropertyBoolean
(final String
The name of the System property.
key
,
final boolean
The default value.
def
)

INTERNAL: Get boolean value of the System property indicated by the specified key.

public static <T> T
getValueFromField(final Field field, final Object object)

Get the value of the given field in the given object.

public static <T> T
invokeConstructor(final Constructor<T> constructor, final Object[] args)

Construct an object with the given Constructor and the given array of arguments.

public static <T> T
invokeMethod(final Method method, final Object object)

Invoke the givenMethod on a givenObject.

public static <T> T
invokeMethod(final Method method, final Object object, final Object[] parameters)

Invoke the givenMethod on a givenObject using the array of parameters given.

private static boolean

Returns:

Value of true if getSystemProperty is allowed defaultUseDoPrivilegedValue override or false otherwise.
isExemptedProperty
(final String
The name of the System property.
key
)

Vet certain System properties as "safe" enough to override defaultUseDoPrivilegedValue setting.

private static boolean

Returns:

Value of true if getSystemProperty is allowed for this property key or false otherwise.
isIllegalProperty
(final String
The name of the System property.
key
)

Check if getSystemProperty is allowed for provided property key.

public static <T> T
newInstanceFromClass(final Class<T> clazz)

Get a new instance of a class using the default constructor.

public static void
setDefaultUseDoPrivilegedValue(boolean def)

INTERNAL It will be used to set default value of property "eclipselink.security.usedoprivileged" if not passed as system property.

public static void
setValueInField(final Field field, final Object object, final Object value)

Set the value of a given field in the given object with the value given.

public static boolean
shouldUsePrivilegedAccess()

This method checks to see if calls should be made to doPrivileged.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait