A token handler API which can be instantiated to allow for custom token types. The token handler API can interact with a web service security handler and security service provider interfaces of security framework in order to do a number of security functions such as authentication, digital signatures and encryption for SOAP messages in a Web Service security system.