You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2007/11/05 19:56:31 UTC
svn commit: r592117 - in /webservices/axis2/trunk/java/modules:
jaxws/src/org/apache/axis2/jaxws/runtime/description/injection/impl/
jaxws/src/org/apache/axis2/jaxws/utility/
metadata/src/org/apache/axis2/jaxws/description/builder/converter/
metadata/s...
Author: scheu
Date: Mon Nov 5 10:56:27 2007
New Revision: 592117
URL: http://svn.apache.org/viewvc?rev=592117&view=rev
Log:
AXIS2-3323
Contributor:Rich Scheuerle
Surround getAnnotation calls with java 2 security doPriv statements.
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/injection/impl/ResourceInjectionServiceRuntimeDescriptionBuilder.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/utility/ClassUtils.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/utility/XMLRootElementUtil.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/ConverterUtils.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/injection/impl/ResourceInjectionServiceRuntimeDescriptionBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/injection/impl/ResourceInjectionServiceRuntimeDescriptionBuilder.java?rev=592117&r1=592116&r2=592117&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/injection/impl/ResourceInjectionServiceRuntimeDescriptionBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/injection/impl/ResourceInjectionServiceRuntimeDescriptionBuilder.java Mon Nov 5 10:56:27 2007
@@ -25,6 +25,9 @@
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.security.PrivilegedAction;
@@ -73,13 +76,13 @@
// Getting this information is expensive, but fortunately is cached.
List<Field> fields = getFields(implClass);
for (Field field : fields) {
- if (field.getAnnotation(Resource.class) != null) {
+ if (getAnnotation(field,Resource.class) != null) {
return true;
}
}
List<Method> methods = getMethods(implClass);
for (Method method : methods) {
- if (method.getAnnotation(Resource.class) != null) {
+ if (getAnnotation(method,Resource.class) != null) {
return true;
}
}
@@ -90,7 +93,7 @@
static private Method getPostConstructMethod(Class implClass) {
List<Method> methods = getMethods(implClass);
for (Method method : methods) {
- if (method.getAnnotation(PostConstruct.class) != null) {
+ if (getAnnotation(method,PostConstruct.class) != null) {
return method;
}
}
@@ -100,7 +103,7 @@
static private Method getPreDestroyMethod(Class implClass) {
List<Method> methods = getMethods(implClass);
for (Method method : methods) {
- if (method.getAnnotation(PreDestroy.class) != null) {
+ if (getAnnotation(method,PreDestroy.class) != null) {
return method;
}
}
@@ -163,5 +166,19 @@
);
return methods;
+ }
+
+ /**
+ * Get an annotation. This is wrappered to avoid a Java2Security violation.
+ * @param cls Class that contains annotation
+ * @param annotation Class of requrested Annotation
+ * @return annotation or null
+ */
+ private static Annotation getAnnotation(final AnnotatedElement element, final Class annotation) {
+ return (Annotation) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return element.getAnnotation(annotation);
+ }
+ });
}
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/utility/ClassUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/utility/ClassUtils.java?rev=592117&r1=592116&r2=592117&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/utility/ClassUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/utility/ClassUtils.java Mon Nov 5 10:56:27 2007
@@ -18,6 +18,7 @@
*/
package org.apache.axis2.jaxws.utility;
+import org.apache.axis2.java.security.AccessController;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -27,8 +28,12 @@
import javax.xml.ws.WebFault;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceProvider;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.security.PrivilegedAction;
import java.util.HashMap;
/** Contains static Class utility methods related to method parameter/argument marshalling. */
@@ -245,25 +250,26 @@
// Or the class is in the jaxws.xml.ws package
// Check for Impl
- WebService wsAnn = (WebService)cls.getAnnotation(WebService.class);
+ WebService wsAnn = (WebService)getAnnotation(cls,WebService.class);
if (wsAnn != null) {
return true;
}
// Check for service
- WebServiceClient wscAnn = (WebServiceClient)cls.getAnnotation(WebServiceClient.class);
+ WebServiceClient wscAnn = (WebServiceClient)getAnnotation(cls,WebServiceClient.class);
if (wscAnn != null) {
return true;
}
// Check for provider
- WebServiceProvider wspAnn = (WebServiceProvider)cls.getAnnotation(WebServiceProvider.class);
+ WebServiceProvider wspAnn = (WebServiceProvider)
+ getAnnotation(cls,WebServiceProvider.class);
if (wspAnn != null) {
return true;
}
// Check for Exception
- WebFault wfAnn = (WebFault)cls.getAnnotation(WebFault.class);
+ WebFault wfAnn = (WebFault)getAnnotation(cls,WebFault.class);
if (wfAnn != null) {
return true;
}
@@ -283,6 +289,18 @@
}
return false;
}
-
+ /**
+ * Get an annotation. This is wrappered to avoid a Java2Security violation.
+ * @param cls Class that contains annotation
+ * @param annotation Class of requrested Annotation
+ * @return annotation or null
+ */
+ private static Annotation getAnnotation(final AnnotatedElement element, final Class annotation) {
+ return (Annotation) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return element.getAnnotation(annotation);
+ }
+ });
+ }
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/utility/XMLRootElementUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/utility/XMLRootElementUtil.java?rev=592117&r1=592116&r2=592117&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/utility/XMLRootElementUtil.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/utility/XMLRootElementUtil.java Mon Nov 5 10:56:27 2007
@@ -31,6 +31,8 @@
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Field;
import java.security.PrivilegedAction;
import java.util.ArrayList;
@@ -75,7 +77,8 @@
public static QName getXmlRootElementQName(Class clazz) {
// See if the object represents a root element
- XmlRootElement root = (XmlRootElement)clazz.getAnnotation(XmlRootElement.class);
+ XmlRootElement root = (XmlRootElement)
+ getAnnotation(clazz,XmlRootElement.class);
if (root == null) {
return null;
}
@@ -91,7 +94,8 @@
// The namespace may need to be defaulted
if (namespace == null || namespace.length() == 0 || namespace.equals("##default")) {
Package pkg = clazz.getPackage();
- XmlSchema schema = (XmlSchema)pkg.getAnnotation(XmlSchema.class);
+ XmlSchema schema = (XmlSchema)
+ getAnnotation(pkg, XmlSchema.class);
if (schema != null) {
namespace = schema.namespace();
} else {
@@ -114,7 +118,7 @@
f.setAccessible(true);
- XmlEnumValue xev = f.getAnnotation(XmlEnumValue.class);
+ XmlEnumValue xev = (XmlEnumValue) getAnnotation(f, XmlEnumValue.class);
if (xev == null){
value = f.getName();
} else {
@@ -296,7 +300,8 @@
*/
private static String getXmlElementName(Class jaxbClass, Field field)
throws NoSuchFieldException {
- XmlElement xmlElement = field.getAnnotation(XmlElement.class);
+ XmlElement xmlElement = (XmlElement)
+ getAnnotation(field,XmlElement.class);
// If XmlElement does not exist, default to using the field name
if (xmlElement == null ||
@@ -307,5 +312,17 @@
}
-
+ /**
+ * Get an annotation. This is wrappered to avoid a Java2Security violation.
+ * @param cls Class that contains annotation
+ * @param annotation Class of requrested Annotation
+ * @return annotation or null
+ */
+ private static Annotation getAnnotation(final AnnotatedElement element, final Class annotation) {
+ return (Annotation) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return element.getAnnotation(annotation);
+ }
+ });
+ }
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/ConverterUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/ConverterUtils.java?rev=592117&r1=592116&r2=592117&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/ConverterUtils.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/ConverterUtils.java Mon Nov 5 10:56:27 2007
@@ -18,6 +18,7 @@
*/
package org.apache.axis2.jaxws.description.builder.converter;
+import org.apache.axis2.java.security.AccessController;
import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
import org.apache.axis2.jaxws.description.builder.FieldDescriptionComposite;
import org.apache.axis2.jaxws.description.builder.HandlerChainAnnot;
@@ -39,6 +40,7 @@
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.WildcardType;
+import java.security.PrivilegedAction;
import java.util.List;
public class ConverterUtils {
@@ -51,9 +53,13 @@
* the annotation (i.e. Class, Method, Field)
* @return - <code>Annotation</code> annotation represented by the given <code>Class</code>
*/
- public static Annotation getAnnotation(Class annotationClass, AnnotatedElement element) {
- return element.getAnnotation(annotationClass);
- }
+ public static Annotation getAnnotation(final Class annotationClass, final AnnotatedElement element) {
+ return (Annotation) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return element.getAnnotation(annotationClass);
+ }
+ });
+ }
/**
* This is a helper method to create a <code>HandlerChainAnnot</code> since the
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java?rev=592117&r1=592116&r2=592117&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java Mon Nov 5 10:56:27 2007
@@ -19,6 +19,7 @@
package org.apache.axis2.jaxws.description.impl;
import java.io.InputStream;
+import java.lang.annotation.Annotation;
import java.net.URL;
import java.security.PrivilegedAction;
import java.util.ArrayList;
@@ -201,9 +202,9 @@
// REVIEW: setting these should probably be done in the getters! It needs to be done before we try to select a
// port to use if one wasn't specified because we'll try to get to the annotations to get the PortType
if (this.implOrSEIClass != null) {
- webServiceAnnotation = (WebService)implOrSEIClass.getAnnotation(WebService.class);
+ webServiceAnnotation = (WebService)getAnnotation(implOrSEIClass,WebService.class);
webServiceProviderAnnotation =
- (WebServiceProvider)implOrSEIClass.getAnnotation(WebServiceProvider.class);
+ (WebServiceProvider)getAnnotation(implOrSEIClass,WebServiceProvider.class);
}
this.isDynamicPort = dynamicPort;
if (DescriptionUtils.isEmpty(portName)) {
@@ -533,9 +534,9 @@
if (!getServiceDescriptionImpl().isDBCMap()) {
- webServiceAnnotation = (WebService)implOrSEIClass.getAnnotation(WebService.class);
+ webServiceAnnotation = (WebService)getAnnotation(implOrSEIClass,WebService.class);
webServiceProviderAnnotation =
- (WebServiceProvider)implOrSEIClass.getAnnotation(WebServiceProvider.class);
+ (WebServiceProvider)getAnnotation(implOrSEIClass,WebServiceProvider.class);
if (webServiceAnnotation == null && webServiceProviderAnnotation == null)
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("endpointDescriptionErr6",implOrSEIClass.getName()));
@@ -1205,7 +1206,7 @@
} else {
if (implOrSEIClass != null) {
serviceModeAnnotation =
- (ServiceMode)implOrSEIClass.getAnnotation(ServiceMode.class);
+ (ServiceMode)getAnnotation(implOrSEIClass,ServiceMode.class);
}
}
}
@@ -1240,7 +1241,7 @@
} else {
if (implOrSEIClass != null) {
bindingTypeAnnotation =
- (BindingType)implOrSEIClass.getAnnotation(BindingType.class);
+ (BindingType)getAnnotation(implOrSEIClass,BindingType.class);
}
}
}
@@ -1348,7 +1349,7 @@
} else {
if (implOrSEIClass != null) {
handlerChainAnnotation =
- (HandlerChain)implOrSEIClass.getAnnotation(HandlerChain.class);
+ (HandlerChain)getAnnotation(implOrSEIClass,HandlerChain.class);
}
}
}
@@ -1736,6 +1737,20 @@
return string.toString();
}
return string.toString();
+ }
+
+ /**
+ * Get an annotation. This is wrappered to avoid a Java2Security violation.
+ * @param cls Class that contains annotation
+ * @param annotation Class of requrested Annotation
+ * @return annotation or null
+ */
+ private static Annotation getAnnotation(final Class cls, final Class annotation) {
+ return (Annotation) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return cls.getAnnotation(annotation);
+ }
+ });
}
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java?rev=592117&r1=592116&r2=592117&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java Mon Nov 5 10:56:27 2007
@@ -24,6 +24,7 @@
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.AxisOperationFactory;
import org.apache.axis2.description.AxisService;
+import org.apache.axis2.java.security.AccessController;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.description.EndpointDescription;
import org.apache.axis2.jaxws.description.EndpointInterfaceDescription;
@@ -44,8 +45,11 @@
import javax.wsdl.Definition;
import javax.wsdl.PortType;
import javax.xml.namespace.QName;
+
+import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -548,7 +552,8 @@
soapBindingAnnotation = dbc.getSoapBindingAnnot();
} else {
if (seiClass != null) {
- soapBindingAnnotation = (SOAPBinding)seiClass.getAnnotation(SOAPBinding.class);
+ soapBindingAnnotation =
+ (SOAPBinding)getAnnotation(seiClass,SOAPBinding.class);
}
}
}
@@ -919,7 +924,7 @@
webServiceAnnotation = dbc.getWebServiceAnnot();
} else {
if (seiClass != null) {
- webServiceAnnotation = (WebService)seiClass.getAnnotation(WebService.class);
+ webServiceAnnotation = (WebService)getAnnotation(seiClass,WebService.class);
}
}
}
@@ -1012,5 +1017,17 @@
}
return string.toString();
}
-
+ /**
+ * Get an annotation. This is wrappered to avoid a Java2Security violation.
+ * @param cls Class that contains annotation
+ * @param annotation Class of requrested Annotation
+ * @return annotation or null
+ */
+ private static Annotation getAnnotation(final Class cls, final Class annotation) {
+ return (Annotation) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return cls.getAnnotation(annotation);
+ }
+ });
+ }
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java?rev=592117&r1=592116&r2=592117&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java Mon Nov 5 10:56:27 2007
@@ -28,6 +28,7 @@
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.java.security.AccessController;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.description.AttachmentDescription;
import org.apache.axis2.jaxws.description.AttachmentType;
@@ -73,10 +74,12 @@
import java.io.File;
import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.net.URL;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -551,7 +554,8 @@
new UnsupportedOperationException(Messages.getMessage("seiMethodErr")));
} else {
seiMethod = method;
- webMethodAnnotation = seiMethod.getAnnotation(WebMethod.class);
+ webMethodAnnotation = (WebMethod)
+ getAnnotation(seiMethod, WebMethod.class);
parameterDescriptions = createParameterDescriptions();
faultDescriptions = createFaultDescriptions();
}
@@ -773,7 +777,7 @@
return null;
}
- WebMethod wmAnnotation = javaMethod.getAnnotation(WebMethod.class);
+ WebMethod wmAnnotation = (WebMethod) getAnnotation(javaMethod,WebMethod.class);
// Per JSR-181 MR Sec 4.2 "Annotation: javax.jws.WebMethod" pg 17,
// if @WebMethod specifies and operation name, use that. Otherwise
// default is the Java method name
@@ -906,7 +910,8 @@
public RequestWrapper getAnnoRequestWrapper() {
if (requestWrapperAnnotation == null) {
if (!isDBC() && seiMethod != null) {
- requestWrapperAnnotation = seiMethod.getAnnotation(RequestWrapper.class);
+ requestWrapperAnnotation = (RequestWrapper)
+ getAnnotation(seiMethod,RequestWrapper.class);
} else if (isDBC() && methodComposite != null) {
requestWrapperAnnotation = methodComposite.getRequestWrapperAnnot();
} else {
@@ -1012,7 +1017,8 @@
public ResponseWrapper getAnnoResponseWrapper() {
if (responseWrapperAnnotation == null) {
if (!isDBC() && seiMethod != null) {
- responseWrapperAnnotation = seiMethod.getAnnotation(ResponseWrapper.class);
+ responseWrapperAnnotation = (ResponseWrapper)
+ getAnnotation(seiMethod,ResponseWrapper.class);
} else if (isDBC() && methodComposite != null) {
responseWrapperAnnotation = methodComposite.getResponseWrapperAnnot();
} else {
@@ -1238,7 +1244,8 @@
public WebResult getAnnoWebResult() {
if (webResultAnnotation == null) {
if (!isDBC() && seiMethod != null) {
- webResultAnnotation = seiMethod.getAnnotation(WebResult.class);
+ webResultAnnotation = (WebResult)
+ getAnnotation(seiMethod,WebResult.class);
} else if (methodComposite != null) {
webResultAnnotation = methodComposite.getWebResultAnnot();
} else {
@@ -1380,7 +1387,8 @@
// JSR-181 Sec 4.7 p. 28
if (soapBindingAnnotation == null) {
if (!isDBC() && seiMethod != null) {
- soapBindingAnnotation = seiMethod.getAnnotation(SOAPBinding.class);
+ soapBindingAnnotation = (SOAPBinding)
+ getAnnotation(seiMethod,SOAPBinding.class);
} else if (isDBC() && methodComposite != null) {
soapBindingAnnotation = methodComposite.getSoapBindingAnnot();
} else {
@@ -1458,7 +1466,7 @@
onewayAnnotation = OneWayAnnot.createOneWayAnnotImpl();
}
} else if (!isDBC() && seiMethod != null) {
- onewayAnnotation = seiMethod.getAnnotation(Oneway.class);
+ onewayAnnotation = (Oneway) getAnnotation(seiMethod,Oneway.class);
} else {
if (log.isDebugEnabled()) {
log.debug("Unable to get OneWay annotation");
@@ -2113,5 +2121,17 @@
}
}
}
-
+ /**
+ * Get an annotation. This is wrappered to avoid a Java2Security violation.
+ * @param cls Class that contains annotation
+ * @param annotation Class of requrested Annotation
+ * @return annotation or null
+ */
+ private static Annotation getAnnotation(final AnnotatedElement element, final Class annotation) {
+ return (Annotation) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return element.getAnnotation(annotation);
+ }
+ });
+ }
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java?rev=592117&r1=592116&r2=592117&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java Mon Nov 5 10:56:27 2007
@@ -24,6 +24,7 @@
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.AxisService;
+import org.apache.axis2.java.security.AccessController;
import org.apache.axis2.jaxws.ClientConfigurationFactory;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.description.DescriptionFactory;
@@ -60,9 +61,11 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.annotation.Annotation;
import java.net.ConnectException;
import java.net.URL;
import java.net.UnknownHostException;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -1428,7 +1431,7 @@
if (this.handlerChainAnnotation == null) {
if (serviceClass != null) {
handlerChainAnnotation =
- (HandlerChain) serviceClass.getAnnotation(HandlerChain.class);
+ (HandlerChain) getAnnotation(serviceClass, HandlerChain.class);
}
}
@@ -1628,5 +1631,18 @@
}
return string.toString();
+ }
+ /**
+ * Get an annotation. This is wrappered to avoid a Java2Security violation.
+ * @param cls Class that contains annotation
+ * @param annotation Class of requrested Annotation
+ * @return annotation or null
+ */
+ private static Annotation getAnnotation(final Class cls, final Class annotation) {
+ return (Annotation) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return cls.getAnnotation(annotation);
+ }
+ });
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org