View Javadoc

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one
    3    *  or more contributor license agreements.  See the NOTICE file
    4    *  distributed with this work for additional information
    5    *  regarding copyright ownership.  The ASF licenses this file
    6    *  to you under the Apache License, Version 2.0 (the
    7    *  "License"); you may not use this file except in compliance
    8    *  with the License.  You may obtain a copy of the License at
    9    *
    10   *    http://www.apache.org/licenses/LICENSE-2.0
    11   *
    12   *  Unless required by applicable law or agreed to in writing,
    13   *  software distributed under the License is distributed on an
    14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    15   *  KIND, either express or implied.  See the License for the
    16   *  specific language governing permissions and limitations
    17   *  under the License.
    18   *
    19   */
    20  package org.apache.mina.proxy;
    21
    22  import org.apache.mina.core.buffer.IoBuffer;
    23  import org.apache.mina.core.filterchain.IoFilter.NextFilter;
    24  import org.apache.mina.core.write.WriteRequest;
    25  import org.apache.mina.proxy.session.ProxyIoSession;
    26
    27  /**
    28   * ProxyLogicHandler.java - Interface implemented by classes containing proxy type specific logic.
    29   *
    30   * @author <a href="http://mina.apache.org">Apache MINA Project</a>
    31   * @since MINA 2.0.0-M3
    32   */
    33  public interface ProxyLogicHandler {
    34      /**
    35       * Tests if handshake process is complete.
    36       *
    37       * @return <code>true</code> if handshaking is complete and
    38       * data can be sent through the proxy, false otherwise.
    39       */
    40      public abstract boolean isHandshakeComplete();
    41
    42      /**
    43       * Handle incoming data during the handshake process. Should consume only the
    44       * handshake data from the buffer, leaving any extra data in place.
    45       *
    46       * @param nextFilter the next filter in the filter chain
    47       * @param buf the buffer holding the received data
    48       * @throws ProxyAuthException if authentication fails
    49       */
    50      public abstract void messageReceived(NextFilter nextFilter, IoBuffer buf) throws ProxyAuthException;
    51
    52      /**
    53       * Called at each step of the handshake procedure.
    54       *
    55       * @param nextFilter the next filter in filter chain
    56       * @throws ProxyAuthException if authentication fails
    57       */
    58      public abstract void doHandshake(NextFilter nextFilter) throws ProxyAuthException;
    59
    60      /**
    61       * Returns the {@link ProxyIoSession}.
    62       *
    63       * @return the proxy session object
    64       */
    65      public abstract ProxyIoSession getProxyIoSession();
    66
    67      /**
    68       * Enqueue a message to be written once handshaking is complete.
    69       *
    70       * @param nextFilter the next filter in filter chain
    71       * @param writeRequest the data to be written
    72       */
    73      public abstract void enqueueWriteRequest(final NextFilter nextFilter, final WriteRequest writeRequest);
    74  }