Is it possible to save client roles in external source?

I successfully implemented User Storage SPI. I have stored roles along with user details in external source. I want to map the roles of the user to client role. Is it possible ?

I am getting the following array of roles from the external source.

[
   {
      "id": 1,
      "name: "admin",
      "client": "user-service"
   }
]

I used the following getClientRoleMappings, in the UserModel implementation:

override fun getClientRoleMappings(app: ClientModel?): MutableSet<RoleModel> {
        logger.info { "Calling getClientRoleMappings" }
        val userRoles = this.user?.roles?.filter { it.client == app?.name } ?: emptyList()
        val clientRoles = mutableSetOf<RoleModel>()
        userRoles.forEach {
            if (app != null) {
                clientRoles.add(app.getRole(it.name))
            }
        }
        return clientRoles
    }

But the above piece is not called. Is there any otherway to handle this situation. I want to map the client role received from the external source to the keycloak client role.

PS: I am using kotlin for coding

Is your UserModel extending AbstractUserAdapterFederatedStorage?

I have a UserModel implementation that extends AbstractUserAdapterFederatedStorage and overrides the getRoleMappingsInternal method, which looks like it should support pulling the roles from external storage and adding roles within keycloak.