summaryrefslogtreecommitdiffstats
path: root/simple/simple-transport/src/main/java/org/simpleframework/transport/Negotiation.java
blob: 4140b345c5fa4ab508a87473b0937a1b8364a7e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * Negotiation.java February 2007
 *
 * Copyright (C) 2007, Niall Gallagher <niallg@users.sf.net>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 * implied. See the License for the specific language governing 
 * permissions and limitations under the License.
 */

package org.simpleframework.transport;

import java.io.IOException;

import org.simpleframework.transport.reactor.Operation;

/**
 * The <code>Negotiation</code> interface is used to represent an
 * SSL negotiation. When an operation can not be completed this
 * will allow a task to perform asynchronous operations and resume
 * the negotiation when those operations can be fulfilled.
 * 
 * @author Niall Gallagher
 */
interface Negotiation extends Operation  {
   
   /**
    * This is used to resume the negotiation when an operation
    * has completed. This will continue the decrypt and encrypt
    * sequence of messages required to fulfil the negotiation.
    */
   void resume() throws IOException;

   /**
    * This method is invoked when the negotiation is done and
    * the next phase of the connection is to take place. This
    * will typically be invoked when an SSL handshake or
    * termination exchange has completed successfully. 
    */
   void commit() throws IOException;     
   
   /**
    * This is used to send any messages the negotiation may have.
    * If the negotiation can not send the information during its
    * execution then this method will be executed when a select
    * operation is signaled.
    * 
    * @return this returns true when the message has been sent
    */
   boolean send() throws IOException;   
   
   /**
    * This is used to receive data from the other side. If at any
    * point during the negotiation a message is required that
    * can not be read immediately this is used to asynchronously
    * read the data when a select operation is signaled.
    *  
    * @return this returns true when the message has been read
    */
   boolean receive() throws IOException; 
}