use of javax.el.ELProcessor in project tomee by apache.
the class RememberMeInterceptor method getElProcessor.
private ELProcessor getElProcessor(InvocationContext invocationContext, HttpMessageContext httpMessageContext) {
ELProcessor elProcessor = new ELProcessor();
elProcessor.getELManager().addELResolver(beanManager.getELResolver());
elProcessor.defineBean("self", invocationContext.getTarget());
elProcessor.defineBean("this", invocationContext.getTarget());
elProcessor.defineBean("httpMessageContext", httpMessageContext);
return elProcessor;
}
use of javax.el.ELProcessor in project tomee by apache.
the class TomEEELInvocationHandler method of.
public static <T extends Annotation> T of(final Class<T> annotationClass, final T annotation, final BeanManager beanManager) {
final ELProcessor elProcessor = new ELProcessor();
elProcessor.getELManager().addELResolver(beanManager.getELResolver());
return of(annotationClass, annotation, elProcessor);
}
use of javax.el.ELProcessor in project Payara by payara.
the class RolesPermittedInterceptor method getElProcessor.
private ELProcessor getElProcessor(InvocationContext invocationContext) {
final BeanManager beanManager = lazyProperties.getBeanManager();
ELProcessor elProcessor = new ELProcessor();
elProcessor.getELManager().addELResolver(beanManager.getELResolver());
elProcessor.defineBean("self", invocationContext.getTarget());
Parameter[] parameters = invocationContext.getMethod().getParameters();
Object[] values = invocationContext.getParameters();
boolean paramAdded = false;
for (int i = 0; i < parameters.length; i++) {
Parameter param = parameters[i];
Named named = param.getAnnotation(Named.class);
String key = null;
if (named != null && !(key = named.value().trim()).isEmpty()) {
elProcessor.defineBean(key, values[i]);
paramAdded = true;
}
}
if (!paramAdded && parameters.length == 1) {
elProcessor.defineBean("param", values[0]);
}
return elProcessor;
}
use of javax.el.ELProcessor in project Payara by payara.
the class RealmUtil method getConfiguredValue.
static <T> T getConfiguredValue(Class<T> type, T value, Config provider, String mpConfigKey) {
T result = value;
Optional<T> configResult = provider.getOptionalValue(mpConfigKey, type);
if (configResult.isPresent()) {
return configResult.get();
}
if (type == String.class) {
result = (T) TranslatedConfigView.expandValue((String) result);
}
if (type == String.class && isELExpression((String) value)) {
ELProcessor elProcessor = new ELProcessor();
BeanManager beanManager = CDI.current().getBeanManager();
elProcessor.getELManager().addELResolver(beanManager.getELResolver());
result = (T) elProcessor.getValue(toRawExpression((String) result), type);
}
return result;
}
use of javax.el.ELProcessor in project tomee by apache.
the class TomEEDatabaseIdentityStore method init.
@PostConstruct
private void init() throws Exception {
definition = definitionSupplier.get();
validationTypes = new HashSet<>(asList(definition.useFor()));
passwordHash = getInstance(definition.hashAlgorithm());
final ELProcessor elProcessor = new ELProcessor();
elProcessor.getELManager().addELResolver(beanManager.getELResolver());
// the trick with hashAlgorithmParameters is that it returns a String[]
// each of them may be an EL to evaluate
// and then we need to create a Map to pass in the password hash class
// 1. get the list of String and evaluate expressions
// 2. then split and create the map
passwordHash.initialize(stream(definition.hashAlgorithmParameters()).flatMap(s -> toStream(eval(elProcessor, s, Object.class))).collect(toMap(s -> (String) s.substring(0, s.indexOf('=')), s -> (String) eval(elProcessor, s.substring(s.indexOf('=') + 1), String.class))));
}
Aggregations