< Day Day Up > |
WS-Security defines a SOAP security header that provides a standard place for you to put security artifacts. The purpose of WS-Security is not to invent any new types of security, but instead to provide a common format for security in a SOAP message. Three major elements make up a SOAP security header: security tokens, XML Encryption, and/or XML Signatures. Security tokens are pieces of information used for authentication or authorization. Examples of security tokens are username/password and X.509 certificates. Many more token types are used, and we discuss them in detail later in this chapter. For XML Encryption, the security header may hold an EncryptedKey element containing a ReferenceList pointing to the specific parts of the message that have been encrypted. Similarly, if an XML Signature is within the security header, its Reference elements will point to the parts of the message that have been digitally signed. Listing 7.1 shows what the basic WS-Security header structure looks like within a SOAP envelope (we have removed namespaces throughout this chapter to simplify). Listing 7.1. Structure of a Basic WS-Security SOAP Header<S:Envelope> < S:Header > <wsse:Security> <!-- Security Token --> <wsse:UsernameToken> ... </wsse:UsernameToken> <!-- XML Signature --> <ds:Signature> ... <ds:Reference URI="#body"> ... </ds:Signature> <!-- XML Encryption Reference List --> <xenc:ReferenceList> <xenc:DataReference URI="#body"/> </xenc:ReferenceList> </wsse:Security> </S:Header> <S:Body> <!-- XML Encrypted Body --> <xenc:EncryptedData Id="body" Type="content"> ... </xenc:EncryptedData> </S:Body> </S:Envelope> As you can see, Listing 7.1 contains a security header, commonly referred to with the namespace prefix wsse , which has three children: UsernameToken , which is an example of a security token; Signature , which represents an XML Signature; and an XML Encryption ReferenceList . In general, you see the following structure for the security header:
In the following sections, we look in turn at each of the security artifacts that can be included in a WS-Security SOAP header.
|
< Day Day Up > |