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   * @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)
51              throws ProxyAuthException;
52  
53      /**
54       * Called at each step of the handshake procedure.
55       * 
56       * @param nextFilter the next filter in filter chain
57       * @throws ProxyAuthException if authentication fails
58       */
59      public abstract void doHandshake(NextFilter nextFilter)
60              throws ProxyAuthException;
61  
62      /**
63       * Returns the {@link ProxyIoSession}.
64       * 
65       * @return the proxy session object
66       */
67      public abstract ProxyIoSession getProxyIoSession();
68  
69      /**
70       * Enqueue a message to be written once handshaking is complete.
71       * 
72       * @param nextFilter the next filter in filter chain
73       * @param writeRequest the data to be written
74       */
75      public abstract void enqueueWriteRequest(final NextFilter nextFilter,
76              final WriteRequest writeRequest);
77  }