Chúng tôi bắt đầu bằng cách tạo ra một thể hiện của cơ chế lọc. Chúng tôi thêm một vài bộ lọc xác định các biến đầu vào nào cần phải được lọc theo các tiêu chí. Chúng tôi cũng có khả năng xác định các thông báo lỗi sẽ được có sẵn nếu kiểm tra không. | else messages filtering- getErrors Get error messages o We start by creating an instance of the filtering mechanism. We add a couple of filters specifying which input variables should be filtered according to which criteria. We also have the ability to specify error messages that will be available if the checks fail. The filter method works on a raw request object. This object is not intended to be used directly. filter returns TRUE if all variables match the filtering criteria. On success we can get a new clean request object this object is a different class than the raw request object. The two classes have different methods so the clean request object cannot be replaced with a raw request object by mistake. We can get the validated values from the clean request object in a convenient way. If the validation fails we can get the error messages we need to display. We are getting a bit ahead of ourselves here since the next chapter deals with input validation. For now let s just make a temporary diagram of which classes might be required to implement this design. Figure is mostly obvious from the example. The CleanRequest and RawRequest objects are given the Filtering object has the methods used in the example and it s reasonable to assume that we will need separate classes for different kinds of filtering. In the next chapter we will go into the details of a secure request architecture using slightly different terminology. Representing the HTTP request in a safe way is a prerequisite to maintaining security when applying web presentation patterns. Now that we have dealt with that we re ready to take on the first one of these patterns Page Controller. Figure Quick sketch of a possible design for request object filtering 360 CHAPTER 16 Controllers Using Page Controllers As mentioned in the previous chapters the two conventional web presentation patterns are called Page Controller and Front Controller. As with Composite View these may be considered fancy