protected void closeAction() throws IOException {
   connectionHandler.closeAsync();
   connectionHandler.addCloseHandler((closed, exception) -> closeComplete());
   for (Auth auth : authMap) {
     auth.dispose();
   }
   final ConnectionPeerIdentityContext peerIdentityContext = this.peerIdentityContext;
   if (peerIdentityContext != null) peerIdentityContext.connectionClosed();
 }
 void receiveAuthResponse(final int id, final byte[] response) {
   log.tracef("Received authentication response for ID %08x", id);
   if (id == 0 || id == 1) {
     // ignore
     return;
   }
   getExecutor()
       .execute(
           () -> {
             Auth auth = authMap.get(id);
             if (auth == null) {
               auth = authMap.putIfAbsent(new Auth(id, new RejectingSaslServer()));
               if (auth == null) {
                 // reject
                 try {
                   connectionHandler.sendAuthReject(id);
                 } catch (IOException e1) {
                   log.trace("Failed to send auth reject", e1);
                 }
                 return;
               }
             }
             final SaslServer saslServer = auth.getSaslServer();
             final byte[] challenge;
             try {
               challenge = saslServer.evaluateResponse(response);
             } catch (SaslException e) {
               try {
                 connectionHandler.sendAuthReject(id);
               } catch (IOException e1) {
                 authMap.remove(auth);
                 auth.dispose();
                 log.trace("Failed to send auth reject", e1);
               }
               return;
             }
             if (saslServer.isComplete()) {
               try {
                 connectionHandler.sendAuthSuccess(id, challenge);
               } catch (IOException e) {
                 authMap.remove(auth);
                 auth.dispose();
                 log.trace("Failed to send auth success", e);
               }
               return;
             } else {
               try {
                 connectionHandler.sendAuthChallenge(id, challenge);
               } catch (IOException e) {
                 authMap.remove(auth);
                 auth.dispose();
                 log.trace("Failed to send auth challenge", e);
               }
               return;
             }
           });
 }
 public SocketAddress getLocalAddress() {
   return connectionHandler.getLocalAddress();
 }
 public void receiveAuthRequest(
     final int id, final String mechName, final byte[] initialResponse) {
   log.tracef("Received authentication request for ID %08x, mech %s", id, mechName);
   if (id == 0 || id == 1) {
     // ignore
     return;
   }
   getExecutor()
       .execute(
           () -> {
             final SaslServer saslServer;
             final IntIndexHashMap<Auth> authMap = this.authMap;
             try {
               saslServer =
                   authenticationFactory.createMechanism(
                       mechName, f -> new ServerNameSaslServerFactory(f, endpoint.getName()));
             } catch (SaslException e) {
               log.trace("Authentication failed at mechanism creation", e);
               try {
                 Auth oldAuth = authMap.put(new Auth(id, new RejectingSaslServer()));
                 if (oldAuth != null) oldAuth.dispose();
                 connectionHandler.sendAuthReject(id);
               } catch (IOException e1) {
                 log.trace("Failed to send auth reject", e1);
               }
               return;
             }
             // clear out any old auth
             final Auth auth = new Auth(id, saslServer);
             Auth oldAuth = authMap.put(auth);
             if (oldAuth != null) oldAuth.dispose();
             final byte[] challenge;
             try {
               challenge = saslServer.evaluateResponse(initialResponse);
             } catch (SaslException e) {
               log.trace("Authentication failed at response evaluation", e);
               try {
                 connectionHandler.sendAuthReject(id);
               } catch (IOException e1) {
                 authMap.remove(auth);
                 auth.dispose();
                 log.trace("Failed to send auth reject", e1);
               }
               return;
             }
             if (saslServer.isComplete()) {
               try {
                 connectionHandler.sendAuthSuccess(id, challenge);
               } catch (IOException e) {
                 authMap.remove(auth);
                 auth.dispose();
                 log.trace("Failed to send auth success", e);
               }
               return;
             } else {
               try {
                 connectionHandler.sendAuthChallenge(id, challenge);
               } catch (IOException e) {
                 authMap.remove(auth);
                 auth.dispose();
                 log.trace("Failed to send auth challenge", e);
               }
               return;
             }
           });
 }
 public SecurityIdentity getLocalIdentity() {
   return connectionHandler.getLocalIdentity();
 }
 public String getRemoteEndpointName() {
   return connectionHandler.getRemoteEndpointName();
 }
 public IoFuture<Channel> openChannel(final String serviceType, final OptionMap optionMap) {
   FutureResult<Channel> result = new FutureResult<Channel>(getExecutor());
   result.addCancelHandler(connectionHandler.open(serviceType, result, optionMap));
   return result.getIoFuture();
 }
 @Override
 public SSLSession getSslSession() {
   return connectionHandler.getSslSession();
 }
 public SocketAddress getPeerAddress() {
   return connectionHandler.getPeerAddress();
 }