Package mireka.pop

Examples of mireka.pop.CommandSyntaxException


        if (session.getSessionState() != SessionState.TRANSACTION)
            throw new IllegalSessionStateException();

        List<String> args = commandParser.parseArguments();
        if (args.size() != 2)
            throw new CommandSyntaxException(
                    "Two numeric arguments are expected");
        int messageNumber;
        int lines;
        try {
            messageNumber = Integer.valueOf(args.get(0));
            lines = Integer.valueOf(args.get(1));
        } catch (NumberFormatException e) {
            throw new CommandSyntaxException(
                    "Two numeric arguments are expected");
        }
        if (lines < 0)
            throw new CommandSyntaxException(
                    "Two numeric arguments are expected");

        InputStream mailAsStream =
                session.getMaildrop().getMailAsStream(messageNumber);
        try {
View Full Code Here


        if (session.getSessionState() != AUTHORIZATION)
            throw new IllegalSessionStateException();

        List<String> args = commandParser.parseArguments();
        if (args.size() != 2)
            throw new CommandSyntaxException("Two arguments are expected");
        String user = args.get(0);
        String digest = args.get(1);
        byte[] digestBytes = valueOfHex(digest);
        LoginResult result =
                loginSpecification.evaluateApop(user, timestamp, digestBytes);
View Full Code Here

        }
    }

    private static byte[] valueOfHex(String s) throws CommandSyntaxException {
        if (s.length() != 32)
            throw new CommandSyntaxException(
                    "Second argument must be a 16 bytes hexadecimal number");
        byte[] result = new byte[16];
        for (int i = 0; i < 16; i++) {
            String byteString = s.substring(i * 2, i * 2 + 2);
            try {
                result[i] = (byte) Integer.parseInt(byteString, 16);
            } catch (NumberFormatException e) {
                throw new CommandSyntaxException(
                        "Second argument must be a 16 bytes hexadecimal number");
            }
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of mireka.pop.CommandSyntaxException

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.