I am totally new to Netty and Java, but this afternoon I have managed to create a chat server based on the Netty telnet sample. It works great and I have ‘/’ slash commands working so people can do things like set their name which I currently store in ctx->setAttachment(name).
I have a back end database server I want to connect them with so I can get their name this way, but I’ll need to add authentication each user first. I know I could do that with more slash commands. But I wanted to see if I could do it using a handler in the event chain. Have a handler that checks if a user is authenticated and if they are not, does the logic for authenticating them. And then somehow stores they are authenticated. And if they are authenticated, it lets my current chat handler do its work instead.
Can anyone please provide some links or tips for doing this? My knowledge with Netty is very very basic right now. Thanks in advance.
It really depends.. You can for example have a custom SimpleChannelUpstreamHandler that handle the authentication and remove it once its done.
Something like this: