/** * Get an iterator from the given object. Since the superclass method * this secure version checks for execute permission. * * @param obj object to iterate over * @param i line, column, template info * @return Iterator for object */ public Iterator getIterator(Object obj, Info i) { if (obj != null) { SecureIntrospectorControl sic = (SecureIntrospectorControl)introspector; if (sic.checkObjectExecutePermission(obj.getClass(), null)) { return super.getIterator(obj, i); } else { log.warn("Cannot retrieve iterator from {} due to security restrictions.", obj.getClass().getName()); } } return null; } }
/** * @param runtimeLogger * @deprecated Use setLog(Log log) instead. */ public void setRuntimeLogger(RuntimeLogger runtimeLogger) { // in the off chance anyone still uses this method // directly, use this hack to keep it working setLog(new RuntimeLoggerLog(runtimeLogger)); }
/** * Property setter - returns VelPropertySet appropos for #set($foo.bar = "geir"). * <br /> * First tries the regular routine. If a setter was not found, * returns a {@link VelPropertySet} that sets to public fields. * * @param obj the object * @param identifier the name of the property * @param arg the value to set to the property * @param i a bunch of information. * @return a valid <code>VelPropertySet</code>, if it was found. * @throws Exception failed to create a valid <code>VelPropertySet</code>. */ public VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info i) throws Exception { VelPropertySet setter = super.getPropertySet(obj, identifier, arg, i); if (setter != null) { return setter; } Field field = obj.getClass().getField(identifier); if (field != null) { return new PublicFieldSetter(field); } return null; }
VelPropertyGet getter = super.getPropertyGet(obj, identifier, i);
if (m != null) return new VelMethodImpl(m, false, getNeededConverters(m.getParameterTypes(), args)); return new VelMethodImpl(m, true, getNeededConverters(m.getParameterTypes(), args)); if (m != null) return new VelMethodImpl(m, false, getNeededConverters(m.getParameterTypes(), args));
new AnnotationPreservingInvocationHandler(value, implementedInterfaceMethods.getMethods())); VelMethod proxiedMethod = super.getMethod(proxiedObject, velMethod.getMethodName(), unboxedArgs, info); if (proxiedMethod == null) {
/** * Get a property getting strategy that will box the end result with any return value annotations on the property getter * * @param obj Object on which a property is being retrieved * @param identifier Property identifier * @param info Current template info * @return A return value boxing property getter */ @Override public final VelPropertyGet getPropertyGet(Object obj, String identifier, Info info) throws Exception { final AnnotatedValueHelper valueHelper = AnnotatedValueHelperFactory.getValueHelper(obj, CLASS_RESOLVER); VelPropertyGet getter = super.getPropertyGet(valueHelper.unbox(), identifier, info); if (getter == null) { return null; } log.debug("Getting introspector method for getter: {}", getter.getMethodName()); Method refMethod = lookupMethod(getter.getMethodName(), valueHelper, EMPTY_ARRAY, info); log.debug("got method: {}", refMethod); if (refMethod == null) { return getter; } Collection<Annotation> annotations = getMethodAnnotations(refMethod); log.debug("Got return annotations: {}", annotations); if (annotations.isEmpty()) { return getter; } return new AnnotationBoxingPropertyGet(getter, annotations); }
/** * Get an iterator responsible for preserving annotations while iterating over a collection that has collection * inheritable return value annotations.' * * @param obj object to get an iterator for * @param info current template info * @return Inheritable annotation preserving iterator */ @Override public final Iterator<?> getIterator(Object obj, Info info) throws Exception { if (!(obj instanceof AnnotatedValue)) { return super.getIterator(obj, info); } AnnotatedValue<?> annotatedValue = (AnnotatedValue<?>) obj; Iterator<?> iterator = super.getIterator(annotatedValue.unbox(), info); if (iterator == null) { return null; } Collection<Annotation> inheritedAnnotations = annotatedValue.getCollectionInheritableAnnotations(); if (inheritedAnnotations.isEmpty()) { return iterator; } return new AnnotatedValueIterator<>(iterator, inheritedAnnotations); }
/** * Return a method that knows how to unbox method call targets and parameters and to box return values * according to the return value boxing policy. * * @param obj Object to locate the method on * @param methodName Name of the method to locate * @param args Method call arguments * @param info Current template info * @return Method calling strategy that will transparently handle boxed arguments and targets while automatically * boxing method return values with return value annotations. */ @Override public final VelMethod getMethod(Object obj, String methodName, Object[] args, Info info) throws Exception { final AnnotatedValueHelper valueHelper = AnnotatedValueHelperFactory.getValueHelper(obj, CLASS_RESOLVER); final Object[] unboxedArgs = BoxingUtils.unboxArrayElements(args); VelMethod method = super.getMethod(valueHelper.unbox(), methodName, unboxedArgs, info); if (method == null) { return null; } method = checkAndGenerateAnnotationPreservingProxy(valueHelper, method, unboxedArgs, info); Method refMethod = lookupMethod(methodName, valueHelper, unboxedArgs, info); Collection<Annotation> returnValueAnnotations = getMethodAnnotations(refMethod); if (!returnValueAnnotations.isEmpty()) { method = new AnnotationBoxingMethod(method, returnValueAnnotations); } return new UnboxingMethod(method); }
/** * @param runtimeLogger * @deprecated Use setLog(Log log) instead. */ public void setRuntimeLogger(RuntimeLogger runtimeLogger) { // in the off chance anyone still uses this method // directly, use this hack to keep it working setLog(new RuntimeLoggerLog(runtimeLogger)); }
/** * Get an iterator from the given object. Since the superclass method * this secure version checks for execute permission. * * @param obj object to iterate over * @param i line, column, template info * @return Iterator for object */ public Iterator getIterator(Object obj, Info i) throws Exception { if (obj != null) { SecureIntrospectorControl sic = (SecureIntrospectorControl)introspector; if (sic.checkObjectExecutePermission(obj.getClass(), null)) { return super.getIterator(obj, i); } else { log.warn("Cannot retrieve iterator from " + obj.getClass() + " due to security restrictions."); } } return null; }
/** * Get an iterator from the given object. Since the superclass method this secure version checks for execute * permission. * * @param obj object to iterate over * @param i line, column, template info * @return Iterator for object * @throws Exception when failing to get iterator */ @Override public Iterator getIterator(Object obj, Info i) throws Exception { if (obj != null) { SecureIntrospectorControl sic = (SecureIntrospectorControl) this.introspector; if (sic.checkObjectExecutePermission(obj.getClass(), null)) { return super.getIterator(obj, i); } else { this.log.warn("Cannot retrieve iterator from " + obj.getClass() + " due to security restrictions."); } } return null; }
/** * Get an iterator from the given object. Since the superclass method * this secure version checks for execute permission. * * @param obj object to iterate over * @param i line, column, template info * @return Iterator for object * @throws Exception */ public Iterator getIterator(Object obj, Info i) throws Exception { if (obj != null) { SecureIntrospectorControl sic = (SecureIntrospectorControl)introspector; if (sic.checkObjectExecutePermission(obj.getClass(), null)) { return super.getIterator(obj, i); } else { log.warn("Cannot retrieve iterator from " + obj.getClass() + " due to security restrictions."); } } return null; }