private static Object getContextProperty( final String propertyName, final Map<String, Object> context, final Object target) throws OgnlException { if (OGNLContextPropertyAccessor.REQUEST_PARAMETERS_RESTRICTED_VARIABLE_NAME.equals(propertyName) && context != null && context.containsKey(OGNLContextPropertyAccessor.RESTRICT_REQUEST_PARAMETERS)) { throw new OgnlException( "Access to variable \"" + propertyName + "\" is forbidden in this context. Note some restrictions apply to " + "variable access. For example, accessing request parameters is forbidden in preprocessing and " + "unescaped expressions, and also in fragment inclusion specifications."); } // 'execInfo' translation from context variable to expression object - deprecated and to be removed in 3.1 if ("execInfo".equals(propertyName)) { // Quick check to avoid deprecated method call final Object execInfoResult = checkExecInfo(propertyName, context); if (execInfoResult != null) { return execInfoResult; } } return ((IContext) target).getVariable(propertyName); }
public Object getProperty(final Map ognlContext, final Object target, final Object name) throws OgnlException { if (!(target instanceof IContext)) { throw new IllegalStateException( "Wrong target type. This property accessor is only usable for " + IContext.class.getName() + " implementations, and " + "in this case the target object is " + (target == null? "null" : ("of class " + target.getClass().getName()))); } if (REQUEST_PARAMETERS_RESTRICTED_VARIABLE_NAME.equals(name) && ognlContext != null && ognlContext.containsKey(RESTRICT_REQUEST_PARAMETERS)) { throw new OgnlException( "Access to variable \"" + name + "\" is forbidden in this context. Note some restrictions apply to " + "variable access. For example, direct access to request parameters is forbidden in preprocessing and " + "unescaped expressions, in TEXT template mode, in fragment insertion specifications and " + "in some specific attribute processors."); } final String propertyName = (name == null? null : name.toString()); // 'execInfo' translation from context variable to expression object - deprecated and to be removed in 3.1 final Object execInfoResult = checkExecInfo(propertyName, ognlContext); if (execInfoResult != null) { return execInfoResult; } /* * NOTE we do not check here whether we are being asked for the 'locale', 'request', 'response', etc. * because there already are specific expression objects for the most important of them, which should * be used instead: #locale, #httpServletRequest, #httpSession, etc. * The variables maps should just be used as a map, without exposure of its more-internal methods... */ final IContext context = (IContext) target; return context.getVariable(propertyName); }
throw new OgnlException("source is null for getProperty(null, \"" + propertyName + "\")");
public Void execute(Object tree) throws OgnlException { if (isEvalExpression(tree, context)) { throw new OgnlException("Eval expression/chained expressions cannot be used as parameter name"); } if (isArithmeticExpression(tree, context)) { throw new OgnlException("Arithmetic expressions cannot be used as parameter name"); } Ognl.setValue(tree, context, root, value); return null; } });
public static PropertyAccessor getPropertyAccessor(Class cls) throws OgnlException { PropertyAccessor answer = (PropertyAccessor) getHandler(cls, _propertyAccessors); if (answer != null) return answer; throw new OgnlException("No property accessor for class " + cls); }
public static NullHandler getNullHandler(Class cls) throws OgnlException { NullHandler answer = (NullHandler) getHandler(cls, _nullHandlers); if (answer != null) return answer; throw new OgnlException("No null handler for class " + cls); }
public boolean hasSetProperty(OgnlContext context, Object target, Object oname) throws OgnlException { try { return OgnlRuntime.hasSetProperty(context, target, oname); } catch (IntrospectionException ex) { throw new OgnlException("checking if " + target + " has settable property " + oname, ex); } }
public static final ElementsAccessor getElementsAccessor( Class cls ) throws OgnlException { ElementsAccessor answer = (ElementsAccessor)getHandler( cls, elementsAccessors ); if ( answer != null ) return answer; throw new OgnlException( "No elements accessor for class " + cls ); }
public static MethodAccessor getMethodAccessor(Class cls) throws OgnlException { MethodAccessor answer = (MethodAccessor) getHandler(cls, _methodAccessors); if (answer != null) return answer; throw new OgnlException("No method accessor for " + cls); }
public boolean hasGetProperty(OgnlContext context, Object target, Object oname) throws OgnlException { try { return OgnlRuntime.hasGetProperty(context, target, oname); } catch (IntrospectionException ex) { throw new OgnlException("checking if " + target + " has gettable property " + oname, ex); } }
public static boolean isInstance(OgnlContext context, Object value, String className) throws OgnlException { try { Class c = classForName(context, className); return c.isInstance(value); } catch (ClassNotFoundException e) { throw new OgnlException("No such class: " + className, e); } }
public static ElementsAccessor getElementsAccessor(Class cls) throws OgnlException { ElementsAccessor answer = (ElementsAccessor) getHandler(cls, _elementsAccessors); if (answer != null) return answer; throw new OgnlException("No elements accessor for class " + cls); }
public static NullHandler getNullHandler(Class cls) throws OgnlException { NullHandler answer = (NullHandler) getHandler(cls, _nullHandlers); if (answer != null) return answer; throw new OgnlException("No null handler for class " + cls); }
private void checkSimpleMethod(Object tree, Map<String, Object> context) throws OgnlException { if (!isSimpleMethod(tree, context)) { throw new OgnlException("It isn't a simple method which can be called!"); } }
private void checkEnableEvalExpression(Object tree, Map<String, Object> context) throws OgnlException { if (!enableEvalExpression && isEvalExpression(tree, context)) { throw new OgnlException("Eval expressions/chained expressions have been disabled!"); } }
public static final MethodAccessor getMethodAccessor( Class cls ) throws OgnlException { MethodAccessor answer = (MethodAccessor)getHandler( cls, methodAccessors ); if ( answer != null ) return answer; throw new OgnlException( "No method accessor for " + cls ); }
@Override public final Object setPossibleProperty(Map context, Object target, String name, Object value) throws OgnlException { if (context.containsKey(READ_ONLY_MODE)) { throw new OgnlException("Expression must be read-only: " + context.get(QUERY)); } Object answer = setProperty0((OgnlContext) context, target, name, value); if (answer == OgnlRuntime.NotFound) { answer = super.setPossibleProperty(context, target, name, value); } return answer; }
public static void setProperty(OgnlContext context, Object target, Object name, Object value) throws OgnlException { PropertyAccessor accessor; if (target == null) { throw new OgnlException("target is null for setProperty(null, \"" + name + "\", " + value + ")"); } if ((accessor = getPropertyAccessor(getTargetClass(target))) == null) { throw new OgnlException("No property accessor for " + getTargetClass(target).getName()); } accessor.setProperty(context, target, name, value); }
public static final Object getProperty( OgnlContext context, Object source, Object name ) throws OgnlException { PropertyAccessor accessor; if (source == null) { throw new OgnlException("source is null for getProperty(null, \"" + name + "\")"); } if ((accessor = getPropertyAccessor(getTargetClass(source))) == null) { throw new OgnlException("No property accessor for " + getTargetClass(source).getName()); } return accessor.getProperty( context, source, name ); }
public static final void setProperty( OgnlContext context, Object target, Object name, Object value ) throws OgnlException { PropertyAccessor accessor; if (target == null) { throw new OgnlException("target is null for setProperty(null, \"" + name + "\", " + value + ")"); } if ((accessor = getPropertyAccessor(getTargetClass(target))) == null) { throw new OgnlException("No property accessor for " + getTargetClass(target).getName()); } accessor.setProperty( context, target, name, value ); }