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 The Apache MINA Project (dev@mina.apache.org)
31   * @version $Rev: 759663 $, $Date: 2009-03-29 12:46:40 +0200 (Sun, 29 Mar 2009) $
32   * @since MINA 2.0.0-M3
33   */
34  public interface ProxyLogicHandler {
35      /**
36       * Tests if handshake process is complete.
37       * 
38       * @return <code>true</code> if handshaking is complete and
39       * data can be sent through the proxy, false otherwise.
40       */
41      public abstract boolean isHandshakeComplete();
42  
43      /**
44       * Handle incoming data during the handshake process. Should consume only the
45       * handshake data from the buffer, leaving any extra data in place.
46       * 
47       * @param nextFilter the next filter in the filter chain
48       * @param buf the buffer holding the received data
49       * @throws ProxyAuthException if authentication fails
50       */
51      public abstract void messageReceived(NextFilter nextFilter, IoBuffer buf)
52              throws ProxyAuthException;
53  
54      /**
55       * Called at each step of the handshake procedure.
56       * 
57       * @param nextFilter the next filter in filter chain
58       * @throws ProxyAuthException if authentication fails
59       */
60      public abstract void doHandshake(NextFilter nextFilter)
61              throws ProxyAuthException;
62  
63      /**
64       * Returns the {@link ProxyIoSession}.
65       * 
66       * @return the proxy session object
67       */
68      public abstract ProxyIoSession getProxyIoSession();
69  
70      /**
71       * Enqueue a message to be written once handshaking is complete.
72       * 
73       * @param nextFilter the next filter in filter chain
74       * @param writeRequest the data to be written
75       */
76      public abstract void enqueueWriteRequest(final NextFilter nextFilter,
77              final WriteRequest writeRequest);
78  }