Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.sshtools.client;
/*-
* #%L
* Client API
* %%
* Copyright (C) 2002 - 2024 JADAPTIVE Limited
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import java.io.IOException;
import com.sshtools.common.nio.WriteOperationRequest;
import com.sshtools.common.ssh.ChannelOpenException;
import com.sshtools.common.ssh.ChannelRequestFuture;
import com.sshtools.common.ssh.RequestFuture;
import com.sshtools.common.util.ByteArrayReader;
import com.sshtools.common.util.ByteArrayWriter;
import com.sshtools.common.util.UnsignedInteger32;
import com.sshtools.synergy.ssh.ChannelNG;
import com.sshtools.synergy.ssh.TerminalModes;
/**
* Implements the client side of the SSH Connection protocol session channel
*/
public abstract class AbstractSessionChannel extends ChannelNG {
public static final int EXITCODE_NOT_RECEIVED = Integer.MIN_VALUE;
public static final int SSH_EXTENDED_DATA_STDERR = 1;
private int exitcode = EXITCODE_NOT_RECEIVED;
private String exitsignalinfo;
private boolean flowControlEnabled;
private boolean singleSession = false;
public AbstractSessionChannel(int maximumPacketSize, UnsignedInteger32 initialWindowSize, UnsignedInteger32 maximumWindowSpace,
UnsignedInteger32 minimumWindowSpace, boolean autoConsume) {
super("session", maximumPacketSize, initialWindowSize, maximumWindowSpace, minimumWindowSpace,
new ChannelRequestFuture(), autoConsume);
}
public AbstractSessionChannel(int maximumPacketSize, UnsignedInteger32 initialWindowSize, UnsignedInteger32 maximumWindowSpace,
UnsignedInteger32 minimumWindowSpace, ChannelRequestFuture closeFuture, boolean autoConsume) {
super("session", maximumPacketSize, initialWindowSize, maximumWindowSpace, minimumWindowSpace, closeFuture, autoConsume);
}
public boolean isSingleSession() {
return singleSession;
}
public void setSingleSession(boolean singleSession) {
this.singleSession = singleSession;
}
@Override
protected void onChannelFree() {
}
@Override
protected byte[] createChannel() throws IOException {
return null;
}
@Override
protected byte[] openChannel(byte[] requestdata) throws WriteOperationRequest, ChannelOpenException {
return null;
}
@Override
protected void onChannelOpenConfirmation() {
}
@Override
protected void onChannelError(Throwable e) {
}
@Override
protected void onChannelClosed() {
if(singleSession) {
con.disconnect();
}
}
@Override
protected void onChannelOpen() {
}
public RequestFuture allocatePseudoTerminal(String type) {
return allocatePseudoTerminal(type, 80, 25);
}
public RequestFuture allocatePseudoTerminal(String type, int cols, int rows) {
return allocatePseudoTerminal(type, cols, rows, 0, 0, (TerminalModes)null);
}
public RequestFuture allocatePseudoTerminal(String type, int cols, int rows, PseudoTerminalModes modes) {
return allocatePseudoTerminal(type, cols, rows, 0, 0, modes);
}
public void changeTerminalDimensions(int cols, int rows, int width, int height) {
ByteArrayWriter request = new ByteArrayWriter();
try {
request.writeInt(cols);
request.writeInt(rows);
request.writeInt(width);
request.writeInt(height);
sendChannelRequest("window-change", false, request.toByteArray());
} catch (IOException ex) {
throw new IllegalStateException(ex.getMessage(), ex);
} finally {
try {
request.close();
} catch (IOException e) {
}
}
}
/**
* Send a signal to the remote process. A signal can be delivered to the
* remote process using this method, some systems may not implement signals.
* The signal name should be one of the following values: