Guest User

Untitled

a guest
Feb 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. /*
  2. // Usage:
  3. Config config = new Config();
  4. SocketInterceptorConfig socketInterceptorConfig = new SocketInterceptorConfig();
  5. VerifyRemoteAddressInterceptor interceptor = new
  6. VerifyRemoteAddressInterceptor();
  7. socketInterceptorConfig.setImplementation(interceptor).setEnabled(true);
  8. config.getNetworkConfig().setSocketInterceptorConfig(socketInterceptorConfig);
  9. Hazelcast.newHazelcastInstance(config);
  10. */
  11.  
  12. public class VerifyRemoteAddressInterceptor implements MemberSocketInterceptor {
  13. @Override
  14. public void init(Properties properties) {}
  15.  
  16. @Override
  17. public void onAccept(Socket acceptedSocket) throws IOException {
  18. if (! customAddressVerificationService.isAllowed(acceptedSocket.getInetAddress())) {
  19. throw new IOException("Connection not allowed");
  20. }
  21. }
  22.  
  23. @Override
  24. public void onConnect(Socket connectedSocket) throws IOException {}
  25. }
Add Comment
Please, Sign In to add comment