001: /*
002: * SSHTools - Java SSH2 API
003: *
004: * Copyright (C) 2002-2003 Lee David Painter and Contributors.
005: *
006: * Contributions made by:
007: *
008: * Brett Smith
009: * Richard Pernavas
010: * Erwin Bolwidt
011: *
012: * This program is free software; you can redistribute it and/or
013: * modify it under the terms of the GNU General Public License
014: * as published by the Free Software Foundation; either version 2
015: * of the License, or (at your option) any later version.
016: *
017: * This program is distributed in the hope that it will be useful,
018: * but WITHOUT ANY WARRANTY; without even the implied warranty of
019: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
020: * GNU General Public License for more details.
021: *
022: * You should have received a copy of the GNU General Public License
023: * along with this program; if not, write to the Free Software
024: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
025: */
026: package com.sshtools.j2ssh.connection;
027:
028: import com.sshtools.j2ssh.io.ByteArrayReader;
029: import com.sshtools.j2ssh.io.ByteArrayWriter;
030: import com.sshtools.j2ssh.transport.InvalidMessageException;
031: import com.sshtools.j2ssh.transport.SshMessage;
032:
033: import java.io.IOException;
034:
035: /**
036: *
037: *
038: * @author $author$
039: * @version $Revision: 1.20 $
040: */
041: public class SshMsgRequestSuccess extends SshMessage {
042: /** */
043: protected final static int SSH_MSG_REQUEST_SUCCESS = 81;
044: private byte[] requestData;
045:
046: /**
047: * Creates a new SshMsgRequestSuccess object.
048: *
049: * @param requestData
050: */
051: public SshMsgRequestSuccess(byte[] requestData) {
052: super (SSH_MSG_REQUEST_SUCCESS);
053: this .requestData = requestData;
054: }
055:
056: /**
057: * Creates a new SshMsgRequestSuccess object.
058: */
059: public SshMsgRequestSuccess() {
060: super (SSH_MSG_REQUEST_SUCCESS);
061: }
062:
063: /**
064: *
065: *
066: * @return
067: */
068: public String getMessageName() {
069: return "SSH_MSG_REQUEST_SUCCESS";
070: }
071:
072: /**
073: *
074: *
075: * @return
076: */
077: public byte[] getRequestData() {
078: return requestData;
079: }
080:
081: /**
082: *
083: *
084: * @param baw
085: *
086: * @throws InvalidMessageException
087: */
088: protected void constructByteArray(ByteArrayWriter baw)
089: throws InvalidMessageException {
090: try {
091: if (requestData != null) {
092: baw.write(requestData);
093: }
094: } catch (IOException ioe) {
095: throw new InvalidMessageException("Invalid message data");
096: }
097: }
098:
099: /**
100: *
101: *
102: * @param bar
103: *
104: * @throws InvalidMessageException
105: */
106: protected void constructMessage(ByteArrayReader bar)
107: throws InvalidMessageException {
108: try {
109: if (bar.available() > 0) {
110: requestData = new byte[bar.available()];
111: bar.read(requestData);
112: }
113: } catch (IOException ioe) {
114: throw new InvalidMessageException("Invalid message data");
115: }
116: }
117: }
|