01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /**
19: * @author Boris Kuznetsov
20: * @version $Revision$
21: */package org.apache.harmony.xnet.provider.jsse;
22:
23: import org.apache.harmony.xnet.provider.jsse.Message;
24:
25: import java.io.IOException;
26:
27: /**
28: *
29: * Represents Finished message
30: * @see TLS 1.0 spec., 7.4.9. Finished
31: * (http://www.ietf.org/rfc/rfc2246.txt)
32: *
33: */
34: public class Finished extends Message {
35:
36: // verify data
37: private byte[] data;
38:
39: /**
40: * Creates outbound message
41: * @param bytes
42: */
43: public Finished(byte[] bytes) {
44: data = bytes;
45: length = data.length;
46: }
47:
48: /**
49: * Creates inbound message
50: * @param in
51: * @param length
52: * @throws IOException
53: */
54: public Finished(HandshakeIODataStream in, int length)
55: throws IOException {
56: if (length == 12 || length == 36) {
57: data = in.read(length);
58: length = data.length;
59: } else {
60: fatalAlert(AlertProtocol.DECODE_ERROR,
61: "DECODE ERROR: incorrect Finished");
62: }
63: }
64:
65: public void send(HandshakeIODataStream out) {
66: out.write(data);
67: }
68:
69: /**
70: * Returns message type
71: * @return
72: */
73: public int getType() {
74: return Handshake.FINISHED;
75: }
76:
77: /**
78: * Returns verify data
79: * @return
80: */
81: public byte[] getData() {
82: return data;
83: }
84: }
|