ProxyConnector
Code IndexAdd Codota to your IDE (free)

Best Java code snippets using org.apache.mina.proxy.ProxyConnector (Showing top 20 results out of 315)

  • Common ways to obtain ProxyConnector
private void myMethod () {
ProxyConnector p =
  • SocketConnector connector;new ProxyConnector(connector)
  • Smart code suggestions by Codota
}
origin: quickfix-j/quickfixj

public static ProxyConnector createIoProxyConnector(SocketConnector socketConnector,
                          InetSocketAddress address,
                          InetSocketAddress proxyAddress,
                          String proxyType,
                          String proxyVersion,
                          String proxyUser,
                          String proxyPassword,
                          String proxyDomain,
                          String proxyWorkstation )  throws ConfigError {
  // Create proxy connector.
  ProxyRequest req;
  ProxyConnector connector = new ProxyConnector(socketConnector);
  connector.setConnectTimeoutMillis(5000);
  if (proxyType.equalsIgnoreCase("http")) {
    req = createHttpProxyRequest(address, proxyVersion, proxyUser, proxyPassword, proxyDomain, proxyWorkstation);
  } else if (proxyType.equalsIgnoreCase("socks")) {
    req = createSocksProxyRequest(address, proxyVersion, proxyUser, proxyPassword);
  } else {
    throw new ConfigError("Proxy type must be http or socks");
  }
  ProxyIoSession proxyIoSession = new ProxyIoSession(proxyAddress, req);
  List<HttpAuthenticationMethods> l = new ArrayList<>();
  l.add(HttpAuthenticationMethods.NO_AUTH);
  l.add(HttpAuthenticationMethods.DIGEST);
  l.add(HttpAuthenticationMethods.BASIC);
  proxyIoSession.setPreferedOrder(l);
  connector.setProxyIoSession(proxyIoSession);
  return connector;
}
origin: org.apache.mina/mina-core

/**
 * Method to reconnect to the proxy when it decides not to maintain the connection 
 * during handshake.
 * 
 * @param nextFilter the next filter
 * @param request the http request
 */
private void reconnect(final NextFilter nextFilter, final HttpProxyRequest request) {
  LOGGER.debug("Reconnecting to proxy ...");
  final ProxyIoSession proxyIoSession = getProxyIoSession();
  // Fires reconnection
  proxyIoSession.getConnector().connect(new IoSessionInitializer<ConnectFuture>() {
    @Override
    public void initializeSession(final IoSession session, ConnectFuture future) {
      LOGGER.debug("Initializing new session: {}", session);
      session.setAttribute(ProxyIoSession.PROXY_SESSION, proxyIoSession);
      proxyIoSession.setSession(session);
      LOGGER.debug("  setting up proxyIoSession: {}", proxyIoSession);
      // Reconnection is done so we send the
      // request to the proxy
      proxyIoSession.setReconnectionNeeded(false);
      writeRequest0(nextFilter, request);
    }
  });
}
origin: org.apache.mina/mina-core

/**
 * Creates a new proxy connector.
 * 
 * @param connector The Connector used to establish proxy connections.
 * @param config The session confiugarion to use
 * @param executor The associated executor
 */
public ProxyConnector(final SocketConnector connector, IoSessionConfig config, Executor executor) {
  super(config, executor);
  setConnector(connector);
}
origin: org.apache.mina/mina-core

/**
 * Sets the proxy session object of this connector.
 * @param proxyIoSession the configuration of this connector.
 */
public void setProxyIoSession(ProxyIoSession proxyIoSession) {
  if (proxyIoSession == null) {
    throw new IllegalArgumentException("proxySession object cannot be null");
  }
  if (proxyIoSession.getProxyAddress() == null) {
    throw new IllegalArgumentException("proxySession.proxyAddress cannot be null");
  }
  proxyIoSession.setConnector(this);
  setDefaultRemoteAddress(proxyIoSession.getProxyAddress());
  this.proxyIoSession = proxyIoSession;
}
origin: org.apache.mina/mina-core

/**
 * Signals that the handshake has finished.
 */
protected final void setHandshakeComplete() {
  synchronized (this) {
    handshakeComplete = true;
  }
  ProxyIoSession proxyIoSession = getProxyIoSession();
  proxyIoSession.getConnector().fireConnected(proxyIoSession.getSession()).awaitUninterruptibly();
  LOGGER.debug("  handshake completed");
  // Connected OK
  try {
    proxyIoSession.getEventQueue().flushPendingSessionEvents();
    flushPendingWriteRequests();
  } catch (Exception ex) {
    LOGGER.error("Unable to flush pending write requests", ex);
  }
}
origin: quickfix-j/quickfixj

private void setupIoConnector() throws ConfigError, GeneralSecurityException {
  final CompositeIoFilterChainBuilder ioFilterChainBuilder = new CompositeIoFilterChainBuilder(userIoFilterChainBuilder);
  boolean hasProxy = proxyType != null && proxyPort > 0 && socketAddresses[nextSocketAddressIndex] instanceof InetSocketAddress;
  SSLFilter sslFilter = null;
  if (sslEnabled) {
    sslFilter = installSslFilter(ioFilterChainBuilder, !hasProxy);
  }
  ioFilterChainBuilder.addLast(FIXProtocolCodecFactory.FILTER_NAME, new ProtocolCodecFilter(new FIXProtocolCodecFactory()));
  IoConnector newConnector;
  newConnector = ProtocolFactory.createIoConnector(socketAddresses[nextSocketAddressIndex]);
  newConnector.setHandler(new InitiatorIoHandler(fixSession, networkingOptions, eventHandlingStrategy));
  newConnector.setFilterChainBuilder(ioFilterChainBuilder);
  if (hasProxy) {
    ProxyConnector proxyConnector = ProtocolFactory.createIoProxyConnector(
        (SocketConnector) newConnector,
        (InetSocketAddress) socketAddresses[nextSocketAddressIndex],
        new InetSocketAddress(proxyHost, proxyPort),
        proxyType, proxyVersion, proxyUser, proxyPassword, proxyDomain, proxyWorkstation
    );
    proxyConnector.setHandler(new InitiatorProxyIoHandler(
        new InitiatorIoHandler(fixSession, networkingOptions, eventHandlingStrategy),
        sslFilter
    ));
    newConnector = proxyConnector;
  }
  if (ioConnector != null) {
    SessionConnector.closeManagedSessionsAndDispose(ioConnector, true, log);
  }
  ioConnector = newConnector;
}
origin: org.apache.mina/mina-core

if (!proxyIoSession.isReconnectionNeeded()) {
  IoHandler handler = getHandler();
  if (!(handler instanceof AbstractProxyIoHandler)) {
    throw new IllegalArgumentException("IoHandler must be an instance of AbstractProxyIoHandler");
origin: org.apache.mina/mina-core

if (evt.getType() == IoSessionEventType.CLOSED) {
  if (proxyIoSession.isAuthenticationFailed()) {
    proxyIoSession.getConnector().cancelConnectFuture();
    discardSessionQueueEvents();
    evt.deliverEvent();
origin: org.apache.directory.api/api-ldap-client-all

/**
 * Sets the proxy session object of this connector.
 * @param proxyIoSession the configuration of this connector.
 */
public void setProxyIoSession(ProxyIoSession proxyIoSession) {
  if (proxyIoSession == null) {
    throw new IllegalArgumentException("proxySession object cannot be null");
  }
  if (proxyIoSession.getProxyAddress() == null) {
    throw new IllegalArgumentException("proxySession.proxyAddress cannot be null");
  }
  proxyIoSession.setConnector(this);
  setDefaultRemoteAddress(proxyIoSession.getProxyAddress());
  this.proxyIoSession = proxyIoSession;
}
origin: org.apache.directory.api/api-ldap-client-all

/**
 * Signals that the handshake has finished.
 */
protected final void setHandshakeComplete() {
  synchronized (this) {
    handshakeComplete = true;
  }
  ProxyIoSession proxyIoSession = getProxyIoSession();
  proxyIoSession.getConnector().fireConnected(proxyIoSession.getSession()).awaitUninterruptibly();
  LOGGER.debug("  handshake completed");
  // Connected OK
  try {
    proxyIoSession.getEventQueue().flushPendingSessionEvents();
    flushPendingWriteRequests();
  } catch (Exception ex) {
    LOGGER.error("Unable to flush pending write requests", ex);
  }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.quickfix

private void setupIoConnector() throws ConfigError, GeneralSecurityException {
  final CompositeIoFilterChainBuilder ioFilterChainBuilder = new CompositeIoFilterChainBuilder(userIoFilterChainBuilder);
  boolean hasProxy = proxyType != null && proxyPort > 0 && socketAddresses[nextSocketAddressIndex] instanceof InetSocketAddress;
  SSLFilter sslFilter = null;
  if (sslEnabled) {
    sslFilter = installSslFilter(ioFilterChainBuilder, !hasProxy);
  }
  ioFilterChainBuilder.addLast(FIXProtocolCodecFactory.FILTER_NAME, new ProtocolCodecFilter(new FIXProtocolCodecFactory()));
  IoConnector newConnector;
  newConnector = ProtocolFactory.createIoConnector(socketAddresses[nextSocketAddressIndex]);
  newConnector.setHandler(new InitiatorIoHandler(fixSession, networkingOptions, eventHandlingStrategy));
  newConnector.setFilterChainBuilder(ioFilterChainBuilder);
  if (hasProxy) {
    ProxyConnector proxyConnector = ProtocolFactory.createIoProxyConnector(
        (SocketConnector) newConnector,
        (InetSocketAddress) socketAddresses[nextSocketAddressIndex],
        new InetSocketAddress(proxyHost, proxyPort),
        proxyType, proxyVersion, proxyUser, proxyPassword, proxyDomain, proxyWorkstation
    );
    proxyConnector.setHandler(new InitiatorProxyIoHandler(
        new InitiatorIoHandler(fixSession, networkingOptions, eventHandlingStrategy),
        sslFilter
    ));
    newConnector = proxyConnector;
  }
  if (ioConnector != null) {
    ioConnector.dispose();
  }
  ioConnector = newConnector;
}
origin: org.apache.directory.api/api-ldap-client-all

if (!proxyIoSession.isReconnectionNeeded()) {
  IoHandler handler = getHandler();
  if (!(handler instanceof AbstractProxyIoHandler)) {
    throw new IllegalArgumentException("IoHandler must be an instance of AbstractProxyIoHandler");
origin: kaazing/gateway

if (evt.getType() == IoSessionEventType.CLOSED) {
  if (proxyIoSession.isAuthenticationFailed()) {
    proxyIoSession.getConnector().cancelConnectFuture();
    discardSessionQueueEvents();
    evt.deliverEvent();
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.quickfix

public static ProxyConnector createIoProxyConnector(SocketConnector socketConnector,
                          InetSocketAddress address,
                          InetSocketAddress proxyAddress,
                          String proxyType,
                          String proxyVersion,
                          String proxyUser,
                          String proxyPassword,
                          String proxyDomain,
                          String proxyWorkstation )  throws ConfigError {
  // Create proxy connector.
  ProxyRequest req;
  ProxyConnector connector = new ProxyConnector(socketConnector);
  connector.setConnectTimeoutMillis(5000);
  if (proxyType.equalsIgnoreCase("http")) {
    req = createHttpProxyRequest(address, proxyVersion, proxyUser, proxyPassword, proxyDomain, proxyWorkstation);
  } else if (proxyType.equalsIgnoreCase("socks")) {
    req = createSocksProxyRequest(address, proxyVersion, proxyUser, proxyPassword);
  } else {
    throw new ConfigError("Proxy type must be http or socks");
  }
  ProxyIoSession proxyIoSession = new ProxyIoSession(proxyAddress, req);
  List<HttpAuthenticationMethods> l = new ArrayList<>();
  l.add(HttpAuthenticationMethods.NO_AUTH);
  l.add(HttpAuthenticationMethods.DIGEST);
  l.add(HttpAuthenticationMethods.BASIC);
  proxyIoSession.setPreferedOrder(l);
  connector.setProxyIoSession(proxyIoSession);
  return connector;
}
origin: kaazing/gateway

/**
 * Creates a new proxy connector. 
 * @see AbstractIoConnector(IoSessionConfig, Executor).
 */
public ProxyConnector(final SocketConnector connector, IoSessionConfig config, Executor executor) {
  super(config, executor);
  setConnector(connector);
}    

origin: kaazing/gateway

/**
 * Sets the proxy session object of this connector.
 * @param proxyIoSession the configuration of this connector.
 */
public void setProxyIoSession(ProxyIoSession proxyIoSession) {
  if (proxyIoSession == null) {
    throw new NullPointerException("proxySession object cannot be null");
  }
  if (proxyIoSession.getProxyAddress() == null) {
    throw new NullPointerException(
        "proxySession.proxyAddress cannot be null");
  }
  proxyIoSession.setConnector(this);
  setDefaultRemoteAddress(proxyIoSession.getProxyAddress());
  this.proxyIoSession = proxyIoSession;
}
origin: kaazing/gateway

/**
 * Signals that the handshake has finished.
 */
protected final void setHandshakeComplete() {
  synchronized (this) {
    handshakeComplete = true;
  }
  ProxyIoSession proxyIoSession = getProxyIoSession();
  proxyIoSession.getConnector()
      .fireConnected(proxyIoSession.getSession())
      .awaitUninterruptibly();
  LOGGER.debug("  handshake completed");
  // Connected OK
  try {
    proxyIoSession.getEventQueue().flushPendingSessionEvents();
    flushPendingWriteRequests();
  } catch (Exception ex) {
    LOGGER.error("Unable to flush pending write requests", ex);
  }
}
origin: org.apache.directory.api/api-ldap-client-all

/**
 * Method to reconnect to the proxy when it decides not to maintain the connection 
 * during handshake.
 * 
 * @param nextFilter the next filter
 * @param request the http request
 */
private void reconnect(final NextFilter nextFilter, final HttpProxyRequest request) {
  LOGGER.debug("Reconnecting to proxy ...");
  final ProxyIoSession proxyIoSession = getProxyIoSession();
  // Fires reconnection
  proxyIoSession.getConnector().connect(new IoSessionInitializer<ConnectFuture>() {
    @Override
    public void initializeSession(final IoSession session, ConnectFuture future) {
      LOGGER.debug("Initializing new session: {}", session);
      session.setAttribute(ProxyIoSession.PROXY_SESSION, proxyIoSession);
      proxyIoSession.setSession(session);
      LOGGER.debug("  setting up proxyIoSession: {}", proxyIoSession);
      // Reconnection is done so we send the
      // request to the proxy
      proxyIoSession.setReconnectionNeeded(false);
      writeRequest0(nextFilter, request);
    }
  });
}
origin: org.quickfixj/quickfixj-all

private void setupIoConnector() throws ConfigError, GeneralSecurityException {
  final CompositeIoFilterChainBuilder ioFilterChainBuilder = new CompositeIoFilterChainBuilder(userIoFilterChainBuilder);
  boolean hasProxy = proxyType != null && proxyPort > 0 && socketAddresses[nextSocketAddressIndex] instanceof InetSocketAddress;
  SSLFilter sslFilter = null;
  if (sslEnabled) {
    sslFilter = installSslFilter(ioFilterChainBuilder, !hasProxy);
  }
  ioFilterChainBuilder.addLast(FIXProtocolCodecFactory.FILTER_NAME, new ProtocolCodecFilter(new FIXProtocolCodecFactory()));
  IoConnector newConnector;
  newConnector = ProtocolFactory.createIoConnector(socketAddresses[nextSocketAddressIndex]);
  newConnector.setHandler(new InitiatorIoHandler(fixSession, networkingOptions, eventHandlingStrategy));
  newConnector.setFilterChainBuilder(ioFilterChainBuilder);
  if (hasProxy) {
    ProxyConnector proxyConnector = ProtocolFactory.createIoProxyConnector(
        (SocketConnector) newConnector,
        (InetSocketAddress) socketAddresses[nextSocketAddressIndex],
        new InetSocketAddress(proxyHost, proxyPort),
        proxyType, proxyVersion, proxyUser, proxyPassword, proxyDomain, proxyWorkstation
    );
    proxyConnector.setHandler(new InitiatorProxyIoHandler(
        new InitiatorIoHandler(fixSession, networkingOptions, eventHandlingStrategy),
        sslFilter
    ));
    newConnector = proxyConnector;
  }
  if (ioConnector != null) {
    SessionConnector.closeManagedSessionsAndDispose(ioConnector, true, log);
  }
  ioConnector = newConnector;
}
origin: kaazing/gateway

if (!proxyIoSession.isReconnectionNeeded()) {
  IoHandler handler = getHandler();
  if (!(handler instanceof AbstractProxyIoHandler)) {
    throw new IllegalArgumentException(
org.apache.mina.proxyProxyConnector

Javadoc

ProxyConnector.java - Decorator for SocketConnector to provide proxy support, as suggested by MINA list discussions.

Operates by intercepting connect requests and replacing the endpoint address with the proxy address, then adding a ProxyFilter as the first IoFilter which performs any necessary handshaking with the proxy before allowing data to flow normally. During the handshake, any outgoing write requests are buffered.

Most used methods

  • <init>
    Creates a new proxy connector.
  • cancelConnectFuture
    Cancels the real connection when reconnection is in use.
  • connect
  • fireConnected
    Fires the connection event on the real future to notify the client.
  • getHandler
  • setConnectTimeoutMillis
  • setConnector
    Sets the SocketConnector to be used for connections to the proxy server.
  • setDefaultRemoteAddress
  • setHandler
  • setProxyIoSession
    Sets the proxy session object of this connector.

Popular in Java

  • Parsing JSON documents to java classes using gson
  • scheduleAtFixedRate (ScheduledExecutorService)
  • onCreateOptionsMenu (Activity)
  • requestLocationUpdates (LocationManager)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base

For IntelliJ IDEA,
Android Studio or Eclipse

  • Search for JavaScript code betaCodota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutBlogContact Us
  • Plugin user guideTerms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)