code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public boolean isCharacter() {
if (permissions != null
&& (permissions.longValue() & SftpFileAttributes.S_IFCHR) == SftpFileAttributes.S_IFCHR) {
return true;
}
return false;
} | java |
public boolean isSocket() {
if (permissions != null
&& (permissions.longValue() & SftpFileAttributes.S_IFSOCK) == SftpFileAttributes.S_IFSOCK) {
return true;
}
return false;
} | java |
public static Provider getProviderForAlgorithm(String jceAlgorithm) {
if (specficProviders.containsKey(jceAlgorithm)) {
return (Provider) specficProviders.get(jceAlgorithm);
}
return defaultProvider;
} | java |
public static SecureRandom getSecureRandom()
throws NoSuchAlgorithmException {
if (secureRandom == null) {
try {
return secureRandom = JCEProvider
.getProviderForAlgorithm(JCEProvider
.getSecureRandomAlgorithm()) == null ? SecureRandom
.getInstance(JCEProvider.getSecureRandomAlgorithm()... | java |
public boolean containsFile(File f) {
return unchangedFiles.contains(f) || newFiles.contains(f)
|| updatedFiles.contains(f) || deletedFiles.contains(f)
|| recursedDirectories.contains(f)
|| failedTransfers.containsKey(f);
} | java |
public boolean containsFile(SftpFile f) {
return unchangedFiles.contains(f) || newFiles.contains(f)
|| updatedFiles.contains(f) || deletedFiles.contains(f)
|| recursedDirectories.contains(f.getAbsolutePath())
|| failedTransfers.containsKey(f);
} | java |
public void addDirectoryOperation(DirectoryOperation op, File f) {
addAll(op.getUpdatedFiles(), updatedFiles);
addAll(op.getNewFiles(), newFiles);
addAll(op.getUnchangedFiles(), unchangedFiles);
addAll(op.getDeletedFiles(), deletedFiles);
Object obj;
for (Enumeration e = op.failedTransfers.keys(); e.hasMor... | java |
public long getTransferSize() throws SftpStatusException, SshException {
Object obj;
long size = 0;
SftpFile sftpfile;
File file;
for (Enumeration e = newFiles.elements(); e.hasMoreElements();) {
obj = e.nextElement();
if (obj instanceof File) {
file = (File) obj;
if (file.isFile()) {
size... | java |
public void writeBigInteger(BigInteger bi) throws IOException {
byte[] raw = bi.toByteArray();
writeInt(raw.length);
write(raw);
} | java |
public void writeInt(long i) throws IOException {
byte[] raw = new byte[4];
raw[0] = (byte) (i >> 24);
raw[1] = (byte) (i >> 16);
raw[2] = (byte) (i >> 8);
raw[3] = (byte) (i);
write(raw);
} | java |
public static byte[] encodeInt(int i) {
byte[] raw = new byte[4];
raw[0] = (byte) (i >> 24);
raw[1] = (byte) (i >> 16);
raw[2] = (byte) (i >> 8);
raw[3] = (byte) (i);
return raw;
} | java |
public void writeString(String str, String charset) throws IOException {
if (str == null) {
writeInt(0);
} else {
byte[] tmp;
if (ByteArrayReader.encode)
tmp = str.getBytes(charset);
else
tmp = str.getBytes();
writeInt(tmp.length);
write(tmp);
}
} | java |
public void initialize() throws SshException, UnsupportedEncodingException {
// Initialize the SFTP subsystem
try {
Packet packet = createPacket();
packet.write(SSH_FXP_INIT);
packet.writeInt(this_MAX_VERSION);
sendMessage(packet);
byte[] msg = nextMessage();
if (msg[0] != SSH_FXP_VERSION) {
... | java |
public void setCharsetEncoding(String charset) throws SshException,
UnsupportedEncodingException {
if (version == -1)
throw new SshException(
"SFTP Channel must be initialized before setting character set encoding",
SshException.BAD_API_USAGE);
String test = "123456890";
test.getBytes(charset);
... | java |
public SftpMessage sendExtensionMessage(String request, byte[] requestData)
throws SshException, SftpStatusException {
try {
UnsignedInteger32 id = nextRequestId();
Packet packet = createPacket();
packet.write(SSH_FXP_EXTENDED);
packet.writeUINT32(id);
packet.writeString(request);
sendMessage(p... | java |
public UnsignedInteger32 postWriteRequest(byte[] handle, long position,
byte[] data, int off, int len) throws SftpStatusException,
SshException {
if ((data.length - off) < len) {
throw new IndexOutOfBoundsException("Incorrect data array size!");
}
try {
UnsignedInteger32 requestId = nextRequestId();... | java |
public void writeFile(byte[] handle, UnsignedInteger64 offset, byte[] data,
int off, int len) throws SftpStatusException, SshException {
getOKRequestStatus(postWriteRequest(handle, offset.longValue(), data,
off, len));
} | java |
public void performSynchronousRead(byte[] handle, int blocksize,
OutputStream out, FileTransferProgress progress, long position)
throws SftpStatusException, SshException,
TransferCancelledException {
if (Log.isDebugEnabled()) {
Log.debug(this, "Performing synchronous read postion="
+ position + " bl... | java |
public UnsignedInteger32 postReadRequest(byte[] handle, long offset, int len)
throws SftpStatusException, SshException {
try {
UnsignedInteger32 requestId = nextRequestId();
Packet msg = createPacket();
msg.write(SSH_FXP_READ);
msg.writeInt(requestId.longValue());
msg.writeBinaryString(handle);
m... | java |
public int readFile(byte[] handle, UnsignedInteger64 offset, byte[] output,
int off, int len) throws SftpStatusException, SshException {
try {
if ((output.length - off) < len) {
throw new IndexOutOfBoundsException(
"Output array size is smaller than read length!");
}
UnsignedInteger32 requestI... | java |
public void createSymbolicLink(String targetpath, String linkpath)
throws SftpStatusException, SshException {
if (version < 3) {
throw new SftpStatusException(
SftpStatusException.SSH_FX_OP_UNSUPPORTED,
"Symbolic links are not supported by the server SFTP version "
+ String.valueOf(version));
... | java |
public String getSymbolicLinkTarget(String linkpath)
throws SftpStatusException, SshException {
if (version < 3) {
throw new SftpStatusException(
SftpStatusException.SSH_FX_OP_UNSUPPORTED,
"Symbolic links are not supported by the server SFTP version "
+ String.valueOf(version));
}
try {
... | java |
public String getAbsolutePath(String path) throws SftpStatusException,
SshException {
try {
UnsignedInteger32 requestId = nextRequestId();
Packet msg = createPacket();
msg.write(SSH_FXP_REALPATH);
msg.writeInt(requestId.longValue());
msg.writeString(path, CHARSET_ENCODING);
sendMessage(msg);
... | java |
public void recurseMakeDirectory(String path) throws SftpStatusException,
SshException {
SftpFile file;
if (path.trim().length() > 0) {
try {
file = openDirectory(path);
file.close();
} catch (SshException ioe) {
int idx = 0;
do {
idx = path.indexOf('/', idx);
String tmp = (id... | java |
public SftpFile openDirectory(String path) throws SftpStatusException,
SshException {
String absolutePath = getAbsolutePath(path);
SftpFileAttributes attrs = getAttributes(absolutePath);
if (!attrs.isDirectory()) {
throw new SftpStatusException(SftpStatusException.SSH_FX_FAILURE,
path + " is not a d... | java |
public void closeFile(SftpFile file) throws SftpStatusException,
SshException {
if (file.getHandle() != null) {
closeHandle(file.getHandle());
EventServiceImplementation.getInstance().fireEvent(
(new Event(this, J2SSHEventCodes.EVENT_SFTP_FILE_CLOSED,
true)).addAttribute(
J2SSHEventCodes.... | java |
public void removeDirectory(String path) throws SftpStatusException,
SshException {
try {
UnsignedInteger32 requestId = nextRequestId();
Packet msg = createPacket();
msg.write(SSH_FXP_RMDIR);
msg.writeInt(requestId.longValue());
msg.writeString(path, CHARSET_ENCODING);
sendMessage(msg);
getO... | java |
public void removeFile(String filename) throws SftpStatusException,
SshException {
try {
UnsignedInteger32 requestId = nextRequestId();
Packet msg = createPacket();
msg.write(SSH_FXP_REMOVE);
msg.writeInt(requestId.longValue());
msg.writeString(filename, CHARSET_ENCODING);
sendMessage(msg);
... | java |
public void renameFile(String oldpath, String newpath)
throws SftpStatusException, SshException {
if (version < 2) {
throw new SftpStatusException(
SftpStatusException.SSH_FX_OP_UNSUPPORTED,
"Renaming files is not supported by the server SFTP version "
+ String.valueOf(version));
}
try {
... | java |
public SftpFileAttributes getAttributes(SftpFile file)
throws SftpStatusException, SshException {
try {
if (file.getHandle() == null) {
return getAttributes(file.getAbsolutePath());
}
UnsignedInteger32 requestId = nextRequestId();
Packet msg = createPacket();
msg.write(SSH_FXP_FSTAT);
msg.wr... | java |
public void makeDirectory(String path) throws SftpStatusException,
SshException {
makeDirectory(path, new SftpFileAttributes(this,
SftpFileAttributes.SSH_FILEXFER_TYPE_DIRECTORY));
} | java |
public ServerAuthenticator startSession(Socket s)
throws IOException{
PushbackInputStream in = new PushbackInputStream(s.getInputStream());
OutputStream out = s.getOutputStream();
int version = in.read();
if(version == 5){
if(!selectSocks5Authentication(in... | java |
public void start() throws IOException{
remote_sock.setSoTimeout(iddleTimeout);
client_sock.setSoTimeout(iddleTimeout);
log("Starting UDP relay server on "+relayIP+":"+relayPort);
log("Remote socket "+remote_sock.getLocalAddress()+":"+
remote_sock.getLocalPort())... | java |
public boolean startSubsystem(String subsystem) throws SshException {
ByteArrayWriter request = new ByteArrayWriter();
try {
request.writeString(subsystem);
boolean success = sendRequest("subsystem", true,
request.toByteArray());
if (success) {
EventServiceImplementation.getInstance().fireEvent(... | java |
boolean requestX11Forwarding(boolean singleconnection, String protocol,
String cookie, int screen) throws SshException {
ByteArrayWriter request = new ByteArrayWriter();
try {
request.writeBoolean(singleconnection);
request.writeString(protocol);
request.writeString(cookie);
request.writeInt(screen)... | java |
public boolean setEnvironmentVariable(String name, String value)
throws SshException {
ByteArrayWriter request = new ByteArrayWriter();
try {
request.writeString(name);
request.writeString(value);
return sendRequest("env", true, request.toByteArray());
} catch (IOException ex) {
throw new SshExcep... | java |
protected void channelRequest(String requesttype, boolean wantreply,
byte[] requestdata) throws SshException {
try {
if (requesttype.equals("exit-status")) {
if (requestdata != null) {
exitcode = (int) ByteArrayReader.readInt(requestdata, 0);
}
}
if (requesttype.equals("exit-signal")) {
... | java |
public void startLocalForwarding(String addressToBind, int portToBind,
String hostToConnect, int portToConnect) throws SshException {
String key = generateKey(addressToBind, portToBind);
SocketListener listener = new SocketListener(addressToBind, portToBind,
hostToConnect, portToConnect);
listener.start(... | java |
public String[] getRemoteForwardings() {
String[] r = new String[remoteforwardings.size()
- (remoteforwardings.containsKey(X11_KEY) ? 1 : 0)];
int index = 0;
for (Enumeration<String> e = remoteforwardings.keys(); e
.hasMoreElements();) {
String key = e.nextElement();
if (!key.equals(X11_KEY))
r... | java |
public String[] getLocalForwardings() {
String[] r = new String[socketlisteners.size()];
int index = 0;
for (Enumeration<String> e = socketlisteners.keys(); e
.hasMoreElements();) {
r[index++] = e.nextElement();
}
return r;
} | java |
public ActiveTunnel[] getRemoteForwardingTunnels() throws IOException {
Vector<ActiveTunnel> v = new Vector<ActiveTunnel>();
String[] remoteForwardings = getRemoteForwardings();
for (int i = 0; i < remoteForwardings.length; i++) {
ActiveTunnel[] tmp = getRemoteForwardingTunnels(remoteForwardings[i]);
for (i... | java |
public ActiveTunnel[] getLocalForwardingTunnels() throws IOException {
Vector<ActiveTunnel> v = new Vector<ActiveTunnel>();
String[] localForwardings = getLocalForwardings();
for (int i = 0; i < localForwardings.length; i++) {
ActiveTunnel[] tmp = getLocalForwardingTunnels(localForwardings[i]);
for (int x =... | java |
public ActiveTunnel[] getX11ForwardingTunnels() throws IOException {
if (incomingtunnels.containsKey(X11_KEY)) {
Vector<ActiveTunnel> v = incomingtunnels.get(X11_KEY);
ActiveTunnel[] t = new ActiveTunnel[v.size()];
v.copyInto(t);
return t;
}
return new ActiveTunnel[] {};
} | java |
public boolean requestRemoteForwarding(String addressToBind,
int portToBind, String hostToConnect, int portToConnect)
throws SshException {
if (ssh.requestRemoteForwarding(addressToBind, portToBind,
hostToConnect, portToConnect, forwardinglistener)) {
String key = generateKey(addressToBind, portToBind);
... | java |
public void cancelRemoteForwarding(String bindAddress, int bindPort,
boolean killActiveTunnels) throws SshException {
String key = generateKey(bindAddress, bindPort);
boolean killedTunnels = false;
if (killActiveTunnels) {
try {
ActiveTunnel[] tunnels = getRemoteForwardingTunnels(
bindAddress, b... | java |
public synchronized void cancelAllRemoteForwarding(boolean killActiveTunnels)
throws SshException {
if (remoteforwardings == null) {
return;
}
for (Enumeration<String> e = remoteforwardings.keys(); e
.hasMoreElements();) {
String host = (String) e.nextElement();
if (host == null)
return;
... | java |
public synchronized void stopAllLocalForwarding(boolean killActiveTunnels)
throws SshException {
for (Enumeration<String> e = socketlisteners.keys(); e
.hasMoreElements();) {
stopLocalForwarding((String) e.nextElement(), killActiveTunnels);
}
} | java |
public synchronized void stopLocalForwarding(String bindAddress,
int bindPort, boolean killActiveTunnels) throws SshException {
String key = generateKey(bindAddress, bindPort);
stopLocalForwarding(key, killActiveTunnels);
} | java |
public synchronized void stopLocalForwarding(String key,
boolean killActiveTunnels) throws SshException {
if (key == null)
return;
boolean killedTunnels = false;
if (killActiveTunnels) {
try {
ActiveTunnel[] tunnels = getLocalForwardingTunnels(key);
if (tunnels != null) {
for (int i = 0;... | java |
public boolean verifySignature(byte[] signature, byte[] data)
throws SshException {
ByteArrayReader bar = new ByteArrayReader(signature);
try {
if (signature.length != 40 // 160 bits
&& signature.length != 56 // 224 bits
&& signature.length != 64) { // 256 bits
byte[] sig = bar.readBinaryStr... | java |
public static ComponentManager getInstance() throws SshException {
synchronized (ComponentManager.class) {
if (instance == null) {
instance = new JCEComponentManager();
instance.init();
}
return instance;
}
} | java |
public void authenticate(AuthenticationProtocol authentication,
String servicename) throws SshException, AuthenticationResult {
try {
if (getUsername() == null || getPassword() == null) {
throw new SshException("Username or password not set!",
SshException.BAD_API_USAGE);
}
if (passwordChangeR... | java |
public void put(String localFileRegExp, String remoteFile,
boolean recursive, FileTransferProgress progress)
throws SshException, ChannelOpenException {
GlobRegExpMatching globMatcher = new GlobRegExpMatching();
String parentDir;
int fileSeparatorIndex;
parentDir = cwd.getAbsolutePath();
String relative... | java |
protected void open(int remoteid, long remotewindow, int remotepacket)
throws IOException {
this.remoteid = remoteid;
this.remotewindow = new DataWindow(remotewindow, remotepacket);
this.state = CHANNEL_OPEN;
synchronized (listeners) {
for (Enumeration<ChannelEventListener> e = listeners.elements(); e
... | java |
protected void open(int remoteid, long remotewindow, int remotepacket,
byte[] responsedata) throws IOException {
open(remoteid, remotewindow, remotepacket);
} | java |
public void close() {
boolean performClose = false;
;
synchronized (this) {
if (!closing && state == CHANNEL_OPEN) {
performClose = closing = true;
}
}
if (performClose) {
synchronized (listeners) {
for (Enumeration<ChannelEventListener> e = listeners.elements(); e
.hasMoreElements(... | java |
protected void channelRequest(String requesttype, boolean wantreply,
byte[] requestdata) throws SshException {
if (wantreply) {
ByteArrayWriter msg = new ByteArrayWriter();
try {
msg.write((byte) SSH_MSG_CHANNEL_FAILURE);
msg.writeInt(remoteid);
connection.sendMessage(msg.toByteArray(), true);
... | java |
public void setPreferredCipherCS(String name) throws SshException {
if (name == null)
return;
if (ciphersCS.contains(name)) {
prefCipherCS = name;
setCipherPreferredPositionCS(name, 0);
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
}
} | java |
public void setPreferredCipherSC(String name) throws SshException {
if (name == null)
return;
if (ciphersSC.contains(name)) {
prefCipherSC = name;
setCipherPreferredPositionSC(name, 0);
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
}
} | java |
public void setPreferredMacCS(String name) throws SshException {
if (name == null)
return;
if (macCS.contains(name)) {
prefMacCS = name;
setMacPreferredPositionCS(name, 0);
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
}
} | java |
public void setPreferredMacSC(String name) throws SshException {
if (name == null)
return;
if (macSC.contains(name)) {
prefMacSC = name;
setMacPreferredPositionSC(name, 0);
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
}
} | java |
public void setPreferredCompressionCS(String name) throws SshException {
if (name == null)
return;
if (compressionsCS.contains(name)) {
prefCompressionCS = name;
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
}
} | java |
public void setPreferredCompressionSC(String name) throws SshException {
if (name == null)
return;
if (compressionsSC.contains(name)) {
prefCompressionSC = name;
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
}
} | java |
public void setPreferredKeyExchange(String name) throws SshException {
if (name == null)
return;
if (keyExchanges.contains(name)) {
prefKeyExchange = name;
setKeyExchangePreferredPosition(name, 0);
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
... | java |
public void setPreferredPublicKey(String name) throws SshException {
if (name == null)
return;
if (publicKeys.contains(name)) {
prefPublicKey = name;
setPublicKeyPreferredPosition(name, 0);
} else {
throw new SshException(name + " is not supported",
SshException.UNSUPPORTED_ALGORITHM);
}
} | java |
public void close() throws IOException {
try {
file.close();
UnsignedInteger32 requestid;
while (outstandingRequests.size() > 0) {
requestid = (UnsignedInteger32) outstandingRequests
.elementAt(0);
outstandingRequests.removeElementAt(0);
sftp.getResponse(requestid);
}
} catch (SshExce... | java |
public static void debug(Object source, String message, Throwable t) {
LoggerFactory.getInstance().log(LoggerLevel.DEBUG, source, message, t);
} | java |
public static void debug(Object source, String message) {
LoggerFactory.getInstance().log(LoggerLevel.INFO, source, message);
} | java |
public static void error(Object source, String message, Throwable t) {
LoggerFactory.getInstance().log(LoggerLevel.ERROR, source, message, t);
} | java |
private void formRequest(){
byte[] user_bytes = userName.getBytes();
byte[] password_bytes = password.getBytes();
request = new byte[3+user_bytes.length+password_bytes.length];
request[0] = (byte) 1;
request[1] = (byte) user_bytes.length;
System.arraycopy(user_bytes,0,request,2,use... | java |
public void startTransportProtocol(SshTransport provider,
Ssh2Context context, String localIdentification,
String remoteIdentification, Ssh2Client client) throws SshException {
try {
this.transportIn = new DataInputStream(provider.getInputStream());
this.transportOut = provider.getOutputStream();
this... | java |
public void disconnect(int reason, String disconnectReason) {
ByteArrayWriter baw = new ByteArrayWriter();
try {
this.disconnectReason = disconnectReason;
baw.write(SSH_MSG_DISCONNECT);
baw.writeInt(reason);
baw.writeString(disconnectReason);
baw.writeString("");
Log.info(this, "Sending SSH_MS... | java |
public byte[] nextMessage() throws SshException {
if (Log.isDebugEnabled()) {
if (verbose) {
Log.debug(this, "transport next message");
}
}
synchronized (transportIn) {
byte[] msg;
do {
msg = readMessage();
} while (processMessage(msg));
return msg;
}
} | java |
public void startService(String servicename) throws SshException {
ByteArrayWriter baw = new ByteArrayWriter();
try {
baw.write(SSH_MSG_SERVICE_REQUEST);
baw.writeString(servicename);
if (Log.isDebugEnabled()) {
Log.debug(this, "Sending SSH_MSG_SERVICE_REQUEST");
}
sendMessage(baw.toByteArray... | java |
public boolean processMessage(byte[] msg) throws SshException {
try {
if (msg.length < 1) {
disconnect(TransportProtocol.PROTOCOL_ERROR,
"Invalid message received");
throw new SshException("Invalid transport protocol message",
SshException.INTERNAL_ERROR);
}
switch (msg[0]) {
case SS... | java |
public static String getFingerprint(byte[] encoded, String algorithm)
throws SshException {
Digest md5 = (Digest) ComponentManager.getInstance().supportedDigests()
.getInstance(algorithm);
md5.putBytes(encoded);
byte[] digest = md5.doFinal();
StringBuffer buf = new StringBuffer();
int ch;
for (in... | java |
public boolean canWrite() throws SftpStatusException, SshException {
// This is long hand because gcj chokes when it is not? Investigate why
if ((getAttributes().getPermissions().longValue() & SftpFileAttributes.S_IWUSR) == SftpFileAttributes.S_IWUSR
|| (getAttributes().getPermissions().longValue() & SftpFileAt... | java |
public boolean canRead() throws SftpStatusException, SshException {
// This is long hand because gcj chokes when it is not? Investigate why
if ((getAttributes().getPermissions().longValue() & SftpFileAttributes.S_IRUSR) == SftpFileAttributes.S_IRUSR
|| (getAttributes().getPermissions().longValue() & SftpFileAtt... | java |
public SftpFileAttributes getAttributes() throws SftpStatusException,
SshException {
if (attrs == null) {
attrs = sftp.getAttributes(getAbsolutePath());
}
return attrs;
} | java |
public boolean isFifo() throws SftpStatusException, SshException {
// This is long hand because gcj chokes when it is not? Investigate why
if ((getAttributes().getPermissions().longValue() & SftpFileAttributes.S_IFIFO) == SftpFileAttributes.S_IFIFO)
return true;
return false;
} | java |
public boolean isBlock() throws SftpStatusException, SshException {
// This is long hand because gcj chokes when it is not? Investigate why
if ((getAttributes().getPermissions().longValue() & SftpFileAttributes.S_IFBLK) == SftpFileAttributes.S_IFBLK) {
return true;
}
return false;
} | java |
public boolean isCharacter() throws SftpStatusException, SshException {
// This is long hand because gcj chokes when it is not? Investigate why
if ((getAttributes().getPermissions().longValue() & SftpFileAttributes.S_IFCHR) == SftpFileAttributes.S_IFCHR) {
return true;
}
return false;
} | java |
public boolean isSocket() throws SftpStatusException, SshException {
// This is long hand because gcj chokes when it is not? Investigate why
if ((getAttributes().getPermissions().longValue() & SftpFileAttributes.S_IFSOCK) == SftpFileAttributes.S_IFSOCK) {
return true;
}
return false;
} | java |
protected synchronized void write(int b) throws IOException {
if (closed) {
throw new IOException("The buffer is closed");
}
verifyBufferSize(1);
buf[writepos] = (byte) b;
writepos++;
notifyAll();
} | java |
protected synchronized int read() throws IOException {
try {
block();
} catch (InterruptedException ex) {
throw new InterruptedIOException(
"The blocking operation was interrupted");
}
if (closed && available() <= 0) {
return -1;
}
return buf[readpos++];
} | java |
protected synchronized int read(byte[] data, int offset, int len)
throws IOException {
try {
block();
} catch (InterruptedException ex) {
throw new InterruptedIOException(
"The blocking operation was interrupted");
}
if (closed && available() <= 0) {
return -1;
}
int read = (len > (write... | java |
public synchronized void add(String name, Class<?> cls) {
if (locked) {
throw new IllegalStateException(
"Component factory is locked. Components cannot be added");
}
supported.put(name, cls);
// add name to end of order vector
if (!order.contains(name))
order.addElement(name);
} | java |
public Object getInstance(String name) throws SshException {
if (supported.containsKey(name)) {
try {
return createInstance(name, (Class<?>) supported.get(name));
} catch (Throwable t) {
throw new SshException(t.getMessage(),
SshException.INTERNAL_ERROR);
}
}
throw new SshException(name + "... | java |
private synchronized String createDelimitedList(String preferred) {
StringBuffer listBuf = new StringBuffer();
int prefIndex = order.indexOf(preferred);
// remove preferred and add it back at the end to ensure it is not
// duplicated in the list returned
if (prefIndex != -1) {
listBuf.append(preferred);
... | java |
public Socket accept() throws IOException{
Socket s;
if(!doing_direct){
if(proxy == null) return null;
ProxyMessage msg = proxy.accept();
s = msg.ip == null? new SocksSocket(msg.host,msg.port,proxy)
: new SocksSocket(msg.ip,msg.port,proxy);
... | java |
public InetAddress getInetAddress(){
if(localIP == null){
try{
localIP = InetAddress.getByName(localHost);
}catch(UnknownHostException e){
return null;
}
}
return localIP;
} | java |
public void setSoTimeout(int timeout) throws SocketException{
super.setSoTimeout(timeout);
if(!doing_direct) proxy.proxySocket.setSoTimeout(timeout);
} | java |
public static String getStatusText(int status) {
switch (status) {
case SSH_FX_OK:
return "OK";
case SSH_FX_EOF:
return "EOF";
case SSH_FX_NO_SUCH_FILE:
return "No such file.";
case SSH_FX_PERMISSION_DENIED:
return "Permission denied.";
case SSH_FX_FAILURE:
return "Server responded with an un... | java |
public static SshPublicKeyFile parse(byte[] formattedkey)
throws IOException {
try {
try {
return new OpenSSHPublicKeyFile(formattedkey);
} catch (IOException ex) {
try {
return new SECSHPublicKeyFile(formattedkey);
} catch (IOException ex2) {
throw new IOException(
"Unable to pa... | java |
public static BigInteger getSafePrime(UnsignedInteger32 maximumSize) {
BigInteger prime = group1;
for(Iterator<BigInteger> it = safePrimes.iterator(); it.hasNext(); ) {
BigInteger p = it.next();
int len = p.bitLength();
if(len > maximumSize.intValue()) {
break;
}
prime = p;
}
return prime... | java |
public void read(InputStream in,boolean clientMode) throws SocksException,
IOException{
data = null;
ip = null;
DataInputStream di = new DataInputStream(in);
version = di.readUnsignedByte();
command = di.readUnsignedByte();
if(clientMode &... | java |
public void write(OutputStream out)throws SocksException,
IOException{
if(data == null){
Socks5Message msg;
if(addrType == SOCKS_ATYP_DOMAINNAME)
msg = new Socks5Message(command,host,port);
else{
if(ip == null){
try... | java |
public InetAddress getInetAddress() throws UnknownHostException{
if(ip!=null) return ip;
return (ip=InetAddress.getByName(host));
} | java |
public void run() {
if (!initProxy()) {
// Check if we have been aborted
if (mode != OK_MODE)
return;
if (net_thread != Thread.currentThread())
return;
mode = COMMAND_MODE;
warning_label.setText("Look up failed.");
warning_label.invalidate();
return;
}
// System.out.println("Done!"... | java |
public void cdup() throws SftpStatusException, SshException {
SftpFile cd = sftp.getFile(cwd);
SftpFile parent = cd.getParent();
if (parent != null)
cwd = parent.getAbsolutePath();
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.