Author: markt Date: Tue Dec 9 10:29:51 2014 New Revision: 1644017 URL: http://svn.apache.org/r1644017 Log: Fix potential issue with BeanELresolver when running under a security manager. Some classes may not be accessible but may have accessible interfaces.
Modified: tomcat/trunk/java/javax/el/BeanELResolver.java Modified: tomcat/trunk/java/javax/el/BeanELResolver.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/BeanELResolver.java?rev=1644017&r1=1644016&r2=1644017&view=diff ============================================================================== --- tomcat/trunk/java/javax/el/BeanELResolver.java (original) +++ tomcat/trunk/java/javax/el/BeanELResolver.java Tue Dec 9 10:29:51 2014 @@ -229,15 +229,39 @@ public class BeanELResolver extends ELRe try { BeanInfo info = Introspector.getBeanInfo(this.type); PropertyDescriptor[] pds = info.getPropertyDescriptors(); - for (int i = 0; i < pds.length; i++) { - this.properties.put(pds[i].getName(), new BeanProperty( - type, pds[i])); + for (PropertyDescriptor pd: pds) { + this.properties.put(pd.getName(), new BeanProperty(type, pd)); + } + if (System.getSecurityManager() != null) { + // When running with SecurityManager, some classes may be + // not accessible, but have accessible interfaces. + populateFromInterfaces(type); } } catch (IntrospectionException ie) { throw new ELException(ie); } } + private void populateFromInterfaces(Class<?> aClass) throws IntrospectionException { + Class<?> interfaces[] = aClass.getInterfaces(); + if (interfaces.length > 0) { + for (Class<?> ifs : interfaces) { + BeanInfo info = Introspector.getBeanInfo(ifs); + PropertyDescriptor[] pds = info.getPropertyDescriptors(); + for (PropertyDescriptor pd : pds) { + if (!this.properties.containsKey(pd.getName())) { + this.properties.put(pd.getName(), new BeanProperty( + this.type, pd)); + } + } + } + } + Class<?> superclass = aClass.getSuperclass(); + if (superclass != null) { + populateFromInterfaces(superclass); + } + } + private BeanProperty get(ELContext ctx, String name) { BeanProperty property = this.properties.get(name); if (property == null) { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org