Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
 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;
             }
           });
 }
Ejemplo n.º 3
0
 public SocketAddress getLocalAddress() {
   return connectionHandler.getLocalAddress();
 }
Ejemplo n.º 4
0
 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;
             }
           });
 }
Ejemplo n.º 5
0
 public SecurityIdentity getLocalIdentity() {
   return connectionHandler.getLocalIdentity();
 }
Ejemplo n.º 6
0
 public String getRemoteEndpointName() {
   return connectionHandler.getRemoteEndpointName();
 }
Ejemplo n.º 7
0
 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();
 }
Ejemplo n.º 8
0
 @Override
 public SSLSession getSslSession() {
   return connectionHandler.getSslSession();
 }
Ejemplo n.º 9
0
 public SocketAddress getPeerAddress() {
   return connectionHandler.getPeerAddress();
 }