Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AuthenticationFilter extends BrokerFilter {
- public AuthenticationFilter(Broker next) {
- super(next);
- }
- @Override
- public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception {
- String username = info.getUserName() ;
- String password = info.getPassword() ;
- if (username.equals("EXAMPLE_USER_NAME") && password.equals("EXAMPLE_PASSWORD")) {
- System.out.println("Authentication Success .");
- super.addConnection(context, info);
- } else {
- System.out.println("Authentication Failed for clientID : " + info.getClientId());
- throw new SecurityException();
- }
- }
- }
- Authentication Failed for clientID : 1112
- Authentication Failed for clientID : 1112
Add Comment
Please, Sign In to add comment