- the bowler has bowls the ball,
- the batsmen misses the ball,
- the ball goes to the wicket-keeper,
- it touches the leg of the keeper,
- and finally it touches the stump,
is that a stumping or not?
If the batsman was out of his crease, then yes, that is a stumping. Law 39.2 states:
39.2 Ball rebounding from wicket-keeper’s person
If the wicket is put down by the ball, it shall be regarded as having been put down by the wicket-keeper if the ball:
rebounds on to the stumps from any part of the wicket-keeper’s person or equipment
or has been kicked or thrown on to the stumps by the wicket-keeper.
Note the word any. Since it hit his leg before going onto the stumps, it's a stumping.