andymc12 closed pull request #325: [CXF-7537] Use doPriv when calling methods 
needing Java 2 permissions
URL: https://github.com/apache/cxf/pull/325
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java 
b/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
index 45a4dc79ade..0ef7a2438ab 100644
--- a/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
+++ b/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
@@ -566,7 +566,7 @@ public void setCipherTransformation(String 
cipherTransformation) {
 
     public static void setDefaultMaxSize(long l) {
         if (l == -1) {
-            String s = 
System.getProperty("org.apache.cxf.io.CachedOutputStream.MaxSize",
+            String s = 
SystemPropertyAction.getProperty("org.apache.cxf.io.CachedOutputStream.MaxSize",
                     "-1");
             l = Long.parseLong(s);
         }
diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
index 39da136c75b..90c4d95ae25 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
@@ -29,6 +29,8 @@
 import java.lang.reflect.Type;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -131,7 +133,15 @@
     }
 
     private ResourceUtils() {
+    }
 
+    private static Method[] getDeclaredMethods(final Class<?> c) {
+        return AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
+            @Override
+            public Method[] run() {
+                return c.getDeclaredMethods();
+            }
+        });
     }
     public static Method findPostConstructMethod(Class<?> c) {
         return findPostConstructMethod(c, null);
@@ -140,7 +150,7 @@ public static Method findPostConstructMethod(Class<?> c, 
String name) {
         if (Object.class == c || null == c) {
             return null;
         }
-        for (Method m : c.getDeclaredMethods()) {
+        for (Method m : getDeclaredMethods(c)) {
             if (name != null) {
                 if (m.getName().equals(name)) {
                     return m;
@@ -170,7 +180,7 @@ public static Method findPreDestroyMethod(Class<?> c, 
String name) {
         if (Object.class == c || null == c) {
             return null;
         }
-        for (Method m : c.getDeclaredMethods()) {
+        for (Method m : getDeclaredMethods(c)) {
             if (name != null) {
                 if (m.getName().equals(name)) {
                     return m;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to