final ConfigurableApplicationContext context = ApplicationContextProvider.getApplicationContext();
final JexlUtil jexlUtil = context.getBean(JexlUtil.class);
// Prepare context using user attributes
final JexlContext jexlContext = jexlUtil.addAttrsToContext(attributes, null);
final AbstractAttributable owner = getOwner();
if (owner instanceof SyncopeUser) {
jexlContext.set("username", ((SyncopeUser) owner).getUsername() != null
? ((SyncopeUser) owner).getUsername()
: "");
jexlContext.set("creationDate", ((SyncopeUser) owner).getCreationDate() != null
? ((SyncopeUser) owner).getDateFormatter().format(((SyncopeUser) owner).getCreationDate())
: "");
jexlContext.set("lastLoginDate", ((SyncopeUser) owner).getLastLoginDate() != null
? ((SyncopeUser) owner).getDateFormatter().format(((SyncopeUser) owner).getLastLoginDate())
: "");
jexlContext.set("failedLogins", ((SyncopeUser) owner).getFailedLogins() != null
? ((SyncopeUser) owner).getFailedLogins()
: "");
jexlContext.set("changePwdDate", ((SyncopeUser) owner).getChangePwdDate() != null
? ((SyncopeUser) owner).getDateFormatter().format(((SyncopeUser) owner).getChangePwdDate())
: "");
}
// Evaluate expression using the context prepared before