I'm using jboss keycloak 1.5 final version.
I developed my custom user federation provider interfacing with keycloak properties and my user enterprise database. 

My need is to send up to user the login interface custom error messages based on particular specific error related to my legacy user db.

I saw keycloak themes have a resources folder by which i can localize and add new messages. Then i can reference them by angular js using 

    $myMessage

notation. The problem is i want to rise up a message from keycloak server. My user federation provider implements UserFederationProvider interface. So i should have to override:

    @Override
public CredentialValidationOutput validCredentials(RealmModel realm, UserCredentialModel credential) {
LOGGER.info("validCredentials(realm, credential)");
return CredentialValidationOutput.failed();
}

In the UserFederationProvider interface i read that validCredentials :
Validate credentials of unknown user. The authenticated user is recognized based on provided credentials and returned back in CredentialValidationOutput

It seems to be the method i was looking for just because CredentialValidationOutput contains custom messages to be sent as validation output. The problem is this method is never called.

The same happens to the close method. It's never called at the end of each request so i cannot dispose my objects
Why?
Thanks a lot