Package com.sshtools.j2ssh.io

Examples of com.sshtools.j2ssh.io.ByteArrayWriter.toByteArray()


                data.write(1);
                data.writeString(key.getAlgorithmName());
                data.writeBinaryString(key.getEncoded());

                // Generate the signature
                baw.writeBinaryString(agent.hashAndSign(key, data.toByteArray()));

                SshMsgUserAuthRequest msg = new SshMsgUserAuthRequest(getUsername(),
                        serviceToStart, getMethodName(), baw.toByteArray());
                authentication.sendMessage(msg);
View Full Code Here


            // Put it all together
            keydata.write(data);

            // Return it
            return keydata.toByteArray();
        } catch (NoSuchAlgorithmException nsae) {
            sendDisconnect(SshMsgDisconnect.KEY_EXCHANGE_FAILED,
                "Application error");
            throw new TransportProtocolException("SHA algorithm not supported");
        } catch (IOException ioe) {
View Full Code Here

        // Call the abstract method so subclasses classes can add their data
        constructByteArray(baw);

        // Return the array
        return baw.toByteArray();
    }

    /**
     * <p>
     * Initializes the message from a byte array.
View Full Code Here

            // Write the padding
            message.write(pad);

            // Get the unencrypted packet data
            byte[] packet = message.toByteArray();
            byte[] mac = null;

            // Generate the MAC
            if (hmac != null) {
                mac = hmac.generate(sequenceNo, packet, 0, packet.length);
View Full Code Here

            }

            bytesTransfered += message.size();

            // Send!
            out.write(message.toByteArray());

            out.flush();
            algorithms.release();

            // Increment the sequence no
View Full Code Here

                            break;
                        }

                        if (read > 0) {
                            baw.write(buffer, 0, read);
                            sendChannelData(baw.toByteArray());
                            baw.reset();
                        }
                    }
                }
            } catch (IOException ex) {
View Full Code Here

        } else {
            data.writeString(getUsername());
        }

        // Generate the signature
        baw.writeBinaryString(key.generateSignature(data.toByteArray()));

        SshMsgUserAuthRequest msg = new SshMsgUserAuthRequest(getUsername(),
                serviceToStart, getMethodName(), baw.toByteArray());
        authentication.sendMessage(msg);
    }
View Full Code Here

                                                                                       .getHostName(),
                        InetAddress.getLocalHost().getHostAddress(),
                        socket.getPort());
                ByteArrayWriter baw = new ByteArrayWriter();
                baw.writeBinaryString(msg.toByteArray());
                sendChannelData(baw.toByteArray());
            }

            super.onChannelOpen();

            // Now bind the socket to the channel
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.