Refactored WS-security.

small modifications to  pull #275