Esempio n. 1
0
        //sign cli entry point
        static int Main(string[] args)
        {
            String             contextJson = args[0];
            RunTimeContext     context     = new RunTimeContext(contextJson);
            ToolManagerFactory tm          = new ToolManagerFactory("path to manifest.xml");

            //abstract AbiTool is concrete signFileTool
            AbiTool signFileTool = tm.GetTool("SignFile");

            //factory makes commands for tools
            //signFile -> sign
            //signFile -> validate
            //KW -> scan
            //KW -> upload
            //...
            AbiToolCommandFactory abiToolCmdFactory = new AbiSignFileCommandFactory(signFileTool, context.getByName("Signing"));

            //abstract command "is a" concrete sign command
            AbiCmd signCmd = abiToolCmdFactory.CreateCommand("sign");

            //abstract result "is a" sign command result
            AbiCmdResult result = signCmd.DoWork("sign target in context");

            //generate the output context from the current AbiCmdResult
            result.getContext().WriteToFile();

            //pass result return code to user
            return(result.code);
        }
Esempio n. 2
0
        public override AbiCmdResult DoWork(AbiCmd cmd)
        {
            //convert AbiCmd to CLI args
            this.psi.Arguments = cmd.GetArgsString();
            Process p = Process.Start(psi);

            p.WaitForExit();

            //read stdout
            return(new SignCmdResult(p, cmd.context));
        }
Esempio n. 3
0
        public SignCommand_v2(AbiCmd abiCmd)
            : base(abiCmd)
        {
            tuples = new List <Tuple <string, string> >();
            //some jask ass changed an arg pattern
            Tuple <string, string> t = new Tuple <string, string>("--hash_algo", (this.cmd.context as SignContext).hash_algo.Item2);

            this.tuples.Add(t);
            this.tuples.Add((this.cmd.context as SignContext).cert);

            //overload the base command tuples with new tuples
            (this.cmd as SignCommand).tuples = this.tuples;
        }
Esempio n. 4
0
        public override AbiCmd CreateCommand(string cmd)
        {
            AbiCmd abiCmd = null;

            switch (cmd)
            {
            case "sign":
                abiCmd = new SignCommand(tool, context);
                switch (this.tool.version)
                {
                //if the SignFile sign command changes, use this to modify the behavior but dont mess with the original impl
                case "2.0":
                    abiCmd = new SignCommand_v2(abiCmd);
                    break;
                }
                break;

            default:
                throw new Exception("Unsupported Signing Command");
            }
            return(abiCmd);
        }
Esempio n. 5
0
 public AbiCmdDecorator(AbiCmd cmd) : base(cmd.tool, cmd.context)
 {
     this.cmd = cmd;
 }
Esempio n. 6
0
 public abstract AbiCmdResult DoWork(AbiCmd cmd);