Securing Web Services with WS-Security: Demystifying WS-Security, WS-Policy, SAML, XML Signature, and XML Encryption
< Day Day Up > |
Probably the best way to understand XML Encryption is to jump right into an example. Let's work through a simple XML Encryption scenario to highlight what can be done with XML Encryption. Then we will go through the different XML Encryption elements. Let's start with a sample document that has some sensitive data in it, as shown in Listing 5.1. Listing 5.1. A Sample Document Containing Sensitive Data
<Employee> <EmployeeID>512-34-4567</EmployeeID> <Manager>Fred Jones</Manager> <Salary>,000</Salary> </Employee>
Because the Employee ID number is a Social Security number, you may want to encrypt it as shown in Listing 5.2. Listing 5.2. A Piece of Sensitive Data Encrypted
<Employee> <EmployeeID><EncryptedData>#A.Ije@OJFdl</EncryptedData></EmployeeID> <Manager>Fred Jones</Manager <Salary>,000</Salary> </Employee>
And you may feel that the salary element is so sensitive that you don't even want the tag Salary to show up. So, the encrypted document might look something like Listing 5.3. Listing 5.3. The Sample Document Encrypting Even a Tag
<Employee> <EmployeeID><EncryptedData> A.Ije@OJFdl</EncryptedData></EmployeeID> <Manager>Fred Jones</Manager> <EncryptedData>J1!%dW2s23#D'?D2@</EncryptedData> </Employee>
XML Encryption allows this type of encryption and much more. XML Encryption allows you to encrypt different sections of the XML document with different keys, thereby making different sections of the document available to different readers. In a Web services scenario, you could imagine that parts of the SOAP message might need to be available to a specific " waypoint " receiver of the message but not necessarily the "endpoint" receiver. For example, say a firewall requires a special SOAP header that contains a priority field. The SOAP message might look something like Listing 5.4. Listing 5.4. SOAP Message with Two Different Encrypted Data Segments
<SOAP:Envelope> <SOAP:Header> <!--Firewall info --> <EncryptedData> binary data </EncryptedData> </SOAP:Header> <SOAP:Body> <EncryptedData> binary data </EncryptedData> </SOAP:Body> </SOAP:Envelope>
One of the tenets of Web services security is that the document itself, the SOAP message, should be protected "end to end" and should not necessarily rely on transport security (SSL, TLS, IPSEC, and so on), which is considered "point to point." This point of view is discussed in more detail in Chapter 7, but for now, let's just say that there are trade-offs to using each approach, and there are arguments for even combining both message-based security and transport security. This example provides a taste of XML Encryption, but even with this tidbit, you can see the available power and flexibility. In the rest of this chapter, we explore the different aspects of XML Encryption and, at the end of the chapter, we discuss the interaction between XML Signature and XML Encryption more fully. |
< Day Day Up > |