changeset 91:adfe30048234

8054367: More references for endpoints Reviewed-by: mkos
author aefimov
date Mon, 19 Jan 2015 07:50:48 +0000
parents 1555e63ddbfc
children 8f931f011036
files drop_included/jaxws_src/src/com/sun/tools/internal/xjc/model/nav/Utils.java drop_included/jaxws_src/src/com/sun/xml/internal/bind/api/Utils.java drop_included/jaxws_src/src/com/sun/xml/internal/bind/v2/model/impl/Utils.java drop_included/jaxws_src/src/com/sun/xml/internal/bind/v2/runtime/Utils.java drop_included/jaxws_src/src/com/sun/xml/internal/bind/v2/runtime/property/Utils.java drop_included/jaxws_src/src/com/sun/xml/internal/bind/v2/runtime/reflect/Utils.java drop_included/jaxws_src/src/com/sun/xml/internal/ws/model/Utils.java drop_included/jaxws_src/src/com/sun/xml/internal/ws/spi/ProviderImpl.java
diffstat 8 files changed, 84 insertions(+), 111 deletions(-) [+]
line wrap: on
line diff
--- a/drop_included/jaxws_src/src/com/sun/tools/internal/xjc/model/nav/Utils.java	Wed Apr 09 10:15:04 2014 -0400
+++ b/drop_included/jaxws_src/src/com/sun/tools/internal/xjc/model/nav/Utils.java	Mon Jan 19 07:50:48 2015 +0000
@@ -54,17 +54,21 @@
 
     static { // we statically initializing REFLECTION_NAVIGATOR property
         try {
-            Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
-            //noinspection unchecked
-            final Method getInstance = refNav.getDeclaredMethod("getInstance");
+            final Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
 
             // requires accessClassInPackage privilege
-            AccessController.doPrivileged(
-                    new PrivilegedAction<Object>() {
+            final Method getInstance = AccessController.doPrivileged(
+                    new PrivilegedAction<Method>() {
+
                         @Override
-                        public Object run() {
-                            getInstance.setAccessible(true);
-                            return null;
+                        public Method run() {
+                            try {
+                                Method getInstance = refNav.getDeclaredMethod("getInstance");
+                                getInstance.setAccessible(true);
+                                return getInstance;
+                            } catch (NoSuchMethodException e) {
+                                throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
+                            }
                         }
                     }
             );
@@ -72,16 +76,10 @@
             //noinspection unchecked
             REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null);
         } catch (ClassNotFoundException e) {
-            e.printStackTrace();
             throw new IllegalStateException("Can't find ReflectionNavigator class");
         } catch (InvocationTargetException e) {
-            e.printStackTrace();
             throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception");
-        } catch (NoSuchMethodException e) {
-            e.printStackTrace();
-            throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
         } catch (IllegalAccessException e) {
-            e.printStackTrace();
             throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible");
         } catch (SecurityException e) {
             LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e);
--- a/drop_included/jaxws_src/src/com/sun/xml/internal/bind/api/Utils.java	Wed Apr 09 10:15:04 2014 -0400
+++ b/drop_included/jaxws_src/src/com/sun/xml/internal/bind/api/Utils.java	Mon Jan 19 07:50:48 2015 +0000
@@ -54,17 +54,20 @@
 
     static { // we statically initializing REFLECTION_NAVIGATOR property
         try {
-            Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
-            //noinspection unchecked
-            final Method getInstance = refNav.getDeclaredMethod("getInstance");
+            final Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
 
             // requires accessClassInPackage privilege
-            AccessController.doPrivileged(
-                    new PrivilegedAction<Object>() {
+            final Method getInstance = AccessController.doPrivileged(
+                    new PrivilegedAction<Method>() {
                         @Override
-                        public Object run() {
-                            getInstance.setAccessible(true);
-                            return null;
+                        public Method run() {
+                            try {
+                                Method getInstance = refNav.getDeclaredMethod("getInstance");
+                                getInstance.setAccessible(true);
+                                return getInstance;
+                            } catch (NoSuchMethodException e) {
+                                throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
+                            }
                         }
                     }
             );
@@ -72,16 +75,10 @@
             //noinspection unchecked
             REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null);
         } catch (ClassNotFoundException e) {
-            e.printStackTrace();
             throw new IllegalStateException("Can't find ReflectionNavigator class");
         } catch (InvocationTargetException e) {
-            e.printStackTrace();
             throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception");
-        } catch (NoSuchMethodException e) {
-            e.printStackTrace();
-            throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
         } catch (IllegalAccessException e) {
-            e.printStackTrace();
             throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible");
         } catch (SecurityException e) {
             LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e);
--- a/drop_included/jaxws_src/src/com/sun/xml/internal/bind/v2/model/impl/Utils.java	Wed Apr 09 10:15:04 2014 -0400
+++ b/drop_included/jaxws_src/src/com/sun/xml/internal/bind/v2/model/impl/Utils.java	Mon Jan 19 07:50:48 2015 +0000
@@ -54,17 +54,20 @@
 
     static { // we statically initializing REFLECTION_NAVIGATOR property
         try {
-            Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
-            //noinspection unchecked
-            final Method getInstance = refNav.getDeclaredMethod("getInstance");
+            final Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
 
             // requires accessClassInPackage privilege
-            AccessController.doPrivileged(
-                    new PrivilegedAction<Object>() {
+            final Method getInstance = AccessController.doPrivileged(
+                    new PrivilegedAction<Method>() {
                         @Override
-                        public Object run() {
-                            getInstance.setAccessible(true);
-                            return null;
+                        public Method run() {
+                            try {
+                                Method getInstance = refNav.getDeclaredMethod("getInstance");
+                                getInstance.setAccessible(true);
+                                return getInstance;
+                            } catch (NoSuchMethodException e) {
+                                throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
+                            }
                         }
                     }
             );
@@ -72,16 +75,10 @@
             //noinspection unchecked
             REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null);
         } catch (ClassNotFoundException e) {
-            e.printStackTrace();
             throw new IllegalStateException("Can't find ReflectionNavigator class");
         } catch (InvocationTargetException e) {
-            e.printStackTrace();
             throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception");
-        } catch (NoSuchMethodException e) {
-            e.printStackTrace();
-            throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
         } catch (IllegalAccessException e) {
-            e.printStackTrace();
             throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible");
         } catch (SecurityException e) {
             LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e);
--- a/drop_included/jaxws_src/src/com/sun/xml/internal/bind/v2/runtime/Utils.java	Wed Apr 09 10:15:04 2014 -0400
+++ b/drop_included/jaxws_src/src/com/sun/xml/internal/bind/v2/runtime/Utils.java	Mon Jan 19 07:50:48 2015 +0000
@@ -54,17 +54,20 @@
 
     static { // we statically initializing REFLECTION_NAVIGATOR property
         try {
-            Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
-            //noinspection unchecked
-            final Method getInstance = refNav.getDeclaredMethod("getInstance");
+            final Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
 
             // requires accessClassInPackage privilege
-            AccessController.doPrivileged(
-                    new PrivilegedAction<Object>() {
+            final Method getInstance = AccessController.doPrivileged(
+                    new PrivilegedAction<Method>() {
                         @Override
-                        public Object run() {
-                            getInstance.setAccessible(true);
-                            return null;
+                        public Method run() {
+                            try {
+                                Method getInstance = refNav.getDeclaredMethod("getInstance");
+                                getInstance.setAccessible(true);
+                                return getInstance;
+                            } catch (NoSuchMethodException e) {
+                                throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
+                            }
                         }
                     }
             );
@@ -72,16 +75,10 @@
             //noinspection unchecked
             REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null);
         } catch (ClassNotFoundException e) {
-            e.printStackTrace();
             throw new IllegalStateException("Can't find ReflectionNavigator class");
         } catch (InvocationTargetException e) {
-            e.printStackTrace();
             throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception");
-        } catch (NoSuchMethodException e) {
-            e.printStackTrace();
-            throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
         } catch (IllegalAccessException e) {
-            e.printStackTrace();
             throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible");
         } catch (SecurityException e) {
             LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e);
--- a/drop_included/jaxws_src/src/com/sun/xml/internal/bind/v2/runtime/property/Utils.java	Wed Apr 09 10:15:04 2014 -0400
+++ b/drop_included/jaxws_src/src/com/sun/xml/internal/bind/v2/runtime/property/Utils.java	Mon Jan 19 07:50:48 2015 +0000
@@ -54,17 +54,20 @@
 
     static { // we statically initializing REFLECTION_NAVIGATOR property
         try {
-            Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
-            //noinspection unchecked
-            final Method getInstance = refNav.getDeclaredMethod("getInstance");
+            final Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
 
             // requires accessClassInPackage privilege
-            AccessController.doPrivileged(
-                    new PrivilegedAction<Object>() {
+            final Method getInstance = AccessController.doPrivileged(
+                    new PrivilegedAction<Method>() {
                         @Override
-                        public Object run() {
-                            getInstance.setAccessible(true);
-                            return null;
+                        public Method run() {
+                            try {
+                                Method getInstance = refNav.getDeclaredMethod("getInstance");
+                                getInstance.setAccessible(true);
+                                return getInstance;
+                            } catch (NoSuchMethodException e) {
+                                throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
+                            }
                         }
                     }
             );
@@ -72,16 +75,10 @@
             //noinspection unchecked
             REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null);
         } catch (ClassNotFoundException e) {
-            e.printStackTrace();
             throw new IllegalStateException("Can't find ReflectionNavigator class");
         } catch (InvocationTargetException e) {
-            e.printStackTrace();
             throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception");
-        } catch (NoSuchMethodException e) {
-            e.printStackTrace();
-            throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
         } catch (IllegalAccessException e) {
-            e.printStackTrace();
             throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible");
         } catch (SecurityException e) {
             LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e);
--- a/drop_included/jaxws_src/src/com/sun/xml/internal/bind/v2/runtime/reflect/Utils.java	Wed Apr 09 10:15:04 2014 -0400
+++ b/drop_included/jaxws_src/src/com/sun/xml/internal/bind/v2/runtime/reflect/Utils.java	Mon Jan 19 07:50:48 2015 +0000
@@ -54,17 +54,20 @@
 
     static { // we statically initializing REFLECTION_NAVIGATOR property
         try {
-            Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
-            //noinspection unchecked
-            final Method getInstance = refNav.getDeclaredMethod("getInstance");
+            final Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
 
             // requires accessClassInPackage privilege
-            AccessController.doPrivileged(
-                    new PrivilegedAction<Object>() {
+            final Method getInstance = AccessController.doPrivileged(
+                    new PrivilegedAction<Method>() {
                         @Override
-                        public Object run() {
-                            getInstance.setAccessible(true);
-                            return null;
+                        public Method run() {
+                            try {
+                                Method getInstance = refNav.getDeclaredMethod("getInstance");
+                                getInstance.setAccessible(true);
+                                return getInstance;
+                            } catch (NoSuchMethodException e) {
+                                throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
+                            }
                         }
                     }
             );
@@ -72,16 +75,10 @@
             //noinspection unchecked
             REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null);
         } catch (ClassNotFoundException e) {
-            e.printStackTrace();
             throw new IllegalStateException("Can't find ReflectionNavigator class");
         } catch (InvocationTargetException e) {
-            e.printStackTrace();
             throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception");
-        } catch (NoSuchMethodException e) {
-            e.printStackTrace();
-            throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
         } catch (IllegalAccessException e) {
-            e.printStackTrace();
             throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible");
         } catch (SecurityException e) {
             LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e);
--- a/drop_included/jaxws_src/src/com/sun/xml/internal/ws/model/Utils.java	Wed Apr 09 10:15:04 2014 -0400
+++ b/drop_included/jaxws_src/src/com/sun/xml/internal/ws/model/Utils.java	Mon Jan 19 07:50:48 2015 +0000
@@ -54,17 +54,20 @@
 
     static { // we statically initializing REFLECTION_NAVIGATOR property
         try {
-            Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
-            //noinspection unchecked
-            final Method getInstance = refNav.getDeclaredMethod("getInstance");
+            final Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
 
             // requires accessClassInPackage privilege
-            AccessController.doPrivileged(
-                    new PrivilegedAction<Object>() {
+            final Method getInstance = AccessController.doPrivileged(
+                    new PrivilegedAction<Method>() {
                         @Override
-                        public Object run() {
-                            getInstance.setAccessible(true);
-                            return null;
+                        public Method run() {
+                            try {
+                                Method getInstance = refNav.getDeclaredMethod("getInstance");
+                                getInstance.setAccessible(true);
+                                return getInstance;
+                            } catch (NoSuchMethodException e) {
+                                throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
+                            }
                         }
                     }
             );
@@ -72,16 +75,10 @@
             //noinspection unchecked
             REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null);
         } catch (ClassNotFoundException e) {
-            e.printStackTrace();
             throw new IllegalStateException("Can't find ReflectionNavigator class");
         } catch (InvocationTargetException e) {
-            e.printStackTrace();
             throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception");
-        } catch (NoSuchMethodException e) {
-            e.printStackTrace();
-            throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
         } catch (IllegalAccessException e) {
-            e.printStackTrace();
             throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible");
         } catch (SecurityException e) {
             LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e);
--- a/drop_included/jaxws_src/src/com/sun/xml/internal/ws/spi/ProviderImpl.java	Wed Apr 09 10:15:04 2014 -0400
+++ b/drop_included/jaxws_src/src/com/sun/xml/internal/ws/spi/ProviderImpl.java	Mon Jan 19 07:50:48 2015 +0000
@@ -109,19 +109,12 @@
     }
 
     public EndpointReference readEndpointReference(final Source eprInfoset) {
-        // EPR constructors are private, so we need privilege escalation.
-        // this unmarshalling can only access instances of a fixed, known set of classes,
-        // so doing that shouldn't introduce security vulnerability.
-        return AccessController.doPrivileged(new PrivilegedAction<EndpointReference>() {
-            public EndpointReference run() {
-                try {
-                    Unmarshaller unmarshaller = eprjc.get().createUnmarshaller();
-                    return (EndpointReference) unmarshaller.unmarshal(eprInfoset);
-                } catch (JAXBException e) {
-                    throw new WebServiceException("Error creating Marshaller or marshalling.", e);
-                }
-            }
-        });
+        try {
+            Unmarshaller unmarshaller = eprjc.get().createUnmarshaller();
+            return (EndpointReference) unmarshaller.unmarshal(eprInfoset);
+        } catch (JAXBException e) {
+            throw new WebServiceException("Error creating Marshaller or marshalling.", e);
+        }
     }
 
     public <T> T getPort(EndpointReference endpointReference, Class<T> clazz, WebServiceFeature... webServiceFeatures) {