mirror of https://github.com/apache/poi.git
Add security check
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1713917 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
01f4f63401
commit
9d89cc817c
|
@ -79,6 +79,7 @@ public class POITestCase {
|
||||||
* Only use this method in test cases!!!
|
* Only use this method in test cases!!!
|
||||||
*/
|
*/
|
||||||
public static <R,T> R getFieldValue(final Class<? super T> clazz, final T instance, final Class<R> fieldType, final String fieldName) {
|
public static <R,T> R getFieldValue(final Class<? super T> clazz, final T instance, final Class<R> fieldType, final String fieldName) {
|
||||||
|
assertTrue("Reflection of private fields is only allowed for POI classes.", clazz.getName().startsWith("org.apache.poi."));
|
||||||
try {
|
try {
|
||||||
return AccessController.doPrivileged(new PrivilegedExceptionAction<R>() {
|
return AccessController.doPrivileged(new PrivilegedExceptionAction<R>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,6 +101,7 @@ public class POITestCase {
|
||||||
*/
|
*/
|
||||||
public static <R,T> R callMethod(final Class<? super T> clazz, final T instance, final Class<R> returnType, final String methodName,
|
public static <R,T> R callMethod(final Class<? super T> clazz, final T instance, final Class<R> returnType, final String methodName,
|
||||||
final Class<?>[] parameterTypes, final Object[] parameters) {
|
final Class<?>[] parameterTypes, final Object[] parameters) {
|
||||||
|
assertTrue("Reflection of private methods is only allowed for POI classes.", clazz.getName().startsWith("org.apache.poi."));
|
||||||
try {
|
try {
|
||||||
return AccessController.doPrivileged(new PrivilegedExceptionAction<R>() {
|
return AccessController.doPrivileged(new PrivilegedExceptionAction<R>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue