001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /**
019: * @author Vera Y. Petrashkova
020: * @version $Revision$
021: */package javax.net.ssl;
022:
023: /**
024: * @com.intel.drl.spec_ref
025: *
026: */
027: public class SSLEngineResult {
028:
029: // Store Status object
030: private final SSLEngineResult.Status status;
031:
032: // Store HandshakeStatus object
033: private final SSLEngineResult.HandshakeStatus handshakeStatus;
034:
035: // Store bytesConsumed
036: private final int bytesConsumed;
037:
038: // Store bytesProduced
039: private final int bytesProduced;
040:
041: /**
042: * @com.intel.drl.spec_ref
043: */
044: public SSLEngineResult(SSLEngineResult.Status status,
045: SSLEngineResult.HandshakeStatus handshakeStatus,
046: int bytesConsumed, int bytesProduced) {
047: if (status == null) {
048: throw new IllegalArgumentException("status is null");
049: }
050: if (handshakeStatus == null) {
051: throw new IllegalArgumentException(
052: "handshakeStatus is null");
053: }
054: if (bytesConsumed < 0) {
055: throw new IllegalArgumentException(
056: "bytesConsumed is negative");
057: }
058: if (bytesProduced < 0) {
059: throw new IllegalArgumentException(
060: "bytesProduced is negative");
061: }
062: this .status = status;
063: this .handshakeStatus = handshakeStatus;
064: this .bytesConsumed = bytesConsumed;
065: this .bytesProduced = bytesProduced;
066: }
067:
068: /**
069: * @com.intel.drl.spec_ref
070: */
071: public final Status getStatus() {
072: return status;
073: }
074:
075: /**
076: * @com.intel.drl.spec_ref
077: */
078: public final HandshakeStatus getHandshakeStatus() {
079: return handshakeStatus;
080: }
081:
082: /**
083: * @com.intel.drl.spec_ref
084: */
085: public final int bytesConsumed() {
086: return bytesConsumed;
087: }
088:
089: /**
090: * @com.intel.drl.spec_ref
091: */
092: public final int bytesProduced() {
093: return bytesProduced;
094: }
095:
096: /**
097: * @com.intel.drl.spec_ref
098: */
099: public String toString() {
100: StringBuffer sb = new StringBuffer("SSLEngineReport: Status = ");
101: sb.append(status.toString());
102: sb.append(" HandshakeStatus = ");
103: sb.append(handshakeStatus.toString());
104: sb.append("\n bytesConsumed = ");
105: sb.append(Integer.toString(bytesConsumed));
106: sb.append(" bytesProduced = ");
107: sb.append(Integer.toString(bytesProduced));
108: return sb.toString();
109: }
110:
111: /**
112: * @com.intel.drl.spec_ref
113: */
114: public enum HandshakeStatus {
115: NOT_HANDSHAKING, FINISHED, NEED_TASK, NEED_WRAP, NEED_UNWRAP
116: }
117:
118: /**
119: * @com.intel.drl.spec_ref
120: */
121: public static enum Status {
122: BUFFER_OVERFLOW, BUFFER_UNDERFLOW, CLOSED, OK
123: }
124: }
|