Let's take a look first at the handler interface here, the contract for the handlers.
So as you can see, there is only one method here for handling requests.
And by the way, you may recognize this code from the flyaway tutorial.
So it's the same one.
But I have adapted it for including the chain of responsibility pattern.
So the handler interface will be implemented by our handlers.
The authentication one is the first one and the authorization will be the second in the chain.
So this is how the authentication handler looks like.
It has a reference to the next item in the chain, which is the authorization handler.
And for the handler requests does have a simple Sisso statement here, but it also will have a reference
to the handler request submitted from the authorization object, as you can see here.
So basically the check authorization method will have a reference, will call the handler request method
that is being part of the handler interface here from the authorization handler.
So basically here, what we want to attempt is to have an authentication and authorization for a user
of an online shop before he or she may order stuff from from from this online store.
So the code is untouched, the rest of the code, except for the client application, which now needs
to start the process from the authentication part.
So basically, here we have a call for the handler request from the handler, which in our case is the
authentication handler.
Then the request will be passed to the authorization handler, which is the second item in the chain,
and after that, the rest of the code will be executed.
So well, let's start this.
So as you can see, the first message is authentication is successful and the next one is client authorized
to use the system as a customer, which is the message that is printed out by the sender request method
from the authorization handler.
So that's it for the chain of responsibility pattern.
Join me in the next video where we are going to discuss about the command pattern.