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(); }
public String getRemoteEndpointName() { return connectionHandler.getRemoteEndpointName(); }
@Override public SSLSession getSslSession() { return connectionHandler.getSslSession(); }
ConnectionImpl(final EndpointImpl endpoint, final ConnectionHandlerFactory connectionHandlerFactory, final ConnectionProviderContext connectionProviderContext, final URI peerUri, final SaslAuthenticationFactory authenticationFactory, final AuthenticationConfiguration authenticationConfiguration, final String saslProtocol) { super(endpoint.getExecutor(), true); this.endpoint = endpoint; this.peerUri = peerUri; this.protocol = connectionProviderContext.getProtocol(); this.authenticationConfiguration = authenticationConfiguration; this.saslProtocol = saslProtocol; this.connectionHandler = connectionHandlerFactory.createInstance(endpoint.new LocalConnectionContext(connectionProviderContext, this)); this.authenticationFactory = authenticationFactory; this.peerIdentityContext = new ConnectionPeerIdentityContext(this, connectionHandler.getOfferedMechanisms(), getConnectionHandler().getPeerSaslServerName(), saslProtocol); }
final SaslServer saslServer; final IntIndexHashMap<Auth> authMap = this.authMap; final SSLSession sslSession = connectionHandler.getSslSession(); try { saslServer = authenticationFactory.createMechanism(mechName, f -> new ServerNameSaslServerFactory(new ProtocolSaslServerFactory(sslSession != null ? new SSLSaslServerFactory(f, connectionHandler::getSslSession) : f, saslProtocol), connectionHandler.getLocalSaslServerName()) ); } catch (SaslException e) { 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); log.trace("Authentication failed at response evaluation", e); try { connectionHandler.sendAuthReject(id); } catch (IOException e1) { authMap.remove(auth); connectionHandler.sendAuthSuccess(id, challenge); } catch (IOException e) { authMap.remove(auth); } else { try { connectionHandler.sendAuthChallenge(id, challenge); } catch (IOException e) {
final LinkedHashMap<String, Throwable> triedMechs = new LinkedHashMap<>(); while (! mechanisms.isEmpty()) { final SSLSession sslSession = connectionHandler.getSslSession(); UnaryOperator<SaslClientFactory> factoryOperator = this.factoryOperator; try { response = null; connectionHandler.sendAuthRequest(id, saslClient.getMechanismName(), response); if (! connectionHandler.isOpen()) { safeDispose(saslClient); futureResult.setException(log.authenticationExceptionClosed()); connectionHandler.sendAuthResponse(id, response); if (! connectionHandler.isOpen()) { safeDispose(saslClient); futureResult.setException(log.authenticationExceptionClosed()); connectionHandler.sendAuthDelete(id); } catch (IOException ignored) { log.trace("Send failed", ignored);
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(); }
public void accept(final ConnectionHandlerFactory connectionHandlerFactory, final SaslAuthenticationFactory authenticationFactory) { synchronized (connectionLock) { try { resourceUntick("an inbound connection"); } catch (NotOpenException e) { throw new IllegalStateException("Accept after endpoint close", e); } boolean ok = false; try { final ConnectionImpl connection = new ConnectionImpl(EndpointImpl.this, connectionHandlerFactory, this, null, authenticationFactory, AuthenticationConfiguration.empty(), saslProtocol); connections.add(connection); connection.getConnectionHandler().addCloseHandler(SpiUtils.asyncClosingCloseHandler(connection)); connection.addCloseHandler(connectionCloseHandler); connection.addCloseHandler(resourceCloseHandler); ok = true; } finally { if (! ok) closeTick1("a failed inbound connection"); } } }
public SocketAddress getLocalAddress() { return connectionHandler.getLocalAddress(); }
public SecurityIdentity getLocalIdentity() { return connectionHandler.getLocalIdentity(); }
public SocketAddress getPeerAddress() { return connectionHandler.getPeerAddress(); }
final SaslServer saslServer; final IntIndexHashMap<Auth> authMap = this.authMap; final SSLSession sslSession = connectionHandler.getSslSession(); try { saslServer = authenticationFactory.createMechanism(mechName, f -> new ServerNameSaslServerFactory(new ProtocolSaslServerFactory(sslSession != null ? new SSLSaslServerFactory(f, connectionHandler::getSslSession) : f, saslProtocol), connectionHandler.getLocalSaslServerName()) ); } catch (SaslException e) { 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); log.trace("Authentication failed at response evaluation", e); try { connectionHandler.sendAuthReject(id); } catch (IOException e1) { authMap.remove(auth); connectionHandler.sendAuthSuccess(id, challenge); } catch (IOException e) { authMap.remove(auth); } else { try { connectionHandler.sendAuthChallenge(id, challenge); } catch (IOException e) {
final LinkedHashMap<String, Throwable> triedMechs = new LinkedHashMap<>(); while (! mechanisms.isEmpty()) { final SSLSession sslSession = connectionHandler.getSslSession(); UnaryOperator<SaslClientFactory> factoryOperator = this.factoryOperator; try { response = null; connectionHandler.sendAuthRequest(id, saslClient.getMechanismName(), response); if (! connectionHandler.isOpen()) { safeDispose(saslClient); futureResult.setException(log.authenticationExceptionClosed()); connectionHandler.sendAuthResponse(id, response); if (! connectionHandler.isOpen()) { safeDispose(saslClient); futureResult.setException(log.authenticationExceptionClosed()); connectionHandler.sendAuthDelete(id); } catch (IOException ignored) { log.trace("Send failed", ignored);
private static Channel getChannel ( ConnectionProviderContextImpl context, ConnectionHandler ch, OptionMap options ) throws IOException { Channel c; FutureResult<Channel> chResult = new FutureResult<Channel>(context.getExecutor()); ch.open("jmx", chResult, options); IoFuture<Channel> cFuture = chResult.getIoFuture(); Status s2 = cFuture.await(); if ( s2 == Status.FAILED ) { System.err.println("Cannot connect"); if ( cFuture.getException() != null ) { throw new IOException("Connect failed", cFuture.getException()); } } else if ( s2 != Status.DONE ) { cFuture.cancel(); throw new IOException("Connect timeout"); } c = cFuture.get(); return c; }
ConnectionImpl(final EndpointImpl endpoint, final ConnectionHandlerFactory connectionHandlerFactory, final ConnectionProviderContext connectionProviderContext, final URI peerUri, final SaslAuthenticationFactory authenticationFactory, final AuthenticationConfiguration authenticationConfiguration, final String saslProtocol) { super(endpoint.getExecutor(), true); this.endpoint = endpoint; this.peerUri = peerUri; this.protocol = connectionProviderContext.getProtocol(); this.authenticationConfiguration = authenticationConfiguration; this.saslProtocol = saslProtocol; this.connectionHandler = connectionHandlerFactory.createInstance(endpoint.new LocalConnectionContext(connectionProviderContext, this)); this.authenticationFactory = authenticationFactory; this.peerIdentityContext = new ConnectionPeerIdentityContext(this, connectionHandler.getOfferedMechanisms(), getConnectionHandler().getPeerSaslServerName(), saslProtocol); }
public void accept(final ConnectionHandlerFactory connectionHandlerFactory) { synchronized (connectionLock) { try { resourceUntick("an inbound connection"); } catch (NotOpenException e) { throw new IllegalStateException("Accept after endpoint close", e); } boolean ok = false; try { final ConnectionImpl connection = new ConnectionImpl(EndpointImpl.this, connectionHandlerFactory, this); connections.add(connection); connection.getConnectionHandler().addCloseHandler(SpiUtils.asyncClosingCloseHandler(connection)); connection.addCloseHandler(connectionCloseHandler); connection.addCloseHandler(resourceCloseHandler); ok = true; } finally { if (! ok) closeTick1("a failed inbound connection"); } } }
public SocketAddress getLocalAddress() { return connectionHandler.getLocalAddress(); }
public SecurityIdentity getLocalIdentity() { return connectionHandler.getLocalIdentity(); }
public SocketAddress getPeerAddress() { return connectionHandler.getPeerAddress(); }
protected void closeAction() throws IOException { connectionHandler.closeAsync(); connectionHandler.addCloseHandler(new CloseHandler<ConnectionHandler>() { public void handleClose(final ConnectionHandler closed, final IOException exception) { closeComplete(); } }); }