Package com.atolsystems.atolutilities

Examples of com.atolsystems.atolutilities.InvalidCommandLineException


            } else if (arg.value.endsWith("k")) {
                unit = 1024;
            } else if (arg.value.endsWith("m")) {
                unit = 1024 * 1024;
            } else {
                throw new InvalidCommandLineException("parameter must end by 'b', 'k' or 'm' to indicate byte, kilo-bytes or mega-bytes respectively.");
            }
            String num = arg.value.substring(ARG_SET_DATA_SIZE.length(), arg.value.length() - 1);
            dataSize = Integer.decode(num);//arg.getInteger(ARG_SET_DATA_SIZE);
            if (null == dataSize) {
                return true;//we will ask for data size at end of command line
            }
            if (dataSize < 0) {
                throw new InvalidCommandLineException("parameter must be positive.");
            }
            dataSize = dataSize * unit;//compute the size in bytes
        } else if (arg.value.startsWith(ARG_SET_MAX_LE_DATA_SIZE)) {
            maxLeDataSize = arg.getInteger(ARG_SET_MAX_LE_DATA_SIZE);
        } else if (arg.value.startsWith(ARG_SET_AIS31_TEST)) {
View Full Code Here


        public boolean inspectArg(Arg arg, CommandLine cl) {
            getRandomDataCmd = arg.getString(ARG_SET_GETRNDDATACMD);
            Apdu getChallengeApdu = new Apdu(getRandomDataCmd);
            if (getChallengeApdu.getExpectedLe() != 256) {
                throw new InvalidCommandLineException("Command to get random data must have LE=256, other case are not supported");
            }
            return true;
        }
View Full Code Here

                        argContext.consumeCurArg();
                        //if(null!=confArgFile)
                        //    throw new RuntimeException("Command line argument \""+ARG_SET_CONF_FOLDER+"\" must appear before any occurence of \""+ARG_ADD_TERMINAL_MANAGER+"\"");
                        File f = argContext.getFileFromCurArgValue();
                        if (false == f.exists()) {
                            throw new InvalidCommandLineException(new FileNotFoundException("Folder specified by \"" + ARG_SET_CONF_FOLDER + "\" argument does not exist:\n" + f.getCanonicalPath()));
                        }
                        confFolderName = f.getAbsolutePath() + System.getProperty("file.separator");
                        break;
                    }
                    case ARG_ADD_JAR_FILE_ID: {
                        argContext.consumeCurArg();
                        File jarFile = argContext.getFileFromCurArgValue();
                        if (false == jarFile.exists()) {
                            throw new InvalidCommandLineException(new FileNotFoundException("File specified by \"" + ARG_ADD_JAR_FILE + "\" argument does not exist:\n" + jarFile.getCanonicalPath()));
                        }
                        String jarCanonicalName = jarFile.getCanonicalPath();
                        if (loadedJarNames.contains(jarCanonicalName)) {
                            break;
                        }
View Full Code Here

                    do {
                        argsRemain = cl.processArg(true);
                    } while (argsRemain);
                    //Configuration check after first pass through command line
                    if (false == cl.isAllArgsRecognized()) {
                        throw new InvalidCommandLineException("Not all arguments were recognized:\n" + cl.toString());
                    }
                } catch (InvalidCommandLineException ex){
                    throw new InvalidCommandLineException("Argument "+cl.getCurArgIndex()+" is not valid\n"+
                            "Command line dump:\n"+cl.toString(),ex);
                }catch (Throwable ex){
                    throw new RuntimeException("Error happened during evaluation of argument "+cl.getCurArgIndex()+
                            "\nCommand line dump:\n"+cl.toString(),ex);
                }

                cl.setCurArgIndex(-1);

                int execOut = t.execute(terminal);

                do{
                    argsRemain=cl.processArg(false);
                }while(argsRemain);
                if(cl.isAllArgsProcessed()){
                    terminal.logLine(ScardLogHandler.LOG_INFO,"INFO: All command line arguments processed.");
                }else{
                    throw new InvalidCommandLineException("Not all command line arguments have been processed.\n"+cl.toString());
                }
            }else{
                oldStyleCommandLine.processArgs();
                int execOut = t.execute(terminal);
            }
View Full Code Here

                        //fall through
                    case 1:
                        autoCloseSuccessMs=params[0];
                        break;
                    default:
                        throw new InvalidCommandLineException("Argument "+ARG_AUTO_CLOSE_WITH_PARAM+ " requires one or two integers as parameters, separated by a coma\n");
                }
            } else {
                autoCloseSuccessMs=500;
                autoCloseErrorMs=5000;
            }
View Full Code Here

                    do {
                        argsRemain = confCl.processArg(true);
                    } while (argsRemain);
                    //Configuration check after first pass through command line
                    if (false == confCl.isAllArgsRecognized()) {
                        throw new InvalidCommandLineException("Not all arguments were recognized:\n" + confCl.toString());
                    }
                } catch (InvalidCommandLineException ex){
                    throw new InvalidCommandLineException("Configuration file argument "+confCl.getCurArgIndex()+" is not valid\n"+
                            "Configuration file dump:\n"+confCl.toString()+"\n"+ex.getMessage(),ex);
                }catch (Throwable ex){
                    throw new RuntimeException("Configuration file: Error happened during evaluation of argument "+confCl.getCurArgIndex()+
                            "\nConfiguration file dump:\n"+confCl.toString(),ex);
                }
View Full Code Here

                do {
                    argsRemain = cl.processArg(true);
                } while (argsRemain);
                //Configuration check after first pass through command line
                if (false == cl.isAllArgsRecognized()) {
                    throw new InvalidCommandLineException("Not all arguments were recognized:\n" + cl.toString());
                }
            } catch (InvalidCommandLineException ex){
                throw new InvalidCommandLineException("Argument "+cl.getCurArgIndex()+" is not valid\n"+
                        "Command line dump:\n"+cl.toString()+"\n"+ex.getMessage(),ex);
            }catch (Throwable ex){
                throw new RuntimeException("Error happened during evaluation of argument "+cl.getCurArgIndex()+
                        "\nCommand line dump:\n"+cl.toString(),ex);
            }
View Full Code Here

        String className = params[0];
        try {
            Class theClass = plugInLoader.getPlugInClass(className);
            SmartCardTask task = (SmartCardTask) theClass.newInstance();
            if (params.length > 2) {
                throw new InvalidCommandLineException("Two parameters are accepted at most. "
                        + "Following parameters were found:\n" + params.toString());
            }
            if (2 == params.length) {
                int nArgs;
                if (params[1].equals("...")) {
                    task.setnArgs(SmartCardTask.ALL_ARGS);
                    cl.addArgDefs(task.getArgDefs());
                } else {
                    try {
                        nArgs = Integer.decode(params[1]);
                    } catch (NumberFormatException ex) {
                        throw new InvalidCommandLineException("Could not convert second parameter to an integer.", ex);
                    }
                    if (nArgs < 0) {
                        throw new InvalidCommandLineException("Only positive values is valid as second parameter.");
                    }
                    if (nArgs > 0) {
                        task.setnArgs(nArgs);
                        cl.addEphemeralArgDefs(task.getArgDefs(), nArgs);
                    }
                }
            } else {
                task.setnArgs(0);
                cl.addArgDefs(task.getArgDefs());
            }
            tasks.add(task);
            if(false==taskClassNames.contains(className)){
                taskClassNames.add(className);
                System.out.println("Task added:");
                System.out.println(task.getAboutMsg());
            }
        } catch (InstantiationException ex) {
            throw new InvalidCommandLineException(ex);
        } catch (IllegalAccessException ex) {
            throw new InvalidCommandLineException(ex);
        } catch (MalformedURLException ex) {
            throw new InvalidCommandLineException(ex);
        } catch (ClassNotFoundException ex) {
            throw new InvalidCommandLineException(ex);
        }
        return true;
    }
View Full Code Here

        else if(policyAsString.equals(PARAM_EXPECTED_RESPONSE_ONLY))
            policy=LogHandlerAsScriptGenerator.CHECK_EXPECTED_RESPONSE_ONLY;
        else if(policyAsString.equals(PARAM_EXPECTED_THEN_ACTUAL_RESPONSE))
            policy=LogHandlerAsScriptGenerator.CHECK_EXPECTED_THEN_ACTUAL_RESPONSE;
        else
            throw new InvalidCommandLineException("\""+policyAsString+"\" is not a valid parameter");
        for (ScardLogHandler logHandler : terminal.getLogs()) {
            if (logHandler instanceof LogHandlerAsScriptGenerator) {
                LogHandlerAsScriptGenerator generator=(LogHandlerAsScriptGenerator) logHandler;
                generator.setResponseCheckPolicy(policy);
            }
View Full Code Here

            else{
                try {
                    StarScriptReader reader = new StarScriptReader(scriptFile);
                    terminal.setBeforeDisconnectScript(reader.getCmds());
                } catch (Throwable ex) {
                    throw new InvalidCommandLineException(ex);
                }
            }
        }else if(arg.value.startsWith(ARG_SET_BEFORE_CONNECT_SCRIPT)){
            File scriptFile=arg.getSingleFile(ARG_SET_BEFORE_CONNECT_SCRIPT);
            if(null==scriptFile)
                terminal.setBeforeConnectScript(null);
            else{
                try {
                    StarScriptReader reader = new StarScriptReader(scriptFile);
                    terminal.setBeforeConnectScript(reader.getCmds());
                } catch (Throwable ex) {
                    throw new InvalidCommandLineException(ex);
                }
            }
        }else if(arg.value.startsWith(ARG_SET_AFTER_CONNECT_SCRIPT)){
           
            File scriptFile=arg.getSingleFile(ARG_SET_AFTER_CONNECT_SCRIPT);
            if(null==scriptFile){
                terminal.setAfterConnectScript(null);
                System.out.println("Set After connect script to null");
            } else {
                try {
                    System.out.println("Set After connect script to " + scriptFile.getCanonicalPath());
                } catch (IOException ex) {
                    Logger.getLogger(TerminalArgHandler.class.getName()).log(Level.SEVERE, null, ex);
                }
                try {
                    StarScriptReader reader = new StarScriptReader(scriptFile);
                    System.out.println("After connect script has " + reader.getCmds().size() + " objects");
                    terminal.setAfterConnectScript(reader.getCmds());
                } catch (Throwable ex) {
                    throw new InvalidCommandLineException(ex);
                }
            }
        }else if(arg.value.startsWith(ARG_SET_UNEXPECTED_CARD_RESPONSE_SCRIPT)){
            File scriptFile=arg.getSingleFile(ARG_SET_UNEXPECTED_CARD_RESPONSE_SCRIPT);
            if(null==scriptFile)
                terminal.setUnexpectedCardResponseScript(null);
            else{
                try {
                    StarScriptReader reader = new StarScriptReader(scriptFile);
                    terminal.setUnexpectedCardResponseScript(reader.getCmds());
                } catch (Throwable ex) {
                    throw new InvalidCommandLineException(ex);
                }
            }
        /*}else if(arg.value.startsWith(ARG_SET_UNEXPECTED_CARD_RESPONSE_RESUME_SCRIPT)){
            File scriptFile=arg.getSingleFile(ARG_SET_UNEXPECTED_CARD_RESPONSE_RESUME_SCRIPT);
            if(null==scriptFile)
                terminal.setUnexpectedCardResponseResumingScript(null);
            else{
                try {
                    StarScriptReader reader = new StarScriptReader(scriptFile);
                    terminal.setUnexpectedCardResponseResumingScript(reader.getCmds());
                } catch (Throwable ex) {
                    throw new InvalidCommandLineException(ex);
                }
            }*/
        }else if(arg.value.startsWith(ARG_SET_APDU_TIMEOUT_SCRIPT)){
            File scriptFile=arg.getSingleFile(ARG_SET_APDU_TIMEOUT_SCRIPT);
            if(null==scriptFile)
                terminal.setApduTimeoutScript(null);
            else{
                try {
                    StarScriptReader reader = new StarScriptReader(scriptFile);
                    terminal.setApduTimeoutScript(reader.getCmds());
                } catch (Throwable ex) {
                    throw new InvalidCommandLineException(ex);
                }
            }
        }else if(arg.value.startsWith(ARG_SET_APDU_MISC_ERROR_SCRIPT)){
            File scriptFile=arg.getSingleFile(ARG_SET_APDU_MISC_ERROR_SCRIPT);
            if(null==scriptFile)
                terminal.setApduMiscErrorScript(null);
            else{
                try {
                    StarScriptReader reader = new StarScriptReader(scriptFile);
                    terminal.setApduMiscErrorScript(reader.getCmds());
                } catch (Throwable ex) {
                    throw new InvalidCommandLineException(ex);
                }
            }
        }else if(arg.value.startsWith(ARG_SET_TERM_ENV)){
            String envDef[]=termEnv.remove(0);
            terminal.putEnvVariable(envDef[0], envDef[1]);
View Full Code Here

TOP

Related Classes of com.atolsystems.atolutilities.InvalidCommandLineException

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.