Package com.sshtools.j2ssh.subsystem

Examples of com.sshtools.j2ssh.subsystem.SubsystemMessage


     * @throws IOException
     */
    public synchronized void setAttributes(String path, FileAttributes attrs)
        throws IOException {
        UnsignedInteger32 requestId = nextRequestId();
        SubsystemMessage msg = new SshFxpSetStat(requestId, path, attrs);
        sendMessage(msg);
        getOKRequestStatus(requestId);
    }
View Full Code Here


        if (!isValidHandle(file.getHandle())) {
            throw new IOException("The handle is not an open file handle!");
        }

        UnsignedInteger32 requestId = nextRequestId();
        SubsystemMessage msg = new SshFxpFSetStat(requestId, file.getHandle(),
                attrs);
        sendMessage(msg);
        getOKRequestStatus(requestId);
    }
View Full Code Here

        boolean result = false;
        SshFxpInit msg = new SshFxpInit(new UnsignedInteger32(version), null);
        sendMessage(msg);

        // Lets give the sftp subsystem 30 seconds to reply
        SubsystemMessage reply = null;

        for (int i = 0; i < 30; i++) {
            try {
                reply = messageStore.nextMessage(1000);
View Full Code Here

    }

    private byte[] getHandleResponse(UnsignedInteger32 requestId)
        throws IOException {
        try {
            SubsystemMessage reply = messageStore.getMessage(requestId);

            if (reply instanceof SshFxpHandle) {
                byte[] handle = ((SshFxpHandle) reply).getHandle();

                // Add the handle to our managed list
                handles.add(handle);

                return handle;
            } else if (reply instanceof SshFxpStatus) {
                throw new IOException(((SshFxpStatus) reply).getErrorMessage());
            } else {
                throw new IOException("Unexpected server response " +
                    reply.getMessageName());
            }
        } catch (InterruptedException ex) {
            throw new IOException("The thread was interrupted");
        }
    }
View Full Code Here

        try {
            if (log.isDebugEnabled()) {
                log.info("Waiting for response");
            }

            SubsystemMessage reply = messageStore.getMessage(requestId);
            log.info("Received response");

            if (reply instanceof SshFxpStatus) {
              SshFxpStatus status = (SshFxpStatus) reply;
             
              if (status.getErrorCode().intValue() != SshFxpStatus.STATUS_FX_OK) {
                throw new IOException(((SshFxpStatus) reply).getErrorMessage());
              }
            } else {
              throw new IOException("Unexpected server response " +
                  reply.getMessageName());
            }
        } catch (InterruptedException ex) {
          throw new IOException("The thread was interrupted");
        }
    }
View Full Code Here

     *
     * @throws IOException if an IO error occurs
     */
    protected void sendVersionRequest(String application)
        throws IOException {
        SubsystemMessage msg = new SshAgentRequestVersion(application);
        sendMessage(msg);
        msg = readMessage();

        if (msg instanceof SshAgentVersionResponse) {
            SshAgentVersionResponse reply = (SshAgentVersionResponse) msg;
View Full Code Here

     * @throws IOException if an IO error occurs
     */
    public void addKey(SshPrivateKey prvkey, SshPublicKey pubkey,
        String description, KeyConstraints constraints)
        throws IOException {
        SubsystemMessage msg = new SshAgentAddKey(prvkey, pubkey, description,
                constraints);
        sendMessage(msg);
        msg = readMessage();

        if (!(msg instanceof SshAgentSuccess)) {
View Full Code Here

     *
     * @throws IOException if an IO error occurs
     */
    public byte[] hashAndSign(SshPublicKey key, byte[] data)
        throws IOException {
        SubsystemMessage msg = new SshAgentPrivateKeyOp(key, HASH_AND_SIGN, data);
        sendMessage(msg);
        msg = readMessage();

        if (msg instanceof SshAgentOperationComplete) {
            return ((SshAgentOperationComplete) msg).getData();
View Full Code Here

     * @return a map of public keys and descriptions
     *
     * @throws IOException if an IO error occurs
     */
    public Map listKeys() throws IOException {
        SubsystemMessage msg = new SshAgentListKeys();
        sendMessage(msg);
        msg = readMessage();

        if (msg instanceof SshAgentKeyList) {
            return ((SshAgentKeyList) msg).getKeys();
View Full Code Here

     * @return true if the agent was locked, otherwise false
     *
     * @throws IOException if an IO error occurs
     */
    public boolean lockAgent(String password) throws IOException {
        SubsystemMessage msg = new SshAgentLock(password);
        sendMessage(msg);
        msg = readMessage();

        return (msg instanceof SshAgentSuccess);
    }
View Full Code Here

TOP

Related Classes of com.sshtools.j2ssh.subsystem.SubsystemMessage

Copyright © 2018 www.massapicom. 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.