public static void setHandler(Record r, Handler handler) { r.set(Handler.class, Handler.class, handler); }
public static void setHandler(Record r, Handler handler) { r.set(Handler.class, Handler.class, handler); }
public static void setHandler(Record r, Handler handler) { r.set(Handler.class, Handler.class, handler); }
/** * Gets the principal representing a connection's client. * * @param con The connection to get the principal for. * @param principal The principal representing the authenticated client. * @throws NullPointerException if any of the parameters is {@code null}. */ public static void setClientPrincipal(final ProtonConnection con, final HonoUser principal) { Objects.requireNonNull(principal); final Record attachments = Objects.requireNonNull(con).attachments(); attachments.set(KEY_CLIENT_PRINCIPAL, HonoUser.class, principal); }
/** * Gets the principal representing a connection's client. * * @param con The connection to get the principal for. * @param principal The principal representing the authenticated client. * @throws NullPointerException if any of the parameters is {@code null}. */ public static void setClientPrincipal(final ProtonConnection con, final HonoUser principal) { Objects.requireNonNull(principal); final Record attachments = Objects.requireNonNull(con).attachments(); attachments.set(KEY_CLIENT_PRINCIPAL, HonoUser.class, principal); }
public void set(E e, T value) { e.attachments().set(this, klass, value); } }
public void set(E e, T value) { e.attachments().set(this, klass, value); } }
/** * Sets the (surrogate) identifier of an AMQP connection. * <p> * The identifier will be added to the connection's <em>attachments</em> under key * {@link #KEY_CONNECTION_ID}. * * @param connection The connection to set id for. * @param id The identifier to set. * @throws NullPointerException if any of the parameters is {@code null}. */ public static void setConnectionId(final ProtonConnection connection, final String id) { Objects.requireNonNull(connection).attachments().set(Constants.KEY_CONNECTION_ID, String.class, Objects.requireNonNull(id)); }
/** * Sets the (surrogate) identifier of an AMQP connection. * <p> * The identifier will be added to the connection's <em>attachments</em> under key * {@link #KEY_CONNECTION_ID}. * * @param connection The connection to set id for. * @param id The identifier to set. * @throws NullPointerException if any of the parameters is {@code null}. */ public static void setConnectionId(final ProtonConnection connection, final String id) { Objects.requireNonNull(connection).attachments().set(Constants.KEY_CONNECTION_ID, String.class, Objects.requireNonNull(id)); }
public static void setHandler(Extendable ext, Handler handler) { ext.attachments().set(Handler.class, Handler.class, handler); }
private static void copyConnectionId(final Record source, final Record target) { target.set(Constants.KEY_CONNECTION_ID, String.class, source.get(Constants.KEY_CONNECTION_ID, String.class)); }
public static void setHandler(Extendable ext, Handler handler) { ext.attachments().set(Handler.class, Handler.class, handler); }
private static void addConnectionLossHandler(final ProtonConnection con, final Handler<Void> handler) { con.attachments().set("connectionLossHandler", Handler.class, handler); }
public static void setHandler(Extendable ext, Handler handler) { ext.attachments().set(Handler.class, Handler.class, handler); }
private void addPrincipal(final Principal authzId) { succeeded = true; protonConnection.attachments().set(Constants.KEY_CLIENT_PRINCIPAL, Principal.class, authzId); LOG.debug("authentication of client [authorization ID: {}] succeeded", authzId.getName()); sasl.done(SaslOutcome.PN_SASL_OK); }
/** * Copies properties from a connection's attachments to a link's attachments. * <p> * The properties copied are * <ul> * <li>{@link #KEY_CONNECTION_ID}</li> * </ul> * * @param source The connection. * @param target The link. */ public static void copyProperties(final ProtonConnection source, final ProtonLink<?> target) { Objects.requireNonNull(source); Objects.requireNonNull(target); target.attachments().set(Constants.KEY_CONNECTION_ID, String.class, getConnectionId(source)); }
/** * Copies properties from a connection's attachments to a link's attachments. * <p> * The properties copied are * <ul> * <li>{@link #KEY_CONNECTION_ID}</li> * </ul> * * @param source The connection. * @param target The link. */ public static void copyProperties(final ProtonConnection source, final ProtonLink<?> target) { Objects.requireNonNull(source); Objects.requireNonNull(target); target.attachments().set(Constants.KEY_CONNECTION_ID, String.class, getConnectionId(source)); }
/** * Associates a downstream sender with a corresponding upstream client. * * @param link The upstream client. * @param sender The downstream sender. */ public final void addSender(final UpstreamReceiver link, final ProtonSender sender) { sender.attachments().set(Constants.KEY_CONNECTION_ID, String.class, link.getConnectionId()); sender.setAutoDrained(false); // we need to propagate drain requests upstream and wait for the result activeSenders.put(link, sender); List<UpstreamReceiver> senders = sendersPerConnection.get(link.getConnectionId()); if (senders == null) { senders = new ArrayList<>(); sendersPerConnection.put(link.getConnectionId(), senders); } senders.add(link); }
private static ProtonConnection newConnection(final HonoUser user) { final Record attachments = new RecordImpl(); attachments.set(Constants.KEY_CONNECTION_ID, String.class, CON_ID); attachments.set(Constants.KEY_CLIENT_PRINCIPAL, HonoUser.class, user); final ProtonConnection con = mock(ProtonConnection.class); when(con.attachments()).thenReturn(attachments); when(con.getRemoteContainer()).thenReturn("test-client"); return con; }
private void setRemoteConnectionOpenHandler(final ProtonConnection connection) { connection.sessionOpenHandler(remoteOpenSession -> handleSessionOpen(connection, remoteOpenSession)); connection.receiverOpenHandler(remoteOpenReceiver -> handleReceiverOpen(connection, remoteOpenReceiver)); connection.senderOpenHandler(remoteOpenSender -> handleSenderOpen(connection, remoteOpenSender)); connection.disconnectHandler(this::handleRemoteDisconnect); connection.closeHandler(remoteClose -> handleRemoteConnectionClose(connection, remoteClose)); connection.openHandler(remoteOpen -> { LOG.info("client [container: {}, user: {}] connected", connection.getRemoteContainer(), getUserFromConnection(connection)); connection.open(); // attach an ID so that we can later inform downstream components when connection is closed connection.attachments().set(Constants.KEY_CONNECTION_ID, String.class, UUID.randomUUID().toString()); }); }