Refactored security provider (tests still pending).