Package org.apache.commons.net

Examples of org.apache.commons.net.MalformedServerReplyException


    private void __parsePassiveModeReply(String reply)
    throws MalformedServerReplyException
    {
        java.util.regex.Matcher m = __PARMS_PAT.matcher(reply);
        if (!m.find()) {
            throw new MalformedServerReplyException(
                    "Could not parse passive host information.\nServer Reply: " + reply);
        }

        __passiveHost = m.group(1).replace(',', '.'); // Fix up to look like IP address

        try
        {
            int oct1 = Integer.parseInt(m.group(2));
            int oct2 = Integer.parseInt(m.group(3));
            __passivePort = (oct1 << 8) | oct2;
        }
        catch (NumberFormatException e)
        {
            throw new MalformedServerReplyException(
                    "Could not parse passive port information.\nServer Reply: " + reply);
        }

        try {
            InetAddress host = InetAddress.getByName(__passiveHost);
            // reply is a local address, but target is not - assume NAT box changed the PASV reply
            if (host.isSiteLocalAddress() && !getRemoteAddress().isSiteLocalAddress()){
                String hostAddress = getRemoteAddress().getHostAddress();
                fireReplyReceived(0,
                            "[Replacing site local address "+__passiveHost+" with "+hostAddress+"]\n");
                __passiveHost = hostAddress;
            }
        } catch (UnknownHostException e) { // Should not happen as we are passing in an IP address
            throw new MalformedServerReplyException(
                    "Could not parse passive host information.\nServer Reply: " + reply);
        }
    }
View Full Code Here


        delim3 = reply.charAt(2);
        delim4 = reply.charAt(reply.length()-1);

        if (!(delim1 == delim2) || !(delim2 == delim3)
                || !(delim3 == delim4))
            throw new MalformedServerReplyException(
                    "Could not parse extended passive host information.\nServer Reply: " + reply);
        try
        {
            port = Integer.parseInt(reply.substring(3, reply.length()-1));
        }
        catch (NumberFormatException e)
        {
            throw new MalformedServerReplyException(
                    "Could not parse extended passive host information.\nServer Reply: " + reply);
        }


        // in EPSV mode, the passive host address is implicit
View Full Code Here

        // In case we run into an anomaly we don't want fatal index exceptions
        // to be thrown.
        length = line.length();
        if (length < 3)
            throw new MalformedServerReplyException(
                "Truncated server reply: " + line);

        String code = null;
        try
        {
            code = line.substring(0, 3);
            _replyCode = Integer.parseInt(code);
        }
        catch (NumberFormatException e)
        {
            throw new MalformedServerReplyException(
                "Could not parse response code.\nServer Reply: " + line);
        }

        _replyLines.add(line);
View Full Code Here

            index = Integer.parseInt(octet1);
            lastIndex = Integer.parseInt(octet2);
        }
        catch (NumberFormatException e)
        {
            throw new MalformedServerReplyException(
                "Could not parse passive host information.\nServer Reply: " + reply);
        }

        index <<= 8;
        index |= lastIndex;
View Full Code Here

        // In case we run into an anomaly we don't want fatal index exceptions
        // to be thrown.
        length = line.length();
        if (length < 3)
            throw new MalformedServerReplyException(
                "Truncated server reply: " + line);

        try
        {
            String code = line.substring(0, 3);
            _replyCode = Integer.parseInt(code);
        }
        catch (NumberFormatException e)
        {
            throw new MalformedServerReplyException(
                "Could not parse response code.\nServer Reply: " + line);
        }

        _replyLines.addElement(line);
View Full Code Here

            index = Integer.parseInt(octet1);
            lastIndex = Integer.parseInt(octet2);
        }
        catch (NumberFormatException e)
        {
            throw new MalformedServerReplyException(
                "Could not parse passive host information.\nServer Reply: " + reply);
        }

        index <<= 8;
        index |= lastIndex;
View Full Code Here

        // In case we run into an anomaly we don't want fatal index exceptions
        // to be thrown.
        length = line.length();
        if (length < 3)
            throw new MalformedServerReplyException(
                "Truncated server reply: " + line);

        try
        {
            String code = line.substring(0, 3);
            _replyCode = Integer.parseInt(code);
        }
        catch (NumberFormatException e)
        {
            throw new MalformedServerReplyException(
                "Could not parse response code.\nServer Reply: " + line);
        }

        _replyLines.addElement(line);
View Full Code Here

        if (line.startsWith(_OK))
            _replyCode = POP3Reply.OK;
        else if (line.startsWith(_ERROR))
            _replyCode = POP3Reply.ERROR;
        else
            throw new
            MalformedServerReplyException(
                "Received invalid POP3 protocol response from server.");

        _replyLines.addElement(line);
        _lastReplyLine = line;
View Full Code Here

            pointer.articleId = tokenizer.nextToken();
            return ;
        }
        while (false);

        throw new MalformedServerReplyException(
            "Could not parse article pointer.\nServer reply: " + reply);
    }
View Full Code Here

            info._setPostingPermission(NewsgroupInfo.UNKNOWN_POSTING_PERMISSION);
            return ;
        }
        while (false);

        throw new MalformedServerReplyException(
            "Could not parse newsgroup info.\nServer reply: " + reply);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.net.MalformedServerReplyException

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.