Package com.sshtools.j2ssh.transport

Examples of com.sshtools.j2ssh.transport.SshMessage


        // Now prepare and send the message
        baw.write(0);
        baw.writeString(key.getAlgorithmName());
        baw.writeBinaryString(key.getEncoded());

        SshMessage msg = new SshMsgUserAuthRequest(username, serviceToStart,
                getMethodName(), baw.toByteArray());
        authentication.sendMessage(msg);

        try {
            msg = authentication.readMessage(SshMsgUserAuthPKOK.SSH_MSG_USERAUTH_PK_OK);
View Full Code Here


        // Now prepare and send the message
        baw.write(0);
        baw.writeString(key.getAlgorithmName());
        baw.writeBinaryString(key.getEncoded());

        SshMessage msg = new SshMsgUserAuthRequest(username, serviceToStart,
                getMethodName(), baw.toByteArray());
        authentication.sendMessage(msg);

        try {
            msg = authentication.readMessage(SshMsgUserAuthPKOK.SSH_MSG_USERAUTH_PK_OK);
View Full Code Here

        // Send the authentication request
        ByteArrayWriter baw = new ByteArrayWriter();
        baw.writeString("");
        baw.writeString("");

        SshMessage msg = new SshMsgUserAuthRequest(getUsername(),
                serviceToStart, getMethodName(), baw.toByteArray());
        authentication.sendMessage(msg);

        // Read a message
        while (true) {
            msg = authentication.readMessage(SshMsgUserAuthInfoRequest.SSH_MSG_USERAUTH_INFO_REQUEST);

            if (msg instanceof SshMsgUserAuthInfoRequest) {
                SshMsgUserAuthInfoRequest request = (SshMsgUserAuthInfoRequest) msg;
                KBIPrompt[] prompts = request.getPrompts();
                handler.showPrompts(request.getName(),
                    request.getInstruction(), prompts);

                // Now send the response message
                msg = new SshMsgUserAuthInfoResponse(prompts);
                authentication.sendMessage(msg);
            } else {
                throw new AuthenticationProtocolException(
                    "Unexpected authentication message " +
                    msg.getMessageName());
            }
        }
    }
View Full Code Here

            int[] messageIdFilter = new int[2];
            messageIdFilter[0] = SshMsgChannelOpenConfirmation.SSH_MSG_CHANNEL_OPEN_CONFIRMATION;
            messageIdFilter[1] = SshMsgChannelOpenFailure.SSH_MSG_CHANNEL_OPEN_FAILURE;

            try {
                SshMessage result = messageStore.getMessage(messageIdFilter);

                if (result.getMessageId() == SshMsgChannelOpenConfirmation.SSH_MSG_CHANNEL_OPEN_CONFIRMATION) {
                    SshMsgChannelOpenConfirmation conf = (SshMsgChannelOpenConfirmation) result;
                    activeChannels.put(channelId, channel);
                    log.debug("Initiating channel");
                    channel.init(this, channelId.longValue(),
                        conf.getSenderChannel(), conf.getInitialWindowSize(),
View Full Code Here

           
            log.info("Waiting for channel request reply");

            try {
              // Wait for either success or failure
              SshMessage reply = messageStore.getMessage(messageIdFilter);
             
              switch (reply.getMessageId()) {
              case SshMsgChannelSuccess.SSH_MSG_CHANNEL_SUCCESS: {
                log.info("Channel request succeeded");
                success = true;
               
                break;
View Full Code Here

            messageIdFilter[1] = SshMsgRequestFailure.SSH_MSG_REQUEST_FAILURE;
            log.debug("Waiting for global request reply");

            try {
                // Wait for either success or failure
                SshMessage reply = messageStore.getMessage(messageIdFilter);

                switch (reply.getMessageId()) {
                case SshMsgRequestSuccess.SSH_MSG_REQUEST_SUCCESS: {
                    log.debug("Global request succeeded");

                    return ((SshMsgRequestSuccess) reply).getRequestData();
                }
View Full Code Here

     */
    public List getAvailableAuths(String username, String serviceName)
        throws IOException {
        log.info("Requesting authentication methods");

        SshMessage msg = new SshMsgUserAuthRequest(username, serviceName,
                "none", null);
        transport.sendMessage(msg, this);

        try {
            msg = messageStore.getMessage(resultFilter);
View Full Code Here

                }
            }

            auth.authenticate(this, serviceToStart.getServiceName());

            SshMessage msg = parseMessage(messageStore.getMessage(resultFilter));

            // We should not get this far
            throw new AuthenticationProtocolException(
                "Unexpected authentication message " + msg.getMessageName());
        } catch (TerminatedStateException tse) {
            if (tse.getState() == AuthenticationProtocolState.COMPLETE) {
                serviceToStart.init(Service.ACCEPTING_SERVICE, transport); //, nativeSettings);
                serviceToStart.start();
View Full Code Here

    }

    private SshMessage internalReadMessage(int[] messageIdFilter)
        throws TerminatedStateException, IOException {
        try {
            SshMessage msg = messageStore.getMessage(messageIdFilter);

            return parseMessage(msg);
        } catch (MessageStoreEOFException meof) {
            throw new AuthenticationProtocolException("Failed to read messages");
        } catch (InterruptedException ex) {
View Full Code Here

    public String getBannerMessage(int timeout) throws IOException {
        try {
            log.debug(
                "getBannerMessage is attempting to read the authentication banner");

            SshMessage msg = messageStore.peekMessage(SshMsgUserAuthBanner.SSH_MSG_USERAUTH_BANNER,
                    timeout);

            return ((SshMsgUserAuthBanner) msg).getBanner();
        } catch (MessageNotAvailableException e) {
            return "";
View Full Code Here

TOP

Related Classes of com.sshtools.j2ssh.transport.SshMessage

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.