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 void remoteClosed() { connection.closeAsync(); }
void receiveAuthDelete(final int id) { log.tracef("Received authentication delete for ID %08x", id); if (id == 0 || id == 1) { // ignore return; } getExecutor().execute(() -> { final Auth auth = authMap.removeKey(id); if (auth != null) auth.dispose(); log.tracef("Deleted authentication ID %08x", id); }); }
public IoFuture<ConnectionPeerIdentity> authenticateAsync(final AuthenticationConfiguration configuration) { Assert.checkNotNullParam("configuration", configuration); if (configuration.equals(connection.getAuthenticationConfiguration())) { return connectionIdentityFuture; } else if (CLIENT.getAuthorizationPrincipal(configuration) instanceof AnonymousPrincipal) { return ioFuture; final FutureResult<ConnectionPeerIdentity> futureResult = new FutureResult<>(connection.getEndpoint().getExecutor()); ioFuture = futureAuths.putIfAbsent(configuration, futureResult.getIoFuture()); if (ioFuture != null) { connection.getEndpoint().getExecutor().execute(() -> { Object oldVal; do {
void doAuthenticate(final AuthenticationConfiguration configuration, FutureResult<ConnectionPeerIdentity> futureResult) { Assert.checkNotNullParam("configuration", configuration); final ConnectionImpl connection = this.connection; assert ! configuration.equals(connection.getAuthenticationConfiguration()); if (! connection.supportsRemoteAuth()) { futureResult.setException(log.authenticationNotSupported()); futureAuths.remove(configuration, futureResult.getIoFuture()); final ConnectionHandler connectionHandler = connection.getConnectionHandler(); UnaryOperator<SaslClientFactory> factoryOperator = this.factoryOperator; try { saslClient = client.createSaslClient(connection.getPeerURI(), configuration, mechanisms, factoryOperator, sslSession); } catch (SaslException e) { futureResult.setException(log.authenticationNoSaslClient(e));
public void receiveAuthDeleteAck(final int id) { if (id == 0 || id == 1) { // ignore return; } connection.getPeerIdentityContext().receiveDeleteAck(id); } }
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); }
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 SecurityIdentity getLocalIdentity(final int id) { if (id == 1) { final SaslAuthenticationFactory authenticationFactory = this.authenticationFactory; return authenticationFactory == null ? null : authenticationFactory.getSecurityDomain().getAnonymousSecurityIdentity(); } else if (id == 0) { return getLocalIdentity(); } final Auth auth = authMap.get(id); return auth != null ? (SecurityIdentity) auth.getSaslServer().getNegotiatedProperty(WildFlySasl.SECURITY_IDENTITY) : null; }
void doAuthenticate(final AuthenticationConfiguration configuration, FutureResult<ConnectionPeerIdentity> futureResult) { Assert.checkNotNullParam("configuration", configuration); final ConnectionImpl connection = this.connection; assert ! configuration.equals(connection.getAuthenticationConfiguration()); if (! connection.supportsRemoteAuth()) { futureResult.setException(log.authenticationNotSupported()); futureAuths.remove(configuration, futureResult.getIoFuture()); final ConnectionHandler connectionHandler = connection.getConnectionHandler(); UnaryOperator<SaslClientFactory> factoryOperator = this.factoryOperator; try { saslClient = client.createSaslClient(connection.getPeerURI(), configuration, mechanisms, factoryOperator, sslSession); } catch (SaslException e) { futureResult.setException(log.authenticationNoSaslClient(e));
if (configuration.equals(connection.getAuthenticationConfiguration())) { return connectionIdentity; } else if (CLIENT.getAuthorizationPrincipal(configuration) instanceof AnonymousPrincipal) { FutureResult<ConnectionPeerIdentity> futureResult = new FutureResult<>(connection.getEndpoint().getExecutor()); final IoFuture<ConnectionPeerIdentity> appearing = futureAuths.putIfAbsent(configuration, futureResult.getIoFuture()); if (appearing != null) {
public ConnectionPeerIdentity getConnectionPeerIdentity() throws SecurityException { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(RemotingPermission.GET_CONNECTION_PEER_IDENTITY); } return getPeerIdentityContext().getConnectionIdentity(); }
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); }
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 SecurityIdentity getLocalIdentity(final int id) { if (id == 1) { final SaslAuthenticationFactory authenticationFactory = this.authenticationFactory; return authenticationFactory == null ? null : authenticationFactory.getSecurityDomain().getAnonymousSecurityIdentity(); } else if (id == 0) { return getLocalIdentity(); } final Auth auth = authMap.get(id); return auth != null ? (SecurityIdentity) auth.getSaslServer().getNegotiatedProperty(WildFlySasl.SECURITY_IDENTITY) : null; }
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 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 IoFuture<ConnectionPeerIdentity> authenticateAsync(final AuthenticationConfiguration configuration) { Assert.checkNotNullParam("configuration", configuration); if (configuration.equals(connection.getAuthenticationConfiguration())) { return connectionIdentityFuture; } else if (CLIENT.getAuthorizationPrincipal(configuration) instanceof AnonymousPrincipal) { return ioFuture; final FutureResult<ConnectionPeerIdentity> futureResult = new FutureResult<>(connection.getEndpoint().getExecutor()); ioFuture = futureAuths.putIfAbsent(configuration, futureResult.getIoFuture()); if (ioFuture != null) { connection.getEndpoint().getExecutor().execute(() -> { Object oldVal; do {
protected void closeAction() throws IOException { synchronized (connectionLock) { // Commence phase one shutdown actions int res; do { res = resourceCount; } while (! resourceCountUpdater.compareAndSet(this, res, res | CLOSED_FLAG)); if (res == 0) { finishPhase1(); } else { for (Object connection : connections.toArray()) { ((ConnectionImpl)connection).closeAsync(); } for (ProtocolRegistration protocolRegistration : connectionProviders.values()) { protocolRegistration.getProvider().closeAsync(); } } } }
public void receiveAuthChallenge(final int id, final byte[] challenge) { if (id == 0 || id == 1) { // ignore return; } connection.getPeerIdentityContext().receiveChallenge(id, challenge); }