Search in sources :

Example 1 with ExpressionManager

use of org.mule.runtime.core.api.el.ExpressionManager in project mule by mulesoft.

the class UsernamePasswordAuthenticationFilter method getAuthenticationToken.

protected Authentication getAuthenticationToken(CoreEvent event) throws UnauthorisedException {
    ExpressionManager expressionManager = (ExpressionManager) registry.lookupByName(OBJECT_EXPRESSION_MANAGER).get();
    Object usernameEval = expressionManager.evaluate(username, event).getValue();
    Object passwordEval = expressionManager.evaluate(password, event).getValue();
    if (usernameEval == null) {
        throw new UnauthorisedException(authNoCredentials());
    }
    if (passwordEval == null) {
        throw new UnauthorisedException(authNoCredentials());
    }
    return new DefaultMuleAuthentication(new DefaultMuleCredentials(usernameEval.toString(), passwordEval.toString().toCharArray()));
}
Also used : ExpressionManager(org.mule.runtime.core.api.el.ExpressionManager) DefaultMuleCredentials(org.mule.runtime.core.api.security.DefaultMuleCredentials) UnauthorisedException(org.mule.runtime.api.security.UnauthorisedException) DefaultMuleAuthentication(org.mule.runtime.api.security.DefaultMuleAuthentication)

Aggregations

DefaultMuleAuthentication (org.mule.runtime.api.security.DefaultMuleAuthentication)1 UnauthorisedException (org.mule.runtime.api.security.UnauthorisedException)1 ExpressionManager (org.mule.runtime.core.api.el.ExpressionManager)1 DefaultMuleCredentials (org.mule.runtime.core.api.security.DefaultMuleCredentials)1